From a cold start to a filled order, in six beats. Every step cites the code that performs
it.
boot
One process takes the lease
A single-writer file lock, TradingRuntimeLease.ts, decides
that exactly one server owns the trading database. A stale owner can remain visible
for at most one heartbeat, but the lock prevents two processes from writing.
record
The archive starts listening
A supervised, keyless child process records market history because Hyperliquid only
serves about 5,000 bars: "a minute not recorded is a minute gone" (archive/config.ts:8-12).
authority
A mission is granted
Binding a chat thread to a market creates a mission with an authority envelope: fixed
authority limits for leverage, total position value, cumulative loss, and planned loss
per position (TestnetAuthority.ts:13-23).
wake
A watch fires and wakes the agent
Saved watch conditions evaluate against live candles. Two persistent checks ensure
that each watch fires once, then a bounded market snapshot resumes the agent under a
one-run-at-a-time lease (WatchEvaluator.ts:16-25).
act
The agent asks, the spine answers
trading_enter runs the 14-item preview, persists the
execution record and risk reservation before signing, signs inside the serialized
nonce lane, and posts to /exchange.
truth
The exchange answers, everyone converges
Fills arrive through the userFills feed. The reconciler updates local tables from
exchange-authoritative data, then signals the web UI to fetch the latest projected
state (HyperliquidReconciler.ts:1100).