{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://quantumetzchaim.com/schemas/trace-v0.3.schema.json",
  "title": "Quantum Etz Chaim complete execution trace 0.3",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "engineVersion", "pathMapVersion", "manifestationVersion", "program", "programHash", "seed", "initialState", "events", "completeTraceHash", "observation"],
  "properties": {
    "schemaVersion": { "const": "qec-trace-0.3" },
    "engineVersion": { "const": "1.0.0" },
    "pathMapVersion": { "const": "qec-path-map-0.3.0" },
    "manifestationVersion": { "const": "qec-manifestation-0.2" },
    "program": { "type": "string", "minLength": 1, "maxLength": 1024, "pattern": "^[א-ת]+$" },
    "programHash": { "$ref": "#/$defs/contentHash" },
    "seed": { "type": "integer", "minimum": 0, "maximum": 21 },
    "initialState": { "$ref": "#/$defs/state" },
    "events": { "type": "array", "minItems": 1, "maxItems": 1024, "items": { "$ref": "#/$defs/event" } },
    "completeTraceHash": { "$ref": "#/$defs/contentHash" },
    "observation": { "$ref": "#/$defs/observation" }
  },
  "$defs": {
    "stateHash": { "type": "string", "pattern": "^[0-9a-f]{8}$" },
    "contentHash": { "type": "string", "pattern": "^fnv1a32-[0-9a-f]{8}$" },
    "state": { "type": "array", "minItems": 23, "maxItems": 23, "items": { "type": "integer", "minimum": 0, "maximum": 21 } },
    "region": { "enum": ["Keter", "Chokhmah", "Binah", "Daat", "Chesed", "Gevurah", "Tiferet", "Netzach", "Hod", "Yesod", "Malchut"] },
    "event": {
      "type": "object", "additionalProperties": false,
      "required": ["sequence", "instructionIndex", "letter", "transform", "route", "services", "before", "after", "beforeHash", "afterHash", "coherence"],
      "properties": {
        "sequence": { "type": "integer", "minimum": 0 },
        "instructionIndex": { "type": "integer", "minimum": 0 },
        "letter": { "type": "string", "pattern": "^[א-ת]$" },
        "transform": { "type": "string", "pattern": "^[a-z][a-z0-9-]+$" },
        "route": { "type": "array", "minItems": 2, "maxItems": 2, "prefixItems": [{ "$ref": "#/$defs/region" }, { "$ref": "#/$defs/region" }], "items": false },
        "services": { "type": "array", "minItems": 2, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
        "before": { "$ref": "#/$defs/state" }, "after": { "$ref": "#/$defs/state" },
        "beforeHash": { "$ref": "#/$defs/stateHash" }, "afterHash": { "$ref": "#/$defs/stateHash" },
        "coherence": { "type": "object", "additionalProperties": false, "required": ["activation", "phase", "coherence"], "properties": { "activation": { "type": "number", "minimum": 0, "maximum": 1 }, "phase": { "type": "number", "minimum": 0, "maximum": 6.283186 }, "coherence": { "type": "number", "minimum": 0, "maximum": 1 } } }
      }
    },
    "projection": { "type": "object", "additionalProperties": false, "required": ["id", "label", "stateHash", "focusLetter", "confidence", "rationale"], "properties": { "id": { "enum": ["register-order", "mirror-order", "phase-offset"] }, "label": { "type": "string", "minLength": 1 }, "stateHash": { "$ref": "#/$defs/stateHash" }, "focusLetter": { "type": "string", "pattern": "^[א-ת]$" }, "confidence": { "type": "number", "minimum": 0, "maximum": 1 }, "rationale": { "type": "string", "minLength": 1 } } },
    "observation": { "type": "object", "additionalProperties": false, "required": ["step", "reason", "stateHash", "traceHash", "candidates", "selectedProjection", "snapshot"], "properties": { "step": { "type": "integer", "minimum": 1 }, "reason": { "const": "program-end" }, "stateHash": { "$ref": "#/$defs/stateHash" }, "traceHash": { "$ref": "#/$defs/contentHash" }, "candidates": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "$ref": "#/$defs/projection" } }, "selectedProjection": { "enum": ["register-order", "mirror-order", "phase-offset"] }, "snapshot": { "$ref": "#/$defs/state" } } }
  }
}
