docs: add reviewed architecture backlog and first execution wave
This commit is contained in:
parent
b7aeca4888
commit
1148673245
75 changed files with 6435 additions and 0 deletions
118
docs/development/backlog/README.md
Normal file
118
docs/development/backlog/README.md
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# Canonical development backlog
|
||||
|
||||
**First-wave execution is authorized; consult manifest execution_scope.** Start with [ROADMAP](../ROADMAP.md), [skeptical review](../REVIEW.md) and [first-wave prompts](../FIRST-WAVE.md). Other tasks and unresolved policies remain gated.
|
||||
|
||||
## One source of truth
|
||||
|
||||
[manifest.json](manifest.json) owns scheduling metadata: status, priorities, dependencies, ADR approvals, assignments and write locks. Task Markdown owns implementation scope/evidence/acceptance. This index and the [graph](dependencies.mmd) are derived views. Only the planning/integration owner updates scheduling state.
|
||||
|
||||
**43 scheduled + 5 deferred + 4 merged IDs = 52 retained IDs.** Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation.
|
||||
|
||||
States: ready, claimed, in_progress, review, done, blocked, deferred, merged. “Ready” means no code/ADR prerequisite, not execution authority. Implementation dependencies require accepted integration. `release_gates` govern enabling an end-to-end feature, not component coding or integration; conditional gates apply only to the named capability. F05 may integrate before F06, but its replay behavior is not released until F06 proves it.
|
||||
|
||||
Relative size: S narrow correction, M coherent boundary, L sensitive owner-controlled integration; not calendar estimates. Actual file overlap overrides symbolic lock names. No compatible structured issue tracker was found; do not duplicate task state in another system.
|
||||
|
||||
## Complete task index
|
||||
|
||||
### E1 — Immediate correctness and runtime containment
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [C01 Correct native terminal valuation](tasks/C01.md) | P0 / ready | None | — | Rust financial correctness / S |
|
||||
| [C02 Reject malformed native data and preserve milliseconds](tasks/C02.md) | P1 / ready | None | — | Rust/NAPI boundary / S |
|
||||
| [C03 Close the existing TypeScript fee-funding hole](tasks/C03.md) | P0 / ready | None | — | Trading infrastructure implementation / M |
|
||||
| [C04 Make partial runtime initialization recoverable](tasks/C04.md) | P1 / ready | None | — | Trading infrastructure implementation / S |
|
||||
| [C05 Create economic regression fixtures independent of implementations](tasks/C05.md) | P0 / merged → F01 | None | — | Quantitative correctness/test engineering / M |
|
||||
| [C06 Contain legacy research/paper interference without a second runtime](tasks/C06.md) | P0 / blocked | C04 | — | Trading infrastructure implementation / S |
|
||||
|
||||
### E2 — Canonical Rust financial engine
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [F01 Define the minimal financial contract and economic fixtures](tasks/F01.md) | P0 / blocked | ADR-002, ADR-003, ADR-004 | — | Rust financial contract owner / M |
|
||||
| [F02 Implement one owner-aware financial ledger](tasks/F02.md) | P0 / blocked | F01, ADR-002 | — | Rust accounting / L |
|
||||
| [F03 Add strategy-owned position books and fill allocations](tasks/F03.md) | P0 / merged → F02 | None | — | Rust portfolio accounting / M |
|
||||
| [F04 Enforce cash reservations and portfolio risk centrally](tasks/F04.md) | P0 / blocked | F02, ADR-002, ADR-003 | — | Rust financial risk / L |
|
||||
| [F05 Unify matching and order lifecycle on the ledger](tasks/F05.md) | P0 / blocked | F04, ADR-003 | F06 | Rust execution semantics / L |
|
||||
| [F06 Implement deterministic replay once, with linear historical traversal](tasks/F06.md) | P0 / blocked | F05, D01, P01, ADR-003 | — | Rust deterministic replay / M |
|
||||
| [F07 Expose bounded Rust step sessions through existing NAPI workers](tasks/F07.md) | P0 / blocked | F06, C02, ADR-004 | — | Rust/TypeScript integration / M |
|
||||
| [F08 Publish canonical metrics and versioned result projections](tasks/F08.md) | P1 / blocked | F06, ADR-002, ADR-003 | — | Quant analytics/Rust integration / M |
|
||||
|
||||
### E3 — Point-in-time datasets and features
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [D01 Introduce availability-aware dataset v2](tasks/D01.md) | P0 / blocked | ADR-003 | — | TypeScript trading infrastructure / M |
|
||||
| [D02 Connect supported intraday storage to research datasets](tasks/D02.md) | P1 / blocked | D01 | — | TypeScript trading infrastructure / M |
|
||||
| [D03 Add dataset eligibility and corporate-action safeguards](tasks/D03.md) | P1 / merged → D01 | None | — | TypeScript trading infrastructure / M |
|
||||
| [D04 Provide prefix-safe shared feature calculation](tasks/D04.md) | P1 / deferred | S01, P01 | — | Quantitative feature engineering / M |
|
||||
|
||||
### E4 — TypeScript strategies and durable paper integration
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [S01 Run deterministic TypeScript decisions on Rust sessions](tasks/S01.md) | P0 / blocked | F07, ADR-004, ADR-005 | — | TypeScript trading infrastructure / M |
|
||||
| [S02 Adapt one SMA strategy for the first canonical path](tasks/S02.md) | P1 / blocked | S01 | — | TypeScript strategy/quant engineering / M |
|
||||
| [S03 Adapt durable paper transactions to Rust financial reducers](tasks/S03.md) | P0 / blocked | S01, C06, ADR-005 | — | Durable execution/Rust integration / L |
|
||||
| [S04 Establish a verified paper feed and operator safety gate](tasks/S04.md) | P1 / blocked | S02, S03 | — | TypeScript trading infrastructure / M |
|
||||
| [S05 Add a small composable multi-signal regime example](tasks/S05.md) | P2 / blocked | S02, F08 | R08 | Quant strategy research / M |
|
||||
| [S06 Retire duplicate simulator paths after cutover proof](tasks/S06.md) | P2 / blocked | S03, S04, R05 | — | TypeScript trading infrastructure / M |
|
||||
|
||||
### E5 — Existing web backtest vertical slice
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [W01 Make existing run controls and selection truthful](tasks/W01.md) | P1 / ready | None | — | Full-stack React/API / M |
|
||||
| [W02 Expose result provenance and legacy correctness limitations](tasks/W02.md) | P1 / blocked | W01 | — | Full-stack research UX / M |
|
||||
| [W03 Separate save, submit and repeat-safe run creation](tasks/W03.md) | P1 / blocked | O01 | — | Full-stack durable workflow / M |
|
||||
| [W04 Verify the first research vertical slice in a browser](tasks/W04.md) | P1 / blocked | W01, W02, W03, C06 | — | Full-stack test engineering / M |
|
||||
|
||||
### E6 — Research product, provenance and validation
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [R01 Persist immutable strategy versions and parameter schemas](tasks/R01.md) | P1 / blocked | O01, ADR-006 | — | Full-stack research product / M |
|
||||
| [R02 Deliver strategy catalog and version-aware backtest setup](tasks/R02.md) | P1 / blocked | R01, W03, ADR-006 | W04 | Full-stack research product / M |
|
||||
| [R03 Add projects, hypotheses and evidence-linked findings APIs](tasks/R03.md) | P1 / blocked | R01, R10, ADR-006 | — | Full-stack research product / M |
|
||||
| [R04 Deliver research workspace and save-findings flow](tasks/R04.md) | P1 / blocked | R03, W02, ADR-006 | W04 | Full-stack research product / M |
|
||||
| [R05 Freeze complete provenance and cut over durable canonical runs](tasks/R05.md) | P0 / blocked | F08, S02, R01, R10, D01, W03, C06, ADR-006 | — | Full-stack research product / M |
|
||||
| [R06 Create immutable experiments and bounded sweep expansion](tasks/R06.md) | P1 / blocked | R05, ADR-006 | — | Full-stack research product / M |
|
||||
| [R07 Deliver sweep configuration and comparable-result views](tasks/R07.md) | P1 / blocked | R06, ADR-006 | W04 | Full-stack research product / M |
|
||||
| [R08 Add bounded chronological and reset-segment validation](tasks/R08.md) | P1 / blocked | R06, ADR-006 | — | Quantitative research integrity / M |
|
||||
| [R09 Expose validation, cost and regime evidence in the workbench](tasks/R09.md) | P1 / blocked | R07, R08, ADR-006 | S05 when Regime comparison is enabled; R03 when Saving or linking a research finding is enabled | Full-stack research product / M |
|
||||
| [R10 Protect retained research evidence and artifact integrity](tasks/R10.md) | P1 / blocked | R01, ADR-006 | — | Full-stack research product / M |
|
||||
| [R11 Select and reuse frozen datasets in the workbench](tasks/R11.md) | P1 / blocked | D01, O01, ADR-003, ADR-006 | W04 | Full-stack market data/research / M |
|
||||
| [R12 Reproduce an original run separately from rerunning current settings](tasks/R12.md) | P1 / blocked | R05, W04, ADR-006 | — | Full-stack reproducible research / S |
|
||||
|
||||
### E7 — Measured research throughput
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [P01 Measure existing research paths before extending the benchmark](tasks/P01.md) | P2 / ready | None | — | Performance/infrastructure engineering / M |
|
||||
| [P02 Remove measured replay queue and hot-loop overhead](tasks/P02.md) | P2 / merged → F06 | None | — | Performance/infrastructure engineering / M |
|
||||
| [P03 Reuse validated datasets within bounded native workers](tasks/P03.md) | P2 / deferred | F07, P01, ADR-004, ADR-008 | — | Performance/infrastructure engineering / M |
|
||||
| [P04 Schedule deterministic batches across a bounded worker pool](tasks/P04.md) | P2 / blocked | F07, R06, C06, P01, ADR-008 | — | Performance/infrastructure engineering / M |
|
||||
| [P05 Separate result summaries from paged detail payloads](tasks/P05.md) | P2 / deferred | R06, P01 | — | Performance/infrastructure engineering / M |
|
||||
| [P06 Conditionally add a minimal Rust-executed strategy plan](tasks/P06.md) | P2 / deferred | P04, S01, ADR-008 | — | Rust/TS performance compiler boundary / M |
|
||||
|
||||
### E8 — Authorized, isolated AI research
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [A01 Add research-only principals and durable job budgets](tasks/A01.md) | P1 / blocked | R06, O01, ADR-007 | — | Backend security/durable scheduling / M |
|
||||
| [A02 Isolate untrusted TypeScript strategy builds and decisions](tasks/A02.md) | P1 / blocked | A01, S01, P01, ADR-007 | — | Process isolation/security / L |
|
||||
| [A03 Implement an evidence-linked AI research workflow client](tasks/A03.md) | P2 / blocked | A02, R08, R03, ADR-007 | — | AI research integration / M |
|
||||
| [A04 Add human-reviewed promotion to paper deployment](tasks/A04.md) | P2 / blocked | S04, R09, A01, R01, ADR-007, ADR-005 | — | Full-stack paper trading integration / M |
|
||||
|
||||
### E9 — Migration and operational safeguards
|
||||
|
||||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [O01 Serialize additive schema migrations safely](tasks/O01.md) | P1 / ready | None | — | PostgreSQL/backend infrastructure / S |
|
||||
| [O02 Expose truthful research and paper readiness diagnostics](tasks/O02.md) | P1 / deferred | S04 | — | Infrastructure/observability / M |
|
||||
|
||||
## Scheduling checks
|
||||
|
||||
Before any wave: unique IDs; existing task/ADR references; acyclic implementation graph; no scheduled task dependent on merged/deferred work; approvals/readiness; actual file locks; isolated native build outputs/workspace dependencies and test databases. Release gates are checked separately at activation.
|
||||
|
||||
First wave: **C01, C03, C04, W01**, each with a copy-ready bounded assignment in [FIRST-WAVE.md](../FIRST-WAVE.md). No task has been implemented by this planning revision.
|
||||
193
docs/development/backlog/dependencies.mmd
Normal file
193
docs/development/backlog/dependencies.mmd
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
flowchart TD
|
||||
%% Generated view of manifest.json. Solid edges: implementation; dotted: release only.
|
||||
subgraph E1["E1: Immediate correctness and runtime containment"]
|
||||
C01["C01: Correct native terminal valuation"]
|
||||
C02["C02: Reject malformed native data and preserve milliseconds"]
|
||||
C03["C03: Close the existing TypeScript fee-funding hole"]
|
||||
C04["C04: Make partial runtime initialization recoverable"]
|
||||
C06["C06: Contain legacy research/paper interference without a second runtime"]
|
||||
end
|
||||
subgraph E2["E2: Canonical Rust financial engine"]
|
||||
F01["F01: Define the minimal financial contract and economic fixtures"]
|
||||
F02["F02: Implement one owner-aware financial ledger"]
|
||||
F04["F04: Enforce cash reservations and portfolio risk centrally"]
|
||||
F05["F05: Unify matching and order lifecycle on the ledger"]
|
||||
F06["F06: Implement deterministic replay once, with linear historical traversal"]
|
||||
F07["F07: Expose bounded Rust step sessions through existing NAPI workers"]
|
||||
F08["F08: Publish canonical metrics and versioned result projections"]
|
||||
end
|
||||
subgraph E3["E3: Point-in-time datasets and features"]
|
||||
D01["D01: Introduce availability-aware dataset v2"]
|
||||
D02["D02: Connect supported intraday storage to research datasets"]
|
||||
D04["D04: Provide prefix-safe shared feature calculation (conditional)"]
|
||||
end
|
||||
subgraph E4["E4: TypeScript strategies and durable paper integration"]
|
||||
S01["S01: Run deterministic TypeScript decisions on Rust sessions"]
|
||||
S02["S02: Adapt one SMA strategy for the first canonical path"]
|
||||
S03["S03: Adapt durable paper transactions to Rust financial reducers"]
|
||||
S04["S04: Establish a verified paper feed and operator safety gate"]
|
||||
S05["S05: Add a small composable multi-signal regime example"]
|
||||
S06["S06: Retire duplicate simulator paths after cutover proof"]
|
||||
end
|
||||
subgraph E5["E5: Existing web backtest vertical slice"]
|
||||
W01["W01: Make existing run controls and selection truthful"]
|
||||
W02["W02: Expose result provenance and legacy correctness limitations"]
|
||||
W03["W03: Separate save, submit and repeat-safe run creation"]
|
||||
W04["W04: Verify the first research vertical slice in a browser"]
|
||||
end
|
||||
subgraph E6["E6: Research product, provenance and validation"]
|
||||
R01["R01: Persist immutable strategy versions and parameter schemas"]
|
||||
R02["R02: Deliver strategy catalog and version-aware backtest setup"]
|
||||
R03["R03: Add projects, hypotheses and evidence-linked findings APIs"]
|
||||
R04["R04: Deliver research workspace and save-findings flow"]
|
||||
R05["R05: Freeze complete provenance and cut over durable canonical runs"]
|
||||
R06["R06: Create immutable experiments and bounded sweep expansion"]
|
||||
R07["R07: Deliver sweep configuration and comparable-result views"]
|
||||
R08["R08: Add bounded chronological and reset-segment validation"]
|
||||
R09["R09: Expose validation, cost and regime evidence in the workbench"]
|
||||
R10["R10: Protect retained research evidence and artifact integrity"]
|
||||
R11["R11: Select and reuse frozen datasets in the workbench"]
|
||||
R12["R12: Reproduce an original run separately from rerunning current settings"]
|
||||
end
|
||||
subgraph E7["E7: Measured research throughput"]
|
||||
P01["P01: Measure existing research paths before extending the benchmark"]
|
||||
P03["P03: Reuse validated datasets within bounded native workers (conditional)"]
|
||||
P04["P04: Schedule deterministic batches across a bounded worker pool"]
|
||||
P05["P05: Separate result summaries from paged detail payloads (conditional)"]
|
||||
P06["P06: Conditionally add a minimal Rust-executed strategy plan (conditional)"]
|
||||
end
|
||||
subgraph E8["E8: Authorized, isolated AI research"]
|
||||
A01["A01: Add research-only principals and durable job budgets"]
|
||||
A02["A02: Isolate untrusted TypeScript strategy builds and decisions"]
|
||||
A03["A03: Implement an evidence-linked AI research workflow client"]
|
||||
A04["A04: Add human-reviewed promotion to paper deployment"]
|
||||
end
|
||||
subgraph E9["E9: Migration and operational safeguards"]
|
||||
O01["O01: Serialize additive schema migrations safely"]
|
||||
O02["O02: Expose truthful research and paper readiness diagnostics (conditional)"]
|
||||
end
|
||||
C04 --> C06
|
||||
ADR002 --> F01
|
||||
ADR003 --> F01
|
||||
ADR004 --> F01
|
||||
F01 --> F02
|
||||
ADR002 --> F02
|
||||
F02 --> F04
|
||||
ADR002 --> F04
|
||||
ADR003 --> F04
|
||||
F04 --> F05
|
||||
ADR003 --> F05
|
||||
F06 -. release only .-> F05
|
||||
F05 --> F06
|
||||
D01 --> F06
|
||||
P01 --> F06
|
||||
ADR003 --> F06
|
||||
F06 --> F07
|
||||
C02 --> F07
|
||||
ADR004 --> F07
|
||||
F06 --> F08
|
||||
ADR002 --> F08
|
||||
ADR003 --> F08
|
||||
ADR003 --> D01
|
||||
D01 --> D02
|
||||
S01 --> D04
|
||||
P01 --> D04
|
||||
F07 --> S01
|
||||
ADR004 --> S01
|
||||
ADR005 --> S01
|
||||
S01 --> S02
|
||||
S01 --> S03
|
||||
C06 --> S03
|
||||
ADR005 --> S03
|
||||
S02 --> S04
|
||||
S03 --> S04
|
||||
S02 --> S05
|
||||
F08 --> S05
|
||||
R08 -. release only .-> S05
|
||||
S03 --> S06
|
||||
S04 --> S06
|
||||
R05 --> S06
|
||||
W01 --> W02
|
||||
O01 --> W03
|
||||
W01 --> W04
|
||||
W02 --> W04
|
||||
W03 --> W04
|
||||
C06 --> W04
|
||||
O01 --> R01
|
||||
ADR006 --> R01
|
||||
R01 --> R02
|
||||
W03 --> R02
|
||||
ADR006 --> R02
|
||||
W04 -. release only .-> R02
|
||||
R01 --> R03
|
||||
R10 --> R03
|
||||
ADR006 --> R03
|
||||
R03 --> R04
|
||||
W02 --> R04
|
||||
ADR006 --> R04
|
||||
W04 -. release only .-> R04
|
||||
F08 --> R05
|
||||
S02 --> R05
|
||||
R01 --> R05
|
||||
R10 --> R05
|
||||
D01 --> R05
|
||||
W03 --> R05
|
||||
C06 --> R05
|
||||
ADR006 --> R05
|
||||
R05 --> R06
|
||||
ADR006 --> R06
|
||||
R06 --> R07
|
||||
ADR006 --> R07
|
||||
W04 -. release only .-> R07
|
||||
R06 --> R08
|
||||
ADR006 --> R08
|
||||
R07 --> R09
|
||||
R08 --> R09
|
||||
ADR006 --> R09
|
||||
S05 -. Regime comparison is enabled .-> R09
|
||||
R01 --> R10
|
||||
ADR006 --> R10
|
||||
D01 --> R11
|
||||
O01 --> R11
|
||||
ADR003 --> R11
|
||||
ADR006 --> R11
|
||||
W04 -. release only .-> R11
|
||||
R05 --> R12
|
||||
W04 --> R12
|
||||
ADR006 --> R12
|
||||
F07 --> P03
|
||||
P01 --> P03
|
||||
ADR004 --> P03
|
||||
ADR008 --> P03
|
||||
F07 --> P04
|
||||
R06 --> P04
|
||||
C06 --> P04
|
||||
P01 --> P04
|
||||
ADR008 --> P04
|
||||
R06 --> P05
|
||||
P01 --> P05
|
||||
P04 --> P06
|
||||
S01 --> P06
|
||||
ADR008 --> P06
|
||||
R06 --> A01
|
||||
O01 --> A01
|
||||
ADR007 --> A01
|
||||
A01 --> A02
|
||||
S01 --> A02
|
||||
P01 --> A02
|
||||
ADR007 --> A02
|
||||
A02 --> A03
|
||||
R08 --> A03
|
||||
R03 --> A03
|
||||
ADR007 --> A03
|
||||
S04 --> A04
|
||||
R09 --> A04
|
||||
A01 --> A04
|
||||
R01 --> A04
|
||||
ADR007 --> A04
|
||||
ADR005 --> A04
|
||||
S04 --> O02
|
||||
R03 -. save or link finding only .-> R09
|
||||
classDef conditional stroke-dasharray: 5 5,fill:#fff3cd,color:#222
|
||||
class D04,P03,P05,P06,O02 conditional
|
||||
%% Merged traceability only: C05 -> F01; F03 -> F02; D03 -> D01; P02 -> F06.
|
||||
224
docs/development/backlog/findings.md
Normal file
224
docs/development/backlog/findings.md
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
# Revalidated audit findings
|
||||
|
||||
Baseline: `b7aeca4`, inspected 2026-10-22. No standalone structured audit/backlog was found in existing docs; this matrix reconciles the supplied audit concerns against current code. Existing informal docs remain historical context, not a second task tracker.
|
||||
|
||||
**Verified** means the cited implementation establishes the behavior or gap. **Likely** would mean an inference not yet reproduced; none is promoted to a confirmed defect here. **Needs Investigation** marks runtime/coverage questions that source alone cannot certify. No full application test suite or new performance benchmark was run during this planning-only task. Numeric acceptance examples are new test requirements, not fabricated passing tests.
|
||||
|
||||
## FIN-01 — Critical / Verified
|
||||
|
||||
Both execution paths can act on a completed bar and fill against its current close; this is not a defensible default bar-close policy.
|
||||
|
||||
Evidence: [apps/stock/engine/src/backtest/engine.rs:249](../../../apps/stock/engine/src/backtest/engine.rs#L249); [apps/stock/orchestrator/src/services/ExecutionService.ts:224](../../../apps/stock/orchestrator/src/services/ExecutionService.ts#L224).
|
||||
|
||||
Disposition: [F01](tasks/F01.md), [F05](tasks/F05.md), [F06](tasks/F06.md), [W02](tasks/W02.md).
|
||||
|
||||
## FIN-02 — Critical / Verified
|
||||
|
||||
Native forced liquidation occurs after the last equity mark; reported final value reads that earlier mark, omitting terminal costs.
|
||||
|
||||
Evidence: [apps/stock/engine/src/backtest/engine.rs:135](../../../apps/stock/engine/src/backtest/engine.rs#L135); [apps/stock/engine/src/backtest/simple_results.rs:308](../../../apps/stock/engine/src/backtest/simple_results.rs#L308).
|
||||
|
||||
Disposition: [C01](tasks/C01.md), [F01](tasks/F01.md), [F02](tasks/F02.md).
|
||||
|
||||
## FIN-03 — Critical / Verified
|
||||
|
||||
Native order risk lacks a cash/fee reservation check. TypeScript compares gross exposure with pre-fee equity, so a fully funded buy can leave negative cash.
|
||||
|
||||
Evidence: [apps/stock/engine/src/risk/mod.rs:89](../../../apps/stock/engine/src/risk/mod.rs#L89); [apps/stock/orchestrator/src/execution/model.ts:234](../../../apps/stock/orchestrator/src/execution/model.ts#L234).
|
||||
|
||||
Disposition: [C03](tasks/C03.md), [F01](tasks/F01.md), [F02](tasks/F02.md), [F04](tasks/F04.md).
|
||||
|
||||
## FIN-04 — Critical / Verified
|
||||
|
||||
Native fills notify every strategy. TypeScript realized P&L uses aggregate symbol cost basis, not per-strategy cost basis.
|
||||
|
||||
Evidence: [apps/stock/engine/src/backtest/engine.rs:489](../../../apps/stock/engine/src/backtest/engine.rs#L489); [apps/stock/orchestrator/src/execution/model.ts:108](../../../apps/stock/orchestrator/src/execution/model.ts#L108).
|
||||
|
||||
Disposition: [F01](tasks/F01.md), [F02](tasks/F02.md), [S02](tasks/S02.md), [S05](tasks/S05.md).
|
||||
|
||||
## FIN-05 — Critical / Verified
|
||||
|
||||
Rust and TypeScript separately implement fill/accounting behavior; the exposed native TypeScript callback method explicitly rejects callbacks.
|
||||
|
||||
Evidence: [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).
|
||||
|
||||
Disposition: [F01](tasks/F01.md), [F02](tasks/F02.md), [F05](tasks/F05.md), [F07](tasks/F07.md), [S01](tasks/S01.md), [S03](tasks/S03.md), [S06](tasks/S06.md), [R05](tasks/R05.md), [P01](tasks/P01.md), [P06](tasks/P06.md).
|
||||
|
||||
## FIN-06 — High / Verified
|
||||
|
||||
Native simulation fills complete requested quantities at the latest price without bar-volume participation; current risk must be enforced at acceptance and fill, including pending exposure.
|
||||
|
||||
Evidence: [apps/stock/engine/src/backtest/engine.rs:374](../../../apps/stock/engine/src/backtest/engine.rs#L374); [apps/stock/engine/src/backtest/engine.rs:414](../../../apps/stock/engine/src/backtest/engine.rs#L414).
|
||||
|
||||
Disposition: [F01](tasks/F01.md), [F04](tasks/F04.md), [F05](tasks/F05.md), [S04](tasks/S04.md).
|
||||
|
||||
## FIN-07 — High / Verified
|
||||
|
||||
Daily return grouping, Sharpe/Sortino conventions and placeholder exposure/VaR produce incomparable or misleading native metrics.
|
||||
|
||||
Evidence: [apps/stock/engine/src/backtest/simple_results.rs:374](../../../apps/stock/engine/src/backtest/simple_results.rs#L374); [apps/stock/engine/src/backtest/simple_results.rs:542](../../../apps/stock/engine/src/backtest/simple_results.rs#L542).
|
||||
|
||||
Disposition: [F08](tasks/F08.md), [W02](tasks/W02.md), [R07](tasks/R07.md), [R08](tasks/R08.md).
|
||||
|
||||
## DAT-01 — Critical / Verified
|
||||
|
||||
Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times.
|
||||
|
||||
Evidence: [libs/core/types/src/historical-data.ts:90](../../../libs/core/types/src/historical-data.ts#L90); [apps/stock/orchestrator/src/services/StorageService.ts:177](../../../apps/stock/orchestrator/src/services/StorageService.ts#L177).
|
||||
|
||||
Disposition: [F06](tasks/F06.md), [D01](tasks/D01.md), [R08](tasks/R08.md), [R11](tasks/R11.md).
|
||||
|
||||
## DAT-02 — High / Verified
|
||||
|
||||
Native input parsing silently discards malformed rows and truncates timestamps to seconds.
|
||||
|
||||
Evidence: [apps/stock/engine/src/api/backtest.rs:217](../../../apps/stock/engine/src/api/backtest.rs#L217); [apps/stock/engine/src/api/backtest.rs:290](../../../apps/stock/engine/src/api/backtest.rs#L290).
|
||||
|
||||
Disposition: [C02](tasks/C02.md).
|
||||
|
||||
## DAT-03 — High / Verified
|
||||
|
||||
Missing VWAP is replaced with typical price; reported volume and provider-adjusted prices are not a complete corporate-action execution model.
|
||||
|
||||
Evidence: [apps/stock/orchestrator/src/data/historical-dataset.ts:230](../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L230); [libs/core/types/src/historical-data.ts:98](../../../libs/core/types/src/historical-data.ts#L98).
|
||||
|
||||
Disposition: [D01](tasks/D01.md).
|
||||
|
||||
## DAT-04 — High / Verified
|
||||
|
||||
Historical storage selects QuestDB or daily MongoDB; the Mongo path explicitly rejects intraday requests. Ingestion-to-research routing requires an executable provider/interval capability check.
|
||||
|
||||
Evidence: [apps/stock/orchestrator/src/services/StorageService.ts:287](../../../apps/stock/orchestrator/src/services/StorageService.ts#L287); [apps/stock/orchestrator/src/services/StorageService.ts:299](../../../apps/stock/orchestrator/src/services/StorageService.ts#L299).
|
||||
|
||||
Disposition: [D02](tasks/D02.md).
|
||||
|
||||
## RUN-01 — Critical / Verified
|
||||
|
||||
TypeScript research preparation calls the shared mode manager, which shuts down the current mode, so a research job can interfere with paper runtime.
|
||||
|
||||
Evidence: [apps/stock/orchestrator/src/container.ts:101](../../../apps/stock/orchestrator/src/container.ts#L101); [apps/stock/orchestrator/src/core/ModeManager.ts:47](../../../apps/stock/orchestrator/src/core/ModeManager.ts#L47).
|
||||
|
||||
Disposition: [C06](tasks/C06.md).
|
||||
|
||||
## RUN-02 — High / Verified
|
||||
|
||||
Partial initialization can allocate services before isInitialized becomes true; shutdown exits early on that failure path.
|
||||
|
||||
Evidence: [apps/stock/orchestrator/src/core/ModeManager.ts:55](../../../apps/stock/orchestrator/src/core/ModeManager.ts#L55); [apps/stock/orchestrator/src/core/ModeManager.ts:157](../../../apps/stock/orchestrator/src/core/ModeManager.ts#L157).
|
||||
|
||||
Disposition: [C04](tasks/C04.md).
|
||||
|
||||
## KEEP-01 — High / Verified
|
||||
|
||||
Preserve transaction-scoped account locking, idempotent fills/event fingerprints, durable decisions and recovery checkpoints; these are real behavior, not interfaces alone.
|
||||
|
||||
Evidence: [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).
|
||||
|
||||
Disposition: [F01](tasks/F01.md), [C06](tasks/C06.md), [F02](tasks/F02.md), [F05](tasks/F05.md), [S01](tasks/S01.md), [S03](tasks/S03.md), [S06](tasks/S06.md), [A04](tasks/A04.md).
|
||||
|
||||
## KEEP-02 — High / Verified
|
||||
|
||||
Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine.
|
||||
|
||||
Evidence: [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
Disposition: [F07](tasks/F07.md), [D01](tasks/D01.md), [D04](tasks/D04.md), [W04](tasks/W04.md), [R05](tasks/R05.md), [R06](tasks/R06.md), [R11](tasks/R11.md), [R12](tasks/R12.md), [P01](tasks/P01.md), [P03](tasks/P03.md), [P04](tasks/P04.md), [O02](tasks/O02.md).
|
||||
|
||||
## STR-01 — High / Verified
|
||||
|
||||
Registry is a useful small boundary, but its factories receive mode/execution services; BaseStrategy mixes author decisions, order submission and hidden signal filtering.
|
||||
|
||||
Evidence: [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).
|
||||
|
||||
Disposition: [F02](tasks/F02.md), [D04](tasks/D04.md), [S01](tasks/S01.md), [S02](tasks/S02.md), [S05](tasks/S05.md), [S06](tasks/S06.md), [R01](tasks/R01.md), [R02](tasks/R02.md), [A02](tasks/A02.md).
|
||||
|
||||
## WEB-01 — High / Verified
|
||||
|
||||
The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders.
|
||||
|
||||
Evidence: [apps/stock/web-app/src/app/App.tsx:24](../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
|
||||
Disposition: [W01](tasks/W01.md), [W03](tasks/W03.md), [W04](tasks/W04.md), [R01](tasks/R01.md), [R02](tasks/R02.md), [R03](tasks/R03.md), [R04](tasks/R04.md), [R06](tasks/R06.md), [R07](tasks/R07.md), [R09](tasks/R09.md), [P05](tasks/P05.md), [A01](tasks/A01.md).
|
||||
|
||||
## WEB-02 — High / Verified
|
||||
|
||||
Detail exposes native-unsupported pause/resume controls, omits cancel wiring, and overlapping polling/selection can apply stale responses.
|
||||
|
||||
Evidence: [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:379](../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L379); [apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts:160](../../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts#L160).
|
||||
|
||||
Disposition: [W01](tasks/W01.md), [W04](tasks/W04.md), [O02](tasks/O02.md).
|
||||
|
||||
## WEB-03 — High / Verified
|
||||
|
||||
Definition creation auto-starts by default and catches submission failure; run creation has no client submission key. Re-run uses current definition rather than immutable original input.
|
||||
|
||||
Evidence: [apps/stock/web-api/src/services/backtest-v2.service.ts:105](../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L105); [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:173](../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L173).
|
||||
|
||||
Disposition: [W03](tasks/W03.md), [R12](tasks/R12.md).
|
||||
|
||||
## WEB-04 — High / Verified
|
||||
|
||||
Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields.
|
||||
|
||||
Evidence: [libs/core/types/src/backtest-run.ts:4](../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
Disposition: [F08](tasks/F08.md), [W02](tasks/W02.md), [R01](tasks/R01.md), [R03](tasks/R03.md), [R04](tasks/R04.md), [R05](tasks/R05.md), [R06](tasks/R06.md), [R07](tasks/R07.md), [R10](tasks/R10.md), [R11](tasks/R11.md), [R12](tasks/R12.md), [A03](tasks/A03.md).
|
||||
|
||||
## WEB-05 — High / Verified
|
||||
|
||||
SQL deletion cascades from definitions to runs/results; evidence retention must be defined before research findings reference those results.
|
||||
|
||||
Evidence: [database/postgres/init/08-create-runs-table.sql:13](../../../database/postgres/init/08-create-runs-table.sql#L13); [database/postgres/init/06-create-backtest-tables.sql:25](../../../database/postgres/init/06-create-backtest-tables.sql#L25).
|
||||
|
||||
Disposition: [R03](tasks/R03.md), [R10](tasks/R10.md).
|
||||
|
||||
## OPS-01 — High / Verified
|
||||
|
||||
Migration runner uses an explicit safe allowlist; adding SQL alone will not run it. Concurrent migration admission lacks an advisory lock.
|
||||
|
||||
Evidence: [apps/stock/web-api/src/migrations/migration-runner.ts:42](../../../apps/stock/web-api/src/migrations/migration-runner.ts#L42); [apps/stock/web-api/src/migrations/migration-runner.ts:57](../../../apps/stock/web-api/src/migrations/migration-runner.ts#L57).
|
||||
|
||||
Disposition: [O01](tasks/O01.md).
|
||||
|
||||
## PER-01 — Medium / 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.
|
||||
|
||||
Evidence: [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).
|
||||
|
||||
Disposition: [F06](tasks/F06.md), [F07](tasks/F07.md), [P01](tasks/P01.md), [P03](tasks/P03.md), [P04](tasks/P04.md), [P05](tasks/P05.md), [P06](tasks/P06.md).
|
||||
|
||||
## AI-01 — High / Verified
|
||||
|
||||
Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary.
|
||||
|
||||
Evidence: [libs/core/di/src/http/security.ts:4](../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../libs/core/di/src/http/security.ts#L144).
|
||||
|
||||
Disposition: [A01](tasks/A01.md), [A02](tasks/A02.md), [A03](tasks/A03.md), [A04](tasks/A04.md).
|
||||
|
||||
## RES-01 — High / Verified
|
||||
|
||||
Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence.
|
||||
|
||||
Evidence: [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
|
||||
Disposition: [D04](tasks/D04.md), [S05](tasks/S05.md), [R08](tasks/R08.md), [R09](tasks/R09.md), [A03](tasks/A03.md).
|
||||
|
||||
## OPS-02 — High / Needs Investigation
|
||||
|
||||
Paper/live operational readiness is not demonstrated end-to-end. Live is deliberately disabled; preserve that gate until feed, reconciliation and broker-specific recovery are verified.
|
||||
|
||||
Evidence: [apps/stock/orchestrator/src/core/ModeManager.ts:33](../../../apps/stock/orchestrator/src/core/ModeManager.ts#L33); [apps/stock/orchestrator/src/container.ts:152](../../../apps/stock/orchestrator/src/container.ts#L152).
|
||||
|
||||
Disposition: [S04](tasks/S04.md), [A04](tasks/A04.md), [O02](tasks/O02.md).
|
||||
|
||||
## Corrections to over-broad audit conclusions
|
||||
|
||||
- The first web workflow is not missing: real list/detail/routes, transactional dispatch and committed-state websocket updates exist. W01–W04 repair and verify it.
|
||||
- Durable recovery and frozen data are implemented, not planned placeholders. Preserve them through S03; do not replace them for language uniformity.
|
||||
- Native callback support is explicitly unavailable; NAPI types alone do not imply TS strategies already run in Rust replay.
|
||||
- Future/native/experimental strategy files and Python research routines are not project-gated runtime capabilities. Do not enable them simply because names appear in a dropdown.
|
||||
- Provider-adjusted data is not automatically executable corporate-action accounting. Hashing a dataset does not establish point-in-time correctness.
|
||||
- No runtime evidence here establishes real broker reliability. Live-disabled guards remain intact.
|
||||
- Exact hardware throughput, storage hot spots, memory limits and sandbox availability require P01/A02 measurements, not architectural confidence.
|
||||
- Preservation rules in [cleanup audit](../../cleanup-audit.md) remain: reviewed calculations, restored helpers and useful research prototypes are not disposable dead code.
|
||||
1765
docs/development/backlog/manifest.json
Normal file
1765
docs/development/backlog/manifest.json
Normal file
File diff suppressed because it is too large
Load diff
65
docs/development/backlog/tasks/A01.md
Normal file
65
docs/development/backlog/tasks/A01.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# A01 — Add research-only principals and durable job budgets
|
||||
|
||||
Parent epic: E8. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Backend security/durable scheduling.
|
||||
|
||||
Scheduling source of truth: [manifest entry A01](../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
|
||||
|
||||
- **AI-01 — Verified:** Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary. [libs/core/di/src/http/security.ts:4](../../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../../libs/core/di/src/http/security.ts#L144).
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Extend the small existing auth boundary with stable owner/agent identities and research-scoped permissions. Enforce per-agent concurrent-job/trial/time/resource budgets at admission and execution; record actor and audit events. Do not reinstate global historical data truncation limits.
|
||||
|
||||
Measurable benefit: Allows autonomous research without autonomous brokerage control.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- libs/core/di/src/http/security.ts
|
||||
- apps/stock/web-api/src/routes/
|
||||
- apps/stock/web-api/src/services/ (admission)
|
||||
- apps/stock/orchestrator/src/backtest/BacktestRunner.ts
|
||||
|
||||
Write locks: auth-contract, experiment-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R06](R06.md), [O01](O01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-007. 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
|
||||
|
||||
- AI research token can register hypotheses and submit authorized experiments but cannot call paper/live administration or mutate financial constraints.
|
||||
- Budget reservations are transactional and released on failure/cancellation/restart; retries do not double-charge.
|
||||
- User-configured budgets and rejections are visible; operator's large trusted datasets remain supported.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- research_token_live_denied, budget_concurrent_admission, budget_recovery, actor_audit.
|
||||
- Existing security/browser-session/CSRF tests; do not break current operator workflow.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: Research-scoped credential routes/claims; typed403/429 with budget diagnostics on same experiment APIs.
|
||||
- Backend/data dependencies: Minimal principal/budget/audit persistence; existing local owner maps to one principal.
|
||||
- Loading/error/empty behavior: API identifies quota wait vs invalid request; UI can show admission error without losing experiment draft.
|
||||
- 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.
|
||||
58
docs/development/backlog/tasks/A02.md
Normal file
58
docs/development/backlog/tasks/A02.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# A02 — Isolate untrusted TypeScript strategy builds and decisions
|
||||
|
||||
Parent epic: E8. Priority/severity: P1 / High. Relative complexity: L. Recommended specialization: Process isolation/security.
|
||||
|
||||
Scheduling source of truth: [manifest entry A02](../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
|
||||
|
||||
- **AI-01 — Verified:** Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary. [libs/core/di/src/http/security.ts:4](../../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../../libs/core/di/src/http/security.ts#L144).
|
||||
- **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).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Compile/import AI artifacts only in an OS-restricted process/container without network, secrets, DB, broker access or full future dataset. Engine supervisor sends prefix-only context and receives intents through a small IPC protocol. Apply wall/CPU/memory limits; pin artifact dependencies. node:vm alone is not a security boundary.
|
||||
|
||||
Measurable benefit: Makes arbitrary AI code execution a contained research capability.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/backtest/ (isolated strategy host)
|
||||
- apps/stock/web-api/src/services/ (artifact registration)
|
||||
- scripts/ (sandbox launch profile)
|
||||
|
||||
Write locks: sandbox-contract, worker-protocol. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [A01](A01.md), [S01](S01.md), [P01](P01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-007. 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
|
||||
|
||||
- Malicious imports, filesystem/network/env probing and infinite loops fail safely without affecting the API/paper process.
|
||||
- Candidate cannot access future bars through files/native handles; only the supervisor owns financial engine and data.
|
||||
- Trusted reviewed artifact fast path is an explicit human promotion, never self-selected by code.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- deny_network_secret_read_child_spawn, infinite_loop_kill, malformed_intent, future_context_exfiltration, worker_cleanup.
|
||||
- Sandbox availability check fails closed; benchmark IPC overhead separately from trusted NAPI path.
|
||||
|
||||
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
|
||||
|
||||
Native runtime/process privileges can invalidate the sandbox; independent security review required.
|
||||
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.
|
||||
63
docs/development/backlog/tasks/A03.md
Normal file
63
docs/development/backlog/tasks/A03.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# A03 — Implement an evidence-linked AI research workflow client
|
||||
|
||||
Parent epic: E8. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: AI research integration.
|
||||
|
||||
Scheduling source of truth: [manifest entry A03](../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
|
||||
|
||||
- **AI-01 — Verified:** Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary. [libs/core/di/src/http/security.ts:4](../../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../../libs/core/di/src/http/security.ts#L144).
|
||||
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Implement a typed authorized research API client/example using backend R03/R06/R08 contracts, independent of whether project UI is complete. Propose hypothesis, register candidate, preview/submit bounded experiments, inspect all outcomes, request validation and save run-linked findings. No new AI service/framework or mandatory vendor/model SDK.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/routes/ (research API contracts)
|
||||
- scripts/ (research client example)
|
||||
- test/integration/ (AI research flow)
|
||||
|
||||
Write locks: ai-workflow-client. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [A02](A02.md), [R08](R08.md), [R03](R03.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-007. 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
|
||||
|
||||
- Every AI finding links immutable run/artifact IDs and distinguishes proposed hypotheses from validated evidence.
|
||||
- An execution failure is returned as a diagnostic, not filtered out of candidate history.
|
||||
- Client cannot promote itself to paper/live or alter operator account risk policy.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- ai_hypothesis_to_validated_finding_contract, bounded_search_rejected, failed_trial_reported, evidence_mismatch_rejected.
|
||||
- Replay the workflow with deterministic fake model suggestions; no paid model call required for CI.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: Reuse projects/hypotheses/versions/experiments/artifacts endpoints and diagnostics; publish typed request/response examples.
|
||||
- Backend/data dependencies: No second task store or AI-only results database.
|
||||
- Loading/error/empty behavior: Client handles202 polling,429 budgets,409 conflicts and terminal failures; UI shows AI authorship in existing workspace.
|
||||
- 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.
|
||||
64
docs/development/backlog/tasks/A04.md
Normal file
64
docs/development/backlog/tasks/A04.md
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# 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](../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
|
||||
|
||||
- **OPS-02 — Needs Investigation:** Paper/live operational readiness is not demonstrated end-to-end. Live is deliberately disabled; preserve that gate until feed, reconciliation and broker-specific recovery are verified. [apps/stock/orchestrator/src/core/ModeManager.ts:33](../../../../apps/stock/orchestrator/src/core/ModeManager.ts#L33); [apps/stock/orchestrator/src/container.ts:152](../../../../apps/stock/orchestrator/src/container.ts#L152).
|
||||
- **AI-01 — Verified:** Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary. [libs/core/di/src/http/security.ts:4](../../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../../libs/core/di/src/http/security.ts#L144).
|
||||
- **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
|
||||
|
||||
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](S04.md), [R09](R09.md), [A01](A01.md), [R01](R01.md) 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](../../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.
|
||||
|
||||
## 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.
|
||||
56
docs/development/backlog/tasks/C01.md
Normal file
56
docs/development/backlog/tasks/C01.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# C01 — Correct native terminal valuation
|
||||
|
||||
Parent epic: E1. Priority/severity: P0 / Critical. Relative complexity: S. Recommended specialization: Rust financial correctness.
|
||||
|
||||
Scheduling source of truth: [manifest entry C01](../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-02 — Verified:** Native forced liquidation occurs after the last equity mark; reported final value reads that earlier mark, omitting terminal costs. [apps/stock/engine/src/backtest/engine.rs:135](../../../../apps/stock/engine/src/backtest/engine.rs#L135); [apps/stock/engine/src/backtest/simple_results.rs:308](../../../../apps/stock/engine/src/backtest/simple_results.rs#L308).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Correct the current native forced-liquidation path only: mark the final account after all closing fills and update the existing terminal-time equity sample instead of appending a duplicate timestamp. Preserve current matching, sizing, liquidation and fee policies. Do not implement the new engine here.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/backtest/engine.rs
|
||||
- apps/stock/engine/src/backtest/simple_results.rs
|
||||
- test/integration/native-terminal-equity.test.ts (new, only if public API can exercise the same fixture)
|
||||
|
||||
Write locks: legacy-native-finance. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- A deterministic test strategy/direct internal fixture buys exactly1 share at4 from cash10, with1% entry/exit fees and zero slippage: final cash/equity/finalValue=9.92 and total fees=0.08.
|
||||
- Positions eligible for liquidation in these fixtures are flat; every closing fill is included once, including multiple symbols. Preserve the existing micro-position threshold; any retained residual still contributes its marked value to final equity.
|
||||
- No-position/zero-fee behavior remains correct; there is exactly one final-time equity sample.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- Inline Rust fixtures: terminal_fee_equity, terminal_no_positions, terminal_zero_fee, terminal_multiple_symbols, terminal_timestamp_unique.
|
||||
- cargo test -p engine --lib --offline; build current addon with bun run --cwd apps/stock/engine build:debug; then bun test test/integration/backtest-result-mapping.test.ts test/integration/backtest-ledger.test.ts.
|
||||
- If a new native-terminal-equity.test.ts is added, run it too. Do not derive expected quantity from production position sizing.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
55
docs/development/backlog/tasks/C02.md
Normal file
55
docs/development/backlog/tasks/C02.md
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# C02 — Reject malformed native data and preserve milliseconds
|
||||
|
||||
Parent epic: E1. Priority/severity: P1 / High. Relative complexity: S. Recommended specialization: Rust/NAPI boundary.
|
||||
|
||||
Scheduling source of truth: [manifest entry C02](../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
|
||||
|
||||
- **DAT-02 — Verified:** Native input parsing silently discards malformed rows and truncates timestamps to seconds. [apps/stock/engine/src/api/backtest.rs:217](../../../../apps/stock/engine/src/api/backtest.rs#L217); [apps/stock/engine/src/api/backtest.rs:290](../../../../apps/stock/engine/src/api/backtest.rs#L290).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Validate all input rows before admission; return row-indexed errors instead of filter_map dropping rows. Preserve epoch milliseconds, reject non-finite/invalid OHLC and duplicate conflicting identities.
|
||||
|
||||
Measurable benefit: Stops silent dataset corruption.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/api/backtest.rs
|
||||
- test/integration/ingestion-backtest.test.ts
|
||||
|
||||
Write locks: native-public-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- One invalid row causes an atomic load failure with its index; valid neighbors are not partially installed.
|
||||
- Events at 1001ms and 1999ms remain distinct and ordered; unknown data types fail explicitly.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- Native bridge tests invalid OHLC/NaN/missing field/unsupported type and sub-second round trip.
|
||||
- Existing native load fixtures remain accepted.
|
||||
|
||||
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
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
57
docs/development/backlog/tasks/C03.md
Normal file
57
docs/development/backlog/tasks/C03.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# C03 — Close the existing TypeScript fee-funding hole
|
||||
|
||||
Parent epic: E1. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: Trading infrastructure implementation.
|
||||
|
||||
Scheduling source of truth: [manifest entry C03](../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-03 — Verified:** Native order risk lacks a cash/fee reservation check. TypeScript compares gross exposure with pre-fee equity, so a fully funded buy can leave negative cash. [apps/stock/engine/src/risk/mod.rs:89](../../../../apps/stock/engine/src/risk/mod.rs#L89); [apps/stock/orchestrator/src/execution/model.ts:234](../../../../apps/stock/orchestrator/src/execution/model.ts#L234).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Narrow interim fix: retain the current legacy gross-exposure financing model and its reducing-order exemption. Add projected unpaid commissions to the existing non-reducing capital test, using proposed remaining quantity plus pending remaining quantities and each order's frozen commission policy. At fill, exclude the current order from other reservations and use its stored policy. Paid fees already reduce current equity and must not be counted again. No new cash-reservation table, schema, long-only rule or independent financing subsystem.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/execution/model.ts
|
||||
- apps/stock/orchestrator/src/execution/SimulationExecution.ts
|
||||
- test/integration/fee-funding.test.ts (new)
|
||||
|
||||
Write locks: ts-execution-model. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- Under existing non-reducing policy:10000 cash, buy100@100,1% fee rejects without financial mutation; buy99@100 succeeds leaving1.
|
||||
- Two zero-liquidity pending buys of50@100 with1% fees cannot both pass: reserved commitments would total10100. Cancellation releases the computed commitment.
|
||||
- A99-share order filled10 then89 shares pays99 total commission and leaves1; duplicate events charge nothing twice.
|
||||
- Existing short/reversal and risk-reducing behavior is unchanged. This fix does not claim the legacy financing model is cash-only or that insolvent short covers cannot create debt.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- Dedicated test/integration/fee-funding.test.ts: fee_budget_10000, fee_budget_99, pending_fee_commitments, partial_fee_not_double_counted, cancelled_commitment_released, frozen_order_fee_policy.
|
||||
- bun test test/integration/fee-funding.test.ts test/integration/order-execution.test.ts test/integration/strategy-recovery.test.ts; bun run typecheck; bun run test:contracts.
|
||||
- Integration owner runs the existing disposable PostgreSQL order-execution suite before merge; no development trading DB.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
55
docs/development/backlog/tasks/C04.md
Normal file
55
docs/development/backlog/tasks/C04.md
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# C04 — Make partial runtime initialization recoverable
|
||||
|
||||
Parent epic: E1. Priority/severity: P1 / High. Relative complexity: S. Recommended specialization: Trading infrastructure implementation.
|
||||
|
||||
Scheduling source of truth: [manifest entry C04](../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
|
||||
|
||||
- **RUN-02 — Verified:** Partial initialization can allocate services before isInitialized becomes true; shutdown exits early on that failure path. [apps/stock/orchestrator/src/core/ModeManager.ts:55](../../../../apps/stock/orchestrator/src/core/ModeManager.ts#L55); [apps/stock/orchestrator/src/core/ModeManager.ts:157](../../../../apps/stock/orchestrator/src/core/ModeManager.ts#L157).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Keep the successful lifecycle ordering. Register cleanup before each stage that may partially acquire resources; on initialization failure stop admission/feed, attempt all applicable cleanups, preserve the original initialization error and clear failed engine/config readiness. Retrying must be safe. Do not redesign runtime composition or add an imaginary native dispose method.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/core/ModeManager.ts
|
||||
- test/integration/mode-lifecycle.test.ts
|
||||
|
||||
Write locks: runtime-composition. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- Inject failure in execution initialize, storage initialize, strategy restore and market initialize. Clean up the failing stage as well as previously acquired stages; untouched stages are not invented resources.
|
||||
- Cleanup failure neither masks the original error nor prevents remaining cleanup; feed stops before strategy/account teardown.
|
||||
- No successful modeChanged event is published on failure; engine/config access cannot expose failed readiness; a retry succeeds.
|
||||
- Existing shutdown ordering and live-disabled validation remain unchanged.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- bun test test/integration/mode-lifecycle.test.ts with initialization_failure_each_stage, partial_acquisition_cleanup, cleanup_preserves_original_error, failed_init_retry and no_success_event.
|
||||
- bun run typecheck; bun run test:contracts.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
5
docs/development/backlog/tasks/C05.md
Normal file
5
docs/development/backlog/tasks/C05.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# C05 — Merged into F01
|
||||
|
||||
This ID is retained for traceability and must not be claimed or implemented separately.
|
||||
|
||||
Its required behavior, fixtures and tests are owned by [F01](F01.md). See [skeptical review](../../REVIEW.md) for the effort reduction and [manifest](../manifest.json) for canonical scheduling metadata.
|
||||
56
docs/development/backlog/tasks/C06.md
Normal file
56
docs/development/backlog/tasks/C06.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# C06 — Contain legacy research/paper interference without a second runtime
|
||||
|
||||
Parent epic: E1. Priority/severity: P0 / Critical. Relative complexity: S. Recommended specialization: Trading infrastructure implementation.
|
||||
|
||||
Scheduling source of truth: [manifest entry C06](../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
|
||||
|
||||
- **RUN-01 — Verified:** TypeScript research preparation calls the shared mode manager, which shuts down the current mode, so a research job can interfere with paper runtime. [apps/stock/orchestrator/src/container.ts:101](../../../../apps/stock/orchestrator/src/container.ts#L101); [apps/stock/orchestrator/src/core/ModeManager.ts:47](../../../../apps/stock/orchestrator/src/core/ModeManager.ts#L47).
|
||||
- **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
|
||||
|
||||
Contain the legacy TS shared-mode hazard without building a second run-local TS execution framework. Use explicit composition roles: a shared paper runtime accepts only already-isolated native research; legacy TS research is allowed only in an explicit research-only composition with paper initialization/activation disabled. Reject unsafe combinations before mode mutation. Canonical TS strategies later use the Rust worker/session path. Keep the existing single-run busy guard.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/container.ts
|
||||
- apps/stock/orchestrator/src/backtest/BacktestRunner.ts
|
||||
- apps/stock/orchestrator/src/backtest/BacktestEngine.ts
|
||||
|
||||
Write locks: runtime-composition. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [C04](C04.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
|
||||
|
||||
- Attempting a legacy TS run in a paper composition fails with a specific unsupported-combination diagnostic before paper shutdown, cash/checkpoint mutation or feed interruption.
|
||||
- Explicit legacy research-only startup remains usable and cannot activate paper in that same composition.
|
||||
- Native research alongside paper preserves paper lifecycle/account hashes; repeated cancelled/failed jobs do not alter them.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- legacy_paper_combination_rejected_before_prepare, standalone_legacy_research_allowed, research_only_paper_activation_denied, native_paper_isolation.
|
||||
- Existing backtest-workflow/typescript-backtest/mode-lifecycle suites; no new worker for legacy TS.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
61
docs/development/backlog/tasks/D01.md
Normal file
61
docs/development/backlog/tasks/D01.md
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# D01 — Introduce availability-aware dataset v2
|
||||
|
||||
Parent epic: E3. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.
|
||||
|
||||
Scheduling source of truth: [manifest entry D01](../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
|
||||
|
||||
- **DAT-01 — Verified:** Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times. [libs/core/types/src/historical-data.ts:90](../../../../libs/core/types/src/historical-data.ts#L90); [apps/stock/orchestrator/src/services/StorageService.ts:177](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L177).
|
||||
- **DAT-03 — Verified:** Missing VWAP is replaced with typical price; reported volume and provider-adjusted prices are not a complete corporate-action execution model. [apps/stock/orchestrator/src/data/historical-dataset.ts:230](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L230); [libs/core/types/src/historical-data.ts:98](../../../../libs/core/types/src/historical-data.ts#L98).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add interval start/end, availableAt, venue/calendar revision and source sequence to frozen events; preserve missing VWAP as missing. Keep v1 snapshots immutable. Convert daily session labels only with an explicit versioned calendar; fail closed for unknown venue/time semantics. Include per-series identity/timeframe so a run can select exactly one execution feed per instrument and separate feature-only series.
|
||||
|
||||
Measurable benefit: Defines point-in-time truth before new replay logic.
|
||||
|
||||
Absorb D03 in the same manifest version: record universe/as-of and corporate-action coverage, distinguish signal-adjusted from raw execution prices and retain limitations. Do not build an action feed or a correctness-gate evidence subsystem. Known unsupported action ranges reject executable policy; unknown coverage stays explicitly exploratory, never silently verified.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- libs/core/types/src/historical-data.ts
|
||||
- apps/stock/orchestrator/src/data/historical-dataset.ts
|
||||
- apps/stock/orchestrator/src/services/StorageService.ts
|
||||
|
||||
Write locks: dataset-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
Architecture decisions: ADR-003. 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
|
||||
|
||||
- A new manifest/hash is produced for every conversion; v1 hashes still verify.
|
||||
- US daily bars become available at actual session end, including DST and half days; invalid/duplicate conflicts reject.
|
||||
- Warmup and trade ranges are separate, with no invented VWAP or interpolation.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- dataset_v1_compatibility, dataset_v2_hash, DST_half_day, missing_vwap, conflicting_duplicate.
|
||||
- Future-suffix mutation does not change prior observable prefixes.
|
||||
|
||||
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.
|
||||
57
docs/development/backlog/tasks/D02.md
Normal file
57
docs/development/backlog/tasks/D02.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# D02 — Connect supported intraday storage to research datasets
|
||||
|
||||
Parent epic: E3. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.
|
||||
|
||||
Scheduling source of truth: [manifest entry D02](../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
|
||||
|
||||
- **DAT-04 — Verified:** Historical storage selects QuestDB or daily MongoDB; the Mongo path explicitly rejects intraday requests. Ingestion-to-research routing requires an executable provider/interval capability check. [apps/stock/orchestrator/src/services/StorageService.ts:287](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L287); [apps/stock/orchestrator/src/services/StorageService.ts:299](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L299).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Trace the actual intraday collection/schema, add the smallest provider adapter or correct routing, and expose an explicit provider/interval coverage capability. Keep a single normalized dataset admission path; do not migrate all storage systems.
|
||||
|
||||
Measurable benefit: Makes supported intraday requests usable and honest.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/services/StorageService.ts
|
||||
- apps/stock/data-ingestion/src/
|
||||
- test/integration/ingestion-backtest.test.ts
|
||||
|
||||
Write locks: storage-adapters. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [D01](D01.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
|
||||
|
||||
- A disposable ingested 5m fixture is retrieved through the research path with unchanged timestamps/OHLC/count.
|
||||
- Unavailable ranges/providers return typed errors, never daily data or synthetic fallbacks.
|
||||
- Record the verified ingestion collection/adapter in the task evidence before changing code.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- ingest_5m_freeze_replay, unsupported_interval, missing_range, provider_priority.
|
||||
- Hash the ingested normalized fixture and compare retrieval.
|
||||
|
||||
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.
|
||||
5
docs/development/backlog/tasks/D03.md
Normal file
5
docs/development/backlog/tasks/D03.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# D03 — Merged into D01
|
||||
|
||||
This ID is retained for traceability and must not be claimed or implemented separately.
|
||||
|
||||
Its required behavior, fixtures and tests are owned by [D01](D01.md). See [skeptical review](../../REVIEW.md) for the effort reduction and [manifest](../manifest.json) for canonical scheduling metadata.
|
||||
62
docs/development/backlog/tasks/D04.md
Normal file
62
docs/development/backlog/tasks/D04.md
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# D04 — Provide prefix-safe shared feature calculation
|
||||
|
||||
Parent epic: E3. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Quantitative feature engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry D04](../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
|
||||
|
||||
- **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).
|
||||
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add a small feature request/result contract keyed by dataset hash, instrument, timeframe, parameters and implementation version. Reuse reviewed calculations; one experiment-local calculation per identical feature request. Prefix-gate precomputed outputs; no distributed feature service or persistent cache framework. Fitted/model features also key by artifact hash, fit-window identity and availability policy; they must not reuse a transform fitted on another partition.
|
||||
|
||||
Measurable benefit: Avoids duplicate work and feature leakage without a framework.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- libs/calculations/
|
||||
- apps/stock/engine/src/indicators/
|
||||
- apps/stock/orchestrator/src/data/
|
||||
- test/integration/strategy-contracts.test.ts
|
||||
|
||||
Write locks: feature-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [S01](S01.md), [P01](P01.md) integrated.
|
||||
|
||||
No additional economic-policy approval is needed for this narrowly scoped task.
|
||||
|
||||
Deferred: Only after profiling demonstrates repeated identical feature work; use reviewed incremental calculations directly first.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- Regime and strategy consumers requesting the same SMA/volatility share results within a run.
|
||||
- Batch and incremental values match reviewed warmup/NaN semantics; a future data mutation cannot affect earlier features.
|
||||
- Float feature outputs never become authoritative monetary calculations.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- batch_incremental_parity, prefix_equivalence, shared_request_counter, warmup_alignment.
|
||||
- Run calculations migration-preservation and numerical suites.
|
||||
|
||||
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.
|
||||
59
docs/development/backlog/tasks/F01.md
Normal file
59
docs/development/backlog/tasks/F01.md
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# F01 — Define the minimal financial contract and economic fixtures
|
||||
|
||||
Parent epic: E2. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: Rust financial contract owner.
|
||||
|
||||
Scheduling source of truth: [manifest entry F01](../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).
|
||||
- **FIN-03 — Verified:** Native order risk lacks a cash/fee reservation check. TypeScript compares gross exposure with pre-fee equity, so a fully funded buy can leave negative cash. [apps/stock/engine/src/risk/mod.rs:89](../../../../apps/stock/engine/src/risk/mod.rs#L89); [apps/stock/orchestrator/src/execution/model.ts:234](../../../../apps/stock/orchestrator/src/execution/model.ts#L234).
|
||||
- **FIN-04 — Verified:** Native fills notify every strategy. TypeScript realized P&L uses aggregate symbol cost basis, not per-strategy cost basis. [apps/stock/engine/src/backtest/engine.rs:489](../../../../apps/stock/engine/src/backtest/engine.rs#L489); [apps/stock/orchestrator/src/execution/model.ts:108](../../../../apps/stock/orchestrator/src/execution/model.ts#L108).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Define only the contracts consumed by the first financial vertical slice: scalar posting rules, owner IDs, account risk-session boundary, commands/effects, snapshot version and stable decision identity. Use a maintained checked decimal implementation, not bespoke arithmetic. Absorb C05: add small hand-derived JSON/table fixtures beside their consumers, without a reference simulator or an expected-failure test campaign. Freeze the TS/Rust command/context shape before consumers implement it.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/financial/ (new small modules)
|
||||
- apps/stock/engine/src/api/
|
||||
- libs/core/types/src/financial-engine.ts (new)
|
||||
- test/fixtures/economics/ (small new fixture set)
|
||||
|
||||
Write locks: financial-contract. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
Architecture decisions: ADR-002, ADR-003, ADR-004. 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
|
||||
|
||||
- Financial postings use8 decimal places with explicit round-half-away-from-zero at ties (matching current TS half-up behavior); reject overflow/non-finite/excess-precision external commands. Float observations/features are not converted into money strings on every native crossing.
|
||||
- Authoritative basis is remaining cost amount, not rounded average price. Fixture buys3 shares for total5; partial/final disposals release exactly5 basis in total.
|
||||
- Stable protocol snapshot/command serialization and unknown-version rejection pass small Rust/TS contract fixtures; scope is one supported version, not a compatibility-negotiation framework.
|
||||
- Each regression fixture lists economic assumptions, hand calculation and owning task. Each implementation task adds its own passing regression coverage; do not merge a blanket failing suite.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- Rust/TS fixture parse parity, rounding_ties_positive_negative, overflow_rejected, basis_residual_spec, command_id_conflict_spec.
|
||||
- Use existing binding smoke tests to confirm Bun/addon compatibility; no temporary simulator or new FFI framework.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
60
docs/development/backlog/tasks/F02.md
Normal file
60
docs/development/backlog/tasks/F02.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# F02 — Implement one owner-aware financial ledger
|
||||
|
||||
Parent epic: E2. Priority/severity: P0 / Critical. Relative complexity: L. Recommended specialization: Rust accounting.
|
||||
|
||||
Scheduling source of truth: [manifest entry F02](../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-02 — Verified:** Native forced liquidation occurs after the last equity mark; reported final value reads that earlier mark, omitting terminal costs. [apps/stock/engine/src/backtest/engine.rs:135](../../../../apps/stock/engine/src/backtest/engine.rs#L135); [apps/stock/engine/src/backtest/simple_results.rs:308](../../../../apps/stock/engine/src/backtest/simple_results.rs#L308).
|
||||
- **FIN-03 — Verified:** Native order risk lacks a cash/fee reservation check. TypeScript compares gross exposure with pre-fee equity, so a fully funded buy can leave negative cash. [apps/stock/engine/src/risk/mod.rs:89](../../../../apps/stock/engine/src/risk/mod.rs#L89); [apps/stock/orchestrator/src/execution/model.ts:234](../../../../apps/stock/orchestrator/src/execution/model.ts#L234).
|
||||
- **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).
|
||||
- **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
|
||||
|
||||
Implement one owner-keyed ledger from its first version; absorb F03 rather than building aggregate cost basis and replacing it later. Adapt existing Rust position calculations. Store owned quantity and remaining cost amount; derive average price and account aggregates. For a partial disposal, round the proportional released basis at posting precision; final disposal releases the exact residual. Fees are separate postings. Use one internal apply(state,command) kernel for resident research and staged durable transactions.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/financial/ledger.rs (new)
|
||||
- apps/stock/engine/src/financial/ownership.rs (only if separate module improves cohesion)
|
||||
- apps/stock/engine/src/positions/mod.rs
|
||||
|
||||
Write locks: financial-contract, rust-ledger. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F01](F01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-002. 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
|
||||
|
||||
- Cash + marked holdings = equity; initial capital + net cashflows + realized gross P&L + unrealized P&L - fees = equity at declared posting precision.
|
||||
- A buys10@100, B buys10@200, A sells10@200 => A gross realized1000, B retains10@200. Only A receives A's fill; wrong-owner disposal rejects.
|
||||
- Total basis5 for quantity3 is not reconstructed as5.00000001 from display average. All partial/final disposals release exactly5.
|
||||
- Duplicate identical fills are idempotent; conflicting ID payload fails; snapshot restore/replay yields identical canonical economic postings.
|
||||
- Resident transitions do not serialize/clone the entire account every observation. Durable staging uses the same kernel and emits required ordered effect views.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- owner_basis_A_B, basis_residual_partial_final, owner_quantity_sum, wrong_owner_disposal, per_fill_fee_once, conflicting_fill_id, snapshot_restore_parity.
|
||||
- Seeded randomized valid transition sequences reconcile; terminal mark retains open positions without inventing a fill.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
5
docs/development/backlog/tasks/F03.md
Normal file
5
docs/development/backlog/tasks/F03.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# F03 — Merged into F02
|
||||
|
||||
This ID is retained for traceability and must not be claimed or implemented separately.
|
||||
|
||||
Its required behavior, fixtures and tests are owned by [F02](F02.md). See [skeptical review](../../REVIEW.md) for the effort reduction and [manifest](../manifest.json) for canonical scheduling metadata.
|
||||
57
docs/development/backlog/tasks/F04.md
Normal file
57
docs/development/backlog/tasks/F04.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# F04 — Enforce cash reservations and portfolio risk centrally
|
||||
|
||||
Parent epic: E2. Priority/severity: P0 / Critical. Relative complexity: L. Recommended specialization: Rust financial risk.
|
||||
|
||||
Scheduling source of truth: [manifest entry F04](../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-03 — Verified:** Native order risk lacks a cash/fee reservation check. TypeScript compares gross exposure with pre-fee equity, so a fully funded buy can leave negative cash. [apps/stock/engine/src/risk/mod.rs:89](../../../../apps/stock/engine/src/risk/mod.rs#L89); [apps/stock/orchestrator/src/execution/model.ts:234](../../../../apps/stock/orchestrator/src/execution/model.ts#L234).
|
||||
- **FIN-06 — Verified:** Native simulation fills complete requested quantities at the latest price without bar-volume participation; current risk must be enforced at acceptance and fill, including pending exposure. [apps/stock/engine/src/backtest/engine.rs:374](../../../../apps/stock/engine/src/backtest/engine.rs#L374); [apps/stock/engine/src/backtest/engine.rs:414](../../../../apps/stock/engine/src/backtest/engine.rs#L414).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Implement canonical cash-long-only funding, pending fee-inclusive reservations, fill-time affordability and existing per-order/symbol/gross limits. Accept explicit account RiskSessionBoundary commands from the F01 contract; do not infer a day from UTC or independently roll for every venue. Marked daily-loss and drawdown checks use canonical marks. Session rollover resets only daily baseline; peak equity and drawdown halt persist until authorized reset.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/risk/mod.rs
|
||||
- apps/stock/engine/src/financial/risk.rs (new)
|
||||
- apps/stock/engine/src/financial/ledger.rs
|
||||
|
||||
Write locks: rust-ledger, risk-policy. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F02](F02.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-002, ADR-003. 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
|
||||
|
||||
- No accepted order/fill creates negative available cash or an unsupported short.
|
||||
- Pending/partial orders reserve resources once and release on cancellation/rejection/expiry.
|
||||
- Stale marks block risk increases; marked losses halt increases even without realized trades; reductions remain possible.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- competing_reservations, adverse_gap_reject_remainder, stale_other_symbol, marked_loss_halt, explicit_risk_session_boundary.
|
||||
- drawdown_halt_survives_rollover_restore, unauthorized_reset_denied, alternate_venue_does_not_reset_account_day.
|
||||
- Property test raw order and target paths cannot bypass the same policy.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
60
docs/development/backlog/tasks/F05.md
Normal file
60
docs/development/backlog/tasks/F05.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# F05 — Unify matching and order lifecycle on the ledger
|
||||
|
||||
Parent epic: E2. Priority/severity: P0 / Critical. Relative complexity: L. Recommended specialization: Rust execution semantics.
|
||||
|
||||
Scheduling source of truth: [manifest entry F05](../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-01 — Verified:** Both execution paths can act on a completed bar and fill against its current close; this is not a defensible default bar-close policy. [apps/stock/engine/src/backtest/engine.rs:249](../../../../apps/stock/engine/src/backtest/engine.rs#L249); [apps/stock/orchestrator/src/services/ExecutionService.ts:224](../../../../apps/stock/orchestrator/src/services/ExecutionService.ts#L224).
|
||||
- **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).
|
||||
- **FIN-06 — Verified:** Native simulation fills complete requested quantities at the latest price without bar-volume participation; current risk must be enforced at acceptance and fill, including pending exposure. [apps/stock/engine/src/backtest/engine.rs:374](../../../../apps/stock/engine/src/backtest/engine.rs#L374); [apps/stock/engine/src/backtest/engine.rs:414](../../../../apps/stock/engine/src/backtest/engine.rs#L414).
|
||||
- **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
|
||||
|
||||
Implement pure matcher/order-transition functions over explicit execution events; replay scheduling belongs to F06. Market/limit orders use declared spread/slippage and available liquidity, with no future-bar fields. Retain DAY/GTC/IOC/FOK semantics needed by the existing paper path; unsupported stop/OCO types reject. Target mode and explicit-order mode are mutually exclusive for one strategy instance in v1. Repeated absolute targets account for owned holdings and outstanding commitments; replacements cancel only owned orders.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/financial/matching.rs (new)
|
||||
- apps/stock/engine/src/backtest/engine.rs
|
||||
|
||||
Write locks: rust-matching, financial-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F04](F04.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-003. Agents may not independently amend their policies.
|
||||
|
||||
Feature activation/release gates: [F06](F06.md). These do not block implementing or integrating this component against its own tests.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- Given an already-eligible execution event, market/limit price protection, volume sharing, partial fill, rejection/cancellation and expiry are deterministic.
|
||||
- IOC cancels remainder; FOK either fills fully or does not fill/charge; DAY accepts only in-session; target-generated GTC survives a session boundary.
|
||||
- Same owner/instrument repeated target after partial fill does not duplicate quantity; mixed target/explicit mode rejects; another owner's order cannot be cancelled.
|
||||
- Pure eligibility tests reject prior/same observed event keys. Full next-open ordering is an F06 release gate, not a hidden F05 implementation requirement.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- matcher_gap_limit, shared_volume_capacity, partial_cancel, IOC_remainder, FOK_atomicity, DAY_expiry, target_GTC_replace.
|
||||
- unchanged_target_no_duplicate, mixed_intent_mode_rejected, wrong_owner_cancel, ineligible_event_key_rejected.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
58
docs/development/backlog/tasks/F06.md
Normal file
58
docs/development/backlog/tasks/F06.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# F06 — Implement deterministic replay once, with linear historical traversal
|
||||
|
||||
Parent epic: E2. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: Rust deterministic replay.
|
||||
|
||||
Scheduling source of truth: [manifest entry F06](../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-01 — Verified:** Both execution paths can act on a completed bar and fill against its current close; this is not a defensible default bar-close policy. [apps/stock/engine/src/backtest/engine.rs:249](../../../../apps/stock/engine/src/backtest/engine.rs#L249); [apps/stock/orchestrator/src/services/ExecutionService.ts:224](../../../../apps/stock/orchestrator/src/services/ExecutionService.ts#L224).
|
||||
- **DAT-01 — Verified:** Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times. [libs/core/types/src/historical-data.ts:90](../../../../libs/core/types/src/historical-data.ts#L90); [apps/stock/orchestrator/src/services/StorageService.ts:177](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L177).
|
||||
- **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
|
||||
|
||||
Implement the replay cursor once: sorted immutable events with stable availability/phase/instrument/sequence ordering; add a small pending-event queue only where required. Absorb P02's nonquadratic load and disabled-by-default hot-loop trade logging. Generate open-only execution events from one designated execution series; feature-only frames do not add liquidity or undeclared decision triggers. Publish completed observations, evaluate declared decision barriers, then next-interval opens under recorded zero/nonzero latency policy.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/backtest/engine.rs
|
||||
- apps/stock/engine/src/backtest/mod.rs
|
||||
- apps/stock/engine/src/financial/replay.rs (new)
|
||||
|
||||
Write locks: rust-replay. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F05](F05.md), [D01](D01.md), [P01](P01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-003. 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
|
||||
|
||||
- Permuting file arrival order does not change economic results after canonical event ordering.
|
||||
- Daily observations remain unavailable before session close; different symbols retain their actual quote timestamps.
|
||||
- Multi-timeframe context includes only completed available bars and marks missing/stale inputs explicitly.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- adjacent_open_zero_latency, positive_latency_skips_open, future_ohlcv_does_not_change_open_fill, daily_close_target_survives_to_open.
|
||||
- feature_timeframe_does_not_duplicate_liquidity, equal_timestamp_symbol_permutation, warmup_cannot_trade, stale_mark_timestamp_preserved.
|
||||
- Replay/restore trace equality. Extend P01 with1k/10k/100k release-build load/replay scaling; preserve economics before accepting faster runs.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
60
docs/development/backlog/tasks/F07.md
Normal file
60
docs/development/backlog/tasks/F07.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# F07 — Expose bounded Rust step sessions through existing NAPI workers
|
||||
|
||||
Parent epic: E2. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: Rust/TypeScript integration.
|
||||
|
||||
Scheduling source of truth: [manifest entry F07](../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).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Expose a small pull session (load/create/advance/submit/finalize/dispose) in the existing worker, backed by the same financial kernel. advance returns a tagged union: progress, decision batch, or complete. For a decision batch, all due strategies receive immutable views from the same ledger revision; collect all decisions before ordered admission. Use one native test strategy/intent trace for conformance, not a port of every Rust built-in. Per-session dataset load once; cross-trial residency is P03.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/api/backtest.rs
|
||||
- apps/stock/orchestrator/src/backtest/native-worker.ts
|
||||
- apps/stock/orchestrator/src/backtest/native-worker-protocol.ts
|
||||
- apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts
|
||||
|
||||
Write locks: native-public-api, worker-protocol. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F06](F06.md), [C02](C02.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-004. 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
|
||||
|
||||
- TS caller handles every step variant; it never assumes each advance returns a decision. Progress/cancel boundaries remain bounded.
|
||||
- All due decisions reference one barrier revision. Reversing callback evaluation order cannot change output when contexts/states are unchanged; final admission uses declared owner priority.
|
||||
- No partial barrier is committed if a decision throws. Rust returns per-intent accepted/rejected outcomes; business rejection is not a rollback of the observed decision event.
|
||||
- Native conformance intent trace and TS fixture use identical financial transitions. Native built-in production strategy parity is not required.
|
||||
- Worker crash/cancel/lease loss cannot publish successful stale results; snapshot/ID/version mismatches reject.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- step_tagged_union, immutable_barrier_revision, reverse_callback_order, decision_exception_aborts_barrier, rejected_intent_is_committed_outcome.
|
||||
- Existing native-worker/runner cancellation and lease tests; extend P01 with step and context-byte timings.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
66
docs/development/backlog/tasks/F08.md
Normal file
66
docs/development/backlog/tasks/F08.md
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# F08 — Publish canonical metrics and versioned result projections
|
||||
|
||||
Parent epic: E2. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Quant analytics/Rust integration.
|
||||
|
||||
Scheduling source of truth: [manifest entry F08](../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-07 — Verified:** Daily return grouping, Sharpe/Sortino conventions and placeholder exposure/VaR produce incomparable or misleading native metrics. [apps/stock/engine/src/backtest/simple_results.rs:374](../../../../apps/stock/engine/src/backtest/simple_results.rs#L374); [apps/stock/engine/src/backtest/simple_results.rs:542](../../../../apps/stock/engine/src/backtest/simple_results.rs#L542).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
- **Verified reusable analytics:** [reviewed return statistics](../../../../libs/calculations/src/analytics/return-statistics.ts#L24) already separate statistical reporting from financial execution.
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Use canonical Rust ledger postings, owned fills, occupied intervals and session-ending marks as the sole financial inputs. Reuse reviewed TypeScript statistical functions in `libs/calculations/src/analytics/` for return ratios and reports; do not port them to Rust merely for language uniformity. Add a small adapter for the engine-declared session calendar rather than blindly regrouping every venue by UTC date.
|
||||
|
||||
Version economics and metrics independently. Define sampling, annualization, benchmark and risk-free conventions in the result policy. Missing benchmark/risk-free inputs must not silently become invented measurements. Undefined or unsupported metrics are null with reasons. Adapt existing result DTOs without rewriting old rows.
|
||||
|
||||
Measurable benefit: comparable, independently checked rankings without a second ledger or a needless analytics rewrite.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No accounting/fill recomputation in TypeScript, statistical library rewrite, forced native port, new service, or silent reinterpretation of historical results. Native analytics remain an option only if measured as a bottleneck.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/backtest/simple_results.rs (authoritative projections, not new statistical formulas)
|
||||
- apps/stock/orchestrator/src/backtest/native-result.ts
|
||||
- apps/stock/orchestrator/src/backtest/BacktestReport.ts
|
||||
- libs/calculations/src/analytics/return-statistics.ts
|
||||
- libs/calculations/src/analytics/equity.ts (review existing UTC grouping; use explicit session marks)
|
||||
- libs/core/types/src/backtest-run.ts
|
||||
|
||||
Write locks: result-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F06](F06.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-002, ADR-003. 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
|
||||
|
||||
- Fees/P&L/equity/trades reconcile to Rust outputs; session returns include the final session and use the declared risk-session/calendar policy.
|
||||
- Sharpe uses periodic excess-return mean/std; Sortino uses downside deviation relative to the declared target; zero-variance/undefined cases are null with reasons.
|
||||
- Exposure uses the union of occupied intervals; open positions count; attribution distinguishes fills and round trips.
|
||||
- Reviewed calculation functions are reused where their conventions match. Any deliberate difference has a versioned policy and independent arithmetic fixture, not an unexplained second formula.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- two_session_marks, constant_negative_returns, zero_variance, overlapping_positions, open_position_exposure.
|
||||
- Existing result mapping and frontend metric unit fixtures; documented independent arithmetic cross-check.
|
||||
|
||||
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
|
||||
|
||||
Financial or compatibility regression; preserve existing fixtures and version changed semantics.
|
||||
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.
|
||||
55
docs/development/backlog/tasks/O01.md
Normal file
55
docs/development/backlog/tasks/O01.md
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# O01 — Serialize additive schema migrations safely
|
||||
|
||||
Parent epic: E9. Priority/severity: P1 / High. Relative complexity: S. Recommended specialization: PostgreSQL/backend infrastructure.
|
||||
|
||||
Scheduling source of truth: [manifest entry O01](../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
|
||||
|
||||
- **OPS-01 — Verified:** Migration runner uses an explicit safe allowlist; adding SQL alone will not run it. Concurrent migration admission lacks an advisory lock. [apps/stock/web-api/src/migrations/migration-runner.ts:42](../../../../apps/stock/web-api/src/migrations/migration-runner.ts#L42); [apps/stock/web-api/src/migrations/migration-runner.ts:57](../../../../apps/stock/web-api/src/migrations/migration-runner.ts#L57).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Preserve the explicit reviewed additive allowlist. On one PostgreSQL transaction client, acquire a transaction-scoped advisory lock BEFORE migration table initialization, migration discovery/check, SQL apply and recording. Do not lock via an arbitrary pooled query or add a migration framework. Integrator allocates additive filenames; applied scripts remain immutable.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/migrations/migration-runner.ts
|
||||
- database/postgres/init/
|
||||
- test/postgres/ (migration tests)
|
||||
|
||||
Write locks: sql-migrations. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- Two API startups apply each new migration once without duplicate object errors.
|
||||
- Upgrade from current schema preserves runs, datasets, execution ledger and checkpoints.
|
||||
- Destructive init scripts cannot enter startup migration discovery.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- two_concurrent_startups_same_client_lock, precheck_inside_lock, migration_failure_rollback, destructive_init_excluded.
|
||||
- bun run test:postgres on disposable fixtures only; existing migrations/data retained.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## 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.
|
||||
68
docs/development/backlog/tasks/O02.md
Normal file
68
docs/development/backlog/tasks/O02.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# O02 — Expose truthful research and paper readiness diagnostics
|
||||
|
||||
Parent epic: E9. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Infrastructure/observability.
|
||||
|
||||
Scheduling source of truth: [manifest entry O02](../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
|
||||
|
||||
- **OPS-02 — Needs Investigation:** Paper/live operational readiness is not demonstrated end-to-end. Live is deliberately disabled; preserve that gate until feed, reconciliation and broker-specific recovery are verified. [apps/stock/orchestrator/src/core/ModeManager.ts:33](../../../../apps/stock/orchestrator/src/core/ModeManager.ts#L33); [apps/stock/orchestrator/src/container.ts:152](../../../../apps/stock/orchestrator/src/container.ts#L152).
|
||||
- **WEB-02 — Verified:** Detail exposes native-unsupported pause/resume controls, omits cancel wiring, and overlapping polling/selection can apply stale responses. [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:379](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L379); [apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts:160](../../../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts#L160).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Report actual worker/queue/lease, engine version/capability, dataset load failure, paper feed freshness and recovery/halt state. Replace unmeasured zeros/always-healthy assumptions with unknown/unavailable. Attach run/attempt/strategy IDs to diagnostics; avoid a new telemetry stack.
|
||||
|
||||
Measurable benefit: Makes failures diagnosable from the primary product.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/routes/monitoring.routes.ts
|
||||
- apps/stock/web-api/src/services/
|
||||
- apps/stock/orchestrator/src/api/rest/
|
||||
- apps/stock/web-app/src/features/monitoring/
|
||||
|
||||
Write locks: readiness-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [S04](S04.md) integrated.
|
||||
|
||||
No additional economic-policy approval is needed for this narrowly scoped task.
|
||||
|
||||
Deferred: Optional cross-service monitoring expansion; required run diagnostics belong to W01/F07 and paper readiness to S04.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- Missing orchestrator/native worker/DB or stale feed cannot report ready.
|
||||
- Run failure includes phase and actionable cause, with secrets excluded.
|
||||
- Research availability and paper readiness are separate indicators; live-disabled is explicit.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- dependency_unavailable_readiness, stale_feed_status, failed_attempt_diagnostics, no_secret_logs.
|
||||
- API/UI tests show unknown versus measured zero and retryable error.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: Extend current health/monitoring and run diagnostics contracts; no separate monitoring API silo.
|
||||
- Backend/data dependencies: Persisted attempts and real service probes; no additional time-series platform.
|
||||
- Loading/error/empty behavior: Unknown, degraded, stale and disconnected states; actionable retry; do not display fake healthy cards.
|
||||
- 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.
|
||||
58
docs/development/backlog/tasks/P01.md
Normal file
58
docs/development/backlog/tasks/P01.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# P01 — Measure existing research paths before extending the benchmark
|
||||
|
||||
Parent epic: E7. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Performance/infrastructure engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry P01](../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
|
||||
|
||||
- **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).
|
||||
- **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).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Extend the current dataset benchmark with one small harness for paths that actually exist: process/addon startup, dataset preparation, native load/run/result parse and repeated parameter trials. No new observability framework or fabricated callback timing. Mark unavailable counters/phases explicitly; F07/S01/P03/P04/A02 extend the same harness as capabilities arrive.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- scripts/benchmark-dataset.ts
|
||||
- scripts/benchmark-research.ts (new)
|
||||
- test/fixtures/ (benchmark datasets)
|
||||
|
||||
Write locks: benchmark-harness. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- Single/multi-asset native fixtures and parameter trials record source/native binary/runtime/host/seed hashes and raw timings.
|
||||
- Separate fresh-process/unprepared data from reused input objects; do not call one-shot repeated loads resident warm throughput.
|
||||
- Report wall time, observed bar/trial rates, result bytes and RSS; DB/queue/allocation counters are unavailable until instrumented, not zero.
|
||||
- Fixed fixture/economic hashes match repeated runs under the same policy; current known economic defects are limitations, not benchmark truth.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- Tiny harness self-test and1k/10k/100k optional scaling; runtime versions/build hash verified.
|
||||
- No timing-flaky CI gate. Unsupported multi-strategy ownership/callback paths are labelled unavailable until canonical tasks land.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## 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.
|
||||
5
docs/development/backlog/tasks/P02.md
Normal file
5
docs/development/backlog/tasks/P02.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# P02 — Merged into F06
|
||||
|
||||
This ID is retained for traceability and must not be claimed or implemented separately.
|
||||
|
||||
Its required behavior, fixtures and tests are owned by [F06](F06.md). See [skeptical review](../../REVIEW.md) for the effort reduction and [manifest](../manifest.json) for canonical scheduling metadata.
|
||||
60
docs/development/backlog/tasks/P03.md
Normal file
60
docs/development/backlog/tasks/P03.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# P03 — Reuse validated datasets within bounded native workers
|
||||
|
||||
Parent epic: E7. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Performance/infrastructure engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry P03](../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
|
||||
|
||||
- **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).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Load/hash/validate one dataset per worker and create isolated trial sessions over it. Measure object/JSON versus typed columnar buffers; adopt typed buffers only with a demonstrated transfer/allocation benefit. Keep ownership/lifetime explicit and invalidate by dataset/feature version.
|
||||
|
||||
Measurable benefit: Reduces repeated preparation before adding a DSL.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/backtest/native-worker-protocol.ts
|
||||
- apps/stock/orchestrator/src/backtest/native-worker.ts
|
||||
- apps/stock/engine/src/api/backtest.rs
|
||||
|
||||
Write locks: worker-protocol, native-public-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F07](F07.md), [P01](P01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-004, ADR-008. Agents may not independently amend their policies.
|
||||
|
||||
Deferred: Only after measured repeated dataset admission is a material sweep cost; not a prerequisite for parallel trials.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- N trials sharing a dataset incur one dataset admission per worker, not per trial.
|
||||
- Disposing a trial clears mutable strategy/account state but retains immutable data; worker disposal releases buffers.
|
||||
- Output hashes match uncached runs and sequential trials cannot contaminate one another.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- resident_dataset_hit_counter, trial_state_reset, incompatible_version_miss, dispose_memory_plateau.
|
||||
- P01 warmed sweep time/RSS and serialization-byte comparison.
|
||||
|
||||
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.
|
||||
56
docs/development/backlog/tasks/P04.md
Normal file
56
docs/development/backlog/tasks/P04.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# P04 — Schedule deterministic batches across a bounded worker pool
|
||||
|
||||
Parent epic: E7. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Performance/infrastructure engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry P04](../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
|
||||
|
||||
- **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).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Use existing isolated one-shot workers and durable claims to run independent trials concurrently at a configurable1/2/4 process limit. Resident dataset reuse is optional P03, not a dependency. Each trial gets deterministic seed/identity and separate mutable state; admission/backpressure honors cancellation/leases. No parallel event processing inside one portfolio.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts
|
||||
- apps/stock/orchestrator/src/backtest/BacktestRunner.ts
|
||||
- apps/stock/web-api/src/services/BacktestDispatcher.ts
|
||||
|
||||
Write locks: worker-pool, web-backtest-dispatch. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F07](F07.md), [R06](R06.md), [C06](C06.md), [P01](P01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-008. 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
|
||||
|
||||
- Concurrency1/2/4 produces identical per-trial economic hashes and completion-independent ranking.
|
||||
- A worker crash retries only affected durable attempts; batch cancellation drains or kills workers with no stale result commit.
|
||||
- Pool concurrency is configurable; no assumption that all available CPUs improve throughput.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- parallel_hash_parity, worker_crash_retry, cancellation_under_load, lease_fencing_pool.
|
||||
- P01 trials/s, efficiency T1/(p*Tp), tail latency and RSS at1/2/4 workers.
|
||||
|
||||
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.
|
||||
65
docs/development/backlog/tasks/P05.md
Normal file
65
docs/development/backlog/tasks/P05.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# P05 — Separate result summaries from paged detail payloads
|
||||
|
||||
Parent epic: E7. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Performance/infrastructure engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry P05](../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
|
||||
|
||||
- **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).
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Deferred until measured detail payload/query/rendering costs justify it. R06 already provides summary projections. This task may add stable paged trade/position detail and display-only downsampling; keep full exports and retained authoritative results. Do not normalize all storage or add an artifact service by default.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No speculative distributed infrastructure or weakened correctness gates.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/services/backtest-v2.service.ts
|
||||
- apps/stock/web-api/src/routes/backtests-v2.routes.ts
|
||||
- apps/stock/web-app/src/features/backtest/
|
||||
- apps/stock/web-app/src/features/experiments/
|
||||
|
||||
Write locks: result-contract, web-backtest-service, web-experiments. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R06](R06.md), [P01](P01.md) integrated.
|
||||
|
||||
No additional economic-policy approval is needed for this narrowly scoped task.
|
||||
|
||||
Deferred: Only after measured trade-detail payload/query/render cost; simple summary projections ship in R06.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- Experiment list retrieves summaries without full OHLC/trade blobs.
|
||||
- Detail pagination/export preserves every trade in stable sequence; changing display density does not alter reported metrics.
|
||||
- Report API bytes, query latency and rendering time before/after on the large-trade workload.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- paged_trade_reassembly_hash, stable_cursor, summary_matches_full_result, complete_export.
|
||||
- Browser loading/error/empty/pagination test and P01 result-store/load timings.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: GET run summary/provenance plus /trades?cursor and display-series projections; full export remains available.
|
||||
- Backend/data dependencies: Existing results first; add normalized detail storage only after query profiling and separate approval if scope expands.
|
||||
- Loading/error/empty behavior: Summary available while detail loads; retry individual page; explicit no trades/end of list; no fake zero risk.
|
||||
- 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.
|
||||
58
docs/development/backlog/tasks/P06.md
Normal file
58
docs/development/backlog/tasks/P06.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# 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.
|
||||
70
docs/development/backlog/tasks/R01.md
Normal file
70
docs/development/backlog/tasks/R01.md
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# R01 — Persist immutable strategy versions and parameter schemas
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R01](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
- **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).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add strategies and append-only strategy_versions; seed registered built-ins with source/bundle hash, parameter schema, checkpoint contract and review status. Store executable artifact bytes or an immutable retained artifact reference, dependency lock and source revision. Draft metadata can change; published executable versions cannot.
|
||||
|
||||
Measurable benefit: Pins executable strategy identity before adding experiments.
|
||||
|
||||
Project/hypothesis linkage is optional and must not require R03 tables or placeholder records. Add nullable foreign-key links only when both entity tables exist, in a coordinated additive migration; standalone versions/experiments work first.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- database/postgres/init/ (new migration)
|
||||
- apps/stock/web-api/src/routes/ (strategy endpoints)
|
||||
- apps/stock/web-api/src/services/ (strategy service)
|
||||
- apps/stock/orchestrator/src/strategies/StrategyRegistry.ts
|
||||
- libs/core/types/src/strategy-version.ts (new)
|
||||
|
||||
Write locks: sql-migrations, strategy-catalog-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [O01](O01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- Invalid versioned parameters reject before enqueue; only registered/reviewed supported artifacts run.
|
||||
- An idempotency key plus content fingerprint makes identical publish retries return the same version; changed content with the same key returns409. An intentional new revision gets a new ID and lineage even if content matches.
|
||||
- Published source/schema/checkpoint/dependency content is immutable and retained. Review/approval is separately audited metadata, not a mutation of executable content.
|
||||
- Registration never executes candidate code in the API; arbitrary untrusted execution stays unavailable until A02.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- strategy_version_immutability_postgres, schema_validation, artifact_hash_mismatch, clone_lineage.
|
||||
- Registry aliases and old definition compatibility.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: GET/POST /api/v2/strategies; GET/POST /strategies/:id/versions; GET /strategy-versions/:id; POST clone. Parameters use a versioned JSON schema subset.
|
||||
- Backend/data dependencies: New strategy/version tables; existing strategy registry; source-artifact storage retained with version.
|
||||
- Loading/error/empty behavior: API typed validation errors,404 and409; UI arrives in R02.
|
||||
- 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.
|
||||
72
docs/development/backlog/tasks/R02.md
Normal file
72
docs/development/backlog/tasks/R02.md
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# R02 — Deliver strategy catalog and version-aware backtest setup
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R02](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **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).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Replace only the strategy placeholder with catalog/detail/version views; allow metadata edits, clone, parameter editing and read-only source/version diff. Add version selection and supported capability filtering to existing backtest form. First release authors code in repository or submits an artifact; no browser IDE.
|
||||
|
||||
Measurable benefit: Makes strategy work a coherent product flow.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-app/src/app/App.tsx
|
||||
- apps/stock/web-app/src/features/strategies/ (new)
|
||||
- apps/stock/web-app/src/features/backtest/components/CreateBacktestDialog.tsx
|
||||
- apps/stock/web-app/src/features/backtest/components/BacktestConfiguration.tsx
|
||||
- apps/stock/web-app/src/components/
|
||||
- apps/stock/web-api/src/services/backtest-v2.service.ts
|
||||
- libs/core/types/src/backtest-run.ts
|
||||
|
||||
Write locks: web-backtest-detail, web-strategies. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R01](R01.md), [W03](W03.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. Agents may not independently amend their policies.
|
||||
|
||||
Feature activation/release gates: [W04](W04.md). These do not block implementing or integrating this component against its own tests.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- User can create/clone metadata, choose immutable version and schema-valid parameters, then open the existing run flow.
|
||||
- Unavailable native/custom strategy choices are not offered as runnable.
|
||||
- Version detail links deployment/backtest history when available; absent histories show empty states.
|
||||
- During legacy migration only registered artifacts matching the current supported build are runnable; version selection is persisted, but legacy runs remain unproject-gated until R05.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- catalog_navigation, parameter_form_validation, immutable_version_selection, clone_revision_diff.
|
||||
- Browser strategy->backtest flow and schema/API contract tests.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: R01 catalog/version endpoints plus version ID in saved backtest template/request snapshot.
|
||||
- Backend/data dependencies: R01 schema; current engine capability metadata. Unsupported version/runtime combinations fail before submit.
|
||||
- Loading/error/empty behavior: Skeleton list/detail; no-strategies create CTA; schema error next to parameter; retry fetch; unsaved edit warning.
|
||||
- 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.
|
||||
65
docs/development/backlog/tasks/R03.md
Normal file
65
docs/development/backlog/tasks/R03.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# R03 — Add projects, hypotheses and evidence-linked findings APIs
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R03](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
- **WEB-05 — Verified:** SQL deletion cascades from definitions to runs/results; evidence retention must be defined before research findings reference those results. [database/postgres/init/08-create-runs-table.sql:13](../../../../database/postgres/init/08-create-runs-table.sql#L13); [database/postgres/init/06-create-backtest-tables.sql:25](../../../../database/postgres/init/06-create-backtest-tables.sql#L25).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add minimal project/hypothesis/note/finding metadata with human/AI authorship and immutable evidence references. Findings refer to runId + metricsVersion + metricPath (and optional immutable artifact ID); the API derives displayed measured values from retained results instead of maintaining another metric truth/validation subsystem. Narrative conclusions may be wrong and must remain distinguishable from referenced measurements.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- database/postgres/init/ (new migration)
|
||||
- apps/stock/web-api/src/routes/ (research endpoints)
|
||||
- apps/stock/web-api/src/services/ (research service)
|
||||
- libs/core/types/src/research.ts (new)
|
||||
|
||||
Write locks: sql-migrations, research-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R01](R01.md), [R10](R10.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- AI-created hypotheses/notes are labelled unvalidated until explicit validation evidence/review exists.
|
||||
- Evidence references must resolve to retained run/artifact and known metric version/path; dangling references reject. No new simulator or narrative fact-checking subsystem.
|
||||
- Archiving metadata does not delete cited runs; narrative changes create a revision while underlying results remain immutable.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- hypothesis_vs_evidence, evidence_fk_integrity, authorship_audit, cited_metric_matches_run.
|
||||
- Migration upgrade fixture retains existing runs/results.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: /api/v2/research-projects, /hypotheses, /analysis-artifacts with explicit evidence references and archive actions.
|
||||
- Backend/data dependencies: New metadata tables; reuse existing run/result IDs and strategy/version IDs.
|
||||
- Loading/error/empty behavior: Typed404/409/422, empty evidence lists and explicit unvalidated state; R04 supplies UI.
|
||||
- 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.
|
||||
68
docs/development/backlog/tasks/R04.md
Normal file
68
docs/development/backlog/tasks/R04.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# R04 — Deliver research workspace and save-findings flow
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R04](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add project overview, hypothesis notes, linked strategies/runs and Save finding from result view. Reuse DataTable/Card/Dialog and current navigation. Keep human conclusions separate from AI suggestions and measured evidence.
|
||||
|
||||
Measurable benefit: Provides the primary research workspace before advanced optimization.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-app/src/features/research/ (new)
|
||||
- apps/stock/web-app/src/app/App.tsx
|
||||
- apps/stock/web-app/src/lib/constants/navigation.ts
|
||||
- apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
|
||||
|
||||
Write locks: web-research, web-backtest-detail. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R03](R03.md), [W02](W02.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. Agents may not independently amend their policies.
|
||||
|
||||
Feature activation/release gates: [W04](W04.md). These do not block implementing or integrating this component against its own tests.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- Project -> strategy -> configure/run -> inspect -> save cited finding -> reopen project is navigable.
|
||||
- Finding links open exact run/version; incomplete/legacy evidence displays limitations.
|
||||
- Notes can be saved without claiming strategy validation.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- research_project_to_finding_browser, missing_evidence_error, ai_authorship_badge, archived_project_read.
|
||||
- Loading/error/empty state component tests.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: R03 project/hypothesis/artifact APIs and existing saved runs.
|
||||
- Backend/data dependencies: R03 entities, existing run provenance, no requirement for full Rust cutover.
|
||||
- Loading/error/empty behavior: Empty project guidance; saving/retry states preserve draft; stale evidence error; archived read-only state.
|
||||
- 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.
|
||||
67
docs/development/backlog/tasks/R05.md
Normal file
67
docs/development/backlog/tasks/R05.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# R05 — Freeze complete provenance and cut over durable canonical runs
|
||||
|
||||
Parent epic: E6. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R05](../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
|
||||
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
- **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).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Freeze strategy/model artifact IDs, parameters, seed, code/lockfile/build hashes and execution policies at submission. For a selected frozen dataset, pin its hash immediately; for a source request, retain the immutable query and atomically attach the first prepared dataset/hash before replay begins. Expose preparing versus reproducibility-finalized state. Wire the canonical Rust session with existing registered TS strategies into the durable runner and versioned result DTO. Exact reproduction API/UI is R12.
|
||||
|
||||
Measurable benefit: Creates reproducible, project-gated runs usable by humans and AI.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/backtest/BacktestRunner.ts
|
||||
- apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository.ts
|
||||
- apps/stock/web-api/src/services/backtest-v2.service.ts
|
||||
- libs/core/types/src/backtest-run.ts
|
||||
|
||||
Write locks: result-contract, web-backtest-service, web-backtest-detail. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F08](F08.md), [S02](S02.md), [R01](R01.md), [R10](R10.md), [D01](D01.md), [W03](W03.md), [C06](C06.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- Changing template, strategy source or provider history after dataset freezing cannot alter an admitted run. A source query alone is not labelled a frozen dataset.
|
||||
- No strategy decision executes before artifact verification and atomic dataset binding; failed preparation remains diagnosed and retry-safe.
|
||||
- New results declare financialEngine=rust and strategyExecution separately; correctness-gate evidence requires approved engine/data gates, not a UI flag.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- mutate_template_after_submit, freeze_before_first_decision, frozen_seed_replay, provider_change_after_dataset_bind.
|
||||
- Full durable runner restart/lease/cancel suite and result contract compatibility.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: Run/results expose immutable request plus resolved dataset binding, provenance and preparation state. No exact-reproduce endpoint until R12.
|
||||
- Backend/data dependencies: Existing request_snapshot/dataset_hash/results extended with retained provenance and engine correctness-gate evidence metadata.
|
||||
- Loading/error/empty behavior: API distinguishes preparing, dataset-pinned, running, failed and completed. W02/R11 render these fields without fabricated provenance.
|
||||
- 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.
|
||||
68
docs/development/backlog/tasks/R06.md
Normal file
68
docs/development/backlog/tasks/R06.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# R06 — Create immutable experiments and bounded sweep expansion
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R06](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Expand immutable bounded experiment grids into existing durable runs with unique trial keys and one pinned dataset hash. Reuse outbox/lease/attempt machinery. A retry-failed action creates a new fenced attempt for the same immutable failed logical run, only when no terminal result exists; append prior attempt diagnostics before clearing the active error. Do not overwrite completed results or create a duplicate candidate/attempt framework. Provide a minimal SQL summary projection excluding OHLC/trade arrays now; P05 later owns only profiled large-detail optimization.
|
||||
|
||||
Project/hypothesis linkage is optional and must not require R03 tables or placeholder records. Add nullable foreign-key links only when both entity tables exist, in a coordinated additive migration; standalone versions/experiments work first.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- database/postgres/init/ (new migration)
|
||||
- apps/stock/web-api/src/routes/ (experiment endpoints)
|
||||
- apps/stock/web-api/src/services/ (experiment expansion)
|
||||
- apps/stock/orchestrator/src/backtest/run-repository.ts
|
||||
|
||||
Write locks: sql-migrations, experiment-api. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R05](R05.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- Repeated expansion has identical ordered candidate fingerprints and creates no duplicate logical runs.
|
||||
- Failed retry preserves run inputs/trial key and prior error/attempt history; stale attempts cannot commit. Completed/cancelled stored results are not silently overwritten.
|
||||
- Experiment summary lists all outcomes and metrics/provenance without reading/transmitting full trade/OHLC blobs.
|
||||
- Batch cancellation stops new admission and requests active child cancellation; all candidates use the same frozen data for comparable windows.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- deterministic_grid, duplicate_expand_race, retry_failed_preserves_attempt_history, stale_retry_fenced, completed_result_retry_rejected.
|
||||
- summary_excludes_detail_payload, partial_batch_failure, cancel_batch, one_dataset_hash_for_all_trials; disposable DB/queue failure tests.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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/GET /api/v2/experiments; GET /experiments/:id/trials; POST cancel/retry; preview validates grid and returns count.
|
||||
- Backend/data dependencies: Experiments table; nullable experiment_id/trial_key on runs; existing result storage.
|
||||
- Loading/error/empty behavior: API distinguishes empty/unsubmitted, partial, cancelled and terminal states; never averages missing failed trials away.
|
||||
- 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.
|
||||
66
docs/development/backlog/tasks/R07.md
Normal file
66
docs/development/backlog/tasks/R07.md
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# R07 — Deliver sweep configuration and comparable-result views
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R07](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **FIN-07 — Verified:** Daily return grouping, Sharpe/Sortino conventions and placeholder exposure/VaR produce incomparable or misleading native metrics. [apps/stock/engine/src/backtest/simple_results.rs:374](../../../../apps/stock/engine/src/backtest/simple_results.rs#L374); [apps/stock/engine/src/backtest/simple_results.rs:542](../../../../apps/stock/engine/src/backtest/simple_results.rs#L542).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Deliver experiment preview/progress/comparison directly on R06 APIs. Accept an existing frozen dataset ID and show its manifest; R11's picker is optional convenience, not a prerequisite. A project/workspace link is optional; users need not build project metadata before comparing a sweep. Reuse current charts/metrics and R06 summary projection.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-app/src/features/experiments/ (new)
|
||||
- apps/stock/web-app/src/features/backtest/components/
|
||||
- apps/stock/web-app/src/components/ui/DataTable/
|
||||
|
||||
Write locks: web-experiments. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R06](R06.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. Agents may not independently amend their policies.
|
||||
|
||||
Feature activation/release gates: [W04](W04.md). These do not block implementing or integrating this component against its own tests.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- User previews bounded trial count, submits, sees all statuses, cancels and opens exact candidate runs.
|
||||
- Default comparison requires matching data, execution/metrics policy, costs and evaluation windows; mismatches remain visible, not silently ranked.
|
||||
- No full detail blobs on summary list; failed/incomplete counts and null metrics are explicit.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- sweep_to_compare_browser, mixed_policy_warning, partial_failure_visibility, reopen_experiment.
|
||||
- Large result table rendering measurement and metric-null tests.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: R06 experiment/trial listing; summary metrics projection from result contracts; pagination where needed.
|
||||
- Backend/data dependencies: Experiments and canonical provenance; full trade arrays are fetched only on run detail.
|
||||
- Loading/error/empty behavior: Preview loading; invalid grid errors; empty not-yet-submitted; per-trial failed/cancelled; retryable aggregate errors.
|
||||
- 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.
|
||||
70
docs/development/backlog/tasks/R08.md
Normal file
70
docs/development/backlog/tasks/R08.md
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# R08 — Add bounded chronological and reset-segment validation
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Quantitative research integrity.
|
||||
|
||||
Scheduling source of truth: [manifest entry R08](../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
|
||||
|
||||
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
- **DAT-01 — Verified:** Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times. [libs/core/types/src/historical-data.ts:90](../../../../libs/core/types/src/historical-data.ts#L90); [apps/stock/orchestrator/src/services/StorageService.ts:177](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L177).
|
||||
- **FIN-07 — Verified:** Daily return grouping, Sharpe/Sortino conventions and placeholder exposure/VaR produce incomparable or misleading native metrics. [apps/stock/engine/src/backtest/simple_results.rs:374](../../../../apps/stock/engine/src/backtest/simple_results.rs#L374); [apps/stock/engine/src/backtest/simple_results.rs:542](../../../../apps/stock/engine/src/backtest/simple_results.rs#L542).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
First implement bounded chronological parameter selection and nonoverlapping walk-forward recipes for deterministic registered strategies. Explicit warmup and evaluation windows; each validation segment starts from its declared initial capital and empty positions with warmed indicators, not carried money/state. Aggregate segment returns as a labelled reset-segment research series, never claim one continuous tradable equity curve. Cost/parameter sensitivity reuses grid expansion. Reject trainable/overlapping-label models until their fit-artifact and declared horizon/embargo contracts are supplied; do not invent general ML infrastructure for SMA.
|
||||
|
||||
Persist the immutable validation manifest/report as experiment-owned JSON on the R06 experiment (or a focused child row if immutability requires it), keyed by experiment/report version and containing every contributing run ID, selection rule and segment policy. This is not R03 research-findings storage. Reopening an experiment must recover the same report; new inputs require a new experiment/report identity.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/services/ (validation recipes)
|
||||
- apps/stock/orchestrator/src/backtest/
|
||||
- test/integration/ (research validation tests)
|
||||
- database/postgres/init/ and reviewed migration registry (only if experiment report persistence needs an additive column/table)
|
||||
|
||||
Write locks: validation-contract, sql-migrations. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R06](R06.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- Training/validation/test inputs and selection rule are frozen before execution. Test values cannot affect earlier parameter selection or fitted inputs.
|
||||
- Every segment declares capital/reset/warmup policy; warmup has no orders/fills; OOS intervals do not overlap.
|
||||
- All tried candidates and holdout accesses remain visible. Independent segment cash accounts are not summed/stitched as a continuous portfolio.
|
||||
- Immutable experiment-owned reports reopen without any project/hypothesis/findings records or R03 API; conflicting attempts cannot overwrite a completed report.
|
||||
- For a later declared nonzero label horizon require gap/purge >= horizon; unsupported/missing horizon/trainable fit metadata rejects rather than leaking future data.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- chronological_selection, test_suffix_cannot_change_selection, warmup_no_trades, nonoverlapping_windows, reset_segment_accounting.
|
||||
- experiment_report_without_research_metadata, immutable_report_reopen, conflicting_report_write_rejected.
|
||||
- reject_uncontracted_trainable_model, horizon_gap_validation, bounded_cost_grid; fixed seeds and retained selected-parameter artifacts.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## Regression risks and rollback
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: Validation recipe and immutable report under the existing experiment API; report includes every contributing run and declared segment/warmup policy.
|
||||
- Backend/data dependencies: R06 experiments/runs and experiment-owned JSON reports. No R03 analysis_artifacts dependency or separate optimization service.
|
||||
- Loading/error/empty behavior: Typed invalid-window/insufficient-warmup errors; validation failures are not profitable candidates.
|
||||
- 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.
|
||||
65
docs/development/backlog/tasks/R09.md
Normal file
65
docs/development/backlog/tasks/R09.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# R09 — Expose validation, cost and regime evidence in the workbench
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R09](../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
|
||||
|
||||
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Expose stored chronological/cost validation evidence from R08. Regime panels render only when valid as-of regime annotations exist; otherwise show unavailable, not fake classification. The basic validation UI need not wait for S05; enabling that example's regime comparison requires its artifact contract.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-app/src/features/experiments/
|
||||
- apps/stock/web-app/src/features/research/
|
||||
- apps/stock/web-app/src/features/backtest/components/
|
||||
|
||||
Write locks: web-experiments. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R07](R07.md), [R08](R08.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. Agents may not independently amend their policies.
|
||||
|
||||
Conditional activation: regime comparison requires [S05](S05.md); saving/linking a research finding requires [R03](R03.md). Neither blocks basic validation display.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- User can validate and inspect each OOS segment with reset/warmup/cost assumptions visible.
|
||||
- Regime data missing => explicit unavailable panel; present => sample counts/unclassified bucket and window coverage displayed.
|
||||
- Validation display works without R03. Enable save/link-finding only when R03 exists; link the exact experiment/report identity and contributing run/metric references through its existing evidence API. Otherwise show the action unavailable.
|
||||
- No client-side accounting or continuous-equity claim for reset segments.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- walk_forward_browser, train_test_badges, insufficient_sample_warning, regime_slice_reconciliation.
|
||||
- Loading/empty/failure states for incomplete validation; validation_without_findings_api; save_finding_requires_R03.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: R08 experiment-owned immutable recipes/reports. R03 evidence-linked findings only for the conditionally enabled save action.
|
||||
- Backend/data dependencies: Canonical returns, as-of regime annotations and sample counts; no client-side financial recomputation.
|
||||
- Loading/error/empty behavior: Loading each segment; unclassified regime bucket; invalid partition feedback; explicit partial validation.
|
||||
- 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.
|
||||
65
docs/development/backlog/tasks/R10.md
Normal file
65
docs/development/backlog/tasks/R10.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# R10 — Protect retained research evidence and artifact integrity
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research product.
|
||||
|
||||
Scheduling source of truth: [manifest entry R10](../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
|
||||
|
||||
- **WEB-05 — Verified:** SQL deletion cascades from definitions to runs/results; evidence retention must be defined before research findings reference those results. [database/postgres/init/08-create-runs-table.sql:13](../../../../database/postgres/init/08-create-runs-table.sql#L13); [database/postgres/init/06-create-backtest-tables.sql:25](../../../../database/postgres/init/06-create-backtest-tables.sql#L25).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Archive existing templates/runs rather than cascading deletion when they retain run history; protect immutable strategy versions, datasets and artifact references established by R01. Add checksum verification on retrieval. R03 subsequently adds finding-reference constraints using the same retention rule. No automatic purge; explicit operator purge later needs a reference check and confirmation.
|
||||
|
||||
Measurable benefit: Prevents accidental loss of reproducibility.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No general workflow framework, browser IDE, multi-tenant identity platform or second simulator.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- database/postgres/init/ (new migration)
|
||||
- apps/stock/web-api/src/services/backtest-v2.service.ts
|
||||
- apps/stock/web-api/src/routes/backtests-v2.routes.ts
|
||||
- apps/stock/web-api/src/services/ (artifact references)
|
||||
|
||||
Write locks: sql-migrations, web-backtest-service. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R01](R01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- Deleting a definition with retained runs cannot cascade-delete those runs/results.
|
||||
- Unreferenced legacy deletion behavior is explicitly tested/documented; archived objects remain reproducible.
|
||||
- Missing/corrupt artifact produces an actionable integrity error; no fallback to current source.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- retained_run_delete_restricted_postgres, archive_preserves_replay, artifact_checksum, legacy_delete_compatibility.
|
||||
|
||||
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
|
||||
|
||||
Schema/API backward compatibility, historical provenance and UI state regression.
|
||||
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: Archive actions and409 reference details on destructive API attempts; retained read APIs stay stable.
|
||||
- Backend/data dependencies: Foreign keys/restrictions on existing run/result relationships and new artifact references.
|
||||
- Loading/error/empty behavior: Archive confirmation; referenced-delete explanation; read-only archived details; missing-artifact error.
|
||||
- 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.
|
||||
70
docs/development/backlog/tasks/R11.md
Normal file
70
docs/development/backlog/tasks/R11.md
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# R11 — Select and reuse frozen datasets in the workbench
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack market data/research.
|
||||
|
||||
Scheduling source of truth: [manifest entry R11](../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
|
||||
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
- **DAT-01 — Verified:** Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times. [libs/core/types/src/historical-data.ts:90](../../../../libs/core/types/src/historical-data.ts#L90); [apps/stock/orchestrator/src/services/StorageService.ts:177](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L177).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Expose metadata-only listing/detail for retained backtest_datasets and add selection by hash to the existing configuration form. Offer either a known frozen dataset or an explicit source request whose data will be prepared asynchronously by the existing runner. Show the eventual pinned hash and coverage; no separate dataset job service.
|
||||
|
||||
Measurable benefit: Delivers dataset choice and reuse as a real web workflow.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No new storage service, arbitrary truncation, full corporate-action feed, or synchronous API-side historical loading.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/routes/ (dataset endpoints)
|
||||
- apps/stock/web-api/src/services/ (dataset metadata)
|
||||
- apps/stock/web-app/src/features/backtest/components/BacktestConfiguration.tsx
|
||||
- apps/stock/web-app/src/features/backtest/components/CreateBacktestDialog.tsx
|
||||
- apps/stock/orchestrator/src/backtest/BacktestRunner.ts
|
||||
|
||||
Write locks: dataset-contract, web-backtest-detail, web-backtest-service. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [D01](D01.md), [O01](O01.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-003, ADR-006. Agents may not independently amend their policies.
|
||||
|
||||
Feature activation/release gates: [W04](W04.md). These do not block implementing or integrating this component against its own tests.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- User selects a compatible dataset by hash or requests a new source/date/interval range; mismatch rejects before simulation.
|
||||
- Source-request submission is labelled unpinned/preparing, not reproducible data; the first prepared snapshot is attached atomically before execution and reused on retry.
|
||||
- Listing does not return full bar arrays; missing/corrupt/unknown-coverage datasets show actionable status.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- dataset_list_metadata_only, select_hash_compatibility, source_request_freeze_status, retry_reuses_bound_hash.
|
||||
- Browser select existing dataset -> run -> inspect pinned hash; invalid coverage/timeframe feedback.
|
||||
|
||||
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
|
||||
|
||||
Confusing source-query identity with frozen content identity; maintain legacy v1 snapshots and explicit preparation state.
|
||||
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: GET dataset metadata/manifest and existing hash-or-source configuration; no new dataset job service.
|
||||
- Backend/data dependencies: D01 and existing retained snapshots. Implementation does not require all W04 browser release work.
|
||||
- Loading/error/empty behavior: Picker empty/loading/retry/incompatible states; source request remains unpinned until atomic preparation.
|
||||
- Release: This flow must pass the shared W04 browser harness before user-facing release; do not build another harness.
|
||||
|
||||
## 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.
|
||||
67
docs/development/backlog/tasks/R12.md
Normal file
67
docs/development/backlog/tasks/R12.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# R12 — Reproduce an original run separately from rerunning current settings
|
||||
|
||||
Parent epic: E6. Priority/severity: P1 / High. Relative complexity: S. Recommended specialization: Full-stack reproducible research.
|
||||
|
||||
Scheduling source of truth: [manifest entry R12](../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
|
||||
|
||||
- **WEB-03 — Verified:** Definition creation auto-starts by default and catches submission failure; run creation has no client submission key. Re-run uses current definition rather than immutable original input. [apps/stock/web-api/src/services/backtest-v2.service.ts:105](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L105); [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:173](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L173).
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add reproduce-original endpoint/action that copies the retained versioned input bundle including dataset/artifact/engine policies into a new durable run. Keep rerun-current a separate labelled action. Verify retained artifacts and compatible engine availability before admission; no fallback to current source or provider history.
|
||||
|
||||
Measurable benefit: Makes exact experiment repetition a user-visible, verifiable capability.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No downloading/executing arbitrary historic binaries, silent economics downgrade or overwriting original results.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/routes/backtests-v2.routes.ts
|
||||
- apps/stock/web-api/src/services/backtest-v2.service.ts
|
||||
- apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
|
||||
- apps/stock/web-app/src/features/backtest/components/RunControlsCompact.tsx
|
||||
|
||||
Write locks: web-backtest-service, web-backtest-detail. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [R05](R05.md), [W04](W04.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-006. 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
|
||||
|
||||
- Original reproduction after template/provider/strategy changes yields the same economic hash on the same supported build/policy.
|
||||
- A missing original artifact or unsupported old engine produces an explicit error; old result remains viewable.
|
||||
- UI previews exact original inputs and links source/reproduction runs without mutating either.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- reproduce_after_template_provider_change, missing_original_artifact, unsupported_engine_version, economic_hash_parity.
|
||||
- Browser original-vs-current action and duplicate-submit idempotency.
|
||||
|
||||
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
|
||||
|
||||
Legacy provenance may be insufficient; fail explicitly instead of pretending exact reproducibility.
|
||||
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 /api/v2/runs/:id/reproduce with idempotency key; response links originalRunId and new run. Rerun-current uses ordinary submit.
|
||||
- Backend/data dependencies: R05 retained input bundle and R10 artifact integrity; require available approved engine build.
|
||||
- Loading/error/empty behavior: Preview/loading; missing artifact or version error; accepted pending run; hash match/mismatch after completion.
|
||||
- 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.
|
||||
59
docs/development/backlog/tasks/S01.md
Normal file
59
docs/development/backlog/tasks/S01.md
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# S01 — Run deterministic TypeScript decisions on Rust sessions
|
||||
|
||||
Parent epic: E4. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.
|
||||
|
||||
Scheduling source of truth: [manifest entry S01](../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
|
||||
|
||||
Implement deterministic-by-contract TS decisions with prefix-only observations plus existing reviewed incremental calculations; shared feature caching is not a prerequisite. Use the F07 tagged step/barrier API, owner-stamped IDs, explicit decision cadence and seeded randomness. Stage next strategy states and RNG cursors until the barrier is submitted. Decision exceptions discard staged states and abort the attempt; rejected financial intents still commit the observation/state transition and return feedback.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/strategies/
|
||||
- apps/stock/orchestrator/src/backtest/native-worker.ts
|
||||
- apps/stock/orchestrator/src/backtest/strategy-plan.ts
|
||||
- libs/core/types/src/
|
||||
|
||||
Write locks: strategy-contract, worker-protocol. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [F07](F07.md) integrated.
|
||||
|
||||
Architecture decisions: ADR-004, 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
|
||||
|
||||
- On the pinned supported runtime/build, controlled clock/random inputs and identical state yield identical fixture decision traces and economic hashes.
|
||||
- Each strategy sees its own state/positions and the same barrier portfolio snapshot, not a state mutated by another callback's early admission.
|
||||
- Retry restores strategy state, RNG position and decision sequence; quantity rejection does not pretend the observation never occurred.
|
||||
- Contract/type checks prohibit broker/account mutation services; trusted callbacks are not a security sandbox. No claim that repeated tests prove arbitrary TS deterministic.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- same_seed_trace, all_callbacks_same_barrier_view, exception_restores_state_rng, rejected_order_feedback, repeated_target_no_duplicate.
|
||||
- Compile-time context tests and preserved strategy-recovery scenarios; P01 adds actual TS decision costs.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## 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.
|
||||
57
docs/development/backlog/tasks/S02.md
Normal file
57
docs/development/backlog/tasks/S02.md
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# S02 — Adapt one SMA strategy for the first canonical path
|
||||
|
||||
Parent epic: E4. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: TypeScript strategy/quant engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry S02](../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
|
||||
|
||||
- **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).
|
||||
- **FIN-04 — Verified:** Native fills notify every strategy. TypeScript realized P&L uses aggregate symbol cost basis, not per-strategy cost basis. [apps/stock/engine/src/backtest/engine.rs:489](../../../../apps/stock/engine/src/backtest/engine.rs#L489); [apps/stock/orchestrator/src/execution/model.ts:108](../../../../apps/stock/orchestrator/src/execution/model.ts#L108).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Adapt one existing SMA strategy first into the approved TS decision API using the current registry alias. Remove direct ModeManager/ExecutionService access for this version; parameters and owner budget are explicit. Keep other strategies/version readers intact and visibly legacy/unsupported on the canonical path until adapted. A native conformance strategy is test-only, not a competing production implementation.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/strategies/StrategyRegistry.ts
|
||||
- apps/stock/orchestrator/src/strategies/BaseStrategy.ts
|
||||
- apps/stock/orchestrator/src/strategies/builtin/SmaCrossoverStrategy.ts
|
||||
- apps/stock/orchestrator/src/strategies/builtin/MeanReversionStrategy.ts
|
||||
|
||||
Write locks: strategy-builtins. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [S01](S01.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
|
||||
|
||||
- The versioned SMA strategy runs via the Rust session with no service injection and isolated checkpoint state.
|
||||
- Entry/exit and owner sizing are explicit; prior registry alias still resolves to a deliberate version/capability.
|
||||
- A new canonical run can ship after this one strategy passes; migrating every native/TS built-in is not a release gate.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- sma_registry_alias, owner_budget_sizing, sma_checkpoint_restore, sma_next_open_trace.
|
||||
- Legacy strategy/result compatibility remains; no wholesale BaseStrategy deletion.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## 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.
|
||||
59
docs/development/backlog/tasks/S03.md
Normal file
59
docs/development/backlog/tasks/S03.md
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# S03 — Adapt durable paper transactions to Rust financial reducers
|
||||
|
||||
Parent epic: E4. Priority/severity: P0 / Critical. Relative complexity: L. Recommended specialization: Durable execution/Rust integration.
|
||||
|
||||
Scheduling source of truth: [manifest entry S03](../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
|
||||
|
||||
- **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).
|
||||
- **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).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Preserve the existing PostgreSQL row lock, checkpoint+intent commit and per-effect journal. Rehydrate a private Rust staged state, call the same in-place financial kernel used by research, persist returned snapshot/effects atomically, publish after commit. Do not serialize/rebuild resident research state per event merely to satisfy paper staging. Metrics/UI are not transaction prerequisites. Before paper cutover, retain supported current order/TIF and recovery semantics or explicitly refuse incompatible outstanding state.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/execution/PostgresExecutionRepository.ts
|
||||
- apps/stock/orchestrator/src/execution/SimulationExecution.ts
|
||||
- apps/stock/orchestrator/src/execution/StrategyRecovery.ts
|
||||
- apps/stock/orchestrator/src/services/ExecutionService.ts
|
||||
- apps/stock/engine/src/api/
|
||||
|
||||
Write locks: ts-execution-model, paper-transaction, financial-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [S01](S01.md), [C06](C06.md) integrated.
|
||||
|
||||
Architecture decisions: 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
|
||||
|
||||
- Rollback discards staged native changes; crash before/after commit/publish has no duplicate fee/order or lost checkpoint.
|
||||
- Restore includes owner cost residuals, open-order policies/reservations, event cursor, strategy/RNG state and IDs.
|
||||
- Existing PostgreSQL failure cases and legacy supported DAY/GTC/IOC/FOK behavior pass the canonical path; incompatible old snapshot versions fail with a migration instruction.
|
||||
- Research and paper reducers match economic postings for the same event/intent trace; different live data/timing is not claimed to produce identical trades.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- Port all existing PostgreSQL order-execution and strategy-recovery failure cases.
|
||||
- fault_before_commit, fault_after_commit_before_publish, multi_owner_lock, same_id_conflict, snapshot_restore_parity.
|
||||
|
||||
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.
|
||||
58
docs/development/backlog/tasks/S04.md
Normal file
58
docs/development/backlog/tasks/S04.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# 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](../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
|
||||
|
||||
- **OPS-02 — Needs Investigation:** Paper/live operational readiness is not demonstrated end-to-end. Live is deliberately disabled; preserve that gate until feed, reconciliation and broker-specific recovery are verified. [apps/stock/orchestrator/src/core/ModeManager.ts:33](../../../../apps/stock/orchestrator/src/core/ModeManager.ts#L33); [apps/stock/orchestrator/src/container.ts:152](../../../../apps/stock/orchestrator/src/container.ts#L152).
|
||||
- **FIN-06 — Verified:** Native simulation fills complete requested quantities at the latest price without bar-volume participation; current risk must be enforced at acceptance and fill, including pending exposure. [apps/stock/engine/src/backtest/engine.rs:374](../../../../apps/stock/engine/src/backtest/engine.rs#L374); [apps/stock/engine/src/backtest/engine.rs:414](../../../../apps/stock/engine/src/backtest/engine.rs#L414).
|
||||
|
||||
## 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](S02.md), [S03](S03.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
|
||||
|
||||
- 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](../../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.
|
||||
58
docs/development/backlog/tasks/S05.md
Normal file
58
docs/development/backlog/tasks/S05.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# S05 — Add a small composable multi-signal regime example
|
||||
|
||||
Parent epic: E4. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Quant strategy research.
|
||||
|
||||
Scheduling source of truth: [manifest entry S05](../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
|
||||
|
||||
- **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).
|
||||
- **FIN-04 — Verified:** Native fills notify every strategy. TypeScript realized P&L uses aggregate symbol cost basis, not per-strategy cost basis. [apps/stock/engine/src/backtest/engine.rs:489](../../../../apps/stock/engine/src/backtest/engine.rs#L489); [apps/stock/orchestrator/src/execution/model.ts:108](../../../../apps/stock/orchestrator/src/execution/model.ts#L108).
|
||||
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Adapt the existing mean-reversion idea as a second TS strategy/example and compose trend/momentum scores plus a simple fixed/training-only volatility regime using reviewed calculations. Ordinary functions, no universal signal/regime framework. Code/decision tests can land before R08; conclusions about performance require R08 validation.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/strategies/builtin/
|
||||
- apps/stock/orchestrator/src/strategies/StrategyRegistry.ts
|
||||
- libs/calculations/
|
||||
|
||||
Write locks: example-strategy. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [S02](S02.md), [F08](F08.md) integrated.
|
||||
|
||||
No additional economic-policy approval is needed for this narrowly scoped task.
|
||||
|
||||
Feature activation/release gates: [R08](R08.md). These do not block implementing or integrating this component against its own tests.
|
||||
|
||||
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- Two strategy instances sharing an asset maintain independent state/basis and route fills correctly.
|
||||
- Exit is not blocked by entry-only volume filters; thresholds and owner budgets are explicit.
|
||||
- Regime/no-regime ablation inputs and cost-sensitivity recipe are reproducible; no alpha claim before validation release gate.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- signal_composition_units, regime_boundary_availability, multi_strategy_ownership, no_regime_ablation_reproducibility.
|
||||
|
||||
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.
|
||||
61
docs/development/backlog/tasks/S06.md
Normal file
61
docs/development/backlog/tasks/S06.md
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# 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.
|
||||
70
docs/development/backlog/tasks/W01.md
Normal file
70
docs/development/backlog/tasks/W01.md
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
# W01 — Make existing run controls and selection truthful
|
||||
|
||||
Parent epic: E5. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack React/API.
|
||||
|
||||
Scheduling source of truth: [manifest entry W01](../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
|
||||
|
||||
- **WEB-02 — Verified:** Detail exposes native-unsupported pause/resume controls, omits cancel wiring, and overlapping polling/selection can apply stale responses. [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:379](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L379); [apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts:160](../../../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts#L160).
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Repair the existing UI flow only: wire cancel, show cancel-requested until persisted terminal state, use one nonoverlapping polling authority, and guard requests by selection generation/abort. Websocket messages invalidate/refetch persisted state, not a competing state store. Repair the current reconnect guard/cleanup as needed. Expose cancel as the supported shared execution control; leave legacy pause/resume/speed endpoints intact but do not advertise them without per-run support. No capability registry, SQL migration or new backend job protocol.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
|
||||
- apps/stock/web-app/src/features/backtest/hooks/useBacktestV2.ts
|
||||
- apps/stock/web-app/src/features/backtest/components/RunControlsCompact.tsx
|
||||
- apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts
|
||||
- apps/stock/web-app/src/hooks/useWebSocket.ts
|
||||
- test/integration/backtest-run-controls.test.tsx (new)
|
||||
- apps/stock/web-app/package.json and bun.lock (only if a focused DOM test dependency is necessary)
|
||||
|
||||
Write locks: web-backtest-detail, websocket-hook, frontend-test-dependencies. Review concrete file overlap; first-wave writable paths are further restricted by FIRST-WAVE.md.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
No code prerequisite. Global execution approval and write-lock acquisition still required.
|
||||
|
||||
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
|
||||
|
||||
- Late getRun(A) AND getResults(A) cannot replace selected B, including completion/error callbacks.
|
||||
- At most one poll is outstanding per mounted selection; switching/unmount invalidates previous requests and cleans timers/subscriptions.
|
||||
- Pending cancellation can persist as cancelled immediately; active cancellation remains requested until stored acknowledgement. Failed/cancelled never display successful completion.
|
||||
- Current native-unsupported server pause/resume/speed controls are absent/disabled; chart playback controls are unaffected.
|
||||
- Reconnect or polling fallback recovers actual status; completed zero-trade data is distinct from missing results.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- New backtest-run-controls.test.tsx: stale_status_response, stale_results_response, one_poll_in_flight, no_publish_after_unmount, pending_vs_active_cancel, unsupported_controls, reconnect_or_poll_recovery.
|
||||
- bun test test/integration/backtest-run-controls.test.tsx test/integration/analytics-ui.test.tsx test/integration/backtest-result-mapping.test.ts test/integration/backtest-workflow.test.ts; bun run typecheck; bun run test:contracts.
|
||||
- Reuse Bun and existing React tests. One minimal DOM test adapter is allowed if needed; W04 owns real browser E2E, not a second harness here.
|
||||
|
||||
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
||||
|
||||
## 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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: Existing v2 getRun/getResults/cancel and websocket invalidation only. No new capability schema or financial fields.
|
||||
- Backend/data dependencies: Existing persisted cancellation/status contract; backend source is read-only for this task.
|
||||
- Loading/error/empty behavior: Preserve selected B during stale A responses; retry errors; requested versus acknowledged cancellation; zero trades versus unavailable result.
|
||||
- Parallelism: Independent of first-wave native finance, TS finance and ModeManager files. Owns frontend test-dependency changes if needed.
|
||||
|
||||
## 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.
|
||||
66
docs/development/backlog/tasks/W02.md
Normal file
66
docs/development/backlog/tasks/W02.md
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# W02 — Expose result provenance and legacy correctness limitations
|
||||
|
||||
Parent epic: E5. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack research UX.
|
||||
|
||||
Scheduling source of truth: [manifest entry W02](../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
|
||||
|
||||
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
||||
- **FIN-01 — Verified:** Both execution paths can act on a completed bar and fill against its current close; this is not a defensible default bar-close policy. [apps/stock/engine/src/backtest/engine.rs:249](../../../../apps/stock/engine/src/backtest/engine.rs#L249); [apps/stock/orchestrator/src/services/ExecutionService.ts:224](../../../../apps/stock/orchestrator/src/services/ExecutionService.ts#L224).
|
||||
- **FIN-07 — Verified:** Daily return grouping, Sharpe/Sortino conventions and placeholder exposure/VaR produce incomparable or misleading native metrics. [apps/stock/engine/src/backtest/simple_results.rs:374](../../../../apps/stock/engine/src/backtest/simple_results.rs#L374); [apps/stock/engine/src/backtest/simple_results.rs:542](../../../../apps/stock/engine/src/backtest/simple_results.rs#L542).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add read-only provenance/limitations DTO and panel using data actually stored. Distinguish missing metadata, legacy semantics and project-gated engine versions; label same-bar/funding/attribution limitations. Do not infer a historical code hash or certify results from engine name alone.
|
||||
|
||||
Measurable benefit: Delivers useful UI now without presenting invalid results as validated.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx
|
||||
- apps/stock/web-app/src/features/backtest/components/BacktestMetrics.tsx
|
||||
- apps/stock/web-api/src/services/backtest-result.ts
|
||||
- libs/core/types/src/backtest-run.ts
|
||||
|
||||
Write locks: web-backtest-detail, result-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [W01](W01.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
|
||||
|
||||
- Every existing run reopens with exact stored configuration where present and explicit unknown fields otherwise.
|
||||
- Legacy/native/TS result limitations are visible next to performance; unproject-gated results cannot be treated as validated promotion evidence.
|
||||
- No zero-valued placeholder is presented as a measured risk metric.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- legacy_missing_provenance, frozen_config_not_mutable_definition, limitation_badge, null_metrics.
|
||||
- Existing backtest-result-mapping and analytics-ui tests.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: Extend GET /api/v2/runs/:id/results with provenance availability, economics version and limitations; backward-compatible optional fields.
|
||||
- Backend/data dependencies: Existing result configuration/dataset; future R05 extends the same contract.
|
||||
- Loading/error/empty behavior: Separate loading, no-result-yet, failed run, and legacy metadata unavailable; never fabricate defaults as provenance.
|
||||
- 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.
|
||||
66
docs/development/backlog/tasks/W03.md
Normal file
66
docs/development/backlog/tasks/W03.md
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# W03 — Separate save, submit and repeat-safe run creation
|
||||
|
||||
Parent epic: E5. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack durable workflow.
|
||||
|
||||
Scheduling source of truth: [manifest entry W03](../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
|
||||
|
||||
- **WEB-03 — Verified:** Definition creation auto-starts by default and catches submission failure; run creation has no client submission key. Re-run uses current definition rather than immutable original input. [apps/stock/web-api/src/services/backtest-v2.service.ts:105](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L105); [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:173](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L173).
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Make the web save action explicitly non-running; add an explicit Save and run operation with visible submit failures. Add a principal-scoped submission key plus payload hash so transport retries return the same run. Preserve transactional request snapshot/outbox creation and legacy compatibility explicitly.
|
||||
|
||||
Measurable benefit: Removes accidental/duplicate runs and hidden submission errors.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/web-api/src/services/backtest-v2.service.ts
|
||||
- apps/stock/web-api/src/routes/backtests-v2.routes.ts
|
||||
- apps/stock/web-app/src/features/backtest/components/CreateBacktestDialog.tsx
|
||||
- apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts
|
||||
- database/postgres/init/ (new additive migration)
|
||||
|
||||
Write locks: web-backtest-detail, web-backtest-service, sql-migrations. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [O01](O01.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
|
||||
|
||||
- Repeated same-key/same-payload submit yields one run and outbox entry; changed payload under same key returns409.
|
||||
- Saving a definition creates no hidden job; submission failure remains visible and retryable.
|
||||
- Concurrent submissions preserve run numbering; non-browser clients use the same endpoint semantics.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- idempotent_submission_postgres_race, submission_key_conflict, save_only, save_and_run_failure.
|
||||
- Existing durable-backtest and workflow suites.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: POST definition with explicit autoStart:false; POST runs with Idempotency-Key, request fingerprint,202/Location;409 conflict.
|
||||
- Backend/data dependencies: Existing definitions/runs/dispatch plus one submission uniqueness constraint.
|
||||
- Loading/error/empty behavior: Submitting disables duplicate clicks; persisted definition survives submit failure; retry reuses the same key; empty strategy list explains unavailable capability.
|
||||
- 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.
|
||||
67
docs/development/backlog/tasks/W04.md
Normal file
67
docs/development/backlog/tasks/W04.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# W04 — Verify the first research vertical slice in a browser
|
||||
|
||||
Parent epic: E5. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack test engineering.
|
||||
|
||||
Scheduling source of truth: [manifest entry W04](../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
|
||||
|
||||
- **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211).
|
||||
- **WEB-02 — Verified:** Detail exposes native-unsupported pause/resume controls, omits cancel wiring, and overlapping polling/selection can apply stale responses. [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:379](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L379); [apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts:160](../../../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts#L160).
|
||||
- **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190).
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
Add a narrowly scoped browser runner if the repository lacks one; prefer Playwright for real navigation and use existing Bun/server-render tests for small components. Exercise actual API/dispatcher/disposable DB and a deterministic fixture worker, plus one native smoke run.
|
||||
|
||||
Measurable benefit: Protects the primary product path while internals migrate.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- test/e2e/ (extend)
|
||||
- apps/stock/web-app/package.json
|
||||
- scripts/test-postgres.ts
|
||||
- apps/stock/web-app/src/features/backtest/
|
||||
|
||||
Write locks: browser-harness. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
Implementation requires [W01](W01.md), [W02](W02.md), [W03](W03.md), [C06](C06.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
|
||||
|
||||
- Select supported strategy -> save/configure -> submit -> pending/running -> completed -> trades -> reload URL works.
|
||||
- Cancellation, worker failure, empty results, inaccessible run and network reconnect have user-visible outcomes.
|
||||
- Initial slice is explicitly exploratory until F08/S02/R05 correctness-gate evidence; no mock fixture is claimed as financial correctness proof.
|
||||
|
||||
## Mandatory tests
|
||||
|
||||
- browser_saved_run_lifecycle, browser_cancel_failure, browser_reopen_and_switch, native_smoke.
|
||||
- Disposable PostgreSQL/Redis suite; browser install is an explicit dependency, not assumed present.
|
||||
|
||||
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.
|
||||
|
||||
## Web/API contract and user states
|
||||
|
||||
- API: Exercise existing v2 APIs and websocket projection; no new business endpoints.
|
||||
- Backend/data dependencies: Isolated test DB/queue and fixture dataset; never local paper accounts.
|
||||
- Loading/error/empty behavior: Assert loading/empty/error/retry/cancelled states in rendered UI.
|
||||
- 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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue