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

← Principles & schemas

Reason codes — global registry

Every bot output carries a reason_code. Codes are stable across versions, machine-readable, and dashboard-filterable. The registry is hybrid: a small set of global severity codes that every system must understand, plus per-bot specifics scoped within those severities.

The five severities

SeverityMeaningBehaviourWhere it lives
HARD_REJECTThe order or action must not proceed.Pipeline aborts; user is shown a plain-English explanation; nothing is signed or submitted.Risk & Security layers.
RESHAPEThe order may proceed only after reshape constraints are applied.Risk emits constraints (size cap, price cap, passive_only, close_only); Execution applies them.Risk layer.
WARNConcern raised; order proceeds.Logged, surfaced on the post-trade explanation; does not block.Any layer.
EXPLAINInformational annotation for post-trade reporting.Attached to the PostTradeExplanation; never shown as an alert.Governance layer.
INFORoutine telemetry.Logs only.Any layer.

Naming rules

Global codes — every system must understand these

CodeSeverityWhen emitted
KILL_SWITCH_ACTIVEHARD_REJECTGlobal kill switch is engaged.
STALE_MARKET_DATAHARD_REJECTRequired market data older than its staleness threshold.
WALLET_PERMISSION_DENIEDHARD_REJECTUser wallet refused the action or session expired.
CONTRACT_ADDRESS_NOT_ALLOWEDHARD_REJECTTarget contract is not on the V2 allow-list.
ORACLE_DISPUTE_ACTIVEHARD_REJECTUMA Optimistic Oracle proposal is under dispute.
PARAMETER_CHANGE_REQUIRES_APPROVALHARD_REJECTStrategy attempted a mid-run parameter change without re-validation.
INSUFFICIENT_VISIBLE_DEPTHRESHAPEOrder would consume too much of visible top-of-book.
SPREAD_TOO_WIDERESHAPECurrent spread exceeds the warning multiple of 30d median.
STRATEGY_BUDGET_EXCEEDEDRESHAPEOrder would push strategy spend over its declared budget.
NEGRISK_CONVERT_AVAILABLEWARNSum of YES prices in a negative-risk set is below 1; arbitrage possible via NegRiskAdapter.
FEE_RATE_CAPPEDWARNBuilder fee rate clamped to 100 bps taker / 50 bps maker.
RECONCILIATION_DRIFT_OBSERVEDEXPLAINInternal view of a fill diverged from on-chain settlement and was reconciled.

Per-bot scoping

Each bot may add its own codes inside one of the five severities. Convention: prefix with the bot's namespace.

Per-bot codes are listed in the Reason codes section of each bot's page.

Deprecation

To retire a code: add the new code, mark the old one as deprecated in the bot's Versioning & Migration block, run both for at least 30 days, then remove emission. Never remove a code from the registry — keep it as DEPRECATED with a pointer to the replacement so historical logs remain decodable.