{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://intelligence.metatron.marketing/schemas/publication-history-event.schema.json",
  "title": "Metatron Intelligence public publication-history event",
  "description": "A validated publication event with deterministic predecessor and content hashes.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "eventId",
    "url",
    "previousEventId",
    "eventKind",
    "effectiveDate",
    "recordedAt",
    "artifact",
    "change",
    "evidence",
    "editorial",
    "integrity"
  ],
  "properties": {
    "schema": {"const": "metatron.intelligence.publication-history-event.v1"},
    "eventId": {"type": "string", "pattern": "^PHE-[0-9]{4}-[0-9]{6}$"},
    "url": {"type": "string", "format": "uri", "pattern": "^https://intelligence\\.metatron\\.marketing/changes/events/PHE-[0-9]{4}-[0-9]{6}/$"},
    "previousEventId": {
      "oneOf": [
        {"type": "string", "pattern": "^PHE-[0-9]{4}-[0-9]{6}$"},
        {"type": "null"}
      ]
    },
    "eventKind": {
      "enum": ["baseline_release", "feature_release", "dataset_revision", "correction", "retraction", "policy_change"]
    },
    "effectiveDate": {"type": "string", "format": "date"},
    "recordedAt": {"type": "string", "format": "date-time"},
    "artifact": {"type": "object"},
    "change": {"type": "object"},
    "evidence": {"type": "object"},
    "editorial": {"type": "object"},
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sequence", "hashAlgorithm", "hashScope", "previousEventSha256", "eventSha256"],
      "properties": {
        "sequence": {"type": "integer", "minimum": 1},
        "hashAlgorithm": {"const": "sha256"},
        "hashScope": {"const": "Metatron canonical JSON v1: UTF-8, sorted keys, no insignificant whitespace; event core plus previousEventSha256"},
        "previousEventSha256": {
          "oneOf": [
            {"type": "string", "pattern": "^[0-9a-f]{64}$"},
            {"type": "null"}
          ]
        },
        "eventSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
      }
    }
  }
}
