{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://analysisreports.github.io/schemas/repertory.schema.json",
  "title": "Canonical Macro & Geopolitical Telemetry Repertory Schema",
  "description": "Formal JSON Schema Draft 2020-12 data contract for the entity- and topic-indexed verified telemetry warehouse (llms-repertory.json).",
  "type": "object",
  "required": [
    "$schema",
    "metadata",
    "index",
    "items"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
    "metadata": {
      "type": "object",
      "required": [
        "title",
        "domain",
        "version",
        "author",
        "license",
        "endpoint",
        "text_endpoint",
        "documentation",
        "last_updated",
        "sync_status",
        "total_items",
        "source_authority",
        "root_index"
      ],
      "properties": {
        "title": { "type": "string" },
        "domain": { "type": "string" },
        "version": { "type": "string" },
        "author": { "type": "string" },
        "license": { "type": "string" },
        "endpoint": { "type": "string", "format": "uri" },
        "text_endpoint": { "type": "string", "format": "uri" },
        "documentation": { "type": "string", "format": "uri" },
        "last_updated": { "type": "string" },
        "sync_status": { "type": "string" },
        "total_items": { "type": "integer", "minimum": 0 },
        "source_authority": { "type": "string" },
        "root_index": { "type": "string", "format": "uri" }
      }
    },
    "index": {
      "type": "object",
      "required": ["topics", "kinds", "entities_count", "chronic_baseline_count"],
      "properties": {
        "topics": {
          "type": "object",
          "additionalProperties": { "type": "integer", "minimum": 0 }
        },
        "kinds": {
          "type": "object",
          "additionalProperties": { "type": "integer", "minimum": 0 }
        },
        "entities_count": { "type": "integer", "minimum": 0 },
        "chronic_baseline_count": { "type": "integer", "minimum": 0 }
      }
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "label",
          "source",
          "topics",
          "entities",
          "value",
          "unit",
          "delta_pct",
          "yoy_pct",
          "status",
          "last_date",
          "is_chronic_baseline"
        ],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string", "minLength": 1 },
          "kind": { "type": "string", "enum": ["series", "chokepoint", "port", "model", "corridor"] },
          "label": { "type": "string" },
          "source": { "type": "string" },
          "topics": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["ENERGY", "MARITIME", "RATES", "TECH", "FOOD", "CREDIT", "FX", "MODELS", "MACRO"]
            }
          },
          "entities": {
            "type": "array",
            "items": { "type": "string" }
          },
          "value": { "type": ["number", "null"] },
          "unit": { "type": ["string", "null"] },
          "delta_pct": { "type": ["number", "null"] },
          "yoy_pct": { "type": ["number", "null"] },
          "status": { "type": ["string", "null"] },
          "last_date": { "type": ["string", "null"] },
          "is_chronic_baseline": { "type": "boolean" },
          "meta": {
            "type": "object"
          }
        }
      }
    }
  }
}
