Polytraders Dev Guide
internal
v3 spine Phase 1 · Shared contracts 9 demo-wired · 0 shadow-ready · 0 production-live · 100 pending · 109 total 15/33 infra tasks the plan status board

Shadow mode — via the mock CLOB V2 adapter

Shadow mode is the gate between demo-wired and shadow-ready. A bot already runs against the synthetic feed; in shadow mode it also runs against an in-memory mock of the real exchange. Same wire format, same envelope shape, same correlation IDs — with no real capital and no on-chain submission. This page explains exactly how a wired bot moves through that gate using the new @polytraders/mock-clob-v2 package.

Reminder. The mock adapter does not perform real EIP-712 signature verification — it validates the message shape only. It is a behavioural mock for the wire format, not a cryptographic verifier. runtime-live requires the real signed adapter and 24h of clean envelopes against it.

What the mock adapter does

Reason codes the adapter emits

All match ^EXEC_[A-Z0-9_]+$ as required by the ReasonCode registry:

The promotion path: demo-wired → shadow-ready

  1. Pre-flight. The bot is already demo-wired: passes npm test, has a fixture pack, runs in the synthetic backtest. If any of these are missing, this page does not apply yet.
  2. Seed the mock book. Call POST /admin/seed (or client.seedMarket()) with deterministic bid/ask ladders for every market the bot will touch. Seed data is part of the test fixture, not improvised.
  3. Run intents through the bot. Drive at least 100 representative OrderIntents through the bot → runner → mock adapter. Mix of fills, partials, rests, cancels, and intentional rejects (bad envelope, FOK that cannot fill, halted market).
  4. Capture envelopes. Every emitted ReportEnvelope is appended to the bot's audit log with the correlation ID. The set of envelopes is the artefact reviewers grade.
  5. Determinism check. Re-run the same intent stream with the same seed. Envelope sequence must be byte-identical except for wall-clock timestamps. The determinism test in packages/polytraders-mock-clob-v2/tests/verify.js demonstrates the contract.
  6. 24h soak. Run the bot continuously for 24 hours against a synthetic market generator that drives the mock book through calm, volatile, drift, fat-tail and resolution regimes. Zero unexpected reason codes. Zero envelope-shape violations.
  7. Promote. When all of the above are green, flip the bot's row in the Plan from demo-wired to shadow-ready. runtime-live requires the real adapter against a real testnet — this page does not cover that.

What "shadow mode" means in this guide

Where this lives in the codebase

What this is not