{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://h33.ai/revocation/schema/log-entry.schema.json",
  "title": "9B Revocation Log Entry v0.2",
  "type": "object",
  "required": ["event_id", "event_type", "ts_ns", "fingerprint_sha3_384", "reason"],
  "properties": {
    "event_id": {
      "type": "string",
      "pattern": "^evt-[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$",
      "description": "UUID v4 prefixed with evt-"
    },
    "event_type": {
      "type": "string",
      "enum": ["registration", "sunset", "revocation", "reinstatement"]
    },
    "ts_ns": { "type": "integer", "minimum": 0, "description": "Nanosecond timestamp" },
    "fingerprint_sha3_384": {
      "type": "string",
      "pattern": "^[0-9a-f]{96}$",
      "description": "96-char lowercase hex SHA3-384"
    },
    "algorithm_set": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 1,
      "description": "Algorithm names this fingerprint covers, e.g. ML-DSA-65"
    },
    "successor_of": {
      "oneOf": [
        { "type": "null" },
        { "type": "string", "pattern": "^[0-9a-f]{96}$" }
      ],
      "description": "Fingerprint this entry supersedes, if any"
    },
    "sunset_ns": {
      "oneOf": [
        { "type": "null" },
        { "type": "integer", "minimum": 0 }
      ],
      "description": "Nanosecond timestamp after which this fingerprint should not be trusted; required when event_type=sunset"
    },
    "reason": { "type": "string", "minLength": 1, "maxLength": 256 },
    "reason_code": {
      "type": "string",
      "enum": [
        "ceremony_completion",
        "scheduled_rotation",
        "emergency_compromise_confirmed",
        "emergency_compromise_suspected",
        "operator_error",
        "administrative_revert",
        "policy_change"
      ]
    },
    "incident_url": { "type": "string", "format": "uri" },
    "founder_signature": {
      "type": "string",
      "description": "Optional founder signature over (event_id || fingerprint || ts_ns)"
    }
  },
  "allOf": [
    {
      "if": { "properties": { "event_type": { "const": "revocation" } } },
      "then": { "required": ["reason_code", "incident_url"] }
    },
    {
      "if": { "properties": { "event_type": { "const": "sunset" } } },
      "then": { "required": ["sunset_ns", "successor_of"] }
    }
  ]
}
