The guarantees that outrank convenience: budgets, protection, authority, and the
constitution sections that name them.
protection (exchange-native stop)
A stop that lives on the exchange as a real reduce-only trigger order, not a
promise the server makes to itself. No acknowledged position increase may remain
without confirmed protection; coverage is read back from the exchange's own open
orders, and a window that closes uncovered escalates to the emergency close.
Take-profit is deliberately not exchange-native anymore: the target is a wake, not
an order. Lives in
apps/server/src/trading/TradingProtectionService.ts:4-9
and
apps/server/src/trading/TradingMissionReactor.ts:2542-2563.
normalTpsl
The Hyperliquid order type that links a take-profit and stop-loss child to a
parent order. Position-increasing entries map a linked normalTpsl child so the
stop travels with the fill; an independently re-placed stop uses na grouping so it
outlives its parent order. Lives in
apps/server/src/trading/HyperliquidExecutionService.ts:140-153
and
apps/server/src/trading/HyperliquidExecutionService.ts:637-666.
reduce-only order
An order the exchange itself will not let open or extend a position. This is what
makes the user controls safe without the harness checklist: the buttons that get
you out skip the preview on purpose, because a reduce-only order physically cannot
add exposure. What they never skip is the signer, the nonce lane, canonical
reconciliation, and protection reconciliation. Lives in
apps/server/src/trading/TradingControlService.ts:10-24.
loss budget
The mission's cumulative loss allowance in dollars, computed by six equations:
realized result is closed PnL plus funding minus fees; losses count toward it,
profits clamp to zero and never raise the ceiling; open positions reserve
loss-to-stop; pending entries reserve planned loss plus fees. When the remainder
reaches zero the mission blocks, and only an explicit user resume clears it. Lives
in
packages/trading-contracts/src/lossAccounting.ts:106-138
and
apps/server/src/trading/TradingBudgetReader.ts:60-74.
authority envelope
What a mission is actually allowed to do: ceilings on leverage, gross notional,
cumulative loss, and planned risk per position, booleans like scale-in and
direction reversal, and a wake budget. It is versioned; harness intents carry
expectedAuthorityVersion and a mismatch refuses at preview. The type itself
forbids profit-funded expansion: positivePnlExpandsLossBudget is the literal
false, not a boolean. Lives in
packages/trading-contracts/src/authority.ts:41 and
packages/trading-contracts/src/authority.ts:59-96.
signer
The local key that signs exchange actions. It resolves from
T3_TRADES_INTERIM_SIGNER_KEY or the machine-canonical file
~/.t3trade/secrets/hyperliquid-interim-signer-key.bin,
fails closed when absent, and refuses a key file readable by group or other. Under
vitest the file source is disabled, so no test can ambiently arm live execution
with the developer's real key. Lives in
apps/server/src/trading/InterimSignerConfig.ts:19-44,
apps/server/src/trading/InterimSignerConfig.ts:213-220,
apps/server/src/trading/InterimSignerConfig.ts:248-259.
research mode
The product mode when no signer is armed. Market data, charts, alerts, backtests,
validations, missions, and wakes all work; only signing-dependent actions refuse,
with one honest line on the trade home: research mode means no trading key is
configured, observation and backtests and validations work, and orders will be
refused. The boundary is enforced by dependency wiring: research services get SQL
and Crypto only, and the code asserts nothing there can reach an order. Lives in
apps/server/src/trading/runtimeLayer.ts:224-245 and
docs/user/research-mode.md.
§14.7
The seven deterministic user controls: pause, resume, cancelEntries,
reducePosition, closePosition, revoke, and closeAndRevokeMission. They must work
while the provider process is dead, the session is unreachable, or the model is
mid-thought. A submitted but unconfirmed close must report its outcome as unknown,
never a number. Lives in
apps/server/src/trading/TradingControlService.ts:1-31
and
apps/server/src/trading/TradingControlService.ts:78-84.
§16.2
The loss-budget equations, six of them, from realized result through remaining
allowance. The inputs are reconciled exchange facts: closedPnl is Hyperliquid's
attribution, never computed by T3. A position without a stop reserves zero
directional risk rather than full notional, because booking entry as risk for an
unstopped long would exhaust the budget instantly. Lives in
packages/trading-contracts/src/lossAccounting.ts:33-138
and docs/architecture/trading-execution.md:192-224.
§16.3
The position-increase checklist: fourteen items plus two exit-only, each with its
own named rejection. Leverage, gross notional, planned loss per position,
reservations within budget, no conflicting pending execution, a valid stop,
freshness windows, an approved wallet. The stop gate runs a second time inside the
execution service, against the price actually going on the wire. Lives in
apps/server/src/trading/TradingPreviewService.ts:31-66
and
apps/server/src/trading/HyperliquidExecutionService.ts:605-624.
§16.4
Loss-exhaustion enforcement. When the budget is exhausted: cancel resting
position-increasing orders, refuse new increases, keep reduce-only protection
working, transition the mission to blocked. Cancel, reduce, close, and modify_stop
stay permitted, because §16.4 blocks taking on risk, not managing the risk already
open. The harness cannot resume itself from the block; only a user resume clears
it. Lives in
apps/server/src/trading/TradingExecutionGuard.ts:1-19,
apps/server/src/trading/TradingExecutionGuard.ts:90-154,
apps/server/src/trading/TradingExecutionGuard.ts:259-271.
§17.5
The bounded emergency close: a deterministic safety action that runs without the
harness. Block increases, cancel non-reduce-only orders, read fresh canonical
state, submit a reduce-only IOC, reconcile, retry with fresh reads; at most three
attempts, then an honest three-way report: flat, open with size, or unknown. Lives
in
apps/server/src/trading/TradingEmergencyCloseService.ts:10-51
and
apps/server/src/trading/TradingEmergencyCloseService.ts:75-117.