{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chris-page-gov.github.io/okf-explorer/evaluation-foundry/schemas/okf-evaluation-profile.v1.schema.json",
  "title": "OKF Explorer evaluation profile v1",
  "type": "object",
  "required": [
    "schema",
    "profile_id",
    "status",
    "title",
    "scope",
    "sources",
    "assertion_policy",
    "mapping_proposals",
    "capabilities",
    "fixtures",
    "consumer_contract",
    "publication_boundary"
  ],
  "properties": {
    "schema": {"const": "okf-evaluation-profile.v1"},
    "profile_id": {"type": "string", "minLength": 1},
    "version": {"type": "string", "minLength": 1},
    "status": {
      "enum": ["draft", "provisional", "evaluated", "retired"]
    },
    "title": {"type": "string", "minLength": 1},
    "description": {"type": "string"},
    "prepared_at": {"type": "string", "format": "date-time"},
    "scope": {
      "type": "object",
      "required": ["record_definition", "included", "excluded", "denominators"],
      "properties": {
        "record_definition": {"type": "string", "minLength": 1},
        "included": {"type": "array", "items": {"type": "string"}},
        "excluded": {"type": "array", "items": {"type": "string"}},
        "boundary_codes": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["code", "name", "vintage"],
            "properties": {
              "code": {"type": "string", "minLength": 1},
              "name": {"type": "string", "minLength": 1},
              "vintage": {"type": "string", "minLength": 1},
              "source": {"type": "string", "format": "uri"}
            },
            "additionalProperties": true
          }
        },
        "denominators": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["id", "definition", "method", "status"],
            "properties": {
              "id": {"type": "string", "minLength": 1},
              "definition": {"type": "string", "minLength": 1},
              "method": {"type": "string", "minLength": 1},
              "status": {"enum": ["complete", "bounded", "partial", "unknown"]},
              "count": {"type": ["integer", "null"], "minimum": 0},
              "limitations": {"type": "array", "items": {"type": "string"}}
            },
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "title", "url", "authority", "access", "rights", "coverage"],
        "properties": {
          "id": {"type": "string", "minLength": 1},
          "title": {"type": "string", "minLength": 1},
          "url": {"type": "string", "format": "uri"},
          "authority": {"type": "string", "minLength": 1},
          "access": {"type": "string", "minLength": 1},
          "rights": {"type": "string", "minLength": 1},
          "coverage": {"type": "string", "minLength": 1},
          "automation_limit": {"type": "string"},
          "snapshot": {
            "type": "object",
            "properties": {
              "path": {"type": "string"},
              "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
              "observed_at": {"type": "string", "format": "date-time"}
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      }
    },
    "assertion_policy": {
      "type": "object",
      "required": ["statuses", "scopes", "synthetic_isolation"],
      "properties": {
        "statuses": {
          "type": "array",
          "contains": {"const": "official"},
          "items": {"enum": ["official", "normalized", "inferred", "model-derived"]}
        },
        "scopes": {
          "type": "array",
          "contains": {"const": "real-world"},
          "items": {"enum": ["real-world", "synthetic-fixture"]}
        },
        "synthetic_isolation": {"const": true}
      },
      "additionalProperties": true
    },
    "mapping_proposals": {
      "type": "array",
      "minItems": 1,
      "items": {"type": "string", "minLength": 1}
    },
    "capabilities": {
      "type": "array",
      "minItems": 1,
      "items": {"type": "string", "minLength": 1}
    },
    "fixtures": {
      "type": "object",
      "required": ["tiny", "faithful", "synthetic"],
      "properties": {
        "tiny": {"type": "string", "minLength": 1},
        "faithful": {"type": "string", "minLength": 1},
        "synthetic": {"type": "string", "minLength": 1}
      },
      "additionalProperties": true
    },
    "consumer_contract": {
      "type": "object",
      "required": ["consumer", "journeys", "deterministic_builds", "compatibility"],
      "properties": {
        "consumer": {"type": "string", "minLength": 1},
        "journeys": {"type": "string", "minLength": 1},
        "deterministic_builds": {"const": 2},
        "compatibility": {"type": "array", "minItems": 2, "items": {"type": "string"}}
      },
      "additionalProperties": true
    },
    "publication_boundary": {"type": "string", "minLength": 1}
  },
  "additionalProperties": true
}
