{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://finance.entelekron.org/schemas/institutional-audit-event.schema.json",
  "title": "EnteleKRON Institutional Audit Event",
  "description": "Append-only evidence envelope. A valid event records evidence; it does not itself grant business, legal or value-movement approval.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "eventId", "sequence", "occurredAt", "recordedAt", "eventClass", "action", "environment", "legalEntity", "jurisdiction", "actor", "subject", "object", "intent", "policy", "evidence", "approvals", "result", "previousEventDigest", "eventDigest"],
  "properties": {
    "schemaVersion": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "eventId": { "type": "string", "minLength": 24, "maxLength": 128 },
    "sequence": { "type": "integer", "minimum": 1 },
    "occurredAt": { "type": "string", "format": "date-time" },
    "recordedAt": { "type": "string", "format": "date-time" },
    "eventClass": { "enum": ["policy-change", "entitlement-decision", "reserve-evidence", "issuance-request", "redemption-request", "custody-instruction", "treasury-transfer", "counterparty-limit-decision", "tokenization-registration", "reconciliation", "incident-and-recovery"] },
    "action": { "type": "string", "minLength": 1, "maxLength": 128 },
    "environment": { "enum": ["development", "test", "sandbox", "production"] },
    "legalEntity": { "type": ["string", "null"], "maxLength": 256 },
    "jurisdiction": { "type": ["string", "null"], "maxLength": 64 },
    "actor": {
      "type": "object",
      "additionalProperties": false,
      "required": ["actorRef", "actorType", "authorityDomain", "authenticationEvidenceRef"],
      "properties": {
        "actorRef": { "type": "string", "minLength": 1, "maxLength": 256 },
        "actorType": { "enum": ["human", "system", "provider"] },
        "authorityDomain": { "type": "string", "minLength": 1, "maxLength": 128 },
        "authenticationEvidenceRef": { "type": "string", "minLength": 1, "maxLength": 256 }
      }
    },
    "subject": {
      "type": "object",
      "additionalProperties": false,
      "required": ["subjectRef", "subjectType"],
      "properties": {
        "subjectRef": { "type": ["string", "null"], "maxLength": 256 },
        "subjectType": { "type": ["string", "null"], "maxLength": 64 }
      }
    },
    "object": {
      "type": "object",
      "additionalProperties": false,
      "required": ["resourceType", "resourceId", "canonicalAssetId"],
      "properties": {
        "resourceType": { "type": "string", "minLength": 1, "maxLength": 128 },
        "resourceId": { "type": "string", "minLength": 1, "maxLength": 256 },
        "canonicalAssetId": { "type": ["string", "null"], "maxLength": 128 }
      }
    },
    "intent": {
      "type": "object",
      "additionalProperties": false,
      "required": ["summary", "amount", "currency", "networkId", "canonicalContract", "beneficiaryRef", "expiresAt", "nonce"],
      "properties": {
        "summary": { "type": "string", "minLength": 1, "maxLength": 512 },
        "amount": { "type": ["string", "null"], "pattern": "^[0-9]+(?:\\.[0-9]+)?$" },
        "currency": { "type": ["string", "null"], "maxLength": 16 },
        "networkId": { "type": ["string", "null"], "maxLength": 64 },
        "canonicalContract": { "type": ["string", "null"], "maxLength": 256 },
        "beneficiaryRef": { "type": ["string", "null"], "maxLength": 256 },
        "expiresAt": { "type": ["string", "null"], "format": "date-time" },
        "nonce": { "type": ["string", "null"], "maxLength": 256 }
      }
    },
    "policy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["policyId", "policyVersion", "decisionRef"],
      "properties": {
        "policyId": { "type": "string", "minLength": 1, "maxLength": 128 },
        "policyVersion": { "type": "string", "minLength": 1, "maxLength": 64 },
        "decisionRef": { "type": "string", "minLength": 1, "maxLength": 256 }
      }
    },
    "evidence": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["evidenceType", "evidenceRef", "sha256", "classification"],
        "properties": {
          "evidenceType": { "type": "string", "minLength": 1, "maxLength": 128 },
          "evidenceRef": { "type": "string", "minLength": 1, "maxLength": 512 },
          "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "classification": { "enum": ["public", "restricted", "confidential"] }
        }
      }
    },
    "approvals": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["approvalRef", "authorityDomain", "decision", "approvedAt", "expiresAt"],
        "properties": {
          "approvalRef": { "type": "string", "minLength": 1, "maxLength": 256 },
          "authorityDomain": { "type": "string", "minLength": 1, "maxLength": 128 },
          "decision": { "enum": ["approve", "deny", "suspend"] },
          "approvedAt": { "type": "string", "format": "date-time" },
          "expiresAt": { "type": "string", "format": "date-time" }
        }
      }
    },
    "result": {
      "type": "object",
      "additionalProperties": false,
      "required": ["outcome", "state", "transactionRef", "settlementRef", "reconciliationRef", "exceptionCode"],
      "properties": {
        "outcome": { "enum": ["accepted", "denied", "suspended", "failed", "completed"] },
        "state": { "type": "string", "minLength": 1, "maxLength": 128 },
        "transactionRef": { "type": ["string", "null"], "maxLength": 256 },
        "settlementRef": { "type": ["string", "null"], "maxLength": 256 },
        "reconciliationRef": { "type": ["string", "null"], "maxLength": 256 },
        "exceptionCode": { "type": ["string", "null"], "maxLength": 128 }
      }
    },
    "previousEventDigest": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
    "eventDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
  }
}
