{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:coi-declaration:v1",
  "title": "COIDeclaration v1",
  "description": "Machine-readable schema for a signed conflict-of-interest declaration used by panel selection. The signed surface uses the same family as the rest of the protocol stack: `orbiplex-coi-declaration-v1\\x00 || deterministic_cbor(payload_without_signature)`.",
  "type": "object",
  "additionalProperties": true,
  "x-dia-workflow": "project",
  "x-dia-status": "draft",
  "x-dia-basis": [
    "doc/normative/50-constitutional-ops/pl/PANEL-SELECTION-PROTOCOL.pl.md",
    "doc/normative/50-constitutional-ops/pl/PROCEDURAL-REPUTATION-SPEC.pl.md"
  ],
  "required": [
    "schema/v",
    "case/hash",
    "participant/id",
    "declaration",
    "ts",
    "nonce",
    "signature"
  ],
  "properties": {
    "schema/v": {
      "const": 1,
      "description": "Schema version."
    },
    "case/hash": {
      "type": "string",
      "minLength": 1,
      "description": "Blinded or otherwise minimally disclosing challenge hash of the case for which the declaration is made."
    },
    "participant/id": {
      "type": "string",
      "pattern": "^participant:did:key:z[1-9A-HJ-NP-Za-km-z]+$",
      "description": "Stable participant identity serving in the governance pipeline. Nym identities are not valid here."
    },
    "declaration": {
      "type": "string",
      "enum": [
        "no-conflict",
        "conflict"
      ],
      "description": "Conflict-of-interest declaration outcome."
    },
    "ts": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp of the declaration."
    },
    "nonce": {
      "type": "string",
      "minLength": 1,
      "description": "Fresh nonce preventing replay of the declaration artifact."
    },
    "conflict/category": {
      "type": "string",
      "minLength": 1,
      "description": "Optional coarse category when `declaration = conflict`."
    },
    "signature": {
      "$ref": "#/$defs/signature",
      "description": "Participant signature over the declaration payload."
    }
  },
  "$defs": {
    "signature": {
      "type": "object",
      "required": [
        "alg",
        "value"
      ],
      "properties": {
        "alg": {
          "type": "string",
          "enum": [
            "ed25519"
          ]
        },
        "value": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "declaration": {
            "const": "conflict"
          }
        },
        "required": [
          "declaration"
        ]
      },
      "then": {
        "required": [
          "conflict/category"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "declaration": {
            "const": "no-conflict"
          }
        },
        "required": [
          "declaration"
        ]
      },
      "then": {
        "not": {
          "required": [
            "conflict/category"
          ]
        }
      }
    }
  ]
}
