feat(engine): add canonical risk and order matching
This commit is contained in:
parent
b65acccd91
commit
ccf333cc0a
13 changed files with 5129 additions and 36 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Canonical development backlog
|
||||
|
||||
**First six waves committed; F02/D02 validated, uncommitted.** Consult manifest execution_scope, [ROADMAP](../ROADMAP.md), [skeptical review](../REVIEW.md) and [first-wave handoff](../FIRST-WAVE.md). ADR-002/003/004 are approved; F02/D02 await owner acceptance/commit, and other tasks/policies remain gated.
|
||||
**First seven waves committed; F04/F05 independently reviewed and validated, uncommitted.** Consult manifest execution_scope, [ROADMAP](../ROADMAP.md), [skeptical review](../REVIEW.md) and [first-wave handoff](../FIRST-WAVE.md). ADR-002/003/004 are approved. The owner authorized F05 on F04's validated integrated source without requesting a commit. Other tasks/policies remain gated.
|
||||
|
||||
## One source of truth
|
||||
|
||||
|
|
@ -30,10 +30,10 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
|
|||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [F01 Define the minimal financial contract and economic fixtures](tasks/F01.md) | P0 / done | ADR-002, ADR-003, ADR-004 (approved) | — | Rust financial contract owner / M |
|
||||
| [F02 Implement one owner-aware financial ledger](tasks/F02.md) | P0 / review | F01, ADR-002 | — | Rust accounting / L |
|
||||
| [F02 Implement one owner-aware financial ledger](tasks/F02.md) | P0 / done | 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 |
|
||||
| [F04 Enforce cash reservations and portfolio risk centrally](tasks/F04.md) | P0 / review | F02, ADR-002, ADR-003 | — | Rust financial risk / L |
|
||||
| [F05 Unify matching and order lifecycle on the ledger](tasks/F05.md) | P0 / review | 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 |
|
||||
|
|
@ -43,7 +43,7 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
|
|||
| Task | Priority / status | Implementation prerequisites | Release gate | Specialist / size |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [D01 Introduce availability-aware dataset v2](tasks/D01.md) | P0 / done | ADR-003 (approved) | — | TypeScript trading infrastructure / M |
|
||||
| [D02 Connect supported intraday storage to research datasets](tasks/D02.md) | P1 / review | D01 | — | TypeScript trading infrastructure / M |
|
||||
| [D02 Connect supported intraday storage to research datasets](tasks/D02.md) | P1 / done | 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 |
|
||||
|
||||
|
|
@ -115,4 +115,4 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
|
|||
|
||||
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.
|
||||
|
||||
The first five waves are independently reviewed, validated and committed with owner approval. **W04** is committed as `550d8b7`. Evidence is recorded in [FIRST-WAVE.md](../FIRST-WAVE.md#execution-record--2026-10-22), the [ROADMAP handoffs](../ROADMAP.md#fifth-wave-handoff--2026-10-22) and the manifest. The owner's subsequent explicit approval of ADR-002/003/004 authorizes **F01 + D01** in parallel. R01 still needs ADR-006; other consumers wait for their dependencies. Deferred work remains deferred. No sixth-wave commit/push/PR or trading operation is authorized.
|
||||
The first seven waves are independently reviewed, validated and committed with owner approval. Evidence is recorded in [FIRST-WAVE.md](../FIRST-WAVE.md#execution-record--2026-10-22), the [ROADMAP handoffs](../ROADMAP.md#ninth-wave-handoff--2026-10-22) and the manifest. The latest owner request authorized **F05** using accepted integrated F04. Both implementations are now independently reviewed and `validated_uncommitted`; F05's explicit integration overlay pins its prerequisite source, and ninth-wave validation records the resulting cumulative seven-file financial overlay. Next after acceptance: F06. R01 still needs ADR-006; other consumers wait for their dependencies. No commit, push, PR or trading operation is authorized.
|
||||
|
|
|
|||
|
|
@ -1,24 +1,22 @@
|
|||
{
|
||||
"schema_version": 1,
|
||||
"plan_revision": "2026-10-22.18",
|
||||
"plan_revision": "2026-10-22.21",
|
||||
"repository_base": "b7aeca4",
|
||||
"plan_status": "seventh_wave_validated_uncommitted",
|
||||
"plan_status": "ninth_wave_validated_uncommitted",
|
||||
"execution_authorized": true,
|
||||
"execution_scope": {
|
||||
"authorized_by": "User: commit and continue (2026-10-22); commit accepted F01/D01 and continue with the explicitly proposed F02/D02 pair",
|
||||
"authorized_by": "User: do it (2026-10-22), authorizing the explicitly proposed F05 continuation on accepted integrated F04; no commit requested",
|
||||
"tasks": [
|
||||
"F02",
|
||||
"D02"
|
||||
"F05"
|
||||
],
|
||||
"permissions": [
|
||||
"commit_validated_sixth_wave",
|
||||
"isolated_implementation",
|
||||
"local_tests",
|
||||
"local_integration_review",
|
||||
"planning_progress_updates"
|
||||
],
|
||||
"excluded": [
|
||||
"seventh_wave_commits_without_further_approval",
|
||||
"commits_without_further_approval",
|
||||
"push",
|
||||
"pull_requests",
|
||||
"live_or_paper_operations",
|
||||
|
|
@ -368,7 +366,7 @@
|
|||
"epic": "E2",
|
||||
"priority": "P0",
|
||||
"severity": "Critical",
|
||||
"status": "review",
|
||||
"status": "done",
|
||||
"dependencies": [
|
||||
"F01"
|
||||
],
|
||||
|
|
@ -392,7 +390,7 @@
|
|||
"assignment": "/root/wave7_f02",
|
||||
"branch": "wave7/f02-owned-ledger",
|
||||
"pull_request": null,
|
||||
"completed_commit": null,
|
||||
"completed_commit": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"blocker": null,
|
||||
"release_gates": [],
|
||||
"worktree": "/tmp/stock-bot-wave7.UIkAQD/f02",
|
||||
|
|
@ -403,8 +401,8 @@
|
|||
"Cargo.lock",
|
||||
"test/fixtures/economics/"
|
||||
],
|
||||
"review_notes": "Independently accepted, exact frozen files integrated, combined repository checks passed. Seventh-wave changes remain uncommitted pending owner acceptance/commit; no downstream task started.",
|
||||
"integration_state": "validated_uncommitted",
|
||||
"review_notes": "Independently accepted, frozen source integrated and combined gates passed. Owner authorized commit and continuation; completed_commit contains F02/D02.",
|
||||
"integration_state": "validated_committed",
|
||||
"reviewed_by": "/root/wave7_review",
|
||||
"verification_reference": "ROADMAP.md#seventh-wave-handoff--2026-10-22"
|
||||
},
|
||||
|
|
@ -439,7 +437,7 @@
|
|||
"epic": "E2",
|
||||
"priority": "P0",
|
||||
"severity": "Critical",
|
||||
"status": "blocked",
|
||||
"status": "review",
|
||||
"dependencies": [
|
||||
"F02"
|
||||
],
|
||||
|
|
@ -459,12 +457,25 @@
|
|||
"risk-policy"
|
||||
],
|
||||
"parallel_policy": "Allowed only with satisfied dependencies/approvals and disjoint write locks AND actual files; see agents/integration.md.",
|
||||
"assignment": null,
|
||||
"branch": null,
|
||||
"assignment": "/root/wave8_f04",
|
||||
"branch": "wave8/f04-financial-risk",
|
||||
"pull_request": null,
|
||||
"completed_commit": null,
|
||||
"blocker": null,
|
||||
"release_gates": []
|
||||
"release_gates": [],
|
||||
"worktree": "/tmp/stock-bot-wave8.pKzr7p/f04",
|
||||
"integration_base": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"concrete_write_scope": [
|
||||
"apps/stock/engine/src/financial/"
|
||||
],
|
||||
"integration_state": "validated_uncommitted",
|
||||
"reviewed_by": [
|
||||
"/root/wave8_risk_review",
|
||||
"/root/wave8_quant_review"
|
||||
],
|
||||
"review_notes": "Both independent reviewers and combined gates passed; owner accepted continuation to F05. Integrated F04 remains uncommitted, with frozen source hashes recorded in eighth_wave_validation.",
|
||||
"verification_reference": "ROADMAP.md#eighth-wave-handoff--2026-10-22",
|
||||
"accepted_by": "Owner: do it, authorizing proposed F05 continuation on validated integrated F04 (2026-10-22)"
|
||||
},
|
||||
{
|
||||
"id": "F05",
|
||||
|
|
@ -472,7 +483,7 @@
|
|||
"epic": "E2",
|
||||
"priority": "P0",
|
||||
"severity": "Critical",
|
||||
"status": "blocked",
|
||||
"status": "review",
|
||||
"dependencies": [
|
||||
"F04"
|
||||
],
|
||||
|
|
@ -493,14 +504,32 @@
|
|||
"financial-contract"
|
||||
],
|
||||
"parallel_policy": "Allowed only with satisfied dependencies/approvals and disjoint write locks AND actual files; see agents/integration.md.",
|
||||
"assignment": null,
|
||||
"branch": null,
|
||||
"assignment": "/root/wave9_f05",
|
||||
"branch": "wave9/f05-matching",
|
||||
"pull_request": null,
|
||||
"completed_commit": null,
|
||||
"blocker": null,
|
||||
"release_gates": [
|
||||
"F06"
|
||||
]
|
||||
],
|
||||
"worktree": "/tmp/stock-bot-wave9.P8EKsc/f05",
|
||||
"integration_base": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"integration_overlay": {
|
||||
"task": "F04",
|
||||
"source_hashes_reference": "eighth_wave_validation.source_hashes",
|
||||
"accepted_integration": true,
|
||||
"note": "Exact validated source copied with apply_patch into isolated worktree; no implicit commit required or created."
|
||||
},
|
||||
"concrete_write_scope": [
|
||||
"apps/stock/engine/src/financial/"
|
||||
],
|
||||
"integration_state": "validated_uncommitted",
|
||||
"review_notes": "Both independent reviewers accepted the final frozen source; root integrated matching hashes and passed all repository checks plus the release matching measurement. No active runtime cutover; F06 remains the replay release gate.",
|
||||
"reviewed_by": [
|
||||
"/root/wave9_execution_review",
|
||||
"/root/wave9_quant_review"
|
||||
],
|
||||
"verification_reference": "ROADMAP.md#ninth-wave-handoff--2026-10-22"
|
||||
},
|
||||
{
|
||||
"id": "F06",
|
||||
|
|
@ -652,7 +681,7 @@
|
|||
"epic": "E3",
|
||||
"priority": "P1",
|
||||
"severity": "High",
|
||||
"status": "review",
|
||||
"status": "done",
|
||||
"dependencies": [
|
||||
"D01"
|
||||
],
|
||||
|
|
@ -670,7 +699,7 @@
|
|||
"assignment": "/root/wave7_d02",
|
||||
"branch": "wave7/d02-intraday-storage",
|
||||
"pull_request": null,
|
||||
"completed_commit": null,
|
||||
"completed_commit": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"blocker": null,
|
||||
"release_gates": [],
|
||||
"worktree": "/tmp/stock-bot-wave7.UIkAQD/d02",
|
||||
|
|
@ -681,8 +710,8 @@
|
|||
"test/integration/intraday-storage.test.ts",
|
||||
"test/fixtures/intraday/"
|
||||
],
|
||||
"review_notes": "Independently accepted, exact frozen files integrated, combined repository checks passed. Seventh-wave changes remain uncommitted pending owner acceptance/commit; no downstream task started.",
|
||||
"integration_state": "validated_uncommitted",
|
||||
"review_notes": "Independently accepted, frozen source integrated and combined gates passed. Owner authorized commit and continuation; completed_commit contains F02/D02.",
|
||||
"integration_state": "validated_committed",
|
||||
"reviewed_by": "/root/wave7_review",
|
||||
"verification_reference": "ROADMAP.md#seventh-wave-handoff--2026-10-22"
|
||||
},
|
||||
|
|
@ -3015,6 +3044,191 @@
|
|||
"Initial isolated D02 builds needed existing logger/config dependencies; native sandbox attempt timed out. Escalated tests and independent rerun passed unchanged. Existing build warnings remain."
|
||||
],
|
||||
"cleanup": "Only D02 stale test980112/worker980619 were terminated after exact PID/cwd checks; original session exited143 and process absence verified. No development services, databases or data touched. Worktrees/logs retained.",
|
||||
"handoff": "F01/D01 committedb4af840 at owner request. F02/D02 independently accepted and validated_uncommitted, awaiting owner acceptance/commit. F04 is next prerequisite-dependent task; other ADR approvals unchanged. No push/PR/trading operation or extra task."
|
||||
"handoff": "Owner subsequently authorized F02/D02 commit b65accc and F04 continuation. Seventh-wave validation remains recorded here; other ADR approvals unchanged. No push, PR or trading operation."
|
||||
},
|
||||
"eighth_wave": [
|
||||
"F04"
|
||||
],
|
||||
"eighth_wave_base": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"eighth_wave_notes": [
|
||||
"One isolated financial implementation owner; two read-only reviewers. Root owns planning and integration.",
|
||||
"Additive RiskAccount privately owns Ledger; no active runtime cutover, F05 matching/target expansion, F06 replay, F07 NAPI or SQL/paper changes.",
|
||||
"Task execution-policy clarifications pin units, fee rounding, cash/inventory commitments, event-time mark freshness, risk halts and operator-reset API authority."
|
||||
],
|
||||
"eighth_wave_validation": {
|
||||
"base": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"integration_state": "validated_uncommitted",
|
||||
"repository_check": {
|
||||
"command": "CARGO_BUILD_JOBS=2 bun run check",
|
||||
"log": "/tmp/stock-bot-wave8.pKzr7p/integration-check.log",
|
||||
"exit_code": 0,
|
||||
"passed": {
|
||||
"tooling": 60,
|
||||
"utils": 43,
|
||||
"calculations": 35,
|
||||
"integration": 342,
|
||||
"rust": 77
|
||||
},
|
||||
"rust_manual_benchmarks_ignored": 2,
|
||||
"other_gates": "Build, typecheck, contracts, lint and secret audit passed."
|
||||
},
|
||||
"independent_review": {
|
||||
"risk": "/root/wave8_risk_review: frozen five-file hashes verified; 18 risk tests and 40 financial tests passed, overlapping totals. Log /tmp/stock-bot-wave8.pKzr7p/f04-independent-financial.log.",
|
||||
"quant": "/root/wave8_quant_review: frozen hashes verified;18 risk tests passed. Reviewed once-rounded fees, owner-book exposure, fill-time commitments and atomic overflow."
|
||||
},
|
||||
"scoped_checks": [
|
||||
"rustfmt --edition 2021 --check --config skip_children=true on five changed financial files passed.",
|
||||
"git diff --check and manifest task-file/DAG/authorized dependency/ADR readiness checks passed.",
|
||||
"Whole-repository rustfmt baseline differs outside owned scope; no unrelated rewrite. Planning manifest Prettier check also differs on HEAD baseline; retained existing JSON formatting."
|
||||
],
|
||||
"source_hashes": {
|
||||
"apps/stock/engine/src/financial/ledger.rs": "f2092937bd0ef60d3267751629dae573900680edb777330a09e5ec8e7fc2d854",
|
||||
"apps/stock/engine/src/financial/mod.rs": "63d0cd994ccfc7dec0a421f9d900ec46877fc2d3e1faa69dffbe3e58f0d8bddc",
|
||||
"apps/stock/engine/src/financial/scalar.rs": "6150e0de5be8432ef13f5d10c2d9a9b50c0387bf8c86810d917eb347bf33d7b2",
|
||||
"apps/stock/engine/src/financial/risk.rs": "9d6189177b158afc87f32ee9b9c8ffd2f24bab269de5f1fedd8c8ab515d237ce",
|
||||
"apps/stock/engine/src/financial/risk_tests.rs": "bcaff321cbe84ef6253ce3552f312b0a2057553ad41ea69247a02db92822d098"
|
||||
},
|
||||
"native_artifact": {
|
||||
"path": "apps/stock/engine/dist/engine.node",
|
||||
"sha256": "3987253b57e515acbb58c1e0e83a9d63309fb36aea267de1995ccc18637e256d",
|
||||
"note": "Independently built from integrated checkout; active simulator remains legacy."
|
||||
},
|
||||
"measurement": {
|
||||
"command": "CARGO_BUILD_JOBS=2 cargo test -p engine --lib --release --offline risk_transition_measurement -- --ignored --nocapture",
|
||||
"author_log": "/tmp/stock-bot-wave8.pKzr7p/f04-risk-release.log",
|
||||
"integrated_log": "/tmp/stock-bot-wave8.pKzr7p/integration-risk-release.log",
|
||||
"result": "1 passed, 0 failed;78 filtered. Author and integrated builds both passed; the earlier ledger-only manual measurement was not repeated this wave.",
|
||||
"artifact": "target/release/deps/engine-abe56cbc3e15ae30",
|
||||
"artifact_sha256": "fd30aea3b087bea9961f5e9d8dd96bf1317f5551ba652560d5538dc5c0880338",
|
||||
"host": "AMD Ryzen9 9950X3D; Linux6.8 x86_64; Rust/Cargo1.88.0; build jobs2. Same artifact hash in author/integrated worktrees.",
|
||||
"workload": "Prebuilt 1k/10k commands: mark10, admit2shares, fill1share, cancel remainder. Fee1%,capital1m. One active owner/asset or two active owners/four assets;3repeats,no explicit warmup. At most1live reservation. Apply includes receipt/outcome collection; checkpoint copying and restore separately timed; serialization/input generation/build excluded.",
|
||||
"equality": "Full checkpoint plus returned outcomes byte-equal across three repeats; restored checkpoint byte-equal. No cross-platform determinism claim.",
|
||||
"raw_integrated_rows": [
|
||||
"risk multi=false commands=1000 repeat=0 apply_us=4764 checkpoint_us=639 restore_us=5273 checkpoint_bytes=990585 open_orders=0 owners=1 assets=1",
|
||||
"risk multi=false commands=1000 repeat=1 apply_us=3964 checkpoint_us=303 restore_us=4891 checkpoint_bytes=990585 open_orders=0 owners=1 assets=1",
|
||||
"risk multi=false commands=1000 repeat=2 apply_us=4026 checkpoint_us=292 restore_us=5049 checkpoint_bytes=990585 open_orders=0 owners=1 assets=1",
|
||||
"risk multi=false commands=10000 repeat=0 apply_us=45071 checkpoint_us=7485 restore_us=58692 checkpoint_bytes=10019596 open_orders=0 owners=1 assets=1",
|
||||
"risk multi=false commands=10000 repeat=1 apply_us=42218 checkpoint_us=4706 restore_us=56548 checkpoint_bytes=10019596 open_orders=0 owners=1 assets=1",
|
||||
"risk multi=false commands=10000 repeat=2 apply_us=41986 checkpoint_us=4951 restore_us=57307 checkpoint_bytes=10019596 open_orders=0 owners=1 assets=1",
|
||||
"risk multi=true commands=1000 repeat=0 apply_us=5195 checkpoint_us=343 restore_us=6067 checkpoint_bytes=996239 open_orders=0 owners=2 assets=4",
|
||||
"risk multi=true commands=1000 repeat=1 apply_us=5171 checkpoint_us=291 restore_us=6012 checkpoint_bytes=996239 open_orders=0 owners=2 assets=4",
|
||||
"risk multi=true commands=1000 repeat=2 apply_us=5189 checkpoint_us=295 restore_us=6004 checkpoint_bytes=996239 open_orders=0 owners=2 assets=4",
|
||||
"risk multi=true commands=10000 repeat=0 apply_us=55959 checkpoint_us=5995 restore_us=74884 checkpoint_bytes=10070263 open_orders=0 owners=2 assets=4",
|
||||
"risk multi=true commands=10000 repeat=1 apply_us=56209 checkpoint_us=6110 restore_us=74580 checkpoint_bytes=10070263 open_orders=0 owners=2 assets=4",
|
||||
"risk multi=true commands=10000 repeat=2 apply_us=54665 checkpoint_us=4800 restore_us=69609 checkpoint_bytes=10070263 open_orders=0 owners=2 assets=4"
|
||||
],
|
||||
"limits": "Narrow component workload, not end-to-end backtesting, batch scaling or speedup evidence. Risk checks scan retained book keys and active commitments with ordered-map factors. Journal memory and restore work grow with history; no compaction."
|
||||
},
|
||||
"not_run": [
|
||||
"Disposable PostgreSQL/Redis, browser and Python suites: persistence/API/UI/Python boundaries unchanged."
|
||||
],
|
||||
"limitations": [
|
||||
"No active-engine cutover, F05 matcher/limit/TIF/capacity eligibility or target expansion/mode coordinator, F06 replay, F07 NAPI, or paper/SQL integration.",
|
||||
"Checkpoint covers risk+ledger, not replay cursors/strategy/RNG. Reconstruction checks consistency, not authenticity.",
|
||||
"Host instance operator capability is API authority separation, not authentication or an arbitrary-code sandbox.",
|
||||
"RiskOutcome.replayed gates publication of all nested original financial effects. Arithmetic overflow is an atomic command error; host must fail unsupported attempts."
|
||||
],
|
||||
"handoff": "F02/D02 committed b65accc at owner request. F04 independently accepted and validated_uncommitted. Owner subsequently authorized F05 on this accepted source without requesting a commit; exact overlay is recorded under F05. F06 remains the replay release gate. No commit, push, PR or trading operation.",
|
||||
"cleanup": "No services/data removed; isolated worktree and logs retained."
|
||||
},
|
||||
"ninth_wave": [
|
||||
"F05"
|
||||
],
|
||||
"ninth_wave_base": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"ninth_wave_overlay_reference": "eighth_wave_validation.source_hashes",
|
||||
"ninth_wave_notes": [
|
||||
"The owner authorized F05 on accepted integrated F04 without requesting commits. Its five exact financial source files were applied and hash-verified in the isolated worktree.",
|
||||
"One financial implementation owner; independent execution and quant reviewers; root owns planning/integration.",
|
||||
"Additive matching/order lifecycle privately owns RiskAccount. No legacy simulator, replay scheduler, native API, paper/SQL or brokerage change.",
|
||||
"F05 task clarifies price stages, shared liquidity, target omission/replacement, coordinator-vs-ledger revisions and terminal failed-attempt prefix receipts."
|
||||
],
|
||||
"ninth_wave_validation": {
|
||||
"base": "b65acccd91c15a7fd82536c0c6b3a65e01055113",
|
||||
"integration_state": "validated_uncommitted",
|
||||
"prerequisite_overlay": "Accepted F04 source in eighth_wave_validation.source_hashes; no prerequisite commit required or created.",
|
||||
"repository_check": {
|
||||
"command": "CARGO_BUILD_JOBS=2 bun run check",
|
||||
"log": "/tmp/stock-bot-wave9.P8EKsc/integration-check.log",
|
||||
"exit_code": 0,
|
||||
"passed": {
|
||||
"tooling": 60,
|
||||
"utils": 43,
|
||||
"calculations": 35,
|
||||
"integration": 342,
|
||||
"rust": 106
|
||||
},
|
||||
"rust_manual_benchmarks_ignored": 3,
|
||||
"other_gates": "Build, typecheck, contracts, lint and secret audit passed."
|
||||
},
|
||||
"independent_review": {
|
||||
"execution": "/root/wave9_execution_review: final frozen five-file hashes accepted; 29 matching regressions passed, one manual benchmark ignored.",
|
||||
"quant": "/root/wave9_quant_review: final frozen hashes accepted; 29 matching regressions passed. Reviewed fee/funding authority, limit pricing, physical quote eligibility, capacity dedup, target commitments and terminal partial failures."
|
||||
},
|
||||
"scoped_checks": [
|
||||
"rustfmt --edition 2021 --check --config skip_children=true on five changed financial files passed.",
|
||||
"git diff --check and manifest task-file/DAG/authorized dependency/ADR readiness checks passed.",
|
||||
"Cumulative seven-file source hashes below include unchanged F04 ledger.rs/risk_tests.rs; final five F05 source files match the isolated reviewed worktree exactly."
|
||||
],
|
||||
"changed_source_files": [
|
||||
"apps/stock/engine/src/financial/mod.rs",
|
||||
"apps/stock/engine/src/financial/scalar.rs",
|
||||
"apps/stock/engine/src/financial/risk.rs",
|
||||
"apps/stock/engine/src/financial/matching.rs",
|
||||
"apps/stock/engine/src/financial/matching_tests.rs"
|
||||
],
|
||||
"source_hashes": {
|
||||
"apps/stock/engine/src/financial/ledger.rs": "f2092937bd0ef60d3267751629dae573900680edb777330a09e5ec8e7fc2d854",
|
||||
"apps/stock/engine/src/financial/mod.rs": "45ec9613eb0db8194cc9b21979043f7edff5ad3dc0116a03209e157ae784013d",
|
||||
"apps/stock/engine/src/financial/scalar.rs": "280cefdc8da4f04e1f3ad9fec999e7b7974c06504191ccace1c8eaec3768e189",
|
||||
"apps/stock/engine/src/financial/risk.rs": "ad57837ef631df4b54f24dc752914964e5f6bf891aa74946e054d960584b3c64",
|
||||
"apps/stock/engine/src/financial/risk_tests.rs": "bcaff321cbe84ef6253ce3552f312b0a2057553ad41ea69247a02db92822d098",
|
||||
"apps/stock/engine/src/financial/matching.rs": "98cda1d4ee802c87dbf948e1bc7b40e8a5b6aff6d44b4f3e0571c27ae40cf7b6",
|
||||
"apps/stock/engine/src/financial/matching_tests.rs": "b718de809e2ea76b4a31284aae946eb257d466c916eae0d00c3f174fe7dae43b"
|
||||
},
|
||||
"native_artifact": {
|
||||
"path": "apps/stock/engine/dist/engine.node",
|
||||
"sha256": "d81b0324c111ff05e54584f311a3d6f3bec907ce0e52e288ca3b97590dfe8062",
|
||||
"note": "Built from integrated checkout; active simulator remains legacy."
|
||||
},
|
||||
"measurement": {
|
||||
"command": "CARGO_BUILD_JOBS=2 cargo test -p engine --lib --release --offline matching_transition_measurement -- --ignored --nocapture",
|
||||
"author_log": "/tmp/stock-bot-wave9.P8EKsc/f05-matching-release-final.log",
|
||||
"integrated_log": "/tmp/stock-bot-wave9.P8EKsc/integration-matching-release.log",
|
||||
"result": "1 passed, 0 failed;108 filtered. Author and integrated builds both passed; earlier ledger/risk manual measurements not repeated this wave.",
|
||||
"artifact": "target/release/deps/engine-abe56cbc3e15ae30",
|
||||
"artifact_sha256": "ed9ac89737bcd57e671c59ef818f7411c7b29c9158bc5eb9dc5e4fc2e777a2bc",
|
||||
"host": "AMD Ryzen9 9950X3D; Linux6.8 x86_64; Rust/Cargo1.88.0; build jobs2. Same artifact hash in author/integrated worktrees.",
|
||||
"workload": "1k/10k execution events/fills, each preceded by one Submit =2k/20k coordinator commands plus4setup. Alternate buy/sell quantity1 at10; fee0.001,capital1m. One active owner/asset or two owners/two assets;3repeats,no explicit warmup.",
|
||||
"timing": "Apply includes fixture construction, helper assertions and outcome collection, unlike the earlier prebuilt F04 workload. Checkpoint copying is separate; restore includes checkpoint.clone() input copying. Serialization/build excluded.",
|
||||
"equality": "Expected fills/fees/cash/flat holdings asserted. Full checkpoint and returned outcome bytes equal across repeats; restored checkpoint equal. No cross-platform determinism claim.",
|
||||
"raw_integrated_rows": [
|
||||
"matching multi=false events=1000 fills=1000 repeat=0 apply_us=24361 checkpoint_us=5945 restore_us=42809 checkpoint_effect_bytes=12635053",
|
||||
"matching multi=false events=1000 fills=1000 repeat=1 apply_us=20561 checkpoint_us=4586 restore_us=37263 checkpoint_effect_bytes=12635053",
|
||||
"matching multi=false events=1000 fills=1000 repeat=2 apply_us=19960 checkpoint_us=4580 restore_us=34314 checkpoint_effect_bytes=12635053",
|
||||
"matching multi=false events=10000 fills=10000 repeat=0 apply_us=235326 checkpoint_us=77381 restore_us=437521 checkpoint_effect_bytes=128041656",
|
||||
"matching multi=false events=10000 fills=10000 repeat=1 apply_us=213718 checkpoint_us=55617 restore_us=455499 checkpoint_effect_bytes=128041656",
|
||||
"matching multi=false events=10000 fills=10000 repeat=2 apply_us=213643 checkpoint_us=55453 restore_us=437177 checkpoint_effect_bytes=128041656",
|
||||
"matching multi=true events=1000 fills=1000 repeat=0 apply_us=22787 checkpoint_us=4393 restore_us=36271 checkpoint_effect_bytes=12635409",
|
||||
"matching multi=true events=1000 fills=1000 repeat=1 apply_us=22417 checkpoint_us=3633 restore_us=36277 checkpoint_effect_bytes=12635409",
|
||||
"matching multi=true events=1000 fills=1000 repeat=2 apply_us=22572 checkpoint_us=3776 restore_us=35502 checkpoint_effect_bytes=12635409",
|
||||
"matching multi=true events=10000 fills=10000 repeat=0 apply_us=238015 checkpoint_us=50975 restore_us=434694 checkpoint_effect_bytes=128042015",
|
||||
"matching multi=true events=10000 fills=10000 repeat=1 apply_us=234303 checkpoint_us=51207 restore_us=434431 checkpoint_effect_bytes=128042015",
|
||||
"matching multi=true events=10000 fills=10000 repeat=2 apply_us=235764 checkpoint_us=51505 restore_us=437413 checkpoint_effect_bytes=128042015"
|
||||
],
|
||||
"limits": "Narrow component-plus-fixture workload, not end-to-end backtesting, batch scaling or speedup evidence. Serialized checkpoint plus external outcomes ~12.6MB/128MB for1k/10k; not RSS. Retained journals grow with history; no compaction."
|
||||
},
|
||||
"not_run": [
|
||||
"Disposable PostgreSQL/Redis, browser and Python suites: persistence/API/UI/Python boundaries unchanged."
|
||||
],
|
||||
"limitations": [
|
||||
"No active-engine cutover, F06 replay scheduler, F07 NAPI sessions or paper/SQL integration. F06 remains matcher replay release gate.",
|
||||
"Checkpoint covers matching+risk+ledger, not strategy/replay/RNG state; validates retained-history consistency, not authenticity or sandbox security.",
|
||||
"Coordinator admission_revision differs from nested FinancialSnapshot ledger revision. F06/F07 must expose the correct barrier token.",
|
||||
"Unexpected numeric errors can follow committed subtransitions: terminal Failed outcome retains the committed prefix. Host must fail/discard the attempt; no successful performance metrics may be published.",
|
||||
"MatchingOutcome.replayed gates all nested original effects. Physical execution dedup uses open instrument+opens_at or quote instrument+observed_at+source_sequence; source sequence need not be chronological.",
|
||||
"Owner target-array order is explicit priority, not an atomic portfolio rebalance. Existing build warnings remain."
|
||||
],
|
||||
"handoff": "F04/F05 independently reviewed and validated, uncommitted. Next after owner acceptance: F06 availability-aware deterministic replay. No commit, push, PR, other task implementation or trading operation.",
|
||||
"cleanup": "No services/data removed; isolated worktree and logs retained."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,20 @@ Implement canonical cash-long-only funding, pending fee-inclusive reservations,
|
|||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Execution policy clarifications
|
||||
|
||||
The approved ADRs remain unchanged. The initial additive implementation pins these explicit configuration semantics; no default production thresholds or active-account migration are introduced:
|
||||
|
||||
- Quantity units for order/position limits; base-currency amounts for symbol/gross exposure, daily loss and explicitly named maximum drawdown amount. Commission is an immutable Rust rate in [0, 1], calculated from exact quantity × price × rate and rounded once at eight places.
|
||||
- Pending buys reserve fee-inclusive cash at the canonical mark (market) or max(mark, limit). Pending sells reserve owner inventory, never anticipated buying power; their fill proceeds fund fees. Pending sells do not offset buy exposure. Actual fills recheck other commitments and the remainder, including split-fill rounding. Unaffordable remainder rejects/releases without resizing or borrowing.
|
||||
- Increasing risk requires fresh non-future canonical marks across held and pending assets, using explicit engine event time and a configured maximum mark age. Reductions still enforce inventory/funding/order-size rules. Daily and drawdown halts latch on marked loss; explicit account boundaries reset only daily state, including when retained marks are old. Same-session repetition cannot rebase, and future/backdated boundaries reject.
|
||||
- A private-owned Ledger facade is the only canonical risk entry point. Normalized explicit-order and target-derived admission share one policy; actual target expansion, mode enforcement, matching, venue expiry scheduling and replay remain F05/F06. Resource-release hooks are not a second matcher.
|
||||
- Operator reset is a separate host-held capability with recorded reason/baseline, absent from strategy inputs. This is API authority separation, not authentication or an untrusted-code sandbox. F07 must expose only the risk-governed facade; later host/auth adapters must enforce their own authority.
|
||||
- Checkpoints validate reservations, risk state and recorded outcomes by deterministic reconstruction. They do not authenticate an attacker-modified history and are not full replay/strategy/RNG or SQL recovery snapshots. Normal transitions must not copy/replay the entire retained history.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/risk/mod.rs
|
||||
- apps/stock/engine/src/risk/mod.rs (reference only during additive implementation)
|
||||
- apps/stock/engine/src/financial/risk.rs (new)
|
||||
- apps/stock/engine/src/financial/ledger.rs
|
||||
|
||||
|
|
@ -44,6 +55,7 @@ Parallel eligibility: only with disjoint actual files and reserved write locks;
|
|||
- 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.
|
||||
- Partial-fill quantum rounding, zero-cash funded sell, pending sells do not credit buy exposure, stale/future other pending symbol, wrong-owner sell/cancel, accepted/rejected command replay and conflicting reuse, same-session no-rebase, future/backdated boundary rejection, restored reservation tamper and overflow atomicity.
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,25 @@ Implement pure matcher/order-transition functions over explicit execution events
|
|||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
||||
## Execution policy clarifications
|
||||
|
||||
The initial component remains additive and Rust-only, privately owning F04 RiskAccount; no mutable risk/ledger escape hatch, parallel accounting, legacy engine or NAPI cutover. F06 derives and schedules events/calendars; F07/S01 supply actual strategy barriers. This task consumes explicit host inputs and proves component behavior.
|
||||
|
||||
- Event eligibility uses availability time, phase, instrument and source sequence plus the pinned execution-series identity. Reject prior/observed execution keys; adjacent next-open at the same timestamp may be eligible under zero latency. Configured latency delays eligibility. No retroactive decision insertion into consumed execution phases. Open events cannot carry future OHLCV. A bar has one shared capacity pool across sides/owners; quotes have explicit bid/ask capacity. Only accepted fills consume it.
|
||||
- Physical quote time is separate from delivery/availability time. Preserve it on marks and require it to be at or after order readiness: late delivery cannot fill an order that did not yet exist. Ineligible old quotes do not consume IOC/FOK opportunities. Explicit open time must match its execution key; F06 must skip/reject missed opens rather than freshen them.
|
||||
- Deduplicate physical opens by instrument/open time and quotes by instrument/observation time/source sequence, independently of delivery key. Exact-key retries return receipts; changed-key redelivery of the same physical event rejects without minting capacity. Do not assume source sequences increase chronologically; distinct quotes sharing a millisecond remain possible.
|
||||
- Pin relative half-spread and slippage rates in [0, 1). For bar opens, derive fixed-eight-place executable bid/ask first; then apply adverse slippage at another declared posting boundary. Quotes already include spread. Limits must cross the executable quote before slippage; qualifying prices are clamped to the limit, never filled through it. Quote financial marks use an exact once-rounded midpoint. F04 alone computes fees and funding.
|
||||
- DAY binds an explicit open venue session and expires at its close; account risk-session reset is separate. IOC/FOK use their first eligible opportunity: IOC cancels remainder; FOK fills the whole remainder once or cancels without fills/fees. Unknown/zero liquidity cannot fill. GTC survives venue closure; run termination cancels without invented liquidation.
|
||||
- Registered strategy mode is fixed. Each listed target is an absolute owner quantity; omitted instruments are unchanged, duplicate entries reject, and explicit zero closes that instrument. Holdings plus signed outstanding commitments determine unchanged targets. Changed targets cancel only that owner's instrument commitments before recomputing; if replacement risk rejects, cancellation remains a recorded outcome.
|
||||
- Owners use stable configured identity order and each decision preserves its explicit intent/target array priority. Sparse target updates are not an atomic portfolio rebalance: earlier entries can reserve cash before later entries release commitments. No anticipated sell proceeds or hidden release-all reordering.
|
||||
- Preflight structural errors across the entire submitted batch/event before mutation. Generated IDs encode tuples unambiguously. Exact repeated events/decisions return original receipts without refilling capacity or replaying effects; conflicting identity reuse rejects. Checkpoints retain order state, priority, identity/cursor/session state and F04 state.
|
||||
- Decision admission uses one coordinator revision for the shared portfolio/order/reservation view. This token is distinct from the nested economic-only FinancialSnapshot ledger revision; F07 must expose the coordinator token for submitting a batch. No wire shape or TypeScript financial arithmetic changes here.
|
||||
- A later internal numeric failure after successful subtransitions is a terminal failed-attempt receipt containing the ordered committed prefix, not a retryable generic error or successful event. All further mutations refuse; restore preserves failure. F06/F07 must discard failed attempts and never publish successful results. This keeps individual F04 transitions atomic without whole-account/history cloning or a second rollback engine.
|
||||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/engine/src/financial/matching.rs (new)
|
||||
- apps/stock/engine/src/backtest/engine.rs
|
||||
- apps/stock/engine/src/backtest/engine.rs (reference only during additive implementation)
|
||||
|
||||
Write locks: rust-matching, financial-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
|
||||
|
|
@ -47,6 +62,7 @@ Parallel eligibility: only with disjoint actual files and reserved write locks;
|
|||
|
||||
- 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.
|
||||
- Adjacent-open/positive-latency eligibility, same quote/key conflict, pinned execution series, unknown/zero capacity, risk rejection preserves shared capacity, later invalid batch member is atomic, terminal numeric failure records prefix and survives restore, partial-fill/target replay and omitted-target semantics.
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Scheduling source of truth: [manifest entry F06](../manifest.json). No task is a
|
|||
|
||||
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.
|
||||
|
||||
Consume F05's explicit event contract without reconstructing a second matcher: quote observation time is not delivery time, and eligibility requires an order to be ready by physical quote time. Open time must equal its execution key; skip/reject missed opens, never relabel them as newly occurring. Decision admission uses the coordinator's shared portfolio/order revision, distinct from the nested economic ledger revision. Terminal F05 failures retain diagnostic prefixes but must fail/discard the replay attempt, never produce successful performance results.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue