stock-bot/docs/development/backlog/tasks/W02.md

4.8 KiB

W02 — Expose result provenance and legacy correctness limitations

Parent epic: E5. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research UX.

Scheduling source of truth: manifest entry W02. 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

Intended behavior and implementation scope

Add read-only provenance/limitations DTO and panel using data actually stored. Distinguish missing metadata, legacy semantics and project-gated engine versions; label same-bar/funding/attribution limitations. Do not infer a historical code hash or certify results from engine name alone.

Measurable benefit: Delivers useful UI now without presenting invalid results as validated.

Exclusions

No unrelated refactor, new service or broker activation.

Likely files and ownership

  • apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
  • apps/stock/web-app/src/features/backtest/components/BacktestMetrics.tsx
  • apps/stock/web-api/src/services/backtest-result.ts
  • libs/core/types/src/backtest-run.ts

Write locks: web-backtest-detail, result-contract. One agent owns this change. Lock names do not override actual overlapping files.

Dependencies and blockers

Implementation requires W01 integrated.

No additional economic-policy approval is needed for this narrowly scoped task.

Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.

Acceptance criteria

  • Every existing run reopens with exact stored configuration where present and explicit unknown fields otherwise.
  • Legacy/native/TS result limitations are visible next to performance; unproject-gated results cannot be treated as validated promotion evidence.
  • No zero-valued placeholder is presented as a measured risk metric.

Mandatory tests

  • legacy_missing_provenance, frozen_config_not_mutable_definition, limitation_badge, null_metrics.
  • Existing backtest-result-mapping and analytics-ui tests.

Apply the relevant quality gates; 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

Compatibility or lifecycle regression; preserve frozen inputs, old results and existing failure tests. 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: Extend GET /api/v2/runs/:id/results with provenance availability, economics version and limitations; backward-compatible optional fields.
  • Backend/data dependencies: Existing result configuration/dataset; future R05 extends the same contract.
  • Loading/error/empty behavior: Separate loading, no-result-yet, failed run, and legacy metadata unavailable; never fabricate defaults as provenance.
  • 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.