{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getzero.dev/contracts/zero.authority_ceremony.v1.schema.json",
  "title": "ZERO Authority Ceremony and Receipt v1",
  "oneOf": [
    { "$ref": "#/$defs/authority_ceremony" },
    { "$ref": "#/$defs/authority_receipt" }
  ],
  "$defs": {
    "authority_action": {
      "enum": [
        "approve_agent",
        "signer_ready",
        "grant_short_live_lease",
        "sign_live_action",
        "sign_schedule_cancel",
        "kill_switch",
        "take_over"
      ]
    },
    "authority_ceremony": {
      "type": "object",
      "required": ["schema_version", "kind", "authority_actions"],
      "properties": {
        "schema_version": { "const": "zero.authority_ceremony.v1" },
        "schema": { "const": "https://getzero.dev/contracts/zero.authority_ceremony.v1.schema.json" },
        "kind": { "const": "authority_ceremony" },
        "authority_actions": {
          "type": "array",
          "items": { "$ref": "#/$defs/authority_action" }
        }
      }
    },
    "authority_receipt": {
      "type": "object",
      "required": [
        "schema_version",
        "ceremony_schema",
        "action",
        "receipt_id",
        "deployment_id",
        "occurred_at",
        "evidence_hash",
        "evidence",
        "public",
        "no_secret_material"
      ],
      "properties": {
        "schema_version": { "const": "zero.authority_receipt.v1" },
        "ceremony_schema": { "const": "https://getzero.dev/contracts/zero.authority_ceremony.v1.schema.json" },
        "action": { "$ref": "#/$defs/authority_action" },
        "receipt_id": { "type": "string", "pattern": "^authority-[a-z_]+-[a-f0-9]{16}$" },
        "deployment_id": { "type": "string" },
        "operator_id": { "type": ["string", "null"] },
        "occurred_at": { "type": "string" },
        "evidence_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "evidence": { "type": "object" },
        "public": { "const": false },
        "no_secret_material": { "const": true }
      }
    }
  }
}
