{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/t0ll-xyz/json-schema/t0ll-xyz-risk-assessment-schema.json",
  "title": "RiskAssessment",
  "description": "ERC-8265 RiskAssessment. Toll's own fields are x- prefixed, as the ERC reserves for vendors.",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/t0ll-xyz-openapi.json#/components/schemas/RiskAssessment",
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "ALLOW",
        "WARN",
        "BLOCK"
      ]
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "machine-readable reason, e.g. unbounded-approval-to-eoa, coin-strong-against, x402-payee-mismatch"
          },
          "severity": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "message": {
            "type": "string"
          },
          "x-toll-evidence": {
            "type": "object",
            "description": "the facts behind this warning"
          }
        },
        "required": [
          "code",
          "severity",
          "message"
        ]
      }
    },
    "scanners": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "verdict": {
            "type": "string",
            "enum": [
              "ALLOW",
              "WARN",
              "BLOCK"
            ]
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "provider",
          "verdict"
        ]
      }
    },
    "x-toll": {
      "type": "object",
      "description": "scanner (ERC-8004 agent id, chain id, registry), checked_at (UTC), decoded (each with its path inside a batch or user operation), coins, payees, retry_after_s, simulation, take, to, intent, link, note",
      "properties": {
        "simulation": {
          "type": "object",
          "description": "the transaction simulated at the current block (eth_simulateV1): status success | reverted | insufficient-eth | not-read. not-read (with why: timeout, rpc, shape, no-from, busy) means its effects were not read, never that it is clean; insufficient-eth carries have, want and the effects with the balance topped up.",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "success",
                "reverted",
                "insufficient-eth",
                "not-read"
              ]
            },
            "block": {
              "type": "integer",
              "description": "the block the simulation ran on top of"
            },
            "baseHash": {
              "type": "string",
              "description": "that block's hash"
            },
            "gasUsed": {
              "type": "string",
              "description": "gas the call used, decimal (the L1 fee is not included)"
            },
            "revertReason": {
              "type": "string",
              "description": "when reverted: the reason, decoded when it can be"
            },
            "deltas": {
              "type": "array",
              "description": "balance changes, netted per token and holder: [{ token (0xeeee...eeee = ETH), name? (ETH, WETH, USDG, CREDIT (Orbio), ORBIO), holder, delta (signed base units, decimal) }]",
              "items": {
                "type": "object"
              }
            },
            "approvals": {
              "type": "array",
              "description": "approvals the call sets: [{ token, owner, spender, amount (base units, decimal; null when it has no amount), kind: erc20 | permit2 | nft-all, approved? }]",
              "items": {
                "type": "object"
              }
            },
            "why": {
              "type": "string",
              "description": "when not-read: why"
            }
          }
        },
        "take": {
          "type": "object",
          "description": "present only for a typed-data signature: what it lets someone take, simulated from the owner at the current block. status read | none | not-read; not-read (with why) means it was not measured, never that nothing can be taken",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "read",
                "none",
                "not-read"
              ]
            },
            "takes": {
              "type": "array",
              "description": "when read: [{ token, owner, spender, signed (base units, decimal, or unlimited), balance, permit2Allowance?, takeable (what the spender could take now; null = not measured), nonceOk, expired, block, note?, symbol?, decimals?, usd? (the amount moved in the simulated pull, in USD; null = no price), simulated? (the simulated pull: status moved | nothing | reverted | not-read, moved, received, to, spender, method, block, why?), line? (the same in one plain sentence) }]",
              "items": {
                "type": "object"
              }
            },
            "why": {
              "type": "string",
              "description": "when none or not-read: why"
            }
          }
        },
        "to": {
          "type": "array",
          "description": "facts on the transaction's to (and the call's to when an agent wallet forwards it): whether it has code, its nonce, what Toll knows of it",
          "items": {
            "type": "object"
          }
        },
        "intent": {
          "type": "object",
          "description": "present only when an intent was sent",
          "properties": {
            "given": {
              "type": "boolean"
            },
            "matched": {
              "type": "boolean",
              "description": "true when no intent finding was made"
            },
            "findings": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "the warning codes the intent raised"
            }
          }
        },
        "ticket": {
          "type": "object",
          "description": "present only when a ticket was asked: { ticket: { scope, verdict, account, consumer, subject, validAfter, validUntil, nonce, reportHash }, signature, signer } (EIP-712 \"Toll Allow\" v1, chain 4663, no verifyingContract), or { why }"
        }
      }
    }
  },
  "required": [
    "action",
    "warnings"
  ]
}