Skip to content

Add durable deterministic shadow execution - #18

Merged
howdymary merged 1 commit into
mainfrom
codex/packet-6-shadow-execution
Jul 15, 2026
Merged

Add durable deterministic shadow execution#18
howdymary merged 1 commit into
mainfrom
codex/packet-6-shadow-execution

Conversation

@howdymary

Copy link
Copy Markdown
Owner

What changed

  • adds immutable fixed-point shadow contracts, UTC replay/system clocks, and a credential-free validated-capture feed
  • adds deterministic displayed-depth and later-trade fills without RNG or fabricated liquidity
  • adds signed, reservation-aware risk with reduce-only splitting and conservative exposure accounting
  • adds a SQLite v1 WAL/FULL/FK state journal with fenced writer leases, deterministic IDs, durable decisions/intents/orders/fills/positions, breakers, cancel-all, reconciliation, and canonical state hashes
  • adds atomic per-trade allocation plans so crash/replay cannot reuse queue or trade volume
  • routes Packet 4 typed providers through strategy.build_orders and Packet 5 replay without exposing outcomes or authenticated venue capabilities
  • adds autopredict shadow run/status/cancel-all/reset, a thin autopredict-paper compatibility wrapper, strict config allowlists, example config, and operating documentation
  • handles stale/gapped/reconnected feeds, conflicting duplicates, provider errors, accounting faults, daily loss, restart, and failed admin cleanup fail-closed

Why / root cause

The previous paper runner only slept and logged empty metrics. State, positions, fills, and resting orders were memory-backed, risk was not direction-aware, and there was no restart reconciliation or point-in-time replay parity. That made the required safety gate before any live consideration nonfunctional.

User and developer impact

Users can now replay validated public captures through the actual forecast→strategy→risk→fill path, persist deterministic state, inspect/cancel/reset it, and resume after crashes without duplicate provider calls or fills. Live order submission remains disabled.

Schema and migration

Introduces autopredict.shadow SQLite schema v1 and autopredict.shadow.config.v1. Shadow configuration is a strict allowlist and rejects credentials, environment substitution, live/adapter/network fields, and unknown keys. Existing paper entrypoint delegates to the new shadow runner.

Verification

  • independent core reviewer: APPROVED after multiple remediation rounds
  • independent integration/safety tester: APPROVED
  • focused shadow suite: 31 passed before main integration
  • full suite on current main stack: 453 passed
  • Python 3.9 installed-wheel entrypoint/import checks: passed
  • Black 26.5.1, compileall, scoped mypy, and git diff --check: passed
  • sdist/wheel build and clean installed-wheel import audit: passed
  • repeat/restart/fresh replay state hashes: identical
  • injected crash tests prove atomic two-order trade allocation and daily-loss breaker recovery
  • no authenticated request, live order, or production credential was used

Residual risks

  • v1 supports persisted, validated Packet 5 capture replay; direct public polling remains intentionally unsupported until it can pass through the same immutable validation boundary
  • deterministic queue-ahead is a conservative simulation assumption, not venue truth
  • multi-day operational evidence has not yet been collected, so this PR does not make live execution ready

Tracks #2
Closes #7

@howdymary
howdymary merged commit a579d08 into main Jul 15, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Packet 6: implement durable shadow execution and direction-aware risk

1 participant