{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:okf:uk-legislation:schema:rich-relationship-route-locator:v1",
  "title": "OKF rich relationship route locator manifest v1",
  "type": "object",
  "required": [
    "schema",
    "generated_at",
    "hash_algorithm",
    "bucket_path_template",
    "buckets",
    "counts"
  ],
  "properties": {
    "schema": {"const": "okf-rich-relationship-route-locator.v1"},
    "generated_at": {"type": "string", "format": "date-time"},
    "hash_algorithm": {"const": "sha256-utf8-first-byte-hex"},
    "bucket_path_template": {"type": "string", "minLength": 1},
    "buckets": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "bucket",
          "path",
          "bytes",
          "sha256",
          "content_encoding",
          "routes",
          "chunk_references",
          "plane_commitments",
          "incident_assertions",
          "active_incident_assertions"
        ],
        "properties": {
          "bucket": {"type": "string", "pattern": "^[0-9a-f]{2}$"},
          "path": {"$ref": "#/$defs/safePath"},
          "bytes": {"type": "integer", "minimum": 1},
          "sha256": {"$ref": "#/$defs/sha256"},
          "content_encoding": {"const": "gzip"},
          "routes": {"type": "integer", "minimum": 1},
          "chunk_references": {"type": "integer", "minimum": 1},
          "plane_commitments": {"type": "integer", "minimum": 1},
          "incident_assertions": {"type": "integer", "minimum": 1},
          "active_incident_assertions": {"type": "integer", "minimum": 0}
        },
        "additionalProperties": false
      }
    },
    "counts": {
      "type": "object",
      "required": [
        "routes",
        "buckets",
        "chunk_references",
        "plane_commitments",
        "incident_assertions",
        "active_incident_assertions",
        "plane_chunk_references",
        "active_plane_chunk_references",
        "max_incident_assertions_per_route",
        "max_active_incident_assertions_per_route",
        "max_chunk_references_per_route",
        "max_active_chunk_references_per_route"
      ],
      "additionalProperties": {"type": "integer", "minimum": 0}
    }
  },
  "additionalProperties": false,
  "$defs": {
    "safePath": {
      "type": "string",
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))[^\\\\]+$"
    },
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
  }
}
