82 lines
6.9 KiB
Markdown
82 lines
6.9 KiB
Markdown
# R04 — Deliver research workspace and save-findings flow
|
|
|
|
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
|
|
|
Scheduling source of truth: [manifest entry R04](../manifest.json). No task is authorized until the plan is approved. Dependencies and decision references below describe the design; the manifest controls current readiness.
|
|
|
|
## Evidence and root cause
|
|
|
|
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; The existing strategy catalog, immutable versions and retained canonical single-asset run path are integrated; this task adds the research workspace around them. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
|
- **WEB-04 — Historical finding, partially resolved by R01/R05:** Retained canonical runs now bind immutable strategy and engine inputs. Legacy projections can still use mutable definition fallbacks; the workspace must preserve each result kind and its evidence limitations. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
|
|
|
## Intended behavior and implementation scope
|
|
|
|
Add project overview, hypothesis notes, linked strategies/runs and Save finding from result view. Reuse DataTable/Card/Dialog and current navigation. Keep human conclusions separate from AI suggestions and measured evidence.
|
|
|
|
Measurable benefit: Provides the primary research workspace before advanced optimization.
|
|
|
|
## Exclusions
|
|
|
|
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
|
|
|
## Likely files and ownership
|
|
|
|
- apps/stock/web-app/src/features/research/ (new)
|
|
- apps/stock/web-app/src/app/App.tsx
|
|
- apps/stock/web-app/src/lib/constants.ts
|
|
- apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
|
|
|
|
Write locks: web-research, web-backtest-detail. Root coordinates separate workspace and save-finding UI owners; actual file assignments are recorded in the manifest. Lock names do not override actual overlapping files.
|
|
|
|
## Dependencies and blockers
|
|
|
|
Implementation requires [R03](R03.md), [W02](W02.md) integrated.
|
|
|
|
Architecture decisions: ADR-006. Agents may not independently amend their policies.
|
|
|
|
Feature activation/release gates: [W04](W04.md). These do not block implementing or integrating this component against its own tests.
|
|
|
|
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
|
|
|
## Acceptance criteria
|
|
|
|
- Project -> strategy -> configure/run -> inspect -> save cited finding -> reopen project is navigable.
|
|
- Finding links open exact run/version; incomplete/legacy evidence displays limitations.
|
|
- Notes can be saved without claiming strategy validation.
|
|
|
|
## Mandatory tests
|
|
|
|
- research_project_to_finding_browser, missing_evidence_error, ai_authorship_badge, archived_project_read.
|
|
- Loading/error/empty state component tests.
|
|
|
|
Apply the relevant [quality gates](../../QUALITY-GATES.md); submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist.
|
|
|
|
## Regression risks and rollback
|
|
|
|
Schema/API backward compatibility, historical provenance and UI state regression.
|
|
Keep migrations additive and previous results readable. Do not add a switch that restores a correctness defect. Versioned cutover/migration is required only when persisted contracts or active engines change; never silently fall back to old economics.
|
|
|
|
## Web/API contract and user states
|
|
|
|
- API: R03 project/hypothesis/artifact APIs and existing saved runs.
|
|
- Backend/data dependencies: R03 entities, existing run provenance, no requirement for full Rust cutover.
|
|
- Loading/error/empty behavior: Empty project guidance; saving/retry states preserve draft; stale evidence error; archived read-only state.
|
|
- User-facing completion is demonstrated by the acceptance criteria and interaction tests above; a backend-only implementation is insufficient where a UI is in scope.
|
|
|
|
## Handoff
|
|
|
|
Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.
|
|
|
|
|
|
## Implemented surface — 2026-10-24
|
|
|
|
- `/research` lists and creates projects; `/research/:projectId` edits metadata, links catalog strategies, and creates or browses hypotheses, notes and findings. Query selectors `hypothesis`/`artifact` plus optional immutable `revision` identify the displayed narrative.
|
|
- Revisions append with `expectedRevision`. A conflict preserves the draft and requires deliberate history review. Historical revisions and archived projects remain readable. Child writes are blocked when project authority cannot be verified.
|
|
- Completed matching backtest results offer **Save finding**. Choose an active project, optional exact hypothesis revision, declared content origin and allowlisted measurements. The browser sends reference identities only; R03 resolves values from retained results. Canonical strategy versions come from the original request; legacy results retain their qualifications.
|
|
- Evidence displays raw and formatted values, units, unavailable reasons, actual financial engine, dataset identity and exact run/version links. Declared AI/human origin is separate from authenticated submitter; citations never validate the narrative.
|
|
- Pending mutations reject duplicate clicks. Lost, malformed or server-error creation responses freeze the draft; users check saved records before explicitly starting another request. Reads and mutation callbacks reject obsolete navigation responses.
|
|
- Existing Card/Dialog, strategy parameter form styles, navigation, authentication and APIs are reused. No backend, database, financial or execution contract changed.
|
|
|
|
The browser acceptance extends the existing retained canonical execution fixture through project creation, an AI-labelled hypothesis, linked strategy selection, backtest setup/run, exact finding, revision history, reload and archived-project reading. It retains the hand-derived two-fill/equity/fee assertions and verifies that original results stay unchanged. Focused DOM tests exercise failure/empty/loading states, conflicts, unavailable evidence, ambiguous saves, archive races and stale replies.
|
|
|
|
Current integration state and exact checks are in `manifest.json` → `twenty_fifth_wave_validation`; this section does not independently change scheduling status. UI origins are declared labels, not authenticated AI identities; agent credentials/execution, experiment management and automated validation remain separate tasks.
|