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

68 lines
5.2 KiB
Markdown

# S06 — Retire duplicate simulator paths after cutover proof
Parent epic: E4. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.
Scheduling source of truth: [manifest entry S06](../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
- **FIN-05 — Verified:** Rust and TypeScript separately implement fill/accounting behavior; the exposed native TypeScript callback method explicitly rejects callbacks. [apps/stock/engine/src/api/backtest.rs:63](../../../../apps/stock/engine/src/api/backtest.rs#L63); [apps/stock/orchestrator/src/execution/SimulationExecution.ts:114](../../../../apps/stock/orchestrator/src/execution/SimulationExecution.ts#L114).
- **STR-01 — Verified:** Registry is a useful small boundary, but its factories receive mode/execution services; BaseStrategy mixes author decisions, order submission and hidden signal filtering. [apps/stock/orchestrator/src/strategies/StrategyRegistry.ts:7](../../../../apps/stock/orchestrator/src/strategies/StrategyRegistry.ts#L7); [apps/stock/orchestrator/src/strategies/BaseStrategy.ts:315](../../../../apps/stock/orchestrator/src/strategies/BaseStrategy.ts#L315).
- **KEEP-01 — Verified:** Preserve transaction-scoped account locking, idempotent fills/event fingerprints, durable decisions and recovery checkpoints; these are real behavior, not interfaces alone. [apps/stock/orchestrator/src/execution/PostgresExecutionRepository.ts:46](../../../../apps/stock/orchestrator/src/execution/PostgresExecutionRepository.ts#L46); [apps/stock/orchestrator/src/execution/StrategyRecovery.ts:151](../../../../apps/stock/orchestrator/src/execution/StrategyRecovery.ts#L151).
## Intended behavior and implementation scope
Delete only unreachable competing accounting/fill implementations after canonical research and paper pass the release gate. Keep old result readers, artifact history, calculation library and research prototypes. Remove the unsupported native callback stub and unused synthetic depth path only after caller inventory.
Measurable benefit: Reduces long-term maintenance only after behavior is preserved.
## Exclusions
No deletion of reviewed calculations, research prototypes, old result compatibility or unrelated dead-code campaign.
## Likely files and ownership
- apps/stock/orchestrator/src/backtest/BacktestEngine.ts
- apps/stock/orchestrator/src/backtest/MarketSimulator.ts
- apps/stock/orchestrator/src/execution/SimulationExecution.ts
- apps/stock/orchestrator/src/execution/model.ts
- apps/stock/engine/src/api/backtest.rs
Write locks: runtime-composition, ts-execution-model. One agent owns this change. Lock names do not override actual overlapping files.
## Dependencies and blockers
Implementation requires [S03](S03.md), [S04](S04.md), [R05](R05.md) 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
- All supported production research/paper entry points call one Rust financial implementation.
- No competing TS applyFill or independent simulation matching remains on active paths.
- Preservation inventory passes; archived experimental algorithms are not deleted for lacking imports.
## Mandatory tests
- Dependency/call-site inventory plus full integration/native/PostgreSQL suites.
- Replay pre-cutover golden fixtures using explicit compatibility expectations; old result reading still works.
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
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.
## 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.
## Accepted completion — 2026-10-24
Production import reachability and composition no longer select competing TypeScript or old native simulators. Prototype strategies/engines, calculation utilities, historic result readers and recovery fixtures remain. Only the unsupported native callback stub was removed. Canonical durable failure/lease/cancel/SSE/process recovery proofs replace retired production execution tests.
Independent review and final repository/native/PostgreSQL/browser gates pass. Exact results and source identities: manifest `thirty_seventh_wave_validation` and the [handoff](../../ROADMAP.md#thirty-seventh-wave-handoff--2026-10-24). No real account migration or paper/live activation occurred.