{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:hayat:schema:bootstrap:vNEXT-D",
  "title": "HAYAT bootstrap \u2014 vNEXT-D draft",
  "type": "object",
  "properties": {
    "protocol_version": {
      "const": "vNEXT-D"
    },
    "project_id": {
      "type": "string",
      "format": "uuid"
    },
    "artifact_id": {
      "type": "string",
      "format": "uuid"
    },
    "record_type": {
      "const": "bootstrap"
    },
    "author_id": {
      "type": "string",
      "format": "uuid"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "visibility": {
      "enum": [
        "local-example",
        "public",
        "shared",
        "private"
      ]
    },
    "source_refs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "artifact_id": {
            "type": "string",
            "format": "uuid"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "location": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
          }
        },
        "required": [
          "artifact_id",
          "sha256"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "content_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "payload_location": {
      "type": "string",
      "minLength": 1
    },
    "provenance_limitation": {
      "type": "string"
    },
    "simulation": {
      "type": "boolean"
    },
    "manifest_ref": {
      "type": "object",
      "properties": {
        "artifact_id": {
          "type": "string",
          "format": "uuid"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "location": {
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
        }
      },
      "required": [
        "artifact_id",
        "sha256"
      ],
      "additionalProperties": false
    },
    "status_ref": {
      "type": "object",
      "properties": {
        "artifact_id": {
          "type": "string",
          "format": "uuid"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "location": {
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
        }
      },
      "required": [
        "artifact_id",
        "sha256"
      ],
      "additionalProperties": false
    },
    "authoritative_source_refs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "artifact_id": {
            "type": "string",
            "format": "uuid"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "location": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
          }
        },
        "required": [
          "artifact_id",
          "sha256"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "decision_refs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "artifact_id": {
            "type": "string",
            "format": "uuid"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "location": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
          }
        },
        "required": [
          "artifact_id",
          "sha256"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "unresolved_questions": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "next_action": {
      "type": "string",
      "minLength": 1
    },
    "known_missing_context": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "capability_ref": {
      "type": "object",
      "properties": {
        "artifact_id": {
          "type": "string",
          "format": "uuid"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "location": {
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
        }
      },
      "required": [
        "artifact_id",
        "sha256"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "protocol_version",
    "project_id",
    "artifact_id",
    "record_type",
    "author_id",
    "created_at",
    "visibility",
    "source_refs",
    "content_sha256",
    "payload_location",
    "provenance_limitation",
    "simulation",
    "manifest_ref",
    "status_ref",
    "authoritative_source_refs",
    "decision_refs",
    "unresolved_questions",
    "next_action",
    "known_missing_context",
    "capability_ref"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "source_refs": {
            "maxItems": 0
          }
        }
      },
      "then": {
        "properties": {
          "provenance_limitation": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  ]
}
