{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aslice.sh/schematics/json/recovery-gate.schema.json",
  "title": "Recovery gate",
  "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}$"
    },
    "operation_id": {
      "type": "string",
      "pattern": "^[0-9a-f]{32}$"
    },
    "epoch": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "intent": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "selections": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^sha256:[0-9a-f]{64}$"
      },
      "uniqueItems": true
    },
    "resources": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "scope": {
      "enum": [
        "bounded",
        "prefix",
        "protected"
      ]
    }
  },
  "required": [
    "format",
    "instance_id",
    "operation_id",
    "epoch",
    "intent",
    "selections",
    "artifacts",
    "resources",
    "scope"
  ]
}
