feat(research): add owner-aware ledger and intraday storage

Implement reviewed F02/D02: exact owner accounting, atomic funding checks, idempotent receipts and ledger checkpoints; connect existing EOD intraday storage through validated research admission without active financial-engine cutover.
This commit is contained in:
Boki 2026-10-22 21:16:53 -04:00
parent b4af840d4e
commit b65acccd91
15 changed files with 2704 additions and 104 deletions

View file

@ -1,8 +1,8 @@
# Revised development roadmap
Baseline `b7aeca4` · reviewed 2026-10-22 · **First five waves committed; ADR-002/003/004 approved; F01/D01 validated, uncommitted**
Baseline `b7aeca4` · reviewed 2026-10-22 · **First six waves committed; F02/D02 validated, uncommitted**
Authorization update: the first five waves are independently reviewed, validated and committed. After the W04 closeout, the owner explicitly answered “yes” to ADR-002/003/004 as written and continuation with F01/D01. Those two tasks were independently reviewed and integrated from isolated worktrees; combined gates passed. They remain `review` / `validated_uncommitted` pending owner acceptance/commit. No other ADR is approved. Sixth-wave commits, pushes, PRs and trading operations remain outside scope.
Authorization update: after explicitly approving ADR-002/003/004 and the validated F01/D01 implementation, the owner requested “commit and continue.” F01/D01 are committed as `b4af840`; F02/D02 were independently reviewed, integrated and validated from isolated worktrees. No other ADR is approved. Seventh-wave commits, pushes, PRs and trading operations remain outside scope.
## Strategy and review outcome
@ -81,7 +81,7 @@ Completed wave; the table records its original rationale. Exact prompts, paths,
Recommend **3 simultaneous implementers**, reserving one slot for coordination/independent review. Start C01 + C03 + W01; rotate C04 into the first freed slot, or start C04 first if runtime containment is the immediate operational need. These four have no mutual code dependencies and disjoint writable files. Four concurrent implementers are technically possible but not recommended without separate review capacity.
O01/P01, W03 and W04 are committed. W04 adds validated real-browser end-to-end verification of the existing workbench. F01/D01 now have explicit ADR approval and passed integrated validation; subsequent tasks remain prerequisite-gated pending acceptance/commit.
O01/P01, W03 and W04 are committed. W04 adds validated real-browser end-to-end verification of the existing workbench. F01/D01 passed integrated validation and are committed; F02/D02 passed integrated validation and await acceptance/commit, while subsequent tasks remain prerequisite-gated.
## Second-wave handoff — 2026-10-22
@ -171,7 +171,7 @@ At the fifth-wave closeout, the readiness review found 32 remaining scheduled ta
## Sixth-wave handoff — 2026-10-22
F01 and D01 are independently accepted and `review` / `validated_uncommitted`. Base `243e9ab`; isolated worktrees under `/tmp/stock-bot-wave6.uIuYHz/`. Financial and dataset owners implemented in parallel, with an independent read-only reviewer; the integrator merged their common types exports.
F01 and D01 are independently accepted and `done` / `validated_committed` in `b4af840`. Base `243e9ab`; isolated worktrees under `/tmp/stock-bot-wave6.uIuYHz/`. Financial and dataset owners implemented in parallel, with an independent read-only reviewer; the integrator merged their common types exports.
- **F01:** Pinned maintained decimal dependency; checked exact decimal ingress, fixed-8 half-away posting, bounded arithmetic, versioned Rust/TypeScript contracts, owner/decision identities and hand-derived economic fixtures. Strategy intents cannot parse as internal financial mutations. Safe integer, Unicode, strict decimal, overflow and wire-roundtrip regressions pass. The snapshot is only an economic projection. F02 still owns actual ledger/dedup transitions and operation-specific proportional basis arithmetic; generic multiply/divide was deliberately not introduced.
- **D01:** Additive v2 normalizer retains interval/event/availability time, source sequence, explicit versioned calendars, execution-series selection, universe/action coverage and limitations. Hash-verified v1 conversion retains its parent hash and makes unverifiable legacy VWAP unknown. DST/half-days, delayed availability, conflicts, overlapping intervals, parent-hash syntax and prefix stability are tested. Unsupported action/adjusted execution data rejects; unknown coverage remains exploratory. Initial intraday support requires full-duration session-contained bars.
@ -186,7 +186,27 @@ No PostgreSQL/Redis or Chromium rerun was needed for these additive, unused cont
Only the verified stalled sandbox test processes were stopped after the successful rerun. No user services or data were removed; worktrees and logs remain available.
Existing v1 snapshots and financial runtimes remain unchanged. F01 is not a working canonical ledger; D01 prefix tests are not F06 replay enforcement. No paper account conversion, extra backlog task, commit, push, PR or trading operation occurred. After acceptance/commit, the next coherent pair is **F02 owner-aware Rust ledger + D02 intraday storage integration**, with one financial owner and disjoint data ownership.
Existing v1 snapshots and financial runtimes remain unchanged. F01 is not a working canonical ledger; D01 prefix tests are not F06 replay enforcement. The subsequent owner request authorized the F01/D01 commit and F02/D02 continuation, not a push, PR or trading operation.
## Seventh-wave handoff — 2026-10-22
F02/D02 are independently accepted and `review` / `validated_uncommitted`. Base `b4af840`; isolated worktrees under `/tmp/stock-bot-wave7.UIkAQD/`. Financial and data owners implemented in parallel; an independent reviewer checked both; root integrated all ten reviewed files with matching hashes.
- **F02:** Owner-keyed quantity, remaining basis, realized P&L and fees; exact rational intermediates rounded once into the maintained decimal posting type. Fee-inclusive funding, wrong-owner disposal, overflow and identity conflicts reject atomically. Command/fill aliases return original replay-labelled receipts, including after intervening operations. Explicit market marks remain separate from fill prices; owner-level marked postings reconcile to account equity. Same-session boundary repetition is an accepted no-op, not a false session-change effect. Ledger-only checkpoints retain and validate ordered receipts by replay; ordinary transitions touch only affected state.
- **D02:** Existing EOD `1m`/`5m`/`1h` Mongo collections now feed the common research storage admission path. Unix-second timestamps/listing identities validate; supported-provider capability reports distinguish configuration/connectivity from coverage. Default QuestDB priority remains, explicit provider selection is available at the storage API, and missing/error ranges never switch to daily/synthetic data. Real writer/read/normalizer composition and repeated legacy native runs are tested on synthetic provider records; HTTP/Mongo transport alone is replaced.
Combined validation:
- `CARGO_BUILD_JOBS=2 bun run check`: 60 tooling, 43 utility, 35 calculation, 342 integration and 59 Rust tests passed, zero failures. Build, typecheck, contracts, lint and secret audit passed. One Rust test is intentionally ignored by the ordinary suite because it is a manually invoked release measurement.
- Independent review: 22 financial Rust tests passed; 36 intraday/ingestion/dataset tests with 264 assertions passed. These overlap the combined totals, not additional independent cases.
- Standalone strict TypeScript including the real ingestion import graph, explicit scoped ESLint, Prettier, scoped rustfmt and `git diff --check` passed. Cargo.toml line endings were normalized alongside its pinned dependency additions; no dependency upgrades occurred. Only num-bigint was newly added to the lockfile.
- A repeatable release ledger workload runs 1k/10k prebuilt commands over one owner/asset or three owners/four assets, with three repeats and full state/effect byte equality. Transition, checkpoint-copy and restore times are recorded separately. Detailed raw measurements/build identities are in the manifest; these are not end-to-end backtest throughput or a speedup claim. Receipt memory and restore work grow with history; compaction is not implemented.
The manual release measurement also passed on the final integrated checkout (1 test, zero failures), with identical repeatability checksums to the author build. It is additional validation, not a skipped correctness test.
Limits: no F04 reservation/portfolio-risk policy, matcher, F06 replay, native session API, SQL/paper cutover, order/strategy/RNG session restoration or canonical-engine release. D02's provider selector is not a web/run-configuration control; no Mongo server-conformance, range-completeness or live-availability claim. Provider delayed-finalization caveats and the explicit bar-close simulation assumption are retained in the task evidence. PostgreSQL/Redis and Chromium suites were not rerun because their persistence/API/UI boundaries did not change. Existing build warnings remain.
Only exact identified stalled D02 sandbox test/worker processes were terminated after the successful escalated rerun; no development services/data were changed. Worktrees and logs remain available. The sixth-wave commit was made as requested; no seventh-wave commit, push, PR or trading operation occurred. Next after acceptance/commit: **F04 central cash reservations and portfolio risk enforcement**. Product/AI work remains subject to its unapproved ADRs.
## Deferred and rejected

View file

@ -1,6 +1,6 @@
# Canonical development backlog
**First five waves committed; ADR-002/003/004 approved; F01/D01 validated, uncommitted.** Consult manifest execution_scope, [ROADMAP](../ROADMAP.md), [skeptical review](../REVIEW.md) and [first-wave handoff](../FIRST-WAVE.md). F01/D01 await owner acceptance/commit; other tasks and unresolved policies remain gated.
**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.
## One source of truth
@ -29,8 +29,8 @@ 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 / review | ADR-002, ADR-003, ADR-004 (approved) | — | Rust financial contract owner / M |
| [F02 Implement one owner-aware financial ledger](tasks/F02.md) | P0 / blocked | F01, ADR-002 | — | Rust accounting / L |
| [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 |
| [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 |
@ -42,8 +42,8 @@ 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 / review | ADR-003 (approved) | — | TypeScript trading infrastructure / M |
| [D02 Connect supported intraday storage to research datasets](tasks/D02.md) | P1 / blocked | D01 | — | TypeScript trading infrastructure / M |
| [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 |
| [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 |

View file

@ -1,23 +1,24 @@
{
"schema_version": 1,
"plan_revision": "2026-10-22.16",
"plan_revision": "2026-10-22.18",
"repository_base": "b7aeca4",
"plan_status": "sixth_wave_validated_uncommitted",
"plan_status": "seventh_wave_validated_uncommitted",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: yes (2026-10-22), explicitly approving ADR-002/003/004 as written and continuation with F01/D01",
"authorized_by": "User: commit and continue (2026-10-22); commit accepted F01/D01 and continue with the explicitly proposed F02/D02 pair",
"tasks": [
"F01",
"D01"
"F02",
"D02"
],
"permissions": [
"commit_validated_sixth_wave",
"isolated_implementation",
"local_tests",
"local_integration_review",
"planning_progress_updates"
],
"excluded": [
"sixth_wave_commits_without_further_approval",
"seventh_wave_commits_without_further_approval",
"push",
"pull_requests",
"live_or_paper_operations",
@ -319,7 +320,7 @@
"epic": "E2",
"priority": "P0",
"severity": "Critical",
"status": "review",
"status": "done",
"dependencies": [],
"decision_dependencies": [
"ADR-002",
@ -341,7 +342,7 @@
"assignment": "/root/wave6_f01",
"branch": "wave6/f01-financial-contract",
"pull_request": null,
"completed_commit": null,
"completed_commit": "b4af840d4edde84b23c099e85c82f43721046067",
"blocker": null,
"release_gates": [],
"worktree": "/tmp/stock-bot-wave6.uIuYHz/f01",
@ -356,10 +357,10 @@
"test/fixtures/economics/",
"test/integration/financial-contract.test.ts"
],
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"reviewed_by": "/root/wave6_review",
"verification_reference": "ROADMAP.md#sixth-wave-handoff--2026-10-22",
"review_notes": "Independently accepted, integrated, and combined gates passed. No commit authorized in this wave; awaiting owner acceptance/commit before scheduling dependents."
"review_notes": "Independently accepted and combined gates passed; owner authorized commit and continuation. Completed commit contains the integrated F01/D01 implementation."
},
{
"id": "F02",
@ -367,7 +368,7 @@
"epic": "E2",
"priority": "P0",
"severity": "Critical",
"status": "blocked",
"status": "review",
"dependencies": [
"F01"
],
@ -388,12 +389,24 @@
"rust-ledger"
],
"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/wave7_f02",
"branch": "wave7/f02-owned-ledger",
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": []
"release_gates": [],
"worktree": "/tmp/stock-bot-wave7.UIkAQD/f02",
"integration_base": "b4af840d4edde84b23c099e85c82f43721046067",
"concrete_write_scope": [
"apps/stock/engine/src/financial/",
"apps/stock/engine/Cargo.toml",
"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",
"reviewed_by": "/root/wave7_review",
"verification_reference": "ROADMAP.md#seventh-wave-handoff--2026-10-22"
},
{
"id": "F03",
@ -595,7 +608,7 @@
"epic": "E3",
"priority": "P0",
"severity": "Critical",
"status": "review",
"status": "done",
"dependencies": [],
"decision_dependencies": [
"ADR-003"
@ -615,7 +628,7 @@
"assignment": "/root/wave6_d01",
"branch": "wave6/d01-dataset-v2",
"pull_request": null,
"completed_commit": null,
"completed_commit": "b4af840d4edde84b23c099e85c82f43721046067",
"blocker": null,
"release_gates": [],
"worktree": "/tmp/stock-bot-wave6.uIuYHz/d01",
@ -628,10 +641,10 @@
"test/integration/historical-dataset-v2.test.ts",
"test/fixtures/historical-v2/"
],
"integration_state": "validated_uncommitted",
"integration_state": "validated_committed",
"reviewed_by": "/root/wave6_review",
"verification_reference": "ROADMAP.md#sixth-wave-handoff--2026-10-22",
"review_notes": "Independently accepted, integrated, and combined gates passed. No commit authorized in this wave; awaiting owner acceptance/commit before scheduling dependents."
"review_notes": "Independently accepted and combined gates passed; owner authorized commit and continuation. Completed commit contains the integrated F01/D01 implementation."
},
{
"id": "D02",
@ -639,7 +652,7 @@
"epic": "E3",
"priority": "P1",
"severity": "High",
"status": "blocked",
"status": "review",
"dependencies": [
"D01"
],
@ -654,12 +667,24 @@
"storage-adapters"
],
"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/wave7_d02",
"branch": "wave7/d02-intraday-storage",
"pull_request": null,
"completed_commit": null,
"blocker": null,
"release_gates": []
"release_gates": [],
"worktree": "/tmp/stock-bot-wave7.UIkAQD/d02",
"integration_base": "b4af840d4edde84b23c099e85c82f43721046067",
"concrete_write_scope": [
"apps/stock/orchestrator/src/services/StorageService.ts",
"apps/stock/orchestrator/src/data/",
"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",
"reviewed_by": "/root/wave7_review",
"verification_reference": "ROADMAP.md#seventh-wave-handoff--2026-10-22"
},
{
"id": "D03",
@ -2785,6 +2810,211 @@
"Existing Rust/frontend build warnings remain."
],
"cleanup": "Only verified stale sandbox check/test/worker processes were stopped after the successful escalated run; root session13178 exited143 and author session45451 exited143. No user services, databases, containers or files were removed. Worktrees/logs remain available.",
"handoff": "F01/D01 remain review/validated_uncommitted; F02/D02 await accepted integration and further execution authorization. No sixth-wave commit, push, PR, trading operation or other task started."
"handoff": "F01/D01 were independently accepted and subsequently committed at owner request as b4af840d4edde84b23c099e85c82f43721046067. The same request authorized F02/D02 continuation; no push, PR or trading operation."
},
"seventh_wave": [
"F02",
"D02"
],
"seventh_wave_base": "b4af840d4edde84b23c099e85c82f43721046067",
"seventh_wave_notes": [
"User authorized committing validated F01/D01 and continuing with the proposed F02/D02 pair; no additional ADR approval.",
"F02 owns financial modules/dependencies and economic fixtures. D02 owns StorageService, narrow data helpers, new intraday tests/fixtures; no shared DTO/index/ingestion source change without coordination.",
"One financial owner, one data owner and an independent read-only reviewer. Root owns planning and integration.",
"No active engine/paper/SQL cutover, native session API or unrelated task. Independent review and combined gates passed; awaiting owner acceptance/commit."
],
"seventh_wave_validation": {
"result": "passed",
"reviewer": "/root/wave7_review",
"base": "b4af840d4edde84b23c099e85c82f43721046067",
"repository_check": {
"command": "CARGO_BUILD_JOBS=2 bun run check",
"log": "/tmp/stock-bot-wave7.UIkAQD/check.log",
"tooling_tests": 60,
"utility_tests": 43,
"calculation_tests": 35,
"integration_tests": 342,
"rust_tests": 59,
"manual_rust_measurement_ignored_by_default": 1,
"failed": 0,
"note": "Escalated native build/worker execution; full build/typecheck/contracts/lint/secret audit passed."
},
"independent_review": {
"financial": "22 financial Rust tests passed;1manualmeasurement ignored;37unrelated tests filtered. All7 frozen hashes matched.",
"intraday": "36 intraday/ingestion/dataset tests passed;264assertions;3 frozen hashes and private rebuilt addon matched. These tests overlap repository totals."
},
"scoped_checks": [
"Standalone strict TypeScript with experimentalDecorators traversing the real ingestion import graph passed.",
"Explicit ESLint and Prettier on all3 D02 files passed.",
"Scoped rustfmt --check on financial modules and git diff --check passed."
],
"source_hashes": {
"Cargo.lock": "8f2ecaa4f1790f14e1650326f78fbf246f454dad6139dc4cb0d61383b9e301e8",
"apps/stock/engine/Cargo.toml": "f7eb29311a0ca2a943607f722ad4fa447857bdf951a8f8d9fa30dab9095a7525",
"apps/stock/engine/src/financial/contract.rs": "06d57c12d33c4f128482544cda31347e4c640f879998dc17f0da379c3f37f9db",
"apps/stock/engine/src/financial/mod.rs": "36645e77811740de41c017dbff6193715009da708f9377d17510dd738fdefdba",
"apps/stock/engine/src/financial/scalar.rs": "65da81ecf33db78935f50aeb53094293e9d4b0814ac25e0d0c281b53b75c5e06",
"apps/stock/engine/src/financial/ledger.rs": "b9016744e76256de4af080a5eba0e635e900b3fc6cb21caee581d88519e7a707",
"apps/stock/engine/src/financial/ledger_tests.rs": "96b5f40ff4cbeeaedc09d824effc1b35888c7d30bfae850e426b48f1d0d7ab05",
"apps/stock/orchestrator/src/services/StorageService.ts": "b06b67fd1d7e29e26d6c9c4f241169f88c18c355395c0e1b9de5813012c45458",
"test/integration/intraday-storage.test.ts": "9c209620097ada21d4a47fab5092f8e3308474708ef7db2422be6daaf3eebe3e",
"test/fixtures/intraday/eod.ts": "bdb9df09718a723736d88ba62ca57dbf842cfdafdb7a6ca2a279a97a20894d45"
},
"native_artifact": {
"path": "apps/stock/engine/dist/engine.node",
"sha256": "b8e272e5846bf8efe37f9f941920f489d012f1bacb3d5675352d1d55a63e772c",
"d02_author_sha256": "48ab4c24e8f56c1fbc537982b54ba07d42dc4b0ecec2ce34ced5ecfd354ef0ae",
"note": "Addons independently built in their own worktrees; no shared/copied native artifact. Active native simulator remains legacy."
},
"financial_measurement": {
"command": "CARGO_BUILD_JOBS=2 cargo test -p engine --lib --release --offline ledger_transition_measurement -- --ignored --nocapture",
"log": "/tmp/stock-bot-wave7.UIkAQD/f02-measurement.log",
"artifact": "/tmp/stock-bot-wave7.UIkAQD/f02/target/release/deps/engine-abe56cbc3e15ae30",
"sha256": "b21531e5c3e97c2d09f827ffccfb89858ed88f04f3055c0d57e5a82255539424",
"host": {
"cpu": "AMD Ryzen 9 9950X3D",
"logical_cpus": 32,
"ram_bytes": 98683457536,
"os": "Linux6.8.0-146-generic x86_64",
"rustc": "1.88.0(6b00bc388),LLVM20.1.5",
"cargo_build_jobs": 2
},
"workload": "Prebuilt commands;80%buys(0.01@100,fee0.001),20%marks;initialcapital1m. Single1owner/1asset vs multi3owners/4assets.3repeats;no explicit warmup. Transition time includes receipts and returned-effect collection;checkpointcopy separate;restore excludes inputclone;serialization outside timed regions.",
"columns": [
"transition_ms",
"checkpoint_ms",
"restore_ms"
],
"rows": {
"1000_single": [
[
4.823,
0.576,
5.484
],
[
4.16,
0.286,
5.9
],
[
4.244,
0.387,
4.99
]
],
"1000_multi": [
[
4.685,
0.298,
5.415
],
[
4.807,
0.298,
5.585
],
[
4.763,
0.282,
5.778
]
],
"10000_single": [
[
47.394,
8.028,
59.606
],
[
44.356,
5.27,
60.23
],
[
44.07,
5.32,
54.266
]
],
"10000_multi": [
[
50.48,
5.235,
62.177
],
[
51.257,
5.547,
65.779
],
[
51.003,
5.662,
60.142
]
]
},
"repeatability": "Full state+effect serialized bytes equal across repeats; DefaultHasher checksums are fixed-artifact diagnostics, not cryptographic provenance.",
"state_and_effect_bytes": {
"1000_single": 1294915,
"1000_multi": 1292139,
"10000_single": 13093921,
"10000_multi": 13050658
},
"limitations": "Scoped ledger sanity workload; no cold dataset/native startup/IPC/storage measurements, end-to-end throughput, legacy speedup or independent performance certification. Receipt history memory and restore work grow linearly; no compaction.",
"integration_recheck": {
"command": "CARGO_BUILD_JOBS=2 cargo test -p engine --lib --release --offline ledger_transition_measurement -- --ignored --nocapture",
"log": "/tmp/stock-bot-wave7.UIkAQD/integration-ledger-measurement.log",
"artifact": "target/release/deps/engine-abe56cbc3e15ae30",
"sha256": "b21531e5c3e97c2d09f827ffccfb89858ed88f04f3055c0d57e5a82255539424",
"result": "1passed,0failed;59filtered. Same state/effect checksums and full byte equality across repetitions.",
"raw_rows": [
"F02 count=1000 multi=false repeat=0 transition_ms=4.819 checkpoint_ms=0.810 restore_ms=5.722 bytes=1294915 checksum=446ce8be40fd4ba1",
"F02 count=1000 multi=false repeat=1 transition_ms=4.131 checkpoint_ms=0.304 restore_ms=5.615 bytes=1294915 checksum=446ce8be40fd4ba1",
"F02 count=1000 multi=false repeat=2 transition_ms=4.203 checkpoint_ms=0.286 restore_ms=4.858 bytes=1294915 checksum=446ce8be40fd4ba1",
"F02 count=1000 multi=true repeat=0 transition_ms=4.712 checkpoint_ms=0.329 restore_ms=5.562 bytes=1292139 checksum=a1df70fcbb707e69",
"F02 count=1000 multi=true repeat=1 transition_ms=4.759 checkpoint_ms=0.288 restore_ms=5.947 bytes=1292139 checksum=a1df70fcbb707e69",
"F02 count=1000 multi=true repeat=2 transition_ms=4.733 checkpoint_ms=0.295 restore_ms=5.511 bytes=1292139 checksum=a1df70fcbb707e69",
"F02 count=10000 multi=false repeat=0 transition_ms=49.398 checkpoint_ms=8.299 restore_ms=58.845 bytes=13093921 checksum=0f92079aeb5beff5",
"F02 count=10000 multi=false repeat=1 transition_ms=42.911 checkpoint_ms=5.375 restore_ms=58.622 bytes=13093921 checksum=0f92079aeb5beff5",
"F02 count=10000 multi=false repeat=2 transition_ms=43.119 checkpoint_ms=5.354 restore_ms=53.319 bytes=13093921 checksum=0f92079aeb5beff5",
"F02 count=10000 multi=true repeat=0 transition_ms=50.560 checkpoint_ms=5.266 restore_ms=61.046 bytes=13050658 checksum=36dcaa5fd201208a",
"F02 count=10000 multi=true repeat=1 transition_ms=49.624 checkpoint_ms=5.318 restore_ms=63.990 bytes=13050658 checksum=36dcaa5fd201208a",
"F02 count=10000 multi=true repeat=2 transition_ms=50.276 checkpoint_ms=5.395 restore_ms=59.666 bytes=13050658 checksum=36dcaa5fd201208a"
]
}
},
"intraday_measurement": {
"kind": "author exploratory adapter-only sanity measurement",
"host": "Same Ryzen9 9950X3D/Linux x64 host;Bun1.2.17/Nodecompat22.6.0",
"recipe": "Synthetic in-memory find() rows, start2024-03-11T13:30Z at300s spacing;FIXTURE.TEST,open100/high101/low99/close100/volume1000. Time only await getHistoricalBars(...,'5m'); construction/hash serialization excluded. Three repeats;no explicitwarmup.",
"milliseconds_1000": [
1.727282,
0.602739,
0.521505
],
"milliseconds_10000": [
6.232302,
5.555884,
4.477247
],
"normalized_hash_1000": "fb2d3f213487a7a2ff0ce4a6b98d74ba793b13355439b88c3eb1efb296339158",
"normalized_hash_10000": "18138da32c3758770703c7376ef05f8c1aae941cb7884bda3c2e628fb6fdabe4",
"limits": "Identical normalized hashes across3repeats per size. No Mongo/network/real-range throughput, baseline speedup or release performance claim; no new benchmark framework."
},
"not_run": [
"PostgreSQL/Redis fixture suite and Chromium E2E not rerun: persistent execution/API/UI boundaries unchanged.",
"No real Mongo server/provider network test; D02 replaces HTTP/Mongo transport and executes real ingestion/storage/dataset/native code."
],
"limitations": [
"F02 remains additive/unwired to active engines. No F04 reservations/portfolio risk, F05 matching, F06 availability/replay, NAPI sessions, SQL/paper cutover or full order/strategy/RNG restore.",
"Ledger checkpoints validate consistency by retained-history replay, not input authenticity; restore/memory scale with receipt history. No compaction or full financial-session snapshot.",
"D02 real ingestion fixture covers5m;1m/1h routing is checked. Provider selector remains StorageService-only; existing loadDataset/UI use auto priority. Connectivity is not range coverage.",
"Provider timestamps/prices checked against https://eodhd.com/financial-apis/intraday-historical-data-api on2026-10-22. Delayed finalization/corrections mean bar-close availability is only an explicit simulation assumption, not observed publication time.",
"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."
}
}

View file

@ -14,6 +14,16 @@ Trace the actual intraday collection/schema, add the smallest provider adapter o
Measurable benefit: Makes supported intraday requests usable and honest.
### Verified ingestion evidence and seventh-wave boundary
Before implementation, inspected `apps/stock/data-ingestion/src/handlers/eod/actions/intraday.ts`: `fetchIntraday` looks up the listing, uses `eodExchange || Exchange`, copies provider Unix-second `timestamp`, `datetime`, `gmtoffset` and OHLCV, then upserts `eodIntraday1M`, `eodIntraday5M` or `eodIntraday1H` keyed by timestamp + `eodSearchCode` (lines 486–585 at base `b4af840`). The research reader currently chooses QuestDB first, otherwise only daily `eodPrices`.
Retain the common `getHistoricalBars` admission path. Add the existing EOD intraday mapping, explicit provider selection/capabilities and typed unavailable/unsupported errors. Capabilities describe connected stores and supported intervals, not proven range coverage. Preserve default QuestDB priority and never switch provider on an empty range/error. Explicit provider requests never fall back to daily or synthetic data. Validate whole Unix seconds and listing identity; Unix timestamps are already UTC and must not be shifted by `gmtoffset`. QM's adjusted/unpinned interval records remain unsupported.
Tests invoke the actual EOD writer with replaced HTTP/Mongo transport, then the real storage reader and v1/v2 dataset normalizers with explicit retained calendar/action metadata. This proves adapter composition, not database-server conformance or F06 replay. No optional v2 loader, active-runtime cutover or storage migration is required here.
Provider check (2026-10-22): [EODHD's intraday documentation](https://eodhd.com/financial-apis/intraday-historical-data-api) identifies the timestamp as UTC bar start and prices as unadjusted for subsequent corporate actions. It also describes delayed finalization after market close and possible historical corrections. Retrieval therefore does **not** establish point-in-time publication availability. Interval-end availability remains an explicit simulation assumption, never provider evidence; frozen content hashes retain the actual retrieved revision. Provider choice is initially a storage API parameter, not a new web/run-configuration control.
## Exclusions
No unrelated refactor, new service or broker activation.

View file

@ -15,6 +15,16 @@ Scheduling source of truth: [manifest entry F02](../manifest.json). No task is a
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.
### Seventh-wave implementation boundary
F01 is committed in `b4af840`. Keep this ledger additive: no replacement of active legacy position/accounting code, native binding, SQL transaction integration or paper migration. ADR-005 remains unapproved; F02 provides the in-memory transition/checkpoint seam, not its durable adapter.
- A ledger checkpoint is distinct from F01's economic projection. It retains genesis, books including closed-position realized P&L, cash/fees, marks, risk-session identity, revision and ordered accepted receipts/aliases. Restore verifies by replay and canonical state comparison. It is not an order/replay/strategy/RNG session snapshot.
- Exact multiplication and proportional release use maintained arithmetic with a single final half-away posting boundary, not precision-losing decimal intermediates. Account valuation sums owner-level marked postings; missing marks reject valuation instead of inventing zero or cost-based prices.
- Invalid commands fail atomically without changing balances, books, marks or receipts. Basic cash funding includes fees. Reservation and portfolio risk policies remain F04, including recording accepted risk-rejection outcomes.
- Identical command retry returns its original receipt even after later transitions. Identical fill under a new command ID aliases that receipt, explicitly marked replayed: compare event time and the entire canonical fill body, excluding only command ID. Different fill content or reuse of a fee ID by another fill rejects. Never emit duplicate economic deltas.
- Normal transitions stage only affected state; checkpoint serialization/replay is explicit. Record repeatable scoped transition and checkpoint/restore measurements without claiming end-to-end research throughput.
## Exclusions
No unrelated refactor, new service, broker enablement, or silent reinterpretation of historical results.