{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fact.io/schemas/signed-receipt.schema.json",
  "title": "SignedVerificationReceipt",
  "description": "Cryptographically signed, timestamped ground-truth receipt returned by fact.io.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "receipt_id",
    "claim_id",
    "claim_url",
    "claim",
    "verdict",
    "confidence",
    "summary",
    "verified_at",
    "expires_at",
    "depth",
    "cache_hit",
    "cost_usdc",
    "sources",
    "consensus",
    "attestation"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "receipt_id": {
      "type": "string",
      "pattern": "^rcpt_[A-Za-z0-9_-]{8,32}$"
    },
    "claim_id": {
      "type": "string",
      "pattern": "^clm_[a-z0-9_-]{3,64}$"
    },
    "claim_url": {
      "type": "string",
      "format": "uri"
    },
    "claim": {
      "type": "string",
      "minLength": 4,
      "maxLength": 1000
    },
    "verdict": {
      "type": "string",
      "enum": ["VERIFIED", "FALSE", "DISPUTED", "UNVERIFIABLE", "FORECASTING"]
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "summary": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000
    },
    "verified_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "depth": {
      "type": "string",
      "enum": ["fast", "deep"]
    },
    "cache_hit": {
      "type": "boolean"
    },
    "cost_usdc": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]{4}$"
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url",
          "title",
          "publisher",
          "retrieved_at",
          "stance",
          "content_sha256"
        ],
        "properties": {
          "url": { "type": "string", "format": "uri" },
          "title": { "type": "string" },
          "publisher": { "type": "string" },
          "published_at": { "type": ["string", "null"], "format": "date-time" },
          "retrieved_at": { "type": "string", "format": "date-time" },
          "stance": { "type": "string", "enum": ["supports", "contradicts", "neutral"] },
          "excerpt": { "type": "string", "maxLength": 500 },
          "content_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
        }
      }
    },
    "consensus": {
      "type": "object",
      "additionalProperties": false,
      "required": ["verifiers_count", "agreement_ratio", "models"],
      "properties": {
        "verifiers_count": { "type": "integer", "minimum": 1 },
        "agreement_ratio": { "type": "number", "minimum": 0, "maximum": 1 },
        "models": {
          "type": "array",
          "items": { "type": "string" },
          "minItems": 1
        }
      }
    },
    "attestation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["algorithm", "key_id", "payload_sha256", "signature", "jwks_url"],
      "properties": {
        "algorithm": { "const": "Ed25519" },
        "key_id": { "type": "string" },
        "payload_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "signature": { "type": "string" },
        "jwks_url": { "type": "string", "format": "uri" }
      }
    }
  }
}
