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

65 lines
4.7 KiB
Markdown

# R09 — Expose validation, cost and regime evidence in the workbench
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
Scheduling source of truth: [manifest entry R09](../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
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [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).
## Intended behavior and implementation scope
Expose stored chronological/cost validation evidence from R08. Regime panels render only when valid as-of regime annotations exist; otherwise show unavailable, not fake classification. The basic validation UI need not wait for S05; enabling that example's regime comparison requires its artifact contract.
## Exclusions
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
## Likely files and ownership
- apps/stock/web-app/src/features/experiments/
- apps/stock/web-app/src/features/research/
- apps/stock/web-app/src/features/backtest/components/
Write locks: web-experiments. One agent owns this change. Lock names do not override actual overlapping files.
## Dependencies and blockers
Implementation requires [R07](R07.md), [R08](R08.md) integrated.
Architecture decisions: ADR-006. Agents may not independently amend their policies.
Conditional activation: regime comparison requires [S05](S05.md); saving/linking a research finding requires [R03](R03.md). Neither blocks basic validation display.
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
## Acceptance criteria
- User can validate and inspect each OOS segment with reset/warmup/cost assumptions visible.
- Regime data missing => explicit unavailable panel; present => sample counts/unclassified bucket and window coverage displayed.
- Validation display works without R03. Enable save/link-finding only when R03 exists; link the exact experiment/report identity and contributing run/metric references through its existing evidence API. Otherwise show the action unavailable.
- No client-side accounting or continuous-equity claim for reset segments.
## Mandatory tests
- walk_forward_browser, train_test_badges, insufficient_sample_warning, regime_slice_reconciliation.
- Loading/empty/failure states for incomplete validation; validation_without_findings_api; save_finding_requires_R03.
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: R08 experiment-owned immutable recipes/reports. R03 evidence-linked findings only for the conditionally enabled save action.
- Backend/data dependencies: Canonical returns, as-of regime annotations and sample counts; no client-side financial recomputation.
- Loading/error/empty behavior: Loading each segment; unclassified regime bucket; invalid partition feedback; explicit partial validation.
- 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.