{
  "openapi": "3.1.0",
  "info": {
    "title": "DoNotAct Risk Gateway v1.2",
    "version": "1.2.0",
    "description": "Fail-closed Risk Gateway for prediction-market agents. Checks dispute lifecycle, resolution ambiguity, public-book capacity and requested action context before an agent acts. No execution, custody, private keys, signing or advice. Agent discovery: https://donotact.com/llms.txt, https://donotact.com/agent.json, https://donotact.com/docs/discovery."
  },
  "x-discovery": {
    "canonical_llms": "https://donotact.com/llms.txt",
    "well_known_llms": "https://donotact.com/.well-known/llms.txt",
    "full_context": "https://donotact.com/llms-full.txt",
    "agent_manifest": "https://donotact.com/agent.json",
    "discovery_docs": "https://donotact.com/docs/discovery",
    "sitemap": "https://donotact.com/sitemap.xml",
    "robots": "https://donotact.com/robots.txt",
    "link_header": "</llms.txt>; rel=\"service-desc\"; type=\"text/plain\"; title=\"DoNotAct llms.txt\", </.well-known/llms.txt>; rel=\"service-desc\"; type=\"text/plain\"; title=\"DoNotAct well-known llms.txt\", </agent.json>; rel=\"describedby\"; type=\"application/json\"; title=\"DoNotAct agent manifest\", </openapi.json>; rel=\"service-desc\"; type=\"application/vnd.oai.openapi+json\"; title=\"DoNotAct OpenAPI\"",
    "version": "2026-06-18.1"
  },
  "paths": {
    "/health": {
      "get": {
        "responses": {
          "200": {
            "description": "Health",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/preflight/{venue}/{market_id}": {
      "get": {
        "summary": "Action-aware preflight Risk Gateway",
        "description": "Evaluates requested action context against public market evidence, conservative book-capacity diagnostics, venue metadata and dispute/resolution evidence. Returns READY, DO_NOT_ACT or INSUFFICIENT_EVIDENCE without execution, custody, signing or advice.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Venue"
          },
          {
            "$ref": "#/components/parameters/MarketId"
          },
          {
            "$ref": "#/components/parameters/Intent"
          },
          {
            "$ref": "#/components/parameters/Side"
          },
          {
            "$ref": "#/components/parameters/NotionalEur"
          },
          {
            "$ref": "#/components/parameters/NotionalUsd"
          },
          {
            "$ref": "#/components/parameters/MaxSlippageBps"
          },
          {
            "$ref": "#/components/parameters/Policy"
          },
          {
            "$ref": "#/components/parameters/Horizon"
          }
        ],
        "responses": {
          "200": {
            "description": "Preflight",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightResponse"
                }
              }
            }
          },
          "404": {
            "description": "Venue or market not found"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/v1/resolution-risk/{venue}/{market_id}": {
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/Venue"
          },
          {
            "$ref": "#/components/parameters/MarketId"
          }
        ],
        "responses": {
          "200": {
            "description": "Resolution risk",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolutionRiskResponse"
                }
              }
            }
          },
          "404": {
            "description": "Venue or market not found"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/v1/dispute/{venue}/{market_id}": {
      "get": {
        "parameters": [
          {
            "$ref": "#/components/parameters/Venue"
          },
          {
            "$ref": "#/components/parameters/MarketId"
          }
        ],
        "responses": {
          "200": {
            "description": "UMA dispute lifecycle intelligence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DisputeResponse"
                }
              }
            }
          },
          "404": {
            "description": "Venue or market not found"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/v1/watchlist": {
      "post": {
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "Add or update a market watchlist item",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WatchlistRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchlistCreateResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "403": {
            "description": "Endpoint not entitled"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      },
      "get": {
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "List active watchlist items",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchlistListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "403": {
            "description": "Endpoint not entitled"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/v1/watchlist/{venue}/{market_id}": {
      "delete": {
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "Deactivate one watchlist item",
        "parameters": [
          {
            "$ref": "#/components/parameters/Venue"
          },
          {
            "$ref": "#/components/parameters/MarketId"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchlistDeleteResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "403": {
            "description": "Endpoint not entitled"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/v1/alerts": {
      "get": {
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "Read early-warning alert feed and delivery status",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertFeedResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "403": {
            "description": "Endpoint not entitled"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/x402/tx/v1/dispute/{venue}/{market_id}": {
      "get": {
        "summary": "Paid dispute diagnostic via Polygon USDC transaction hash",
        "description": "Compatibility alias for agents that can make a Polygon USDC transfer but cannot yet construct a standard x402 v2 PAYMENT-SIGNATURE. The canonical route /x402/v1/dispute/{venue}/{market_id} also accepts X-402-Tx-Hash.",
        "operationId": "get_x402_tx_dispute",
        "parameters": [
          {
            "name": "venue",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "polymarket"
              ]
            },
            "description": "Prediction market venue. Only polymarket is currently supported for this route."
          },
          {
            "name": "market_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Polymarket market id."
          },
          {
            "name": "X-402-Tx-Hash",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[a-fA-F0-9]{64}$"
            },
            "description": "Confirmed Polygon USDC transaction hash paying the exact configured amount to DoNotAct. Each hash can be used once."
          }
        ],
        "responses": {
          "200": {
            "description": "Payment verified and dispute diagnostic returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment hash missing or not accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "409": {
            "description": "Transaction hash already consumed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "Verification temporarily unavailable or service not configured.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-not-advice": true,
        "x-custody": false,
        "x-execution": false
      }
    },
    "/x402/v1/dispute/{venue}/{market_id}": {
      "get": {
        "summary": "Paid dispute diagnostic via canonical x402 machine-payment route",
        "description": "Canonical machine-payment route. Clients may retry with standard x402 v2 PAYMENT-SIGNATURE/x-payment, or send X-402-Tx-Hash after a confirmed exact Polygon USDC transfer. Transaction hashes are verified on-chain and consumed once.",
        "operationId": "get_x402_dispute",
        "parameters": [
          {
            "name": "venue",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "polymarket"
              ]
            },
            "description": "Prediction market venue."
          },
          {
            "name": "market_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Polymarket market id."
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Base64 x402 v2 PaymentPayload generated by a compatible client."
          },
          {
            "name": "x-payment",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Alternative x402 payment header accepted by middleware."
          },
          {
            "name": "X-402-Tx-Hash",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^0x[a-fA-F0-9]{64}$"
            },
            "description": "Polygon USDC transaction hash for agents that cannot construct x402 PaymentPayload. Verified on-chain and consumed once."
          }
        ],
        "responses": {
          "200": {
            "description": "Payment verified and dispute diagnostic returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "x402 payment required or not accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "503": {
            "description": "x402 settlement not configured.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "x-not-advice": true,
        "x-custody": false,
        "x-execution": false
      }
    },
    "/v1/receipts/verify": {
      "post": {
        "summary": "Verify a DoNotAct signed receipt payload",
        "description": "Public read-only helper. Submit a full diagnostic response including its receipt object. The endpoint verifies the Ed25519 receipt against the current public receipt key. It does not create keys, charge, trade, custody funds, sign orders, or mutate account state.",
        "operationId": "verifyReceipt",
        "tags": [
          "receipts"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true,
                "description": "Full DoNotAct diagnostic response including a receipt object."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receipt verification result. valid=false is returned for missing, unsigned, malformed, tampered, or wrong-key receipts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "schema_version",
                    "valid",
                    "reason",
                    "verification",
                    "receipt_key",
                    "not_advice"
                  ],
                  "properties": {
                    "schema_version": {
                      "type": "string",
                      "const": "donotact_receipt_verification_response_v1"
                    },
                    "valid": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "verification": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "receipt_key": {
                      "type": "object",
                      "required": [
                        "status",
                        "algorithm",
                        "key_id"
                      ],
                      "properties": {
                        "status": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "algorithm": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "key_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "additionalProperties": false
                    },
                    "not_advice": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or non-object payload."
          }
        }
      }
    },
    "/v1/webhooks/test": {
      "post": {
        "summary": "Send one synthetic webhook test event",
        "description": "Authenticated integration test for webhook delivery. It does not create a watchlist item, store the URL, or send a real alert.",
        "operationId": "testWebhookDelivery",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookTestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook delivery attempted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsafe webhook URL"
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "429": {
            "description": "Webhook test rate limited"
          }
        }
      }
    },
    "/v1/proof-root/verify": {
      "post": {
        "summary": "Verify a public proof-root manifest",
        "description": "Public verifier for the signed Merkle manifest exposed at /proof-root.json. This verifies tamper evidence and signature; it does not claim OTS or blockchain timestamp anchoring while ots_status is not_anchored.",
        "operationId": "verifyProofRoot",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofRootVerifyResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON manifest"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Venue": {
        "name": "venue",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "enum": [
            "polymarket",
            "kalshi"
          ]
        }
      },
      "MarketId": {
        "name": "market_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "Intent": {
        "name": "intent",
        "in": "query",
        "required": false,
        "description": "Optional action intent for the Risk Gateway v1.2 preflight extension.",
        "schema": {
          "type": "string",
          "enum": [
            "enter",
            "exit",
            "hold",
            "redeem",
            "monitor"
          ],
          "default": "monitor"
        }
      },
      "Side": {
        "name": "side",
        "in": "query",
        "required": false,
        "description": "Optional action side for the Risk Gateway v1.2 preflight extension.",
        "schema": {
          "type": "string",
          "enum": [
            "buy_yes",
            "buy_no",
            "sell_yes",
            "sell_no",
            "none"
          ],
          "default": "none"
        }
      },
      "NotionalEur": {
        "name": "notional_eur",
        "in": "query",
        "required": false,
        "description": "Optional EUR notional context. It is context only until an explicit FX source is available.",
        "schema": {
          "type": "number",
          "minimum": 0
        }
      },
      "NotionalUsd": {
        "name": "notional_usd",
        "in": "query",
        "required": false,
        "description": "Optional USD/USDC notional context for action-aware risk checks.",
        "schema": {
          "type": "number",
          "minimum": 0
        }
      },
      "MaxSlippageBps": {
        "name": "max_slippage_bps",
        "in": "query",
        "required": false,
        "description": "Optional maximum tolerated slippage in basis points for action-aware risk checks.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      },
      "Policy": {
        "name": "policy",
        "in": "query",
        "required": false,
        "description": "Risk Gateway policy profile.",
        "schema": {
          "type": "string",
          "enum": [
            "conservative",
            "balanced",
            "aggressive"
          ],
          "default": "balanced"
        }
      },
      "Horizon": {
        "name": "horizon",
        "in": "query",
        "required": false,
        "description": "Optional action horizon for risk context.",
        "schema": {
          "type": "string",
          "enum": [
            "intraday",
            "hold_to_resolution",
            "unknown"
          ],
          "default": "unknown"
        }
      }
    },
    "schemas": {
      "Verdict": {
        "type": "string",
        "enum": [
          "READY",
          "DO_NOT_ACT",
          "INSUFFICIENT_EVIDENCE"
        ]
      },
      "NoTradeReason": {
        "type": "object",
        "required": [
          "class",
          "code",
          "message",
          "advisory"
        ],
        "properties": {
          "class": {
            "type": "string",
            "enum": [
              "R1_WALLET_BINDING",
              "R2_ALLOWANCE_BALANCE",
              "R3_TICK_PRECISION",
              "R4_METADATA_READINESS",
              "R5_MARKET_STATE",
              "R6_BOOK_STALENESS_LIQUIDITY",
              "R7_VENUE_MODE",
              "R8_RESOLUTION_AMBIGUITY"
            ]
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "advisory": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "RiskGatewayDecision": {
        "type": "string",
        "enum": [
          "READY",
          "CAUTION",
          "DO_NOT_ACT",
          "INSUFFICIENT_EVIDENCE"
        ]
      },
      "RiskGatewayReason": {
        "type": "object",
        "required": [
          "class",
          "code",
          "message",
          "advisory"
        ],
        "properties": {
          "class": {
            "type": "string",
            "enum": [
              "R1_WALLET_BINDING",
              "R2_ALLOWANCE_BALANCE",
              "R3_TICK_PRECISION",
              "R4_METADATA_READINESS",
              "R5_MARKET_STATE",
              "R6_BOOK_STALENESS_LIQUIDITY",
              "R7_EXIT_LIQUIDITY",
              "R8_RESOLUTION_AMBIGUITY",
              "R9_INSUFFICIENT_EVIDENCE",
              "R10_CLIENT_POLICY",
              "R11_CROSS_VENUE_DIVERGENCE"
            ]
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "advisory": {
            "type": "boolean"
          },
          "component": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "RiskGatewayComponentScores": {
        "type": "object",
        "properties": {
          "action_readiness": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100
          },
          "exit_liquidity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100
          },
          "resolution_integrity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100
          },
          "evidence_quality": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100
          }
        },
        "additionalProperties": false
      },
      "RiskGatewaySafeOperatingLimits": {
        "type": "object",
        "properties": {
          "max_notional_usd": {
            "type": [
              "number",
              "string",
              "null"
            ],
            "minimum": 0
          },
          "max_notional_eur": {
            "type": [
              "number",
              "string",
              "null"
            ],
            "minimum": 0
          },
          "max_slippage_bps": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_order_age_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "basis": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "RiskGatewayOperationalSummary": {
        "type": "object",
        "required": [
          "state",
          "agent_action",
          "headline",
          "size_status"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "ready",
              "caution",
              "block",
              "unknown"
            ]
          },
          "agent_action": {
            "type": "string",
            "enum": [
              "continue",
              "review",
              "halt",
              "retry_later"
            ]
          },
          "headline": {
            "type": "string"
          },
          "size_status": {
            "type": "string",
            "enum": [
              "within_limit",
              "exceeds_limit",
              "not_evaluated",
              "unknown"
            ]
          },
          "primary_reason_class": {
            "type": [
              "string",
              "null"
            ]
          },
          "primary_reason_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "requested_notional_usd": {
            "type": [
              "number",
              "string",
              "null"
            ],
            "minimum": 0
          },
          "safe_notional_usd": {
            "type": [
              "number",
              "string",
              "null"
            ],
            "minimum": 0
          },
          "requested_slippage_bps": {
            "type": [
              "number",
              "string",
              "null"
            ],
            "minimum": 0
          },
          "operator_action": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "RiskGatewayFreshnessEvidence": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "age_ms": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "status": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "RiskGatewayContext": {
        "type": "object",
        "properties": {
          "intent": {
            "type": "string"
          },
          "side": {
            "type": "string"
          },
          "notional_eur": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0
          },
          "notional_usd": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0
          },
          "max_slippage_bps": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "policy": {
            "type": "string"
          },
          "horizon": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "BaseDiagnosticResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "venue",
          "market_id",
          "as_of",
          "verdict",
          "checks_evaluated",
          "no_trade_reasons",
          "what_would_change_this",
          "notes",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string"
          },
          "venue": {
            "type": "string",
            "enum": [
              "polymarket",
              "kalshi"
            ]
          },
          "market_id": {
            "type": "string"
          },
          "as_of": {
            "type": "string"
          },
          "verdict": {
            "$ref": "#/components/schemas/Verdict"
          },
          "checks_evaluated": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "no_trade_reasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NoTradeReason"
            }
          },
          "what_would_change_this": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "not_advice": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "PreflightResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseDiagnosticResponse"
          },
          {
            "type": "object",
            "required": [
              "wallet_binding_risk",
              "venue_rule_changes_recent"
            ],
            "properties": {
              "wallet_binding_risk": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "venue_rule_changes_recent": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "risk_gateway_schema_version": {
                "type": "string"
              },
              "risk_gateway_context": {
                "$ref": "#/components/schemas/RiskGatewayContext"
              },
              "decision": {
                "$ref": "#/components/schemas/RiskGatewayDecision"
              },
              "decision_type": {
                "type": "string",
                "enum": [
                  "operational_guardrail"
                ]
              },
              "risk_score": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 100
              },
              "component_scores": {
                "$ref": "#/components/schemas/RiskGatewayComponentScores"
              },
              "blocking_reasons": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayReason"
                }
              },
              "warning_reasons": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayReason"
                }
              },
              "repair_hints": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "safe_operating_limits": {
                "$ref": "#/components/schemas/RiskGatewaySafeOperatingLimits"
              },
              "operational_summary": {
                "$ref": "#/components/schemas/RiskGatewayOperationalSummary"
              },
              "freshness": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayFreshnessEvidence"
                }
              },
              "evidence_refs": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "ruleset_version": {
                "type": "string"
              },
              "fail_closed": {
                "type": "boolean"
              },
              "risk_factors": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayFactor"
                },
                "description": "Deduplicated factors from blocking and warning evidence, optimized for agent routing without parsing reason text."
              },
              "blocking_factors": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayFactor"
                },
                "description": "Risk factors that currently block the requested action."
              },
              "warning_factors": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayFactor"
                },
                "description": "Risk factors that require review but do not block under the supplied policy."
              },
              "confidence_score": {
                "type": [
                  "number",
                  "null"
                ],
                "minimum": 0,
                "maximum": 1,
                "description": "Evidence-completeness score for the diagnostic response. This is not an accuracy, profit, edge, or outcome-probability claim."
              },
              "confidence_score_basis": {
                "type": "string",
                "enum": [
                  "evidence_completeness_not_outcome_probability"
                ]
              },
              "liquidity_confidence_score": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 100,
                "description": "Request-specific confidence in public-book liquidity evidence. Null when side, notional or fresh two-sided book evidence is missing."
              },
              "liquidity_confidence_status": {
                "type": "string",
                "enum": [
                  "high",
                  "medium",
                  "low",
                  "unknown"
                ],
                "description": "Coarse liquidity-confidence band derived from live CLOB depth, freshness, spread, requested slippage and safe size."
              },
              "liquidity_confidence_basis": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Machine-readable evidence basis used for liquidity_confidence_score."
              },
              "evidence_set": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RiskGatewayEvidenceItem"
                },
                "description": "Structured evidence used by the Risk Gateway decision, suitable for agent audit logs."
              },
              "risk_factor_bitmap": {
                "type": "integer",
                "minimum": 0,
                "description": "Stable bitmask derived from risk_factors for agents that need compact routing without parsing text. Bit positions are defined by risk_factor_bit_index."
              },
              "risk_factor_bitmap_hex": {
                "type": "string",
                "pattern": "^0x[0-9a-f]+$",
                "description": "Hex representation of risk_factor_bitmap."
              },
              "risk_factor_bit_index": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer",
                  "minimum": 0
                },
                "description": "Stable mapping of RiskGatewayFactor names to bit positions used by risk_factor_bitmap."
              }
            }
          }
        ]
      },
      "ResolutionRiskResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseDiagnosticResponse"
          },
          {
            "type": "object",
            "required": [
              "resolution"
            ],
            "properties": {
              "resolution": {
                "type": "object",
                "required": [
                  "rule_text",
                  "resolution_source",
                  "resolution_mechanism",
                  "ambiguity_flags",
                  "dispute_risk"
                ],
                "properties": {
                  "rule_text": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "resolution_source": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "resolution_mechanism": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "ambiguity_flags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "dispute_risk": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        ]
      },
      "DisputeResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BaseDiagnosticResponse"
          },
          {
            "type": "object",
            "required": [
              "dispute",
              "early_warning",
              "ledger"
            ],
            "properties": {
              "dispute": {
                "type": "object",
                "required": [
                  "lifecycle_state",
                  "status_history",
                  "has_disputed_history",
                  "evidence_status",
                  "source_refs"
                ],
                "properties": {
                  "lifecycle_state": {
                    "type": "string",
                    "enum": [
                      "unknown",
                      "none",
                      "proposed",
                      "disputed",
                      "dvm_vote",
                      "resolved"
                    ]
                  },
                  "raw_lifecycle_status": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status_history": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "has_disputed_history": {
                    "type": "boolean"
                  },
                  "question_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "condition_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "liveness_deadline_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "resolved_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "resolved_outcome": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "evidence_status": {
                    "type": "string"
                  },
                  "source_refs": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                },
                "additionalProperties": false
              },
              "early_warning": {
                "type": "object",
                "required": [
                  "prepared_for_m3",
                  "first_observation",
                  "previous_status_history",
                  "new_statuses_since_last_refresh",
                  "new_disputed_detected"
                ],
                "properties": {
                  "prepared_for_m3": {
                    "type": "boolean"
                  },
                  "first_observation": {
                    "type": "boolean"
                  },
                  "previous_status_history": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "new_statuses_since_last_refresh": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "new_disputed_detected": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "ledger": {
                "type": "object",
                "required": [
                  "status",
                  "event_id"
                ],
                "properties": {
                  "status": {
                    "type": "string"
                  },
                  "event_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        ]
      },
      "HealthResponse": {
        "type": "object",
        "required": [
          "status",
          "service",
          "version",
          "as_of"
        ],
        "properties": {
          "status": {
            "type": "string"
          },
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "as_of": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "WatchlistRequest": {
        "type": "object",
        "required": [
          "venue",
          "market_id"
        ],
        "properties": {
          "venue": {
            "type": "string",
            "enum": [
              "polymarket",
              "kalshi"
            ]
          },
          "market_id": {
            "type": "string",
            "minLength": 1
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048,
            "description": "Optional HTTP/HTTPS endpoint for early-warning push delivery."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 254,
            "description": "Optional email target. Email sending may be not_configured until enabled."
          }
        },
        "additionalProperties": false
      },
      "WatchlistItem": {
        "type": "object",
        "required": [
          "id",
          "venue",
          "market_id",
          "channels",
          "webhook_configured",
          "email_configured",
          "active"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "venue": {
            "type": "string"
          },
          "market_id": {
            "type": "string"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "webhook_configured": {
            "type": "boolean"
          },
          "email_configured": {
            "type": "boolean"
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "InitialAlertStatus": {
        "type": "object",
        "required": [
          "status",
          "queued_alerts",
          "suppressed_duplicate_alerts"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "duplicate_suppressed",
              "not_needed",
              "not_applicable",
              "unavailable"
            ]
          },
          "lifecycle_state": {
            "type": "string"
          },
          "has_disputed_history": {
            "type": "boolean"
          },
          "queued_alerts": {
            "type": "integer"
          },
          "suppressed_duplicate_alerts": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "WatchlistCreateResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "status",
          "item",
          "initial_alert",
          "delivery",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "donotact_watchlist_v1"
          },
          "status": {
            "type": "string"
          },
          "item": {
            "$ref": "#/components/schemas/WatchlistItem"
          },
          "initial_alert": {
            "$ref": "#/components/schemas/InitialAlertStatus"
          },
          "delivery": {
            "type": "object",
            "properties": {
              "api_feed": {
                "type": "boolean"
              },
              "webhook_configured": {
                "type": "boolean"
              },
              "email_configured": {
                "type": "boolean"
              },
              "external_delivery_started": {
                "type": "boolean"
              }
            },
            "additionalProperties": true
          },
          "not_advice": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "WatchlistListResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "items",
          "count",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "donotact_watchlist_v1"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WatchlistItem"
            }
          },
          "count": {
            "type": "integer"
          },
          "not_advice": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "WatchlistDeleteResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "venue",
          "market_id",
          "deleted",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "donotact_watchlist_delete_v1"
          },
          "venue": {
            "type": "string"
          },
          "market_id": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean"
          },
          "not_advice": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "DeliverySummary": {
        "type": "object",
        "required": [
          "state",
          "counts"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "empty",
              "has_failures",
              "has_queued",
              "all_sent",
              "not_configured",
              "mixed"
            ]
          },
          "counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          }
        },
        "additionalProperties": false
      },
      "AlertEvent": {
        "type": "object",
        "required": [
          "id",
          "venue",
          "market_id",
          "alert_type",
          "lifecycle_state",
          "transition_status",
          "payload",
          "webhook_delivery_status",
          "email_delivery_status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "venue": {
            "type": "string"
          },
          "market_id": {
            "type": "string"
          },
          "alert_type": {
            "type": "string",
            "enum": [
              "uma_dispute_detected",
              "uma_lifecycle_transition",
              "uma_dispute_already_active"
            ]
          },
          "lifecycle_state": {
            "type": "string"
          },
          "transition_status": {
            "type": "string"
          },
          "ledger_event_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "status_history": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "payload": {
            "type": "object",
            "additionalProperties": true
          },
          "delivery_status": {
            "type": "string"
          },
          "webhook_delivery_status": {
            "type": "string",
            "enum": [
              "queued",
              "sent",
              "failed",
              "not_configured"
            ]
          },
          "webhook_http_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "webhook_delivery_attempts": {
            "type": "integer"
          },
          "webhook_last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "webhook_delivered_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "email_delivery_status": {
            "type": "string"
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": true
      },
      "AlertFeedResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "alerts",
          "count",
          "delivery",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "donotact_alert_feed_v1"
          },
          "alerts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AlertEvent"
            }
          },
          "count": {
            "type": "integer"
          },
          "delivery": {
            "type": "object",
            "properties": {
              "api_feed": {
                "type": "boolean"
              },
              "webhook_delivery": {
                "$ref": "#/components/schemas/DeliverySummary"
              },
              "email_delivery": {
                "$ref": "#/components/schemas/DeliverySummary"
              }
            },
            "additionalProperties": false
          },
          "not_advice": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "RiskGatewayFactor": {
        "type": "string",
        "enum": [
          "wallet_binding",
          "allowance_balance",
          "tick_precision",
          "metadata_readiness",
          "market_state",
          "book_staleness",
          "book_liquidity",
          "exit_liquidity",
          "slippage",
          "resolution_ambiguity",
          "dispute",
          "insufficient_evidence",
          "venue_constraint",
          "cross_venue_divergence",
          "unknown"
        ],
        "description": "Stable machine-readable risk factor for routing, dashboards, and agent policy decisions."
      },
      "RiskGatewayEvidenceItem": {
        "type": "object",
        "required": [
          "id",
          "source",
          "status",
          "confidence",
          "freshness_status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable evidence identifier used by the diagnostic decision."
          },
          "component": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "action_readiness",
              "exit_liquidity",
              "resolution_integrity",
              "venue_constraint_risk",
              "evidence_quality",
              null
            ]
          },
          "source": {
            "type": "string",
            "description": "Public or internal diagnostic source category, never a secret."
          },
          "status": {
            "type": "string",
            "enum": [
              "present",
              "missing",
              "unknown"
            ]
          },
          "confidence": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "unknown"
            ],
            "description": "Confidence in evidence availability/interpretation, not an outcome probability."
          },
          "freshness_status": {
            "type": "string",
            "enum": [
              "fresh",
              "stale",
              "missing",
              "unknown"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "WebhookTestRequest": {
        "type": "object",
        "required": [
          "webhook_url"
        ],
        "properties": {
          "webhook_url": {
            "type": "string",
            "minLength": 8,
            "maxLength": 2048,
            "description": "HTTP(S) URL that should receive one synthetic DoNotAct webhook test event. Secrets must not be placed in query strings."
          },
          "venue": {
            "type": "string",
            "default": "polymarket",
            "maxLength": 32
          },
          "market_id": {
            "type": "string",
            "default": "580810",
            "maxLength": 128
          }
        },
        "additionalProperties": false
      },
      "WebhookTestResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "status",
          "http_status",
          "elapsed_ms",
          "payload_sha256",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "donotact_webhook_test_v1"
          },
          "status": {
            "type": "string",
            "enum": [
              "sent",
              "failed"
            ]
          },
          "http_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "elapsed_ms": {
            "type": "integer",
            "minimum": 0
          },
          "payload_sha256": {
            "type": "string"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "not_advice": {
            "type": "boolean",
            "const": true
          }
        },
        "additionalProperties": true
      },
      "ProofRootVerifyResponse": {
        "type": "object",
        "required": [
          "schema_version",
          "valid",
          "reason",
          "signature_valid",
          "tamper_evident",
          "ots_status",
          "not_advice"
        ],
        "properties": {
          "schema_version": {
            "type": "string",
            "const": "donotact_public_proof_root_verification_v0"
          },
          "valid": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "signature_valid": {
            "type": "boolean"
          },
          "tamper_evident": {
            "type": "boolean",
            "const": true
          },
          "ots_status": {
            "type": "string",
            "description": "not_anchored until an external timestamp anchor is published."
          },
          "merkle_root_sha256": {
            "type": [
              "string",
              "null"
            ]
          },
          "manifest_sha256": {
            "type": [
              "string",
              "null"
            ]
          },
          "entry_count": {
            "type": [
              "integer",
              "null"
            ]
          },
          "key_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "not_advice": {
            "type": "boolean",
            "const": true
          }
        },
        "additionalProperties": true
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Do Not Act API key. Never expose in public logs or prompts."
      }
    }
  }
}
