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

3.9 KiB

S04 — Establish a verified paper feed and operator safety gate

Parent epic: E4. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.

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

Verify the real paper feed path, recovery and stale-feed/kill controls on the canonical engine. Own the minimal paper-readiness endpoint/status needed to activate safely; do not wait for optional O02 cross-service dashboards. Reuse existing monitoring routes/components for actual state, unknown rather than fake zeros. Live remains disabled.

Exclusions

No unrelated refactor, new service or broker activation.

Likely files and ownership

  • apps/stock/orchestrator/src/paper/PaperTradingManager.ts
  • apps/stock/orchestrator/src/services/MarketDataService.ts
  • apps/stock/orchestrator/src/services/ExecutionService.ts
  • apps/stock/orchestrator/src/api/rest/
  • apps/stock/data-ingestion/src/

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

Dependencies and blockers

Implementation requires S02, S03 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

  • Controlled feed observation -> shared TS strategy -> Rust fill -> SQL commit -> restart reconciles.
  • Readiness is false for stale/disconnected feed, incomplete recovery, unsupported account state or persisted halt; no default capital reset.
  • Human operator halt persists; activation is acknowledged only after readiness. Optional general monitoring is not necessary for this gate.

Mandatory tests

  • paper_feed_to_fill_restart, stale_feed_halt, persisted_kill_switch, configured_capital.
  • Live route/adapter disabled tests and readiness 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.

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.