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

4.1 KiB

C06 — Contain legacy research/paper interference without a second runtime

Parent epic: E1. Priority/severity: P0 / Critical. Relative complexity: S. Recommended specialization: Trading infrastructure implementation.

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

Contain the legacy TS shared-mode hazard without building a second run-local TS execution framework. Use explicit composition roles: a shared paper runtime accepts only already-isolated native research; legacy TS research is allowed only in an explicit research-only composition with paper initialization/activation disabled. Reject unsafe combinations before mode mutation. Canonical TS strategies later use the Rust worker/session path. Keep the existing single-run busy guard.

Exclusions

No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.

Likely files and ownership

  • apps/stock/orchestrator/src/container.ts
  • apps/stock/orchestrator/src/backtest/BacktestRunner.ts
  • apps/stock/orchestrator/src/backtest/BacktestEngine.ts

Write locks: runtime-composition. One agent owns this change. Lock names do not override actual overlapping files.

Dependencies and blockers

Implementation requires C04 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

  • Attempting a legacy TS run in a paper composition fails with a specific unsupported-combination diagnostic before paper shutdown, cash/checkpoint mutation or feed interruption.
  • Explicit legacy research-only startup remains usable and cannot activate paper in that same composition.
  • Native research alongside paper preserves paper lifecycle/account hashes; repeated cancelled/failed jobs do not alter them.

Mandatory tests

  • legacy_paper_combination_rejected_before_prepare, standalone_legacy_research_allowed, research_only_paper_activation_denied, native_paper_isolation.
  • Existing backtest-workflow/typescript-backtest/mode-lifecycle suites; no new worker for legacy TS.

Apply relevant quality gates. Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.

Regression risks and rollback

Financial or compatibility regression; preserve existing fixtures and version changed semantics. 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.

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.