- 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>
2.2 KiB
2.2 KiB
Execution
execution turns an approved order into a TWAK swap. It never decides whether
to trade — that is the risk engine's job — it only orchestrates the ordered
sequence and reconciles the result.
Pipeline: OrderIntent → execution
execution::quote_then_approve (and the equivalent inline path in
agent-runtime::process_order):
- OrderIntent — a strategy proposal (
side,from_symbol,to_symbol,amount_usd,reason). Intent only; carries no authority. - Pre-trade risk —
RiskEngine::pre_trade(intent, ctx).Rejected→ stop, returnExecutionError::RiskRejected.Clipped→ carry the reducednew_amount_usdforward into the quote.Approved→ proceed unchanged.
- TWAK quote —
TwakExecutor::quote_swap(intent)returns aSwapQuotewhosesummary: QuoteSummary(expected out, price impact, slippage, liquidity) is the only quote data risk sees. - Final risk —
RiskEngine::approve(intent, ctx, "e.summary)re-runs the pre-trade checks plus the quote-aware slippage and liquidity checks. On pass it returns anApprovedOrder { id, intent, approved_amount_usd, decision }; otherwise it returns the rejectingRiskDecision. - Execute —
TwakExecutor::execute_swap(&approved)submits the swap and returns aTxReceipt { tx_hash, status, block_number }. - Reconcile — the fill (notional, prices, slippage + gas fee) is applied to
the portfolio via
portfolio::trade_accounting::apply_fill, updating NAV and holdings.
Every stage emits an AgentEvent (OrderProposed, TwakQuoteReceived,
RiskApproved / RiskClipped / RiskRejected, TwakSwapSubmitted,
TxConfirmed, PortfolioReconciled) to the event store.
Guarantees
- Risk is consulted twice — before and after the quote — so a quote that reveals excessive slippage or vanished liquidity is rejected even if the pre-trade check passed.
- A quote is mandatory before any swap (
require_quote_before_swap,pre_trade::QUOTE_BEFORE_SWAP). - The only route is
twak(router::route_name); there is no alternate execution path. reconciliation::reconciliation_required()is always true — the book is reconciled after every fill.