{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://palimpsest.info/protocol/regional-editorial-evidence-v1.schema.json",
  "title": "Palimpsest regional editorial evidence registry v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "as_of", "evidence", "editorials", "method", "limitations"],
  "properties": {
    "schema_version": {"const": "palimpsest.regional-editorial-evidence.v1"},
    "as_of": {"type": "string", "format": "date"},
    "evidence": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/evidence"}
    },
    "editorials": {
      "type": "object",
      "additionalProperties": false,
      "required": ["bri", "gwadar", "balochistan", "myanmar"],
      "properties": {
        "bri": {"$ref": "#/$defs/editorial"},
        "gwadar": {"$ref": "#/$defs/editorial"},
        "balochistan": {"$ref": "#/$defs/editorial"},
        "myanmar": {"$ref": "#/$defs/editorial"}
      }
    },
    "method": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
    "limitations": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}}
  },
  "$defs": {
    "region": {"enum": ["bri", "gwadar", "balochistan", "myanmar"]},
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["evidence_id", "regions", "source_name", "source_title", "url", "published_at", "source_role", "evidence_state", "statement", "interpretation_limit"],
      "properties": {
        "evidence_id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]+$"},
        "regions": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"$ref": "#/$defs/region"}},
        "source_name": {"type": "string", "minLength": 1},
        "source_title": {"type": "string", "minLength": 1},
        "url": {"type": "string", "format": "uri"},
        "published_at": {"type": "string", "format": "date"},
        "source_role": {"type": "string", "minLength": 1},
        "evidence_state": {"type": "string", "minLength": 1},
        "statement": {"type": "string", "minLength": 1},
        "interpretation_limit": {"type": "string", "minLength": 1}
      }
    },
    "section": {
      "type": "object",
      "additionalProperties": false,
      "required": ["section_id", "heading", "paragraphs", "evidence_ids"],
      "properties": {
        "section_id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]+$"},
        "heading": {"type": "string", "minLength": 1},
        "paragraphs": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
        "evidence_ids": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]+$"}}
      }
    },
    "editorial": {
      "type": "object",
      "additionalProperties": false,
      "required": ["title", "dek", "sections"],
      "properties": {
        "title": {"type": "string", "minLength": 1},
        "dek": {"type": "string", "minLength": 1},
        "sections": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/section"}}
      }
    }
  }
}
