guardrail/docs/LIVE_RUNBOOK.md
Caelum c7d296d2c5
feat: submission-complete — proof capture, CMC hub lineage, live wiring, docker fix (#3)
* fix(docker): deterministic pnpm + CI flag for dashboard image

corepack enable downloaded a nondeterministic 'latest' pnpm (v11+) whose
TTY/CI gates broke the non-interactive build. Pin pnpm@9.15.4, set CI=true,
require the lockfile (drop the silent '|| pnpm install' fallback). Verified
with a full local 'docker build -f infra/Dockerfile.dashboard .' (next build
completes, image exports). Greens the docker CI job.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(cmc): CMC Agent Hub capability/lineage surface (Phase B)

Make the CMC integration verifiable and discoverable, not just asserted —
the gap that kept the CMC Agent Hub lane at PARTIAL. Read-only only; no
execution is ever exposed to the hub.

- configs/cmc/capabilities.json: single source of truth declaring each CMC
  dataset (quotes/OHLCV/Fear&Greed/DEX-liquidity/security/trending/global)
  -> the capability it powers, with the exact cmc-client source and the
  API route / MCP tool that exposes it.
- GET /cmc/capabilities (apps/guardrail-api/src/cmc_capabilities.rs): serves
  the descriptor + a summary (datasets, capabilities, execution_exposed=false).
- MCP resource guardrail://cmc/capabilities mirrors the descriptor.
- agent_card.json: advertise a "CMC Agent Hub" service so the agent is
  discoverable from its ERC-8004 identity document.
- docs/CMC_AGENT_HUB.md + PRIZE_MAP row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(submission): one-command proof capture + evidence auto-ticker (Phase C)

Turn the unchecked submission checklist into a captured, evidence-backed
artifact in one command — and tick it from real evidence, never by hand.

- python-lab/scripts/tick_checklist.py: reads the SQLite event log, the run
  report, and configs, then flips each proof-artifact checkbox based on whether
  the artifact actually exists, and regenerates an evidence table. Honest by
  construction: items needing a real on-chain tx report "pending (live)" in
  paper mode instead of a false tick. Evidence is scoped to the primary run's
  run_id so the shared-DB kill-switch demo can't shadow it.
- configs/risk_policy.killswitch_demo.json + configs/killswitch_demo.toml: a
  low-threshold (0.05%) policy/config that trips the kill switch on a normal
  paper run, emitting a real KillSwitchTriggered event (shared DB, throwaway
  report so the primary run report is preserved).
- scripts/capture_submission.sh: orchestrates run -> kill-switch demo -> export
  submission.md -> proof-verify -> tick. Offline-safe (paper/mock); flips to
  live when keys + production config are supplied.

Verified end-to-end: a paper capture ticks 10/11 from real evidence; only
Competition registration stays pending (live), exactly as it should.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(live): registration wiring + go-live preflight + go_live.sh (Phase D)

Make the live path turn-key and the on-chain registration proof flow end to
end, so the keyed go-live (the one human-in-the-loop step) is a single safe
command.

- agent-runtime: thread the competition registration tx through RunMeta into
  the run report, the AgentProof, and the AgentReportPublished summary — but
  only for a real LIVE registration. In paper the mock executor's synthetic
  hash is logged as an event for the demo and never presented as an anchored
  on-chain tx, so proof_verify and the checklist stay honest (registration =
  pending until live). The run report now also carries agent_id.
- guardrail-doctor --live: a preflight safety gate — required credentials
  (CMC_API_KEY, BSC_RPC_URL, TWAK transport), production config in live mode,
  and conservative policy caps. Env + file checks only; refuses to green when
  unconfigured. +2 tests.
- tick_checklist.py: registration ticks only on a live tx; a paper mock stays
  pending (live).
- scripts/go_live.sh: preflight -> on-chain reachability -> confirm -> bounded
  live run -> capture proof -> print BscScan links. Requires a typed "GO LIVE"
  confirmation (spends real money) unless --yes.

Workspace builds green, clippy clean, agent-runtime e2e tests pass, paper
capture still ticks 10/11.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: runbook one-command paths, checklist regen note, WHATS_NEW (Phase F)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 02:54:00 +03:00

6.1 KiB

Live Competition Runbook

Operator runbook for taking Guardrail Alpha live during competition week. The live profile is configs/production.toml and the one-command launcher is scripts/compete.sh. The runtime falls back to deterministic mocks whenever a key or URL is absent, so it never fails closed mid-window — but a real live run requires the environment below.

Competition contract: 0x212c61b9b72c95d95bf29cf032f5e5635629aed5


0. The one-command paths

Two turn-key scripts cover the whole lifecycle. Both auto-tick docs/SUBMISSION_CHECKLIST.md from real evidence.

# Offline-safe: paper run + kill-switch demo + proof capture. No keys needed.
scripts/capture_submission.sh

# Live: spends real money. Requires CMC_API_KEY, BSC_RPC_URL, and a funded TWAK
# wallet (see §1). Preflights, confirms, registers on-chain, trades, captures.
scripts/go_live.sh

Before going live, run the live preflight — it refuses to green until the credentials, live config, and conservative caps are all in place:

cargo run -q -p guardrail-doctor -- --live

scripts/go_live.sh runs this preflight for you, then the independent on-chain verifier against BSC_RPC_URL, and only then asks for a typed GO LIVE confirmation before placing any real trade.


1. Required environment

Export these before launch (in .env or the shell). See .env.example.

Variable Required Purpose
CMC_API_KEY yes CoinMarketCap API key for the REST data path
TWAK_BASE_URL yes Base URL of the TWAK REST execution surface (resolves [twak].base_url)
BSC_RPC_URL yes BNB Smart Chain JSON-RPC endpoint
CMC_X402_FROM optional Payer address for x402-settled CMC requests
CMC_X402_SIGNATURE optional Signature authorizing the x402 payment

If any required var is missing, the agent stays on offline mocks (safe, but not competing). Confirm everything is set with the checklist printed by scripts/compete.sh.

cargo run -q -p guardrail-doctor      # preflight: configs parse + readiness

2. Register before the trading window opens

Registration must land before the trading window opens — treat the window open as a hard deadline and register at least a few hours early so a failed attempt can be retried. Registration is one-time per competition.

# Via the launcher (recommended), or standalone:
cargo run -q -p guardrail-cli -- register --transport rest --autonomous true
  • With TWAK_BASE_URL set, this self-submits the registration over REST and prints the wallet address, transport, and competition contract.
  • With TWAK_BASE_URL unset, it falls back to the offline mock and prints the manual self-custody fallback: run twak compete register by hand.

Verify the agent identity / proof commitments any time:

cargo run -q -p guardrail-cli -- identity --config configs/production.toml

3. Start the live agent

./scripts/compete.sh            # doctor -> register -> contract -> live agent

Or start the agent directly once registered:

cargo run -p guardrail-agent -- --config configs/production.toml

The launcher prints the env checklist, runs preflight, registers, echoes the contract, then execs the agent so Ctrl-C cleanly stops the process.


4. Monitoring

Keep these running for the duration of the window.

# Prometheus metrics exporter (NAV, trades, drawdown, positions, kill switch)
EXPORTER_ADDR="127.0.0.1:9109" cargo run -p guardrail-exporter
curl -fsS http://127.0.0.1:9109/metrics | grep -E "guardrail_(nav_usd|trades_total|total_drawdown_pct|positions|kill_switch)"

# Live operator monitor
cargo run -p guardrail-monitor

# Read-only API + dashboard
DATABASE_URL=sqlite://data/guardrail_alpha.db cargo run -p guardrail-api   # :8080
(cd dashboard && pnpm dev)                                                 # :3000

Operator API surfaces: /cockpit, /alerts, /readiness, /metrics, /policy, /universe, /config, /ops, /report. The dashboard mirrors these at /alerts, /readiness, /events, /policy, /observability, /reports, and /proof.

Watch /alerts for freshness, slippage, drawdown, daily-trade, and kill-switch alerts.


5. Kill switch

Trigger an immediate halt if drawdown or operational risk demands it:

cargo run -q -p guardrail-cli -- kill-switch --reason "drawdown breach"

Our policy kill switch is wired at 24% drawdown — a deliberate margin below the competition disqualification threshold (see below). When the kill switch trips, stop accepting new positions and investigate before restarting.


6. Competition requirements

Requirement Rule Our margin
Daily trade At least 1 trade per day Strategy loop runs every 15 min; heartbeat + /alerts daily-trade alert flag a stale day before it counts against us
Drawdown DQ Disqualified at >= 30% drawdown Kill switch trips at 24%, a 6-point safety margin

Daily-trade heartbeat: monitor the daily-trade alert on /alerts (and the dashboard). If a day is at risk of zero trades, intervene — the alert fires ahead of the deadline so there is time to act.

Drawdown DQ: guardrail_total_drawdown_pct on the exporter and the drawdown alert track the live number. Treat 24% as the operator hard stop; the kill switch enforces it automatically.


7. Recovery and restart

  1. Identify the trigger: check /alerts, the exporter metrics, and the agent logs (RUST_LOG=info).
  2. If the kill switch tripped on a transient issue (RPC outage, data freshness), resolve the root cause first.
  3. Re-run preflight before restarting:
    cargo run -q -p guardrail-doctor
    
  4. Restart the agent (registration persists — do not re-register):
    cargo run -p guardrail-agent -- --config configs/production.toml
    
  5. Confirm trades resume and the daily-trade requirement is still satisfiable for the current day; if the day is nearly over, ensure at least one trade lands.

State (NAV, positions, events) lives in sqlite://data/guardrail_alpha.db and survives restarts, so the agent resumes from where it left off.