62 lines
4.7 KiB
Markdown
62 lines
4.7 KiB
Markdown
# 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](../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).
|
||
- **PER-01 — Verified:** EventQueue insertion scans prior events; native run is synchronous/one-shot and returns full JSON. Actual end-to-end bottleneck distribution still needs controlled measurements. [apps/stock/engine/src/backtest/mod.rs:138](../../../../apps/stock/engine/src/backtest/mod.rs#L138); [apps/stock/engine/src/api/backtest.rs:194](../../../../apps/stock/engine/src/api/backtest.rs#L194).
|
||
|
||
## 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](P04.md), [S01](S01.md) 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](../../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
|
||
|
||
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.
|
||
|
||
## Conditional review — October 28, 2026
|
||
|
||
No-go for now: one Rust financial kernel already serves TypeScript callbacks. Local state-handling optimization provides a measured gain without a second strategy representation. Current evidence does not justify the cost and restricted expressiveness of a DSL. Reopen only with representative callback-bound screening demand, a small supported subset and explicit bounded prototype budget. Status remains **deferred**, not implemented or silently cancelled. The owner authorized judgment on all remaining conditions and explicitly resumed performance work. [Current review](../../conditional-review.md). Earlier audit findings above are historical evidence: F02–F07/S06 already resolved competing financial cores and the old insertion queue; they are not reasons to implement this extension now.
|