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

5.1 KiB

R12 — Reproduce an original run separately from rerunning current settings

Parent epic: E6. Priority/severity: P1 / High. Relative complexity: S. Recommended specialization: Full-stack reproducible research.

Scheduling source of truth: manifest entry R12. 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 reproduce-original endpoint/action that copies the retained versioned input bundle including dataset/artifact/engine policies into a new durable run. Keep rerun-current a separate labelled action. Verify retained artifacts and compatible engine availability before admission; no fallback to current source or provider history.

Measurable benefit: Makes exact experiment repetition a user-visible, verifiable capability.

Exclusions

No downloading/executing arbitrary historic binaries, silent economics downgrade or overwriting original results.

Likely files and ownership

  • apps/stock/web-api/src/routes/backtests-v2.routes.ts
  • apps/stock/web-api/src/services/backtest-v2.service.ts
  • apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
  • apps/stock/web-app/src/features/backtest/components/RunControlsCompact.tsx

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

Dependencies and blockers

Implementation requires R05, W04 integrated.

Architecture decisions: ADR-006. Agents may not independently amend their policies.

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

Acceptance criteria

  • Original reproduction after template/provider/strategy changes yields the same economic hash on the same supported build/policy.
  • A missing original artifact or unsupported old engine produces an explicit error; old result remains viewable.
  • UI previews exact original inputs and links source/reproduction runs without mutating either.

Mandatory tests

  • reproduce_after_template_provider_change, missing_original_artifact, unsupported_engine_version, economic_hash_parity.
  • Browser original-vs-current action and duplicate-submit idempotency.

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

Legacy provenance may be insufficient; fail explicitly instead of pretending exact reproducibility. 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: POST /api/v2/runs/:id/reproduce with idempotency key; response links originalRunId and new run. Rerun-current uses ordinary submit.
  • Backend/data dependencies: R05 retained input bundle and R10 artifact integrity; require available approved engine build.
  • Loading/error/empty behavior: Preview/loading; missing artifact or version error; accepted pending run; hash match/mismatch after completion.
  • 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.