feat(engine): expose canonical replay sessions through native workers

This commit is contained in:
Boki 2026-10-23 00:54:36 -04:00
parent 417a7bd21e
commit e3635f23cf
26 changed files with 2693 additions and 33 deletions

View file

@ -1,8 +1,8 @@
# Revised development roadmap
Baseline `b7aeca4` · reviewed 2026-10-22 · **F04/F05 committed; F06 independently reviewed and validated, uncommitted**
Baseline `b7aeca4` · handoff 2026-10-23 · **F06 committed; F07 validated, uncommitted**
Authorization update: the latest owner request “commit all and do it” authorized committing the reviewed F04/F05 source and planning changes (`ccf333c`), then implementing F06. Its worktree starts at that commit; no prerequisite overlay is needed. No other ADR is approved. Pushes, PRs, trading operations and further task implementation remain outside scope.
Authorization update: the latest owner request “commit and continue” authorized committing the reviewed F06 source and planning changes (`417a7bd`), then implementing F07. Its isolated worktree starts at that commit. No other ADR or multi-asset mark policy is approved. Pushes, PRs, trading operations and further task implementation remain outside scope.
## Strategy and review outcome
@ -255,6 +255,22 @@ Release measurement: one/two assets, 1k/10k/100k execution bars plus one cadence
Other limits: trusted internal prepared bars only; F07 must verify/adapt frozen D01 inputs and preserve provenance/model limitations. Quote replay and abutting sessions explicitly reject. Event budget bounds count, not wall time. Active legacy simulator, native API, SQL/paper and web paths are unchanged; no PostgreSQL/Redis, browser or Python rerun was needed. Existing build warnings remain. No services/data removed; worktree/logs retained. **F06 remains uncommitted. Next after acceptance: F07 native pull-session/dataset adapter**; F08 result projection may follow with coordinated contract ownership. No push, PR, trading operation or further task implementation occurred.
## Eleventh-wave handoff — 2026-10-23
F06 was accepted and committed as `417a7bd` at owner request, superseding its uncommitted handoff status above. F07 is independently reviewed and `validated_uncommitted`. Isolated worktree `/tmp/stock-bot-wave11.l8cJnN/f07` starts at that commit. One native/worker owner implemented; a second owner supplied three disjoint benchmark files reviewed by root. Independent boundary/lifecycle and data/quant reviews accepted the boundary. Root integrated 22 matching source/test files. See [F07 clarifications](backlog/tasks/F07.md#execution-handoff-clarifications).
- **FinancialReplaySession:** thin NAPI export over one ReplayHost/F06 core; strict identity/version envelopes, event-count-bounded progress/decision/complete/failed steps, synchronized admission revisions, complete-batch submission, terminal success gate and disposal. One read-only observation-range accessor avoids checkpoint copies. The exact host is tested against direct Rust Replay with identical barriers, outcomes and receipts; TS uses the same frozen fixture and independent arithmetic.
- **TypeScript/worker:** existing D01 validator verifies actual data and derived eligibility/limitations. Numeric ingress expands scientific notation and rejects unsupported precision without rounding. Calendars, execution feed and availability are retained. Callbacks receive only shared immutable published deltas and financial views. Exceptions submit no partial batch; worker results must match captured identity/policy. Existing process cancellation, crash, wait-for-close and lease protections remain.
- **Scope:** fixed trace and fixture callbacks only, not S01 production strategy state/RNG or a DSL. The legacy request, durable runner default and paper/live behavior are unchanged. Exact architecture tests permit only the worker and its helper to reach native replay; shared schemas still cannot import native/data/services.
Final validation: `CARGO_BUILD_JOBS=2 bun run check` passed build/types/contracts/lint/audit plus **63 tooling, 43 utility, 35 calculation, 353 integration and 133 Rust tests**, zero failures. Four earlier manual Rust measurements remain intentionally ignored by the ordinary suite. Independent frozen-artifact review ran 69 focused TS tests and 29 replay-related Rust cases (overlapping totals). Disposable PostgreSQL/Redis suites passed **58 tests / 345 assertions** before and after integration. Release-addon replay/binding tests passed **17 tests / 120 assertions**. Extra strict TypeScript for affected scripts/tests, scoped ESLint, rustfmt and diff checks passed. Explicit lint of the normally ignored architecture test confirms the same 13 pre-existing curly-style errors at HEAD and in the worktree; no new ones. The clean isolated build initially needed the existing logger prerequisite built manually; no build-system rewrite.
Release measurement: 1k/10k total bars, one asset/owner or ten assets/two owners, two fresh processes with two fresh native sessions each; alternate one-unit buy/sell targets. Full normalized results match across repeats, reverse callback order and debug/release profiles. Independent integer-cent cash/equity/basis/fee/fill checks pass. At 10k, release whole-trial times were **2.65–2.93s single / 3.51–3.61s multi**; finalization alone was **0.89–1.03s / 1.34–1.40s**. Final receipt payloads were approximately **66.7MB / 103.6MB**, not RSS. Cold imports and detached dataset verification, mapping, session load, real advance/submit/decision timings, bytes and process RSS are recorded separately in the manifest/logs. This is order-heavy component conformance throughput, not empty-crossing overhead, a production research benchmark, an isolated-host SLA or a legacy-engine speedup. No cache, batch pool, compaction or DSL was introduced.
Limits remain explicit: trusted host interface, not an untrusted-code sandbox; native prepared input does not independently authenticate D01. Quote/abutting-session replay remains unsupported; event count is not a wall-time guarantee. Sequential equal-time marks can still latch intermediate risk halts; R05's owner policy gate remains unresolved. Full receipts are retained and serialized; F08 can use these measurements when designing canonical results without prematurely adding a general storage framework.
Only the two named disposable fixture containers and their recreatable synthetic data were removed; development services were untouched. Worktree/logs retained. Browser/Python suites were not rerun because those boundaries did not change. **F07 remains uncommitted. Next recommended: F08 canonical metrics/result projections**, now code/ADR-ready but not yet authorized. S01 requires ADR-005 approval. No push, PR, default cutover or trading operation occurred.
## Deferred and rejected
Conditional: shared feature cache D04; cross-trial resident datasets P03; large-detail pagination/storage P05; tiny DSL P06; expanded cross-service monitoring O02. Each has a measured/real-need trigger and is not a prerequisite for scheduled work.

View file

@ -1,6 +1,6 @@
# Canonical development backlog
**First nine waves committed; F06 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 the F04/F05 commit (`ccf333c`) and F06 continuation. Other tasks/policies remain gated.
**First ten waves committed; F07 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 the F06 commit (`417a7bd`) and F07 continuation. Other tasks/policies remain gated.
## One source of truth
@ -34,9 +34,9 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
| [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 / done | F02, ADR-002, ADR-003 | — | Rust financial risk / L |
| [F05 Unify matching and order lifecycle on the ledger](tasks/F05.md) | P0 / done | F04, ADR-003 | F06 | Rust execution semantics / L |
| [F06 Implement deterministic replay once, with linear historical traversal](tasks/F06.md) | P0 / review | 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 |
| [F06 Implement deterministic replay once, with linear historical traversal](tasks/F06.md) | P0 / done | F05, D01, P01, ADR-003 | — | Rust deterministic replay / M |
| [F07 Expose bounded Rust step sessions through existing NAPI workers](tasks/F07.md) | P0 / review | F06, C02, ADR-004 | — | Rust/TypeScript integration / M |
| [F08 Publish canonical metrics and versioned result projections](tasks/F08.md) | P1 / ready | F06, ADR-002, ADR-003 | — | Quant analytics/Rust integration / M |
### E3 — Point-in-time datasets and features
@ -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 nine 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#tenth-wave-handoff--2026-10-22) and the manifest. The latest owner request committed F04/F05 as `ccf333c` and authorized **F06**, now reviewed and `validated_uncommitted`. Next after acceptance: F07's verified dataset/native adapter. F08 is another eligible component successor after acceptance; coordinate any shared result/native contracts. R01 still needs ADR-006. The manifest's canonical release gate records the unresolved multi-asset mark-policy decision; this does not block additive adapter work. No push, PR, trading operation or further task implementation is authorized.
The first ten waves are independently reviewed, validated and committed with owner approval. F07 is reviewed and validated but uncommitted; see the [eleventh-wave handoff](../ROADMAP.md#eleventh-wave-handoff--2026-10-23) and manifest evidence. Next recommended after acceptance: **F08 canonical metrics/result projections**, whose code and ADR prerequisites are satisfied; readiness is not execution authority. S01 still needs ADR-005 and R01 needs ADR-006. The unresolved multi-asset mark-policy gate still blocks default activation, not additive components. No push, PR, trading operation or further task implementation is authorized.

View file

@ -1,13 +1,13 @@
{
"schema_version": 1,
"plan_revision": "2026-10-22.23",
"plan_revision": "2026-10-23.25",
"repository_base": "b7aeca4",
"plan_status": "tenth_wave_validated_uncommitted",
"plan_status": "eleventh_wave_review",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: commit all and do it (2026-10-22), authorizing the F04/F05 commit and proposed F06 continuation",
"authorized_by": "User: commit and continue (2026-10-22), authorizing the F06 commit and proposed F07 continuation",
"tasks": [
"F06"
"F07"
],
"permissions": [
"isolated_implementation",
@ -538,7 +538,7 @@
"epic": "E2",
"priority": "P0",
"severity": "Critical",
"status": "review",
"status": "done",
"dependencies": [
"F05",
"D01",
@ -562,7 +562,7 @@
"assignment": "/root/wave10_f06",
"branch": "wave10/f06-replay",
"pull_request": null,
"completed_commit": null,
"completed_commit": "417a7bd21efc3cf906ae88001066ad9984a19324",
"blocker": null,
"release_gates": [],
"worktree": "/tmp/stock-bot-wave10.8uCLfa/f06",
@ -572,13 +572,14 @@
"apps/stock/engine/src/financial/replay_tests.rs",
"apps/stock/engine/src/financial/mod.rs"
],
"integration_state": "validated_uncommitted",
"review_notes": "Both independent reviewers accepted exact frozen source; combined repository gates and integrated release replay measurement passed. Internal bar replay only; active simulator/NAPI/SQL unchanged. Material sequential equal-time risk approximation remains the canonical multi-asset default policy gate.",
"integration_state": "validated_committed",
"review_notes": "Both independent reviewers accepted exact frozen source; combined repository gates and integrated release replay measurement passed. Internal bar replay only; active simulator/NAPI/SQL unchanged. Material sequential equal-time risk approximation remains the canonical multi-asset default policy gate. Subsequently committed at owner request as 417a7bd.",
"reviewed_by": [
"/root/wave10_replay_review",
"/root/wave10_quant_review"
],
"verification_reference": "ROADMAP.md#tenth-wave-handoff--2026-10-22"
"verification_reference": "ROADMAP.md#tenth-wave-handoff--2026-10-22",
"accepted_by": "Owner: commit and continue (2026-10-22); accepted F06 and authorized proposed F07"
},
{
"id": "F07",
@ -586,7 +587,7 @@
"epic": "E2",
"priority": "P0",
"severity": "Critical",
"status": "blocked",
"status": "review",
"dependencies": [
"F06",
"C02"
@ -607,12 +608,38 @@
"worker-protocol"
],
"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/wave11_f07",
"branch": "wave11/f07-native-sessions",
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": []
"release_gates": [],
"worktree": "/tmp/stock-bot-wave11.l8cJnN/f07",
"integration_base": "417a7bd21efc3cf906ae88001066ad9984a19324",
"integration_state": "validated_uncommitted",
"concrete_write_scope": [
"apps/stock/engine/src/api/",
"apps/stock/engine/index.mjs",
"apps/stock/engine/dist/index.d.ts (generated, not authored)",
"apps/stock/orchestrator/src/backtest/native*",
"apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts",
"apps/stock/orchestrator/src/contracts/native-replay.ts (schema-only)",
"apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts (legacy request type narrowing only)",
"test/integration/native-replay*.test.ts",
"test/fixtures/native-replay*",
"scripts/benchmark-research.ts",
"scripts/benchmark-replay.ts",
"scripts/test/benchmark-replay.test.ts",
"scripts/test/architecture.test.ts (exact worker-helper reachability gate)",
"scripts/test/native-bindings.test.ts",
"test/fixtures/native-backtest-worker.ts (request union/type adaptation)",
"apps/stock/engine/src/financial/mod.rs (test-only adapter include)",
"apps/stock/engine/src/financial/replay.rs (read-only prefix range accessor only)",
"apps/stock/engine/src/financial/replay_tests.rs (accessor regression only)"
],
"review_notes": "Independent boundary and data/quant reviewers accepted frozen production code. Boundary reviewer implemented disjoint benchmark files; root independently reviewed those. Root integrated 22 matching files, validated final tests/build, disposable durability suites and debug/release measured workloads. Native module ordering and three test-only type corrections were revalidated. No active runner cutover, S01 state framework, F08 metrics or SQL changes.",
"reviewed_by": ["/root/wave11_boundary_review", "/root/wave11_data_review", "/root"],
"verification_reference": "ROADMAP.md#eleventh-wave-handoff--2026-10-23"
},
{
"id": "F08",
@ -620,7 +647,7 @@
"epic": "E2",
"priority": "P1",
"severity": "High",
"status": "blocked",
"status": "ready",
"dependencies": [
"F06"
],
@ -3362,5 +3389,468 @@
],
"handoff": "F04/F05 committed ccf333c at owner request. F06 independently reviewed and validated, uncommitted. Next after acceptance: F07 verified dataset/native pull adapter; F08 result projection may follow with coordinated contracts. No push, PR, other task implementation or trading operation.",
"cleanup": "No services/data removed; isolated worktree and logs retained."
},
"eleventh_wave": [
"F07"
],
"eleventh_wave_base": "417a7bd21efc3cf906ae88001066ad9984a19324",
"eleventh_wave_notes": [
"Owner authorized committing reviewed F06 and continuing F07; prior work committed417a7bd. No push/PR/trading or other task implementation.",
"One isolated native/worker boundary owner and two independent reviewers; root owns integration/planning. F06/C02 committed, ADR004 approved.",
"Canonical frozen dataset/session path is additive. Preserve legacy run/default, existing process supervision and durable lease/cancellation behavior.",
"Only read-only replay prefix-range accessor allowed in financial core; no accounting/matching/risk policy change. Sequential equal-time mark default-release gate remains unresolved."
],
"eleventh_wave_validation": {
"base": "417a7bd21efc3cf906ae88001066ad9984a19324",
"integration_state": "validated_uncommitted",
"repository_check": {
"command": "CARGO_BUILD_JOBS=2 bun run check",
"log": "/tmp/stock-bot-wave11.l8cJnN/integration-check-final.log",
"exit_code": 0,
"passed": {
"tooling": 63,
"utils": 43,
"calculations": 35,
"integration": 353,
"rust": 133
},
"rust_manual_benchmarks_ignored": 4,
"other_gates": "Build, typecheck, contracts, lint and secret audit passed on final source."
},
"durability": {
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32805/stock_bot_safety BACKTEST_TEST_REDIS_URL=redis://127.0.0.1:32806/15 bun run test:postgres",
"baseline_log": "/tmp/stock-bot-wave11.l8cJnN/baseline-postgres.log",
"integrated_log": "/tmp/stock-bot-wave11.l8cJnN/integration-postgres.log",
"exit_code": 0,
"passed": 58,
"assertions": 345,
"note": "Before and after boundary integration; final subsequent edits were test typing and native module ordering only. Dedicated disposable PostgreSQL tmpfs and Redis DB15; development services untouched."
},
"independent_review": {
"boundary": "/root/wave11_boundary_review accepted production boundary, host delegation, identity/policy, cursor/disposal, cancellation and exact architecture gate. Authored three disjoint benchmark files, excluded them from independent signoff; root independently accepted benchmark implementation.",
"data": "/root/wave11_data_review accepted frozen boundary/data semantics and subsequent three-file type-only test correction; independently ran 69 focused TS tests/484 assertions and 29 replay-related Rust tests, zero failures; one manual Rust benchmark ignored. No rebuilds/source changes during review.",
"logs": [
"/tmp/stock-bot-wave11.l8cJnN/data-review-focused.log",
"/tmp/stock-bot-wave11.l8cJnN/data-review-rust-replay.log"
],
"reviewed_debug_addon_sha256": "d15dd24224af882a3bca0de8a36b78cf56698c0f23dee043a339634b6951de07",
"reviewed_rust_binary_sha256": "b7d70937857422e3b878fb60cf8b8726b89eeb5fe511e9d0db14ee5a1c0c80a9",
"note": "Root subsequently sorted two api/mod.rs declarations per rustfmt; no bodies changed. Final combined build/tests validated the exact integrated source."
},
"scoped_checks": [
"Strict affected scripts/tests TypeScript: bun run node_modules/typescript/bin/tsc --project /tmp/stock-bot-wave11.l8cJnN/tsconfig.scoped.json --noEmit; exit0. Temporary config extends root check options, explicitly includes affected tests/scripts and repository type roots.",
"Explicit ESLint --no-ignore for affected benchmark/fixture/integration/binding files: exit0. Normally ignored architecture.test.ts independently compared at HEAD and worktree: same13 pre-existing curly errors, no new errors.",
"rustfmt --edition2021 --check --config skip_children=true on five changed Rust files: exit0.",
"git diff --check; exact22-file source equality against isolated worktree; final manifest DAG/readiness/reference checks."
],
"source_hashes": {
"apps/stock/engine/index.mjs": "cc085e5b5e111c64c301c395dda0928e85586d39d9fd77c826c67f7a41f14738",
"apps/stock/engine/src/api/mod.rs": "b57ed60e9c138f82e5b0597baf1a5fbcd770f3e884d10dcdd0f900461c063c36",
"apps/stock/engine/src/api/replay.rs": "71e5d8aebb28e43e0cc4694fa60ba3320002027221d38b75737e8abdf4d6685a",
"apps/stock/engine/src/financial/mod.rs": "b359e505b67bb16faa7c06fbae3ec12f16674270f2d806f641c2a9f3e957cfa8",
"apps/stock/engine/src/financial/replay.rs": "a81f9316f9638f9aa9ce27a829ec42c1585fd3cb08feb48cb34f0a0a7417343a",
"apps/stock/engine/src/financial/replay_tests.rs": "d67aabb5331f91a01b9a0b91430fb1a0c3bf1d502baf7ad8728b0c1987b78886",
"apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts": "c3491bd8c814b77a6cea70b1b77dd848153decbfc78f80e095efb989edef3a66",
"apps/stock/orchestrator/src/backtest/RustBacktestAdapter.ts": "3d8a3069787f7c84f106122c24bc16f8efdd025e276d03291a2667eeda8811e4",
"apps/stock/orchestrator/src/backtest/native-replay.ts": "fa422e95d249bc9c578525f5b25e2066d964a34801b8a0e4e365bad9b92d94ad",
"apps/stock/orchestrator/src/backtest/native-worker-protocol.ts": "9cf92049ae0cd9405b780d34fa37bf7a6b4a204617ee7ae0830d8b3ee0d8d5a7",
"apps/stock/orchestrator/src/backtest/native-worker.ts": "8bf5ee81b67f6bc58c278b5441ef3d57691a3de5ea1e665efcbb1012dd5b5689",
"apps/stock/orchestrator/src/contracts/native-replay.ts": "b65cd1fce35fb44717548b71c64387588f5157795b2f2ac80fb06c911c2e9134",
"scripts/benchmark-replay.ts": "e6ccf35dc45860891bcecfad296493684b2ecdbc36f55bd1febc5edc1aca357a",
"scripts/benchmark-research.ts": "58083373e812f856bb8546ceffb47ef827e7256ba4e1b095a68810553c02e32c",
"scripts/test/architecture.test.ts": "fb370e932678308806b64cabe7841d1194048897c1fb3733bd0283f1d2f4916f",
"scripts/test/benchmark-replay.test.ts": "8005192fd2e547926ebc880fdd6c86f48a46620be08ce5e48e872ab8a5a095ff",
"scripts/test/native-bindings.test.ts": "2504a4888434cc0d8caee7cd2905321430be8c3a07b8cc75121e269c32fb6d52",
"test/fixtures/native-backtest-worker.ts": "5dcedb6fcd5dcff9b3088c94c8cd0173097e60bdf932eb1807f521f9486aac0a",
"test/fixtures/native-replay-load.json": "b56a005eaac06c52947abd079a2678b12b4889a58ac1d292f84955b58f40d96f",
"test/fixtures/native-replay-worker.ts": "32327bf7990dbcc657ebafb6ac43b0937e612ea5aacf8112f6a0eeedee97549d",
"test/fixtures/native-replay.ts": "7a6df7a2c499c27f2572489fe0d8d67835f7615bbea9cb06da84a7011722b00e",
"test/integration/native-replay.test.ts": "515227ae92e7f373a836fc0e1d6875bb39ff4b768ad25496015078f388332b1b"
},
"release_native": {
"path": "apps/stock/engine/dist/engine.node",
"sha256": "b62e85283325020de09d44dccb27ae5ec5da97cc514ccd92c9b510c0fd814aad",
"matching_library": "target/release/libengine.so",
"build_command": "CARGO_BUILD_JOBS=2 bun run --cwd apps/stock/engine build:release",
"build_log": "/tmp/stock-bot-wave11.l8cJnN/integration-release-build.log",
"test_command": "bun test test/integration/native-replay.test.ts scripts/test/native-bindings.test.ts",
"test_log": "/tmp/stock-bot-wave11.l8cJnN/integration-release-focused.log",
"passed": 17,
"assertions": 120,
"exit_code": 0
},
"measurement": {
"command": "bun run scripts/benchmark-research.ts --session --measure",
"release_report": "/tmp/stock-bot-wave11.l8cJnN/integration-session-release.json",
"release_log": "/tmp/stock-bot-wave11.l8cJnN/integration-session-release.log",
"debug_report": "/tmp/stock-bot-wave11.l8cJnN/integration-session-benchmark.json",
"exit_code": 0,
"host": {
"platform": "linux",
"arch": "x64",
"kernel": "6.8.0-146-generic",
"cpu": "AMD Ryzen 9 9950X3D 16-Core Processor",
"logicalCpus": 32,
"availableParallelism": 32,
"totalMemoryBytes": 98683457536,
"sha256": "917b26b1f87814e6cb82648bbbb8ae255a930da13b57abb3a9e463b4507f1c4c"
},
"runtime": {
"bun": "1.2.17",
"nodeCompatibility": "v22.6.0",
"executableSha256": "6cd2f181c30d3cb1497b0b9d4bc9d63eb1ec4a9142f809183fed18fcc4e1051b",
"rustc": "rustc 1.88.0 (6b00bc388 2025-06-23)",
"lockSha256": "1a2b653bbaaeb5075785b860487557b8fc379f0c50cbe8f2554c90e4a3ac4514",
"cargoLockSha256": "8f2ecaa4f1790f14e1650326f78fbf246f454dad6139dc4cb0d61383b9e301e8"
},
"source_snapshot": {
"commit": "417a7bd21efc3cf906ae88001066ad9984a19324",
"dirty": true,
"contentSha256": "5710c547b6dce71be2c4ecd3b33a87ae3e95459effff9dcaea3be413c2c73339",
"files": 1153,
"scope": "Tracked and nonignored untracked file paths/content, including dirty changes; generated ignored artifacts excluded."
},
"workload": "1k/10k total bars;1asset/1owner or10assets/2owners;2fresh processes ×2fresh native sessions, second reverses callback evaluation. Alternating unit targets,1% fee,initialcapital1000000,600bars/session with retained gaps. No randomness, storage, queue, indicators or parallel simulation.",
"equality": "Exact complete normalized result hashes match every repeat and debug/release profile. Independent integer-cent cash/equity/remaining basis/owner fees/fill count oracle passes. Economically different results invalidate measurement.",
"timing": "Report separates imports, detached D01 verify, once-per-child prepared-JS mapping, fresh native load, actual advance/submit/decision/finalize and validation/hash. Native call timers include JS encoding/schema/immutable projection plus Rust work/serialization, not pure crossing cost. Trial wall includes load+replay+finalization+oracle/hash, excludes one-time preparation/import and parent aggregation. No explicit warmup or OS-cache flush; means only, not latency distributions. Shared host; release focused checks briefly overlapped initial measurement, so not an isolated performance SLA.",
"workloads": [
{
"workload": {
"totalBars": 1000,
"assets": 1,
"owners": 1,
"eventBudget": 64
},
"dataset_hash": "d7373071536b302c95938e7b174207086d86f39e070c7d735adeaff4746012ab",
"policy_hash": "5033c5bc74a54e41bc443bb7a0c9159a0c6e863a9f8a81514fc81deaf9753712",
"result_hash": "dbf14999e978f2d1b970c794aa9306e7278cb071dc1419b3cbf62a5c791f2c55",
"economic_oracle": {
"cash": "998700.10000000",
"equity": "998749.10000000",
"feePerOwner": "289.90000000",
"quantity": "1.00000000",
"remainingCost": "48.00000000",
"fills": 999,
"decisions": 999,
"fees": 999
},
"calls_per_trial": {
"create": 1,
"advance": 1000,
"submit": 999,
"finalize": 1,
"dispose": 1,
"decisions": 999
},
"bytes_per_trial": {
"createRequest": 298995,
"advanceRequests": 150000,
"advanceResponses": 1594052,
"submitRequests": 474197,
"submitResponses": 1653733,
"finalizeRequest": 120,
"finalizeResponse": 6618188
},
"cold_processes": [
{
"processRepeat": 0,
"processWallMs": 661.6411169999999,
"phasesMs": {
"entryUptimeMs": 17.989492,
"applicationImportMs": 7.721003000000003,
"addonImportMs": 3.302654999999998,
"adapterImportMs": 1.8754419999999996,
"fixtureGenerationMs": 26.622123,
"datasetTransportRoundtripMs": 1.1517809999999997,
"frozenDatasetVerificationMs": 6.792315000000002,
"preparedReuseAndMappingMs": 2.202702000000002,
"requestSizingMs": 0.6443500000000029,
"childWallMs": 627.174377
},
"peakRssBytes": 301342720
},
{
"processRepeat": 1,
"processWallMs": 655.0907609999999,
"phasesMs": {
"entryUptimeMs": 17.513791,
"applicationImportMs": 8.486132999999999,
"addonImportMs": 3.8382700000000014,
"adapterImportMs": 1.7702929999999988,
"fixtureGenerationMs": 24.009442999999997,
"datasetTransportRoundtripMs": 1.1287380000000056,
"frozenDatasetVerificationMs": 8.813603,
"preparedReuseAndMappingMs": 2.3357539999999943,
"requestSizingMs": 0.8061170000000004,
"childWallMs": 615.3559439999999
},
"peakRssBytes": 301826048
}
],
"raw_rows": [
"process=0 repeat=0 reverse=false create_ms=5.837 advance_ms=111.434 submit_ms=48.305 decision_ms=5.820 finalize_ms=103.084 run_ms=282.927 validation_hash_ms=16.111 trial_ms=304.885 rss_bytes=259719168",
"process=0 repeat=1 reverse=true create_ms=11.309 advance_ms=88.767 submit_ms=41.545 decision_ms=4.419 finalize_ms=88.671 run_ms=238.374 validation_hash_ms=15.971 trial_ms=271.152 rss_bytes=296042496",
"process=1 repeat=0 reverse=false create_ms=5.872 advance_ms=105.751 submit_ms=45.869 decision_ms=7.073 finalize_ms=96.598 run_ms=270.411 validation_hash_ms=18.130 trial_ms=294.422 rss_bytes=256008192",
"process=1 repeat=1 reverse=true create_ms=9.696 advance_ms=96.633 submit_ms=45.206 decision_ms=4.885 finalize_ms=88.541 run_ms=244.470 validation_hash_ms=14.739 trial_ms=268.963 rss_bytes=296484864"
]
},
{
"workload": {
"totalBars": 1000,
"assets": 10,
"owners": 2,
"eventBudget": 64
},
"dataset_hash": "2c09236354f09d017cac5c2564e64801827ca2c62c5ae26cd33cf42cd45db591",
"policy_hash": "2e55eb1dcae65f847ab53914a7a11afaa46b0c9a199b20565dafe08cc1b94c95",
"result_hash": "02ec46d0810d9015856dbe682a543dd89cfd35642c4a60c6929750e043753f30",
"economic_oracle": {
"cash": "997222.00000000",
"equity": "998202.00000000",
"feePerOwner": "289.00000000",
"quantity": "1.00000000",
"remainingCost": "48.00000000",
"fills": 1980,
"decisions": 198,
"fees": 1980
},
"calls_per_trial": {
"create": 1,
"advance": 100,
"submit": 99,
"finalize": 1,
"dispose": 1,
"decisions": 198
},
"bytes_per_trial": {
"createRequest": 304030,
"advanceRequests": 15000,
"advanceResponses": 771228,
"submitRequests": 161669,
"submitResponses": 2870078,
"finalizeRequest": 120,
"finalizeResponse": 10211261
},
"cold_processes": [
{
"processRepeat": 0,
"processWallMs": 788.2048580000001,
"phasesMs": {
"entryUptimeMs": 15.259431,
"applicationImportMs": 8.28377,
"addonImportMs": 4.707255,
"adapterImportMs": 5.777583,
"fixtureGenerationMs": 26.400312,
"datasetTransportRoundtripMs": 1.6383530000000022,
"frozenDatasetVerificationMs": 10.224725999999997,
"preparedReuseAndMappingMs": 3.6051980000000015,
"requestSizingMs": 1.0060459999999978,
"childWallMs": 748.412532
},
"peakRssBytes": 368349184
},
{
"processRepeat": 1,
"processWallMs": 821.422493,
"phasesMs": {
"entryUptimeMs": 13.583367,
"applicationImportMs": 13.815114999999999,
"addonImportMs": 6.963970000000003,
"adapterImportMs": 4.928774999999995,
"fixtureGenerationMs": 23.262509,
"datasetTransportRoundtripMs": 1.7333030000000065,
"frozenDatasetVerificationMs": 10.020107999999993,
"preparedReuseAndMappingMs": 3.5597620000000063,
"requestSizingMs": 1.041753,
"childWallMs": 786.7616939999999
},
"peakRssBytes": 359272448
}
],
"raw_rows": [
"process=0 repeat=0 reverse=false create_ms=6.549 advance_ms=99.120 submit_ms=63.205 decision_ms=4.502 finalize_ms=135.594 run_ms=325.784 validation_hash_ms=20.771 trial_ms=353.111 rss_bytes=307449856",
"process=0 repeat=1 reverse=true create_ms=10.039 advance_ms=95.032 submit_ms=56.225 decision_ms=2.315 finalize_ms=122.526 run_ms=298.653 validation_hash_ms=21.863 trial_ms=333.230 rss_bytes=362307584",
"process=1 repeat=0 reverse=false create_ms=6.779 advance_ms=107.722 submit_ms=65.977 decision_ms=3.926 finalize_ms=142.593 run_ms=338.320 validation_hash_ms=31.209 trial_ms=376.321 rss_bytes=305405952",
"process=1 repeat=1 reverse=true create_ms=8.583 advance_ms=101.354 submit_ms=58.865 decision_ms=2.515 finalize_ms=127.850 run_ms=310.347 validation_hash_ms=22.903 trial_ms=344.188 rss_bytes=354123776"
]
},
{
"workload": {
"totalBars": 10000,
"assets": 1,
"owners": 1,
"eventBudget": 64
},
"dataset_hash": "3cca7ed706f28a56a9ea463df1a310bb72dae8c52366ad631330ea439f2b7396",
"policy_hash": "5033c5bc74a54e41bc443bb7a0c9159a0c6e863a9f8a81514fc81deaf9753712",
"result_hash": "492467b561adb8792f6b75a6d8754e10fc5361772218bd7bcdbb1984748953bd",
"economic_oracle": {
"cash": "987090.10000000",
"equity": "987139.10000000",
"feePerOwner": "2899.90000000",
"quantity": "1.00000000",
"remainingCost": "48.00000000",
"fills": 9999,
"decisions": 9999,
"fees": 9999
},
"calls_per_trial": {
"create": 1,
"advance": 10000,
"submit": 9999,
"finalize": 1,
"dispose": 1,
"decisions": 9999
},
"bytes_per_trial": {
"createRequest": 2974606,
"advanceRequests": 1500000,
"advanceResponses": 16031754,
"submitRequests": 4796202,
"submitResponses": 16682062,
"finalizeRequest": 120,
"finalizeResponse": 66707481
},
"cold_processes": [
{
"processRepeat": 0,
"processWallMs": 5901.124175999999,
"phasesMs": {
"entryUptimeMs": 17.556242,
"applicationImportMs": 6.730817999999999,
"addonImportMs": 5.032081000000002,
"adapterImportMs": 4.58794,
"fixtureGenerationMs": 84.677629,
"datasetTransportRoundtripMs": 14.557602000000003,
"frozenDatasetVerificationMs": 62.00848399999998,
"preparedReuseAndMappingMs": 20.191041000000013,
"requestSizingMs": 8.44956400000001,
"childWallMs": 5777.450008
},
"peakRssBytes": 1954250752
},
{
"processRepeat": 1,
"processWallMs": 5903.965668999999,
"phasesMs": {
"entryUptimeMs": 18.012255,
"applicationImportMs": 10.324835,
"addonImportMs": 5.431056000000002,
"adapterImportMs": 2.3624650000000003,
"fixtureGenerationMs": 89.00218899999999,
"datasetTransportRoundtripMs": 12.282512999999994,
"frozenDatasetVerificationMs": 55.98375300000001,
"preparedReuseAndMappingMs": 14.392830000000004,
"requestSizingMs": 6.046502000000004,
"childWallMs": 5779.638424000001
},
"peakRssBytes": 1863028736
}
],
"raw_rows": [
"process=0 repeat=0 reverse=false create_ms=79.629 advance_ms=951.834 submit_ms=423.590 decision_ms=48.473 finalize_ms=1030.548 run_ms=2679.932 validation_hash_ms=165.799 trial_ms=2925.392 rss_bytes=1496563712",
"process=0 repeat=1 reverse=true create_ms=74.777 advance_ms=851.794 submit_ms=407.244 decision_ms=40.309 finalize_ms=896.594 run_ms=2410.872 validation_hash_ms=159.670 trial_ms=2645.348 rss_bytes=1947648000",
"process=1 repeat=0 reverse=false create_ms=78.815 advance_ms=961.375 submit_ms=435.331 decision_ms=50.952 finalize_ms=1032.592 run_ms=2675.814 validation_hash_ms=164.248 trial_ms=2918.895 rss_bytes=1493749760",
"process=1 repeat=1 reverse=true create_ms=108.628 advance_ms=845.282 submit_ms=403.395 decision_ms=41.444 finalize_ms=890.541 run_ms=2397.735 validation_hash_ms=158.155 trial_ms=2664.540 rss_bytes=1857527808"
]
},
{
"workload": {
"totalBars": 10000,
"assets": 10,
"owners": 2,
"eventBudget": 64
},
"dataset_hash": "ebaf4f6908d3897539ab7c52bb5003d81a10e099d66aa3ab3e60c43c97bc93ef",
"policy_hash": "2e55eb1dcae65f847ab53914a7a11afaa46b0c9a199b20565dafe08cc1b94c95",
"result_hash": "b065da3a8ff7c0a341bf8d4326c455fac0a029027446f9734d13ac117ea13e4c",
"economic_oracle": {
"cash": "974002.00000000",
"equity": "974982.00000000",
"feePerOwner": "2899.00000000",
"quantity": "1.00000000",
"remainingCost": "48.00000000",
"fills": 19980,
"decisions": 1998,
"fees": 19980
},
"calls_per_trial": {
"create": 1,
"advance": 1000,
"submit": 999,
"finalize": 1,
"dispose": 1,
"decisions": 1998
},
"bytes_per_trial": {
"createRequest": 2969186,
"advanceRequests": 150000,
"advanceResponses": 7818768,
"submitRequests": 1640280,
"submitResponses": 29200102,
"finalizeRequest": 120,
"finalizeResponse": 103598570
},
"cold_processes": [
{
"processRepeat": 0,
"processWallMs": 7471.874861,
"phasesMs": {
"entryUptimeMs": 15.425926,
"applicationImportMs": 6.739083999999998,
"addonImportMs": 3.763588000000002,
"adapterImportMs": 3.005122,
"fixtureGenerationMs": 86.40961899999999,
"datasetTransportRoundtripMs": 15.727568000000005,
"frozenDatasetVerificationMs": 55.450342000000006,
"preparedReuseAndMappingMs": 19.996653999999978,
"requestSizingMs": 7.253488000000004,
"childWallMs": 7308.53601
},
"peakRssBytes": 2546876416
},
{
"processRepeat": 1,
"processWallMs": 7542.137738999998,
"phasesMs": {
"entryUptimeMs": 13.804856,
"applicationImportMs": 7.877509000000002,
"addonImportMs": 14.412988999999996,
"adapterImportMs": 5.680057000000005,
"fixtureGenerationMs": 88.133104,
"datasetTransportRoundtripMs": 10.459769999999992,
"frozenDatasetVerificationMs": 64.49405099999998,
"preparedReuseAndMappingMs": 13.91592700000001,
"requestSizingMs": 6.098469999999992,
"childWallMs": 7403.1065260000005
},
"peakRssBytes": 2554671104
}
],
"raw_rows": [
"process=0 repeat=0 reverse=false create_ms=78.571 advance_ms=964.182 submit_ms=614.812 decision_ms=21.184 finalize_ms=1394.367 run_ms=3286.854 validation_hash_ms=235.141 trial_ms=3600.595 rss_bytes=2048065536",
"process=0 repeat=1 reverse=true create_ms=123.926 advance_ms=934.619 submit_ms=567.542 decision_ms=19.933 finalize_ms=1341.980 run_ms=3158.524 validation_hash_ms=226.714 trial_ms=3509.189 rss_bytes=2541584384",
"process=1 repeat=0 reverse=false create_ms=79.123 advance_ms=976.004 submit_ms=617.892 decision_ms=23.249 finalize_ms=1398.552 run_ms=3295.705 validation_hash_ms=230.761 trial_ms=3605.613 rss_bytes=2052440064",
"process=1 repeat=1 reverse=true create_ms=121.809 advance_ms=951.035 submit_ms=578.639 decision_ms=20.921 finalize_ms=1371.665 run_ms=3222.154 validation_hash_ms=241.815 trial_ms=3585.798 rss_bytes=2548953088"
]
}
],
"limits": "Order-heavy conformance component, not production strategy, durable research throughput, legacy speedup or pure NAPI probe. Native data reloads each trial. Journals/results grow with history; finalized10k receipt payloads~66.7MB single/~103.6MB multi, not RSS. No caching, compaction, shared feature model or DSL. Sequential multi-asset risk mark semantics unchanged."
},
"not_run": [
"Browser E2E and Python analytics: UI/API/Python behavior unchanged.",
"100k --large session benchmark, earlier manual ledger/risk/matching/replay benchmarks: not required for this boundary; no claim of those throughput gates."
],
"limitations": [
"Trusted host API, not an untrusted-code sandbox. TS worker verifies D01; native prepared payload/hash labels alone are not dataset authentication.",
"Exact represented numeric decimal ingress; values needing more than8fractional digits or exceeding range reject, including feature OHLCV. No silent rounding.",
"Fixed intent traces/fixture callbacks only. S01 production strategy artifacts/state/RNG and recovery, F08 metrics/projections and R05 durable canonical default remain separate.",
"Opaque read-only order/reservation/effect diagnostics are not another admission API or finalized F08 reporting schema.",
"Quote/abutting-session replay unsupported. Event budget counts events, not wall time.",
"Sequential equal-time marks can latch intermediate loss/drawdown; canonical_release_gates.multi_asset_mark_policy remains unresolved.",
"Existing build warnings remain. Clean isolated build required explicit existing logger prerequisite. No unrelated dependency/build-system cleanup."
],
"cleanup": "Stopped/removed only disposable containers4843a8d42953aefac9c323ff0a8913f0d5e0c39dd862273f149c1ba9cfc3bf63 and4a518cf5400aef08eae49e029d1ddd6649d3af152e051f17bc5fbc082e2a9915, deleting recreatable synthetic fixture state. Development services untouched; worktree/logs retained.",
"handoff": "F06 committed417a7bd. F07 independently accepted and validated, uncommitted. F08 now ready by existing code/approved ADR prerequisites, recommended after owner acceptance; not authorized yet. S01 needs ADR005. No push, PR, default-engine activation or paper/live operation."
}
}

View file

@ -18,16 +18,30 @@ F06 consumes internal typed prepared bars/session tables, not an independently a
Expose recorded model limitations, including F06's explicitly unsupported abutting venue sessions and F04/F05's sequential equal-time portfolio marks (intermediate valuations can latch risk halts). An event budget bounds event count, not wall time or the cost of an individual matching transition. These are not promises of atomic multi-asset valuation, arbitrary-calendar support or constant-latency cancellation.
## Execution handoff clarifications
- Add a separate NAPI FinancialReplaySession and a fixed-intent-trace request variant in the existing worker. Keep the legacy run request and durable runner default unchanged. The trace path is for conformance/debugging, not a declarative strategy language or S01 strategy runtime.
- Verify frozen D01 inputs inside the worker before native creation; native prepared input remains a trusted host boundary, not independent proof of a supplied dataset hash. Convert represented numeric values to plain decimal strings, expanding scientific notation and rejecting precision/range loss rather than silently rounding.
- Pin a strict version/session/dataset envelope and validate response identities. Emit prefix observation deltas and one shared financial/order/risk view; never pass full prepared data/checkpoints to a callback or clone retained checkpoints in the hot loop. A small read-only F06 range accessor is permitted; replay and risk semantics are not changed.
- Permit a test-only include of the new adapter from the financial test module: the crate excludes its API module from ordinary unit builds. Exercise the production host/direct-Replay parity without enabling unrelated legacy NAPI wrappers or changing production module direction. The thin exported wrapper delegates one-to-one to that host and is separately tested through the built addon.
- The conformance loop may evaluate fixture callbacks in varied order, but submits the complete due-owner batch once. Callback failure fails/disposes the attempt; no partial submission or later successful finalization. Production strategy state/RNG, artifact imports and durable canonical cutover remain S01/R05.
- Preserve existing process supervision: one process/request, hard cancellation, wait for close after a result, rejection after abort, failed worker reuse and stale attempt protection. Run existing runner cancellation/lease regressions, including the disposable PostgreSQL suite at integration.
- Extend the existing P01 harness with actual session preparation/load, advance/submit call timings and counts, context/delta bytes and finalization. Calls include real Rust/serialization work; do not label them empty crossings or end-to-end strategy throughput.
## 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/engine/src/api/replay.rs (additive session; existing backtest API unchanged)
- apps/stock/engine/src/financial/replay.rs (read-only published-observation range accessor only)
- apps/stock/orchestrator/src/backtest/native-replay.ts
- apps/stock/orchestrator/src/contracts/native-replay.ts (schema-only boundary)
- apps/stock/orchestrator/src/backtest/native-worker.ts
- apps/stock/orchestrator/src/backtest/native-worker-protocol.ts
- apps/stock/orchestrator/src/backtest/NativeBacktestWorker.ts
- scripts/benchmark-research.ts and focused native/worker fixtures
Write locks: native-public-api, worker-protocol. One agent owns this change. Lock names do not override actual overlapping files.