{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dicworkflowkit.local/schemas/ontology-action-record.schema.json",
  "title": "DIC Ontology Action Ledger Record",
  "description": "One immutable entry in reports/ontology-actions.jsonl.",
  "oneOf": [
    { "$ref": "#/$defs/legacyRecord" },
    { "$ref": "#/$defs/chainedRecord" }
  ],
  "$defs": {
    "legacyRecord": {
      "type": "object",
      "required": ["schema", "recordedAt", "sha256", "action"],
      "properties": {
        "schema": { "const": "dic.ontology-action-record.v1" },
        "recordedAt": { "type": "string", "format": "date-time" },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "action": { "$ref": "ontology-action.schema.json" }
      },
      "additionalProperties": false
    },
    "chainedRecord": {
      "type": "object",
      "required": [
        "schema",
        "sequence",
        "recordedAt",
        "previousHash",
        "baseSnapshotRevision",
        "actionHash",
        "recordHash",
        "action"
      ],
      "properties": {
        "schema": { "const": "dic.ontology-action-record.v2" },
        "sequence": { "type": "integer", "minimum": 1 },
        "recordedAt": { "type": "string", "format": "date-time" },
        "previousHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "baseSnapshotRevision": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "actionHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "recordHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "action": { "$ref": "ontology-action.schema.json" }
      },
      "additionalProperties": false
    }
  }
}
