{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://certiv.org/schema/certiv-receipt.schema.json",
  "title": "certiv receipt (receipt.certiv)",
  "description": "The verifiable output of `certiv pack`. Author-side receipts NEVER carry verifier-node fields (verification_result, verified_at, node_id); those are written only by a verification node.",
  "type": "object",
  "required": ["schema", "paper", "tier", "created_at", "claims", "claims_merkle_root", "coverage", "receipt_sha256"],
  "not": { "anyOf": [
    { "required": ["verification_result"] },
    { "required": ["verified_at"] },
    { "required": ["node_id"] }
  ]},
  "properties": {
    "schema": { "const": "certiv_receipt_v1" },
    "paper": { "type": "object", "required": ["title", "authors"],
      "properties": { "title": { "type": "string" }, "authors": { "type": "array", "items": { "type": "string" } } } },
    "tier": { "enum": ["T0", "T1", "T2", "T3"] },
    "created_at": { "type": "string" },
    "claims": { "type": "array", "items": {
      "type": "object",
      "required": ["claim_id", "statement", "weight", "kind", "status", "claim_sha256"],
      "properties": {
        "claim_id": { "type": "string" },
        "statement": { "type": "string" },
        "weight": { "enum": ["load_bearing", "supporting"] },
        "kind": { "enum": ["executable", "certificate"] },
        "status": { "enum": ["verified_local", "failed", "unverifiable", "non_deterministic"], "description": "author-side status; a verification node writes the unqualified 'verified'" },
        "claim_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
      }
    }},
    "claims_merkle_root": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "coverage": { "type": "object",
      "required": ["load_bearing_total", "load_bearing_verified_local", "receipt_coverage_local"],
      "properties": {
        "load_bearing_total": { "type": "integer", "minimum": 0 },
        "load_bearing_verified_local": { "type": "integer", "minimum": 0 },
        "receipt_coverage_local": { "type": "number", "minimum": 0, "maximum": 1 }
      }},
    "receipt_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
  }
}
