{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chris-page-gov.github.io/okf-explorer/profile/context-archive/v1/archive.schema.json",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "okf-context-archive.v1"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "question": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "question_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "context_id": {
      "type": "string",
      "pattern": "^urn:sha256:[a-f0-9]{64}$"
    },
    "package_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "package_bytes": {
      "type": "integer",
      "minimum": 1,
      "maximum": 524288
    },
    "source_version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "bundle": {
      "type": "object"
    },
    "binding": {
      "type": "object"
    },
    "engine_id": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      ]
    },
    "original_engine_id": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      ]
    },
    "observation_kind": {
      "enum": [
        "local",
        "public",
        "synthetic"
      ]
    },
    "publication_note": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "input_receipt": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        "bytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2097152
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "path",
        "bytes",
        "sha256"
      ]
    },
    "evidence_status": {
      "enum": [
        "sufficient",
        "insufficient",
        "conflicting"
      ]
    },
    "ai_answer": {
      "type": "null"
    },
    "budget": {
      "type": "object"
    },
    "counts": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "records": {
          "type": "integer",
          "minimum": 0,
          "maximum": 200
        },
        "relationships": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000
        }
      },
      "required": [
        "records",
        "relationships"
      ]
    },
    "catalogues": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1024,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65536
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "required": [
          "bytes",
          "sha256"
        ]
      }
    },
    "record_indexes": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 65536
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "required": [
          "bytes",
          "sha256"
        ]
      }
    },
    "sections": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "package": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1024,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "bytes": {
                "type": "integer",
                "minimum": 1,
                "maximum": 65536
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "bytes",
              "sha256"
            ]
          }
        },
        "diagnostics": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1024,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "bytes": {
                "type": "integer",
                "minimum": 1,
                "maximum": 65536
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "bytes",
              "sha256"
            ]
          }
        },
        "relationships": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1024,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "bytes": {
                "type": "integer",
                "minimum": 1,
                "maximum": 65536
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "bytes",
              "sha256"
            ]
          }
        }
      },
      "required": [
        "package",
        "diagnostics",
        "relationships"
      ]
    },
    "limits": {
      "type": "object"
    },
    "notice": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    }
  },
  "required": [
    "schema",
    "id",
    "title",
    "question",
    "question_sha256",
    "context_id",
    "package_sha256",
    "package_bytes",
    "source_version",
    "bundle",
    "binding",
    "engine_id",
    "original_engine_id",
    "observation_kind",
    "publication_note",
    "input_receipt",
    "evidence_status",
    "ai_answer",
    "budget",
    "counts",
    "catalogues",
    "record_indexes",
    "sections",
    "limits",
    "notice"
  ]
}
