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

3.9 KiB

P06 — Conditionally add a minimal Rust-executed strategy plan

Parent epic: E7. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Rust/TS performance compiler boundary.

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

Deferred. First inspect actual warmed trial profiles after the TS path works. Owner may authorize a time-boxed prototype of a tiny typed feature/comparison/target plan only if projected end-to-end benefit and maintenance savings justify it. The same Rust financial kernel is mandatory; do not use arbitrary fixed percentage/speed thresholds as automatic permission.

Exclusions

No speculative distributed infrastructure or weakened correctness gates.

Likely files and ownership

  • apps/stock/orchestrator/src/backtest/strategy-plan.ts
  • apps/stock/engine/src/strategies/
  • apps/stock/engine/src/financial/

Write locks: strategy-contract, native-public-api. One agent owns this change. Lock names do not override actual overlapping files.

Dependencies and blockers

Implementation requires P04, S01 integrated.

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

Deferred: Owner go/no-go after representative profiling and explicit prototype budget; no fixed 20%/1.5x magic thresholds.

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

Acceptance criteria

  • Owner records baseline, suspected bottleneck, bounded prototype budget and required end-to-end improvement BEFORE implementation; absence of that decision means stay deferred.
  • Prototype compares identical supported TS/declarative decision and economic traces on representative workloads; report Amdahl limit, wall time, memory and maintenance cost.
  • Go/no-go either accepts the small supported subset or stops it; no implicit universal DSL work.

Mandatory tests

  • ts_plan_differential, invalid_plan_validation, state_reset, no_risk_bypass.
  • P01 full workload speed/memory comparison, not a no-op microbenchmark alone.

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.

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.