{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://governedai.ai/schemas/rdl_registry.schema.json",
  "title": "RDL Registry Entry",
  "description": "A single entry in the public receipts registry. Every entry is hash-anchored where an anchor exists; missing anchors are written as 'not_recorded' and never invented.",
  "type": "object",
  "required": [
    "receipt_id",
    "schema_version",
    "date",
    "subject",
    "status",
    "tier",
    "source_artifact",
    "verification_status"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^(RDL-[0-9]{3}|RDL-CANDIDATE-[0-9]{3}|UI-[0-9]+\\.[0-9]+(\\.[0-9]+)?-SEAL)$",
      "description": "Globally unique receipt identifier; numeric RDLs, candidates, or UI-version seals"
    },
    "schema_version": {
      "type": "string",
      "const": "0.1.0"
    },
    "date": {
      "type": "string",
      "format": "date",
      "description": "Date the receipt was created (sealed or candidate-marked)"
    },
    "subject": {
      "type": "string",
      "minLength": 5,
      "description": "Short human-readable subject of the receipt"
    },
    "status": {
      "type": "string",
      "enum": ["SEALED", "CANDIDATE", "DRAFT", "RETIRED", "SUPERSEDED"],
      "description": "Lifecycle status of the receipt"
    },
    "tier": {
      "type": "string",
      "enum": ["TIER_0_PUBLIC", "TIER_1_PARTNER", "TIER_2_NDA", "TIER_3_INTERNAL_ONLY"],
      "description": "Disclosure tier of the receipt. Patent-sensitive material is never anchored in the public registry."
    },
    "source_artifact": {
      "type": "object",
      "required": ["type", "reference"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["git_commit", "tarball", "deployment", "markdown_document", "schema_seal", "audit_packet"]
        },
        "reference": {
          "type": "string",
          "description": "Reference to the source artifact (commit SHA, tar path, deployment URL, etc.)"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$|^not_recorded$",
          "description": "SHA-256 of the source artifact in canonical form. 'not_recorded' if no anchor exists; never invent."
        }
      },
      "additionalProperties": false
    },
    "verification_status": {
      "type": "object",
      "required": ["state"],
      "properties": {
        "state": {
          "type": "string",
          "enum": ["verified", "pending", "not_applicable", "failed"]
        },
        "verified_by": {
          "type": "string",
          "description": "Who or what verified the receipt (e.g. CI, counsel, sovereign)"
        },
        "verified_at": {
          "type": "string",
          "format": "date-time"
        },
        "replay_command": {
          "type": "string",
          "description": "Exact command that reproduces the verification"
        }
      },
      "additionalProperties": false
    },
    "link": {
      "type": "string",
      "description": "Public link to the receipt document, deployment, or rendered artifact"
    },
    "supersedes": {
      "type": "string",
      "description": "Reference to a prior receipt this one supersedes"
    },
    "superseded_by": {
      "type": "string",
      "description": "Reference to a later receipt that supersedes this one"
    },
    "notes": {
      "type": "string",
      "description": "Free-form notes; must remain tier-clean"
    }
  }
}
