feat(execution): preserve durable recovery on canonical Rust core
This commit is contained in:
parent
5e9655de0b
commit
c01e96e4dd
27 changed files with 3644 additions and 182 deletions
|
|
@ -25,7 +25,7 @@ No unrelated refactor, new service or broker activation.
|
|||
- apps/stock/orchestrator/src/services/ExecutionService.ts
|
||||
- apps/stock/engine/src/api/
|
||||
|
||||
Write locks: ts-execution-model, paper-transaction, financial-contract. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
Write locks: ts-execution-model, paper-transaction, financial-contract. The integration owner coordinates disjoint native and durable custody slices; one designated owner controls each shared contract. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
|
|
@ -68,12 +68,22 @@ At the paper boundary, intermediate views may be reconstructed by restoring the
|
|||
|
||||
**Durable custody:** retain the existing SQL account row lock and transaction mechanism. New explicitly canonical account IDs use a versioned outer envelope containing the opaque native checkpoint plus TS cursors/pending work. Reuse generic JSON journal/checkpoint/input storage where compatible; add only the all-owner batch-intent storage actually needed. Native order snapshots and ordered fill journal facts are authoritative persisted records; do not introduce UUID remapping or redundant financial projections. Legacy repository reads/initialization explicitly refuse canonical envelopes, and canonical initialization refuses legacy state or changed configuration. No implicit account conversion.
|
||||
|
||||
SQL custody is trusted. Account reads validate outer versions, identities, revision consistency and bound definitions. Rust replays and validates the opaque financial checkpoint before each financial transition; initialization alone does not certify every nested stored financial receipt. Do not introduce a second TypeScript ledger validator.
|
||||
|
||||
**Actual strategy recovery:** a canonical paper runner accepts trusted normalized input commands/observations and optional decision scheduling metadata. S04 supplies the real feed/calendar/scheduler; the caller cannot supply a portfolio or revision. Capture the committed native view for a decision. Restore program JSON state, RNG state/draws, decision cursors and pending observation prefixes for every owner before evaluating all due owners against that same view. Functionally extract/reuse S01 staging logic; preserve its public research diagnostics and complete-retry behavior. Never invent a historical dataset hash for paper.
|
||||
|
||||
Atomically save all next checkpoints and one complete decision-batch intent. Dispatch that batch in a subsequent locked transaction and persist actual admission feedback with its financial snapshot/effects. Drain pending batch, then pending decision, then next input; do not admit later financial input while recovery is pending. Reject caller-supplied Submit commands on the paper input path. Per-owner pending observations must survive mixed-cadence restarts. Trusted program definitions are bound by declared metadata/version/seed/mode/initial state; immutable code artifact retention remains R01/R05.
|
||||
|
||||
Ordinary decisions use a Decision-phase event key. Quote-driven decisions may use the exact consumed quote's Execution key, as the existing native matcher permits; they cannot fill against that consumed quote. Never invent a later timestamp to bypass event ordering.
|
||||
|
||||
This custody slice accepts observations only for configured execution series. An auxiliary feature/timeframe observation manifest and feed cadence/alignment belong to S04; this does not claim full research multi-timeframe parity. Invalid admitted commands fail closed at drain without financial advancement and remain pending for diagnosis; there is no automatic skip or dead-letter framework. S04 readiness must refuse incomplete/failed recovery, including a pending invalid input.
|
||||
|
||||
**Failures:** SQL failure discards all private staged changes. Native validation/restore errors with no returned transition roll back. A returned native `Failed` outcome can contain a committed financial prefix: save its failed snapshot and exact ordered effects atomically, mark the account/batch terminal, then surface failure after commit. Never report successful execution or keep a running retry state. Publication occurs after commit and cannot roll back finance; stable readable journal IDs recover notification gaps without claiming exactly-once delivery.
|
||||
|
||||
Port existing failure/recovery scenarios to approved canonical economics. Legacy immediate cached-quote fills, UTC implicit resets, shorts and mutable policy reloads are not canonical compatibility promises. Preserve DAY/GTC/IOC/FOK under next-eligible-event timing and explicit venue/risk sessions, and retain legacy tests unchanged. Required added cases include old-command/alias retries after later fills, failed-prefix custody, shared-revision owner batches, mixed-cadence restart, pending-input recovery, SQL decision/intent/effect failures, lost commit acknowledgement and competing producers.
|
||||
Port existing failure/recovery scenarios to approved canonical economics. Legacy immediate cached-quote fills, UTC implicit resets, shorts and mutable policy reloads are not canonical compatibility promises. Preserve DAY/GTC/IOC/FOK under next-eligible-event timing and explicit venue/risk sessions, and retain legacy tests unchanged. Required added cases include old-command/alias retries after later fills, failed-prefix custody, shared-revision owner batches, mixed-cadence restart, pending-input recovery, SQL decision/intent/effect failures, lost commit acknowledgement and competing producers. Kill a separate process before decision commit, after checkpoint/batch commit, after admission commit and after fill/fee commit; compare recovered checkpoints and ordered journals with uninterrupted execution.
|
||||
|
||||
Native and TypeScript owners work in separate worktrees with an accepted wire-schema overlay. The native owner controls the new API/schema and minimal existing-schema exports; the durable owner controls custody, shared strategy staging and canonical recovery. Root controls integration/migrations acceptance; independent review checks invariants. No default/service/feed activation or paper trading operation is authorized by this task.
|
||||
|
||||
## Validation handoff — 2026-10-23
|
||||
|
||||
Implementation and independent G1/G2 review passed. The manifest records the 22-file source hashes, native artifact, commands and raw logs. Full repository checks and all 81 disposable-database tests passed; strict new-test TypeScript and 38 final targeted tests passed after test-only typing corrections. The host and native adapter are integrated but uncommitted; S04 activation and feed work remain separate. See the [sixteenth-wave record](../../ROADMAP.md#sixteenth-wave-execution--2026-10-23).
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ Scheduling source of truth: [manifest entry S04](../manifest.json). No task is a
|
|||
|
||||
Verify the real paper feed path, recovery and stale-feed/kill controls on the canonical engine. Own the minimal paper-readiness endpoint/status needed to activate safely; do not wait for optional O02 cross-service dashboards. Reuse existing monitoring routes/components for actual state, unknown rather than fake zeros. Live remains disabled.
|
||||
|
||||
S03 supplies transaction custody and trusted command ingestion, not feed scheduling. Define the host's observation-series/cadence manifest before accepting auxiliary feature timeframes; retain the separate native execution-series configuration. Schedule ordinary completed observations and exact consumed-quote decisions without timestamp restamping. A durably admitted invalid input remains pending and drain rejects it: readiness must fail closed until recovery succeeds, without silently skipping data or resetting capital.
|
||||
|
||||
## Exclusions
|
||||
|
||||
No unrelated refactor, new service or broker activation.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue