{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.glyphd.com/schemas/semantic-fractal-topology.revisions.schema.json",
  "title": "Semantic Fractal Topology Revision Ledger",
  "description": "Immutable content-addressed scene revisions and mutable branch pointers. A branch pointer or merge candidate is not human acceptance.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "sequence", "revisions", "branches"],
  "properties": {
    "schemaVersion": { "const": "sft.revisions.v1" },
    "sequence": { "type": "integer", "minimum": 0 },
    "revisions": {
      "type": "object",
      "additionalProperties": { "$ref": "#/$defs/revision" }
    },
    "branches": {
      "type": "object",
      "additionalProperties": { "$ref": "#/$defs/contentId" },
      "required": ["MAIN"]
    }
  },
  "$defs": {
    "contentId": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "event": {
      "type": "object",
      "required": ["type", "actor", "logicalTime", "note"],
      "properties": {
        "type": { "type": "string", "minLength": 1 },
        "actor": { "type": "string", "minLength": 1 },
        "logicalTime": { "type": "integer", "minimum": 0 },
        "command": { "$ref": "semantic-fractal-topology.command.schema.json" },
        "note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "revision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "contentId", "parentIds", "graph", "event"],
      "properties": {
        "id": { "$ref": "#/$defs/contentId" },
        "contentId": { "$ref": "#/$defs/contentId" },
        "parentIds": { "type": "array", "items": { "$ref": "#/$defs/contentId" }, "uniqueItems": true },
        "graph": { "$ref": "semantic-fractal-topology.scene.schema.json" },
        "event": { "$ref": "#/$defs/event" }
      }
    }
  }
}
