{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aslice.sh/schematics/json/execution-catalog.schema.json",
  "title": "Execution catalog",
  "description": "Version 1 structural contract. Normative field semantics: docs/STATE-AND-RECOVERY.md section 10.2 and docs/DATABASE.md section 9. Cryptography, canonical encoding, chain continuity, ordering, and filesystem safety require semantic validation.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": 1
    },
    "instance_id": {
      "type": "string",
      "pattern": "^[0-9a-f]{32}$"
    },
    "profile": {
      "type": "string",
      "minLength": 1
    },
    "generation": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "prepared_head": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "defaults": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "minLength": 1
      }
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "package": {
            "type": "string",
            "minLength": 1
          },
          "stream": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "artifact": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "package_record": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "digest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "size": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "digest",
              "size"
            ]
          },
          "manifest": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "digest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "size": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "digest",
              "size"
            ]
          },
          "materialization": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "digest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "size": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "digest",
              "size"
            ]
          },
          "dependencies": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "uniqueItems": true
          },
          "configuration": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "digest": {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                },
                "size": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "digest",
                "size"
              ]
            },
            "uniqueItems": true
          },
          "cpu_features": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "min_os": {
            "type": "string",
            "minLength": 1
          },
          "max_os": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "package",
          "stream",
          "artifact",
          "package_record",
          "manifest",
          "materialization",
          "dependencies",
          "configuration",
          "cpu_features",
          "min_os",
          "max_os"
        ],
        "description": "Dependencies are the complete transitive closure; configuration binds loader, runtime/extension and external code-loading inputs. Values must agree with authenticated manifests."
      },
      "uniqueItems": true
    }
  },
  "required": [
    "format",
    "instance_id",
    "profile",
    "generation",
    "prepared_head",
    "defaults",
    "entries"
  ]
}
