openapi: 3.1.0 info: title: Guardrail Alpha API version: 0.1.0 description: >- Read-only HTTP API for the Guardrail Alpha trading agent. Every endpoint is a GET and is side-effect free: it never mutates the live book or the event log. Responses are JSON unless noted as text/plain or text/markdown. This document is generated by hand to match apps/guardrail-api/src/server.rs. servers: - url: http://localhost:8080 description: Local Guardrail API server tags: - name: ops description: Operational and health endpoints - name: portfolio description: Live book, signals, and risk views - name: reports description: Run reports and submission exports - name: config description: Policy, universe, and configuration inventory - name: analytics description: On-demand backtest, walk-forward, and sweep analytics - name: agent description: Agent identity, services, and SDK surface - name: trading description: Assets, indicators, quotes, costs, and execution analytics - name: data description: Persisted market-snapshot history and ingestion summaries paths: /health: get: tags: [ops] summary: Liveness and database visibility description: Reports whether the event store is reachable and how many events are visible. responses: "200": description: Health status content: application/json: schema: type: object additionalProperties: true properties: ok: type: boolean database_url: type: string events_visible: type: integer /portfolio: get: tags: [portfolio] summary: Latest reconciled portfolio snapshot responses: "200": description: Latest PortfolioReconciled payload content: application/json: schema: $ref: "#/components/schemas/LooseObject" /trades: get: tags: [portfolio] summary: Recent trade-related events responses: "200": description: Recent order/quote/swap/confirmation events content: application/json: schema: type: object additionalProperties: true properties: trades: type: array items: $ref: "#/components/schemas/LooseObject" /signals: get: tags: [portfolio] summary: Latest regime and portfolio target signals responses: "200": description: Latest regime classification and target computation content: application/json: schema: type: object additionalProperties: true properties: regime: $ref: "#/components/schemas/LooseObject" target: $ref: "#/components/schemas/LooseObject" /risk: get: tags: [portfolio] summary: Recent risk decisions and kill-switch state responses: "200": description: Risk events and kill-switch flag content: application/json: schema: type: object additionalProperties: true properties: kill_switch: type: boolean events: type: array items: $ref: "#/components/schemas/LooseObject" /alerts: get: tags: [ops] summary: Operator alerts derived from the run report and events responses: "200": description: Evaluated alerts with status, counts, and inputs content: application/json: schema: $ref: "#/components/schemas/AlertsResponse" /readiness: get: tags: [ops] summary: Submission readiness checks description: Aggregates run-report, wallet, event, and proof checks into a ready/blocking verdict. responses: "200": description: Readiness status with per-check results content: application/json: schema: type: object additionalProperties: true properties: status: type: string enum: [ready, blocking] blocking: type: integer checks: type: array items: $ref: "#/components/schemas/LooseObject" artifacts: $ref: "#/components/schemas/LooseObject" /events: get: tags: [ops] summary: Recent stored events (newest first) responses: "200": description: Recent events from the event log content: application/json: schema: type: object additionalProperties: true properties: events: type: array items: $ref: "#/components/schemas/LooseObject" error: type: string /proof: get: tags: [reports] summary: Execution and registration proof responses: "200": description: Agent identity, registration tx, latest report, and run report content: application/json: schema: $ref: "#/components/schemas/LooseObject" /cockpit: get: tags: [ops] summary: Combined operator cockpit view description: One-shot aggregate of health, portfolio, regime, target, risk, execution, and recent activity. responses: "200": description: Aggregated cockpit payload content: application/json: schema: $ref: "#/components/schemas/LooseObject" /report: get: tags: [reports] summary: Run report as JSON responses: "200": description: Run report wrapped in an ok/report envelope content: application/json: schema: type: object additionalProperties: true properties: ok: type: boolean report: $ref: "#/components/schemas/LooseObject" path: type: string error: type: string /report/markdown: get: tags: [reports] summary: Run report rendered as Markdown responses: "200": description: Markdown run report content: text/markdown: schema: type: string "404": description: Run report unavailable content: text/plain: schema: type: string /export/submission.md: get: tags: [reports] summary: Submission package rendered as Markdown responses: "200": description: Markdown submission export including execution proof and recent events content: text/markdown: schema: type: string "404": description: Submission export unavailable content: text/plain: schema: type: string /policy: get: tags: [config] summary: Risk policy files and enforcement model responses: "200": description: Production/paper policies, schema, and enforcement settings content: application/json: schema: $ref: "#/components/schemas/LooseObject" /policy/compile: get: tags: [config] summary: Compile a natural-language mandate into a risk policy parameters: - name: mandate in: query required: true description: Free-text mandate to compile (must be non-empty). schema: type: string responses: "200": description: Compiled policy with canonical hash, or an error object content: application/json: schema: type: object additionalProperties: true properties: hash: type: string policy: $ref: "#/components/schemas/LooseObject" error: type: string /universe: get: tags: [config] summary: Eligible-asset universe responses: "200": description: Universe path, enabled-asset count, and asset list content: application/json: schema: type: object additionalProperties: true properties: path: type: string enabled_assets: type: integer assets: $ref: "#/components/schemas/LooseObject" /config: get: tags: [config] summary: Configuration inventory description: Runtime TOML configs, strategy weights, execution limits, and environment. responses: "200": description: Aggregated configuration inventory content: application/json: schema: $ref: "#/components/schemas/LooseObject" /ops: get: tags: [ops] summary: Operator command reference and HTTP surface map responses: "200": description: Operator commands, HTTP surfaces, docker, and safety notes content: application/json: schema: $ref: "#/components/schemas/LooseObject" /metrics: get: tags: [ops] summary: Prometheus exposition metrics responses: "200": description: Prometheus text exposition format (version 0.0.4) content: text/plain: schema: type: string /backtest: get: tags: [analytics] summary: On-demand backtest over a synthetic price path parameters: - name: steps in: query required: false description: Number of steps to simulate (default 60, clamped to 1..1000). schema: type: integer minimum: 1 maximum: 1000 default: 60 - name: fear_greed in: query required: false description: Fear & Greed value 0..100 driving the regime (default 60). schema: type: integer minimum: 0 maximum: 100 default: 60 - name: preset in: query required: false description: Strategy preset name (default "balanced"). schema: type: string default: balanced responses: "200": description: Backtest metrics and equity curve content: application/json: schema: $ref: "#/components/schemas/BacktestResponse" /walkforward: get: tags: [analytics] summary: On-demand walk-forward analysis across windows parameters: - name: windows in: query required: false description: Number of windows to evaluate (default 6, clamped to 1..24). schema: type: integer minimum: 1 maximum: 24 default: 6 - name: steps in: query required: false description: Steps per window (default 30, clamped to 1..500). schema: type: integer minimum: 1 maximum: 500 default: 30 - name: preset in: query required: false description: Strategy preset name (default "balanced"). schema: type: string default: balanced responses: "200": description: Per-window metrics and aggregate summary content: application/json: schema: type: object additionalProperties: true properties: preset: type: string windows: type: array items: $ref: "#/components/schemas/LooseObject" aggregate: $ref: "#/components/schemas/LooseObject" /sweep: get: tags: [analytics] summary: Sentiment sweep across fear/greed readings parameters: - name: steps in: query required: false description: Steps to simulate per reading (default 40, clamped to 1..500). schema: type: integer minimum: 1 maximum: 500 default: 40 - name: fear_greed in: query required: false description: Comma-separated fear/greed readings (default "20,40,60,80", max 12 readings). schema: type: string default: "20,40,60,80" - name: preset in: query required: false description: Strategy preset name (default "balanced"). schema: type: string default: balanced responses: "200": description: Comparison row per fear/greed reading content: application/json: schema: type: object additionalProperties: true properties: steps: type: integer preset: type: string rows: type: array items: $ref: "#/components/schemas/LooseObject" /history: get: tags: [reports] summary: Live NAV equity curve description: NAV series assembled from recent PortfolioReconciled events in chronological order. responses: "200": description: NAV points and count content: application/json: schema: type: object additionalProperties: true properties: points: type: array items: type: object additionalProperties: true properties: timestamp: type: string nav_usd: type: string count: type: integer error: type: string /audit-manifest: get: tags: [reports] summary: Audit manifest of artifacts and integrity hashes responses: "200": description: Manifest of audit artifacts and their hashes content: application/json: schema: $ref: "#/components/schemas/LooseObject" /agent-services: get: tags: [agent] summary: Agent service catalog responses: "200": description: Services advertised by the agent content: application/json: schema: $ref: "#/components/schemas/LooseObject" /agent-card: get: tags: [agent] summary: Agent card (A2A-style capability descriptor) responses: "200": description: Agent identity, capabilities, and endpoints content: application/json: schema: $ref: "#/components/schemas/LooseObject" /.well-known/agent-card.json: get: tags: [agent] summary: Well-known agent card discovery endpoint responses: "200": description: Agent card served at the well-known discovery path content: application/json: schema: $ref: "#/components/schemas/LooseObject" /bnb-sdk: get: tags: [agent] summary: BNB chain SDK surface and integration metadata responses: "200": description: BNB SDK capabilities and integration details content: application/json: schema: $ref: "#/components/schemas/LooseObject" /sdk-catalog: get: tags: [agent] summary: Catalog of SDKs and integrations used by the agent responses: "200": description: SDK catalog entries content: application/json: schema: $ref: "#/components/schemas/LooseObject" /signing-policy: get: tags: [config] summary: Transaction signing policy and constraints responses: "200": description: Signing policy rules and limits content: application/json: schema: $ref: "#/components/schemas/LooseObject" /exposure: get: tags: [portfolio] summary: Current portfolio exposure breakdown responses: "200": description: Exposure by asset and category content: application/json: schema: $ref: "#/components/schemas/LooseObject" /commerce: get: tags: [agent] summary: Commerce and monetization surface responses: "200": description: Commerce metadata and offerings content: application/json: schema: $ref: "#/components/schemas/LooseObject" /playbook: get: tags: [ops] summary: Operator playbook and runbook reference responses: "200": description: Playbook entries and procedures content: application/json: schema: $ref: "#/components/schemas/LooseObject" /prizes: get: tags: [ops] summary: Competition prize tracking responses: "200": description: Prize categories and status content: application/json: schema: $ref: "#/components/schemas/LooseObject" /briefing: get: tags: [reports] summary: Operator briefing summary responses: "200": description: Aggregated briefing payload content: application/json: schema: $ref: "#/components/schemas/LooseObject" /budget: get: tags: [ops] summary: Budget and spend tracking responses: "200": description: Budget allocations and consumption content: application/json: schema: $ref: "#/components/schemas/LooseObject" /heartbeat: get: tags: [ops] summary: Agent heartbeat and liveness signal responses: "200": description: Heartbeat status and timing content: application/json: schema: $ref: "#/components/schemas/LooseObject" /wallet-controls: get: tags: [config] summary: Wallet control settings and guardrails responses: "200": description: Wallet controls and enforcement settings content: application/json: schema: $ref: "#/components/schemas/LooseObject" /assets: get: tags: [trading] summary: Tradable asset metadata responses: "200": description: Asset list with metadata content: application/json: schema: $ref: "#/components/schemas/LooseObject" /costs: get: tags: [trading] summary: Estimated execution costs across routes parameters: - name: amount_usd in: query required: false description: Optional notional (USD) applied to every configured route. schema: type: number responses: "200": description: Per-route cost estimates, or an error object content: application/json: schema: $ref: "#/components/schemas/LooseObject" /drift: get: tags: [portfolio] summary: Allocation drift versus targets responses: "200": description: Drift per asset relative to target weights content: application/json: schema: $ref: "#/components/schemas/LooseObject" /exit-triggers: get: tags: [portfolio] summary: Configured exit triggers and their state responses: "200": description: Exit trigger definitions and current evaluation content: application/json: schema: $ref: "#/components/schemas/LooseObject" /indicators: get: tags: [trading] summary: Technical indicators over a synthetic close series parameters: - name: symbol in: query required: false description: Asset symbol to chart (default "WBNB"). schema: type: string default: WBNB - name: steps in: query required: false description: Number of close samples to generate (default 60, clamped 10..500). schema: type: integer minimum: 10 maximum: 500 default: 60 responses: "200": description: EMA, SMA, RSI, MACD, and Bollinger bands over the series content: application/json: schema: $ref: "#/components/schemas/LooseObject" /job-simulator: get: tags: [analytics] summary: Job execution simulator responses: "200": description: Simulated job run output content: application/json: schema: $ref: "#/components/schemas/LooseObject" /liquidity: get: tags: [trading] summary: Liquidity depth and availability per route responses: "200": description: Liquidity metrics by asset/route content: application/json: schema: $ref: "#/components/schemas/LooseObject" /mandates: get: tags: [config] summary: Configured mandates and their compiled policies responses: "200": description: Mandate definitions and compiled policy references content: application/json: schema: $ref: "#/components/schemas/LooseObject" /trending: get: tags: [trading] summary: Trending assets and momentum signals responses: "200": description: Trending asset rankings content: application/json: schema: $ref: "#/components/schemas/LooseObject" /watchlist: get: tags: [trading] summary: Watchlist of candidate assets parameters: - name: limit in: query required: false description: Number of rows to return (default 12, clamped 1..50). schema: type: integer minimum: 1 maximum: 50 default: 12 responses: "200": description: Watchlist rows, or an error object content: application/json: schema: $ref: "#/components/schemas/LooseObject" /quotes: get: tags: [trading] summary: Sample swap quotes across routes parameters: - name: amount_usd in: query required: false description: Notional (USD) used for every sample route. schema: type: number responses: "200": description: Quote samples per route, or an error object content: application/json: schema: $ref: "#/components/schemas/LooseObject" /optimize: get: tags: [analytics] summary: Portfolio allocation across optimization methods parameters: - name: symbols in: query required: false description: Comma-separated symbols (default "CAKE,WBNB,BTCB"). schema: type: string default: "CAKE,WBNB,BTCB" - name: scores in: query required: false description: Comma-separated scores aligned to symbols. schema: type: string - name: vols in: query required: false description: Comma-separated volatilities aligned to symbols. schema: type: string responses: "200": description: Weights for equal-weight, score-proportional, inverse-vol, and risk-parity methods content: application/json: schema: $ref: "#/components/schemas/LooseObject" /experiments: get: tags: [analytics] summary: Strategy experiment results responses: "200": description: Experiment definitions and outcomes content: application/json: schema: $ref: "#/components/schemas/LooseObject" /skill: get: tags: [agent] summary: Agent skill descriptor and metadata responses: "200": description: Skill manifest and capabilities content: application/json: schema: $ref: "#/components/schemas/LooseObject" /scorecard: get: tags: [reports] summary: Performance and compliance scorecard responses: "200": description: Scorecard metrics across categories content: application/json: schema: $ref: "#/components/schemas/LooseObject" /compete: get: tags: [reports] summary: Competition standing and submission readiness responses: "200": description: Competition metrics and standing content: application/json: schema: $ref: "#/components/schemas/LooseObject" /regime: get: tags: [portfolio] summary: Current market regime classification responses: "200": description: Regime label and supporting signals content: application/json: schema: $ref: "#/components/schemas/LooseObject" /funding: get: tags: [trading] summary: Funding-rate snapshot across markets responses: "200": description: Funding rates by market content: application/json: schema: $ref: "#/components/schemas/LooseObject" /rebalance: get: tags: [analytics] summary: What-if rebalance plan for a preset parameters: - name: preset in: query required: false description: Strategy preset name (default "balanced"). schema: type: string default: balanced - name: nav_usd in: query required: false description: Override NAV (USD) for what-if sizing. schema: type: string responses: "200": description: Proposed rebalance trades, or an error object content: application/json: schema: $ref: "#/components/schemas/LooseObject" /scenarios: get: tags: [analytics] summary: Stress-test scenario outcomes responses: "200": description: Scenario definitions and projected outcomes content: application/json: schema: $ref: "#/components/schemas/LooseObject" /journal: get: tags: [reports] summary: Decision journal projection of the agent's reasoning description: >- Reconstructs the agent's per-cycle reasoning chain from the append-only event log: market snapshot, classified regime, scored assets, planned orders, risk decisions, confirmed trades, and the reconciled book. Events before the first cycle are folded into a leading "startup" slice so nothing is dropped. Read-only. responses: "200": description: Cycle-by-cycle decision journal plus aggregate counts content: application/json: schema: $ref: "#/components/schemas/JournalResponse" /ensemble: get: tags: [analytics] summary: Regime-routed ensemble meta-allocator (static view) description: >- Returns the static configuration of the four-skill regime ensemble: the member skills, the per-regime blend weights, the reserve symbol, the max risk allocation, and the currently classified regime with its active weights. The live blended book is exposed separately under /ensemble/live (PLAN_V2 Track C). Read-only. responses: "200": description: Ensemble configuration and current regime weights content: application/json: schema: $ref: "#/components/schemas/EnsembleResponse" /skills: get: tags: [analytics] summary: Track-2 strategy skill catalog description: >- Typed projection of skills/INDEX.json: the count of registered Track-2 strategy skills, their ids, and the full per-skill index entries (summary, regimes, inputs, eligible universe size, examples count, and spec file path). Read-only. responses: "200": description: Skill count, ids, and the full index entries content: application/json: schema: $ref: "#/components/schemas/SkillsResponse" /version: get: tags: [ops] summary: Service version, build target, and uptime description: >- Reports the API service name and semantic version (from the crate manifest), the build target (arch-os), the run mode (GUARDRAIL_MODE, default "paper"), and process uptime in seconds and human-readable form. Read-only. responses: "200": description: Version, build target, mode, and uptime content: application/json: schema: $ref: "#/components/schemas/VersionResponse" /stream: get: tags: [realtime] summary: Server-Sent Events stream of agent events description: >- A text/event-stream of live AgentEvents tailed from the append-only event log (cross-process). Each frame is `event: agent_event` with a JSON StoredEvent data payload, plus periodic keep-alive comments. Read-only. responses: "200": description: SSE stream of agent events content: text/event-stream: schema: type: string /proof/verify: get: tags: [proof] summary: Independent proof verification description: >- Recomputes the agent's policy hash (sha256 of the risk policy file) and validates the competition contract, wallet, BscScan URL, and registration tx formats against data/run_report.json. Mirrors clients/proof-verifier. Read-only. responses: "200": description: Verification result (passed + per-check status) content: application/json: schema: type: object /skills/{id}: get: tags: [skills] summary: Skill detail description: Catalog entry + parsed strategy-spec summary for one skill. parameters: - name: id in: path required: true schema: type: string responses: "200": description: Skill detail content: application/json: schema: type: object /skills/{id}/backtest: get: tags: [skills] summary: Backtest a skill description: >- Runs the real strategy + risk + portfolio pipeline over the eligible universe with the requested preset, contextualized by the skill. Read-only. parameters: - name: id in: path required: true schema: type: string - name: preset in: query required: false schema: type: string responses: "200": description: Backtest metrics content: application/json: schema: type: object /snapshots: get: tags: [data] summary: Persisted market-snapshot history summary description: >- Read-only summary of the periodic market snapshots persisted by the agent (Track G). The agent writes one row per ingestion cycle to the append-only snapshot store under data/snapshots/; this route projects that history into a compact, chartable summary: how many snapshots are retained, the time span they cover, the most recent snapshot's regime and per-asset prices, and a lightweight series suitable for plotting NAV or price history without replaying the full event log. The route never ingests, mutates, or backfills data — it only reads what the agent has already persisted, so it is safe to call repeatedly and remains deterministic in paper/offline mode. parameters: - name: limit in: query required: false description: >- Maximum number of most-recent snapshots to include in the series (the summary counters still reflect the full retained history). schema: type: integer minimum: 1 default: 100 responses: "200": description: Snapshot history summary content: application/json: schema: $ref: "#/components/schemas/SnapshotsResponse" "503": description: >- The snapshot store is not yet initialized (no snapshots have been persisted in this environment). content: application/json: schema: $ref: "#/components/schemas/LooseObject" /ensemble/live: get: tags: [analytics] summary: Live ensemble routing from the event log description: >- Returns the per-skill ensemble weights the running agent actually computed for the most recent classified regime, extracted from the latest RegimeClassified event (distinct from /ensemble, which recomputes from the embedded config). Read-only; degrades to {available:false} with no data. responses: "200": description: Live ensemble routing content: application/json: schema: type: object components: schemas: LooseObject: type: object additionalProperties: true description: >- Loose object schema. The API returns dynamic JSON shapes assembled from event payloads and run reports; fields vary and are not exhaustively modeled here. SnapshotsResponse: type: object additionalProperties: true description: >- Shape of the /snapshots persisted market-snapshot history summary (Track G). Counters describe the full retained history; the series carries up to `limit` most-recent entries for charting. properties: count: type: integer description: Total number of snapshots currently retained in the store. first_at: type: string description: Timestamp (RFC3339) of the oldest retained snapshot, if any. last_at: type: string description: Timestamp (RFC3339) of the most recent snapshot, if any. span_seconds: type: integer description: Seconds between the first and last retained snapshot. store_path: type: string description: Filesystem path of the append-only snapshot store. latest: allOf: - $ref: "#/components/schemas/LooseObject" description: >- The most recent snapshot: classified regime, fear/greed level, and per-asset prices at ingestion time. series: type: array description: >- Up to `limit` most-recent snapshot summaries (timestamp, regime, and a representative NAV/price point) suitable for plotting. items: $ref: "#/components/schemas/LooseObject" JournalResponse: type: object additionalProperties: true description: Shape of the /journal decision-journal projection. properties: total_events: type: integer total_cycles: type: integer run_ids: type: array items: type: string confirmed_trades_total: type: integer cycles: type: array items: $ref: "#/components/schemas/LooseObject" EnsembleResponse: type: object additionalProperties: true description: Shape of the /ensemble meta-allocator configuration view. properties: name: type: string version: type: string reserve_symbol: type: string max_risk_allocation_pct: type: number current_regime: type: string active_weights: type: object additionalProperties: true skills: type: array items: type: object additionalProperties: true properties: id: type: string label: type: string regimes: type: array items: type: object additionalProperties: true properties: regime: type: string weights: type: object additionalProperties: true SkillsResponse: type: object additionalProperties: true description: Shape of the /skills catalog projection. properties: index_path: type: string count: type: integer ids: type: array items: type: string skills: type: array items: $ref: "#/components/schemas/LooseObject" VersionResponse: type: object additionalProperties: true description: Shape of the /version response. properties: service: type: string version: type: string build_target: type: string mode: type: string uptime_seconds: type: integer uptime_human: type: string BacktestResponse: type: object additionalProperties: true description: Approximate shape of the /backtest response. properties: steps: type: integer preset: type: string fear_greed: type: integer starting_nav_usd: type: string final_nav_usd: type: string benchmark_return_pct: type: string excess_return_pct: type: string metrics: type: object additionalProperties: true properties: total_return_pct: type: string max_drawdown_pct: type: string trade_count: type: integer win_rate_pct: type: string profit_factor: type: string volatility_pct: type: string calmar_ratio: type: string equity_curve: type: array items: type: string error: type: string AlertsResponse: type: object additionalProperties: true description: Approximate shape of the /alerts response. properties: status: type: string enum: [clear, warning, critical] counts: type: object additionalProperties: true properties: critical: type: integer warning: type: integer total: type: integer alerts: type: array items: $ref: "#/components/schemas/LooseObject" inputs: type: object additionalProperties: true properties: report_age_seconds: type: integer total_drawdown_pct: type: number drawdown_soft_limit_pct: type: number drawdown_hard_limit_pct: type: number latest_slippage_pct: type: number slippage_limit_pct: type: number kill_switch: type: boolean daily_trade_executed: type: boolean events_visible: type: integer trades_visible: type: integer report_path: type: string