feat(execution): preserve durable recovery on canonical Rust core

This commit is contained in:
Boki 2026-10-23 15:58:44 -04:00
parent 5e9655de0b
commit c01e96e4dd
27 changed files with 3644 additions and 182 deletions

View file

@ -1,8 +1,8 @@
{
"schema_version": 1,
"plan_revision": "2026-10-23.35",
"plan_revision": "2026-10-23.36",
"repository_base": "b7aeca4",
"plan_status": "sixteenth_wave_in_progress",
"plan_status": "sixteenth_wave_validated",
"execution_authorized": true,
"execution_scope": {
"authorized_by": "User: commit and continue, then stop performance work for now and continue remaining backlog (2026-10-23). S02 accepted and committed ca5abdd. S03 is the highest-priority ready non-performance task under approved ADR-005.",
@ -1037,7 +1037,7 @@
"epic": "E4",
"priority": "P0",
"severity": "Critical",
"status": "in_progress",
"status": "review",
"dependencies": [
"S01",
"C06"
@ -1066,7 +1066,7 @@
"release_gates": [],
"worktree": "/tmp/stock-bot-wave16.kgaZm4/durable",
"integration_base": "ca5abdde0e131ef4ec8c60ff9a4de4e277fc0820",
"integration_state": "isolated_implementation",
"integration_state": "validated_uncommitted",
"implementation_slices": [
{
"owner": "/root/s03_native",
@ -1080,7 +1080,10 @@
"branch": "wave16/s03-durable",
"scope": "Versioned SQL custody, shared S01 decision staging, actual canonical strategy/RNG/pending-prefix recovery, one durable owner-batch outbox, migration and failure tests."
}
]
],
"reviewed_by": "/root/s03_review",
"verification_reference": "ROADMAP.md#sixteenth-wave-execution--2026-10-23",
"review_notes": "Integrated canonical native staging and SQL custody with actual strategy/RNG/mixed-cadence recovery. Independent G1/G2 review, full repository checks, full disposable PostgreSQL/Redis suites, strict test types and final targeted/release tests passed. Source remains uncommitted. No default, feed, paper/live activation or performance work."
},
{
"id": "S04",
@ -5894,6 +5897,166 @@
"S03 reuses Rust financial semantics and existing SQL transaction/row-lock/journal guarantees. Native and durable owners have isolated worktrees; review is independent.",
"Versioned new canonical accounts only. No implicit legacy migration, current service/default switch, operator reset, broker execution or paper feed activation.",
"Native Failed outcomes with committed-prefix effects persist as terminal before surfacing error; SQL failure discards private state. Duplicate outcomes emit no duplicate effects.",
"Persist all-owner checkpoint/intent batches and mixed-cadence observation prefixes; reuse S01 staging without changing its public research recovery semantics or inventing a paper dataset hash."
]
"Persist all-owner checkpoint/intent batches and mixed-cadence observation prefixes; reuse S01 staging without changing its public research recovery semantics or inventing a paper dataset hash.",
"S03 is validated for review, with 22 integrated source/test files. Root added actual process-kill cases at decision/checkpoint/admission/fill boundaries.",
"Exact consumed-quote decisions and persisted identity/revision checks were corrected during review. Canonical Failed prefixes persist terminal before errors surface, including failed admission batches.",
"Full repository and all 81 disposable-database tests passed. Strict test-only typing corrections preserve runtime assertions; final targeted tests and release-addon checks passed.",
"After S03 acceptance/commit, S04 is the next non-performance task. S05 is independently code/ADR-ready; R01/R11 still require ADR-006. P08 remains deferred."
],
"sixteenth_wave_validation": {
"state": "validated_uncommitted",
"work_root": "/tmp/stock-bot-wave16.kgaZm4",
"committed_before_implementation": {
"S02": "ca5abdde0e131ef4ec8c60ff9a4de4e277fc0820",
"planning": "5e9655de0bf367ec4c740e13796dd84eb39ae6f2"
},
"scope": [
"Stateless native transaction adapter on existing MatchingAccount/RiskAccount",
"Exact per-effect native financial views and original replay outcomes with current checkpoints",
"Versioned canonical SQL custody and complete all-owner batch intents",
"Shared S01 strategy staging with durable JSON/RNG/pending-observation recovery",
"Explicit refusal between legacy and canonical account envelopes",
"Additive canonical batch migration and failure/recovery tests"
],
"source_integration": {
"files": 22,
"exact_hashes": {
"apps/stock/engine/index.mjs": "cc9e8206880590baae8a988005f9bfb1b92e7dfe689ca47b81e89f2ca28ca7a3",
"apps/stock/engine/src/api/mod.rs": "b04df31c1a67e88c2533579903267425e048b0ffc134727a7f80c8e79fe19f01",
"apps/stock/engine/src/api/paper.rs": "1352a493eaa7684c06455f76a83d87e66463e3a400e33ea107f7b4a816f9766e",
"apps/stock/engine/src/api/paper/tests.rs": "03e0e935467e7aec2d1b9cb309c35a907a25ad63bdaf660cdc9e304128e47b7e",
"apps/stock/engine/src/financial/mod.rs": "66bc1a0d2455a345c4b796742ed188f85a79c04e660cce84121ae432008d205d",
"apps/stock/orchestrator/src/backtest/strategy-runtime.ts": "d72cc4749847d2506d6808be364f16b465896063c04cb5434e6c1d412c96dc8a",
"apps/stock/orchestrator/src/contracts/canonical-execution.ts": "9af274b41e8c3179d18776e249c8af1914dbb8091b63a38bc5871a4c5da7dfed",
"apps/stock/orchestrator/src/contracts/native-replay.ts": "3fc0aac64767355121e232fd71be12c80327cb49b2f2496c92c41e622a3d7f0a",
"apps/stock/orchestrator/src/execution/CanonicalPaperExecution.ts": "216f447a8922ebd328a0416aa76dfe2af0d4b22efb798a3b0b418152e8b28fe2",
"apps/stock/orchestrator/src/execution/PostgresCanonicalExecutionRepository.ts": "f1b43a971325fc91c8857d4c0ede35a40acacce0d354ab4907cac67ecb0a55fe",
"apps/stock/orchestrator/src/execution/PostgresExecutionRepository.ts": "992fdca2454ecf098c76ed97c8d444817ff0b939f0918b68aedeb2a6e44774d8",
"apps/stock/orchestrator/src/execution/canonical-paper.ts": "252bb14103024ad364432ddd33792b188105989389194e0052cd9f0a5dcef7f4",
"apps/stock/orchestrator/src/strategies/strategy-decision.ts": "a5c78e95447daa45d7f5fc8f5e2ab9ae1f8aa27eec5a0dd5460f8d0d4ac56b8f",
"apps/stock/web-api/src/migrations/migration-runner.ts": "7d3fcdac4ce5f6dd14b20cf143f2c49f4a87a9401c564185b0bc9a5e5b3a3ff2",
"database/postgres/init/15-canonical-paper-intents.sql": "5e4cd7b03f5194c4cd1a4d198f5dbfdbc4d7b7985ae30f848a34f4b929795bda",
"scripts/test/architecture.test.ts": "edb5524f14c2cba29d3001ad53d26a43be4f0670c1b7f679d94922840b05707c",
"scripts/test/native-bindings.test.ts": "af6a6fa3eb252d48d9cefb6e6d4fd9e87fccfd6f0075314835f6c7814f1ecf50",
"test/fixtures/canonical-paper-crash-owner.ts": "e46478ffea29ef19ccd172dfcd2dfc736048ccc71e5822f9b957052fe5b037fb",
"test/fixtures/canonical-paper.ts": "b627d3e7750b60670811d262796a2cb2fd072cf2d9cf10e2cb0572b633cd55a5",
"test/postgres/canonical-paper-crash.test.ts": "6cef77f13032d4fa91e70d6ae0f548dd88cb9aef7a1b7d3f6aae9741ac97641d",
"test/postgres/canonical-paper.test.ts": "89896f1e9635e491f4070e74be6dccb4424418ace5b1aa945093798050beab8e",
"test/postgres/migration-runner.test.ts": "7b572cfca9914c85429ed7b6b8ad624ff7c4f75e99f726f907778d3f646e3fe3"
},
"source_archive": "/tmp/stock-bot-wave16.kgaZm4/s03-integrated-source.tar",
"source_archive_sha256": "7f63dd118a7a8aacae5c406d1722f3ec6aef606de74e6eb6e209fbf3b237943c",
"native_archive_sha256": "b6bb48ece6625b115bf28d1688b4425620a85945320dfd4a695817d2fa974e23",
"durable_archive_sha256": "48ac2501fea24d609db11710871855ea22ec4c75a61c8bdc136ff9a426c93ecb",
"test_overlays": {
"native": "77f1efcbb17f0e2b9efda92cf203c98bc78a69f5d6f872aeb6a57fbfb8d44cfc",
"durable": "38334e9cd25f4700654271bbad58f8b3867c7843db6f76b489c8e63535680b89"
},
"note": "Production source matches independently reviewed frozen slices. Root adds four-boundary crash tests; final test-only corrections use branded decimals, discriminator narrowing, correct fixture username and explicit migration logger. No application change followed full repository validation."
},
"review": {
"reviewer": "/root/s03_review",
"result": "G1/G2 accepted; final test-only delta reviewed with no signoff regression",
"findings_resolved": [
"Allow exact consumed Quote Execution key without same-quote fills",
"Validate persisted envelope/context identity and revisions before callback",
"Commit native failed execution/admission prefixes before surfacing errors",
"Retain slow-owner observation prefixes and immutable callback context",
"Test all four actual process-kill boundaries including committed fill and fee"
]
},
"checks": [
{
"command": "CARGO_BUILD_JOBS=2 bun run check",
"result": "passed",
"counts": {
"tooling": 82,
"utilities": 43,
"calculations": 44,
"integration": 432,
"rust": 150,
"rust_manual_ignored": 4
},
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-check.log"
},
{
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32816/stock_bot_safety BACKTEST_TEST_REDIS_URL=redis://127.0.0.1:32815/15 bun run test:postgres",
"result": "passed",
"tests": 81,
"assertions": 545,
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-postgres.log"
},
{
"command": "bunx --no-install tsc --project /tmp/stock-bot-wave16.kgaZm4/tsconfig.s03-tests.json --noEmit",
"result": "passed",
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-test-types-final.log"
},
{
"command": "Scoped Prettier --check and ESLint --no-ignore --max-warnings 0 over integrated TypeScript except the existing architecture test; full architecture tests pass through bun run check. git diff --check.",
"result": "passed",
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-format-lint.log"
},
{
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32816/stock_bot_safety bun test test/postgres/canonical-paper.test.ts test/postgres/canonical-paper-crash.test.ts test/postgres/migration-runner.test.ts scripts/test/native-bindings.test.ts",
"result": "passed after test-only typing corrections",
"tests": 38,
"assertions": 281,
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-final-focused.log"
},
{
"command": "CARGO_BUILD_JOBS=2 bun run --cwd apps/stock/engine build:release",
"result": "passed; final addon matches local target/release/libengine.so",
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-release-build.log"
},
{
"command": "bun test scripts/test/native-bindings.test.ts test/integration/strategy-runtime.test.ts test/integration/canonical-sma.test.ts",
"result": "passed against final release addon",
"tests": 38,
"assertions": 366,
"log": "/tmp/stock-bot-wave16.kgaZm4/integration-release-focused.log"
}
],
"native": {
"debug_sha256": "75e33ffdd1e2738537879e62243a9d8f63665864835a58c46087bb4b78f274ff",
"final_profile": "release",
"final_addon_sha256": "ef00eed556f5c32332d36a9a00ef710682e90deb00b54552e4b5c8bfdfbe8103",
"local_library_matches": true,
"performance_measurements": false
},
"economic_and_recovery_evidence": [
"Direct Rust command tape equals staged persisted checkpoints and ordered effects",
"Same-revision owner batches reconcile shared cash reservations, owner fills and fees",
"Restart and four hard-kill boundaries match uninterrupted complete snapshots/journals",
"Actual canonical SMA buy and sell executions preserve checkpoint/journal parity after replacement",
"Failed admission batch and failed execution prefix are terminal, committed exactly once, and refuse restart mutation",
"DAY/GTC/IOC/FOK, stale quote rejection, cancellation, explicit daily risk rollover and reducing risk orders survive restart",
"Old command and quote aliases retain current financial state without duplicate observations/effects"
],
"environment_notes": [
"Initial NAPI sandbox EPERM required escalation; one native-owner approval wait was interrupted and root took over isolated builds.",
"Restricted database connections failed; authorized disposable-fixture tests passed outside sandbox.",
"Three initial PostgreSQL fixture expectations were corrected to existing native semantics: only supported quote events alias, stale marks reject orders requiring readmission, all owners have fee entries including zero.",
"Extra strict test compilation found test-only decimal branding/narrowing/config errors and an existing incomplete migration test container; corrections preserve production behavior.",
"Browser E2E and Python analytics were not rerun because those boundaries were unchanged.",
"No profiling, optimization, benchmark measurements, default cutover, trading operations, push or PR."
],
"limitations": [
"Only explicitly initialized new canonical accounts; incompatible legacy snapshots/config changes refuse conversion.",
"Trusted SQL custody: outer metadata checked on reads; opaque native receipts replay-validated before each financial transition, not fully audited by initialization alone.",
"Only configured execution-series observations; S04 owns auxiliary observation/cadence manifests, real feed alignment and operator readiness.",
"Invalid queued commands fail closed and remain pending with drain diagnostics; no automatic skip/dead-letter framework.",
"Program metadata/version/seed/initial-state binding is not retained immutable code provenance; R01/R05 own artifacts.",
"Research keeps its resident native loop; no per-event paper snapshot transport added to research."
],
"cleanup": {
"status": "completed",
"stopped_container_ids": [
"d915a0cd02120d8d09a7e2bb9b3fe4ad1b58e69ca6fd081fba003029f53ead23",
"02c258682d95171a7e58740bb5d24c8ba544be6789fd1382e47367ad22d0f78d"
],
"development_resources_untouched": true,
"worktrees_and_logs_retained": true
},
"next": "Accept/commit S03, then S04 verified paper feed/operator readiness. S05 independently ready; research-product R01/R11 require ADR-006. P08 remains deferred by owner request."
}
}