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

4.8 KiB

A04 — Add human-reviewed promotion to paper deployment

Parent epic: E8. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Full-stack paper trading integration.

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

Human-only paper deployment of a frozen version requires S04 readiness, research-only permission separation and explicit evidence. It must work for human-authored as well as AI-originated strategies; the A03 AI client is not a prerequisite. Reuse version/evidence APIs and add a deployment record only when this flow is implemented.

Exclusions

No speculative distributed infrastructure or weakened correctness gates.

Likely files and ownership

  • apps/stock/web-app/src/features/strategies/
  • apps/stock/web-api/src/routes/ (paper promotion)
  • apps/stock/orchestrator/src/paper/PaperTradingManager.ts
  • database/postgres/init/ (optional deployment table)

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

Dependencies and blockers

Implementation requires S04, R09, A01, R01 integrated.

Architecture decisions: ADR-007, ADR-005. 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

  • Research-only token cannot create/activate a deployment; operator must review OOS/cost evidence and limitations.
  • Only paper deployment is offered; live remains explicitly unavailable.
  • Promotion never overwrites existing account capital/checkpoints or silently upgrades strategy state.

Mandatory tests

  • human_only_promotion, immutable_deployment_version, incompatible_checkpoint_block, no_live_option.
  • Browser AI candidate -> evidence review -> paper status workflow.

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

Performance measurements can hide semantic changes; require economic hash equivalence. 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 paper-deployments and explicit activate/halt operations for operator only; read-only history for research clients.
  • Backend/data dependencies: Optional deployments table with version/account/evidence FKs, existing durable paper state.
  • Loading/error/empty behavior: Not-ready reasons, approval pending, active/halted/failed; no cosmetic success before backend confirmation.
  • 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.