guardrail/docs/adr/0002-risk-engine-is-the-only-gate.md
caelum0x 2d2b15c7fe feat: full guardrail-alpha system + CLI modularization + Vercel deploy config
- Rust engine: real bootstrap/wiring preflight (guardrail-agent), execution layer (retry/router/pre-trade/post-trade/reconciliation), guardrail-doctor diagnostics with allowlist-drift guard.

- guardrail-cli: extracted pure helpers into util.rs (split in progress).

- 6 Track-2 skills + ensemble; python-lab analytics (regime/drawdown/montecarlo/dossier/ensemble/journal/seed); clients (ts/py/go/mcp/langchain/web-lite/proof-verifier); alert relay; scenarios; helm/k8s/compose; docs.

- dashboard/vercel.json + docs/VERCEL_DEPLOY.md for Vercel deployment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 11:02:22 +03:00

1.3 KiB

ADR 0002 — The risk engine is the only gate to execution

  • Status: Accepted
  • Date: 2026-06-13

Context

A strategy that can reach the executor directly is one bug away from a bad trade. We need a single, auditable choke point that every order must pass.

Decision

No RiskDecision::Approved (or Clipped) ⇒ no TWAK swap. Every order is evaluated twice:

  1. Pre-trade — allowlist, position cap, new-position cap, daily-loss gate, total-drawdown gate, stable-reserve floor, security flags, trade-frequency.
  2. Final — re-runs the gates with the live quote attached (slippage, quoted liquidity).

The strategy engine produces intent only; it cannot sign or call TWAK. The kill switch and drawdown throttle sit in the runtime loop ahead of order processing. Forbidden actions (launch token, custodial signing, bypass TWAK, trade non-eligible assets) are enumerated in the policy and rejected.

Consequences

  • The dependency graph forbids strategy-engine → twak-client and execution → (skip risk-engine).
  • Every approval/rejection/clip is recorded as an event, making "why did it trade?" fully replayable (see ADR 0004).
  • Risk limits are data (RiskPolicy), compiled and hashed, not code — they can be changed and proven without recompiling the engine.