{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://zambo.dev/aer-1/schema.json",
  "title": "AER-1 Live MCP Receipt",
  "description": "Raw MCP result._receipt shape for current AER-1 draft -12; validate the receipt object without normalizing its transport fields.",
  "$comment": "This schema applies directly to result._receipt in the JSON-RPC response from POST /api/mcp. It does not describe the outer JSON-RPC envelope.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "id",
    "tool",
    "timestamp",
    "provenance_class",
    "verification_status",
    "hash_algorithm",
    "canonical_bytes",
    "canonical_byte_length",
    "output_hash",
    "status"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "tool": {
      "type": "string",
      "minLength": 1
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "receipt_schema_version": {
      "type": "string",
      "const": "0.3"
    },
    "tool_context": {
      "type": "object",
      "required": [
        "name",
        "version",
        "scope"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "provenance_class": {
      "type": "string",
      "enum": [
        "EXECUTED BY ZAMBO",
        "OBSERVED VIA GATEWAY",
        "LOGGED BY AGENT"
      ]
    },
    "canonical_bytes": {
      "type": "string",
      "contentEncoding": "base64",
      "description": "Base64 of the exact UTF-8 bytes hashed below."
    },
    "output_hash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "canonical_byte_length": {
      "type": "integer",
      "minimum": 0
    },
    "hash_algorithm": {
      "type": "string",
      "const": "sha256"
    },
    "verification_status": {
      "type": "string",
      "minLength": 1,
      "description": "Transport status such as execution_observed or not_verified; preserve it unchanged."
    },
    "status": {
      "type": "string",
      "minLength": 1
    },
    "anchor": {
      "type": [
        "object",
        "null"
      ]
    }
  }
}
