stock-bot/docs/development/architecture/decisions/006-research-product.md

27 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ADR-006 — Web-first research product and minimal persistence
Status: **approved by owner continuation on 2026-10-23**, after the S05 handoff explicitly linked this decision for the next research-product work. Web as primary product is user-mandated. Approval covers direction; engine cutover and trading activation remain separate release gates.
## Selected approach
Extend current React features, Hono v2 APIs, SQL definitions/runs/results, durable outbox/queue, frozen datasets and websocket projection. The browser and AI clients use the same business APIs.
Add only strategies, immutable strategy_versions, research_projects, hypotheses, experiments and analysis_artifacts. Attach candidate/experiment identity to existing runs; keep backtests as editable templates. A later paper deployment record is optional. Store stable single-owner/agent identity without implementing full multi-tenancy.
Retain artifact bytes or immutable retained references, not hashes alone. Archive referenced evidence; no automatic purge by default. Future operator retention must respect references and explicit consent.
## Evidence
[Existing submission transaction](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211), [existing result contract](../../../../libs/core/types/src/backtest-run.ts#L4), [schema deletion cascade](../../../../database/postgres/init/08-create-runs-table.sql#L13), [existing UI routes](../../../../apps/stock/web-app/src/app/App.tsx#L24).
## Alternatives / tradeoffs
A separate research database, job service, AI-only APIs or general laboratory/workflow system duplicates working infrastructure. SQL metadata and bounded job expansion suffice. Existing JSONB results are acceptable until measurement warrants paged/normalized detail. Source editing initially uses repository/artifact submission plus schema forms and version diff; no browser IDE prerequisite.
## Migration
W01–W04 deliver the existing exploratory workflow while engine work proceeds. R01–R04 add strategy/workspace value independently of Rust cutover. R05 turns that same workbench into a reproducible canonical-engine workflow; R06–R09 add experiments/validation. Legacy results stay read-only and visibly qualified. See [product contracts](../research-product.md).
## Reduced product dependencies
API/data contracts gate implementation, not unrelated screens. Catalog/workspace/experiment/dataset UI tasks can use focused tests before W04 is complete, but shared browser coverage remains a feature-release gate. Basic experiment comparison needs a frozen dataset ID, not the entire project workspace or dataset picker. Findings reference immutable metric paths rather than creating another metric store. R06 ships summary projections; P05 is only a later measured detail optimization.