{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "compare",
  "type": "object",
  "required": ["published_at", "months", "official_yoy_pct", "official_core_yoy_pct",
               "gauge_yoy_pct", "col_yoy_pct", "tracker_yoy_pct", "supercore_yoy_pct",
               "pce_yoy_pct", "validation"],
  "additionalProperties": false,
  "properties": {
    "published_at": {"type": "string"},
    "months": {"type": "array",
               "items": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"}},
    "official_yoy_pct": {"type": "array", "items": {"type": "number"}},
    "official_core_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "official_pce_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "official_core_pce_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "official_supercore_yoy_pct": {"description": "BLS CPI services less rent of shelter (CUUR0000SASL2RS) YoY — supercore's reference from 2026-09-28", "type": "array", "items": {"type": ["number", "null"]}},
    "gauge_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "col_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "tracker_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "supercore_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "pce_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
    "realtime": {
      "description": "Vintage-true month-end gauge track (2026-09-28): the headline as it could have been known at each month-end. Publish-ledger readings where they exist, else reconstructed by applying each official print only from its first release date. Absent in older artifacts.",
      "type": "object",
      "required": ["dates", "months", "gauge_yoy_pct", "source", "basis", "lag_days",
                   "n_ledger", "n_reconstructed", "validation"],
      "additionalProperties": false,
      "properties": {
        "dates": {"type": "array",
                  "items": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"}},
        "months": {"type": "array",
                   "items": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"}},
        "gauge_yoy_pct": {"type": "array", "items": {"type": ["number", "null"]}},
        "source": {"type": "array", "items": {"enum": ["ledger", "reconstructed"]}},
        "basis": {"type": "string"},
        "lag_days": {"type": "object",
                     "additionalProperties": {"type": "integer", "minimum": 0}},
        "n_ledger": {"type": "integer", "minimum": 0},
        "n_reconstructed": {"type": "integer", "minimum": 0},
        "validation": {"$ref": "#/$defs/stats"}
      }
    },
    "validation": {
      "type": "object",
      "required": ["gauge", "col", "tracker", "supercore", "pce"],
      "additionalProperties": false,
      "properties": {
        "gauge": {"$ref": "#/$defs/stats"},
        "col": {"$ref": "#/$defs/stats"},
        "tracker": {"$ref": "#/$defs/stats"},
        "supercore": {"$ref": "#/$defs/stats"},
        "pce": {"$ref": "#/$defs/stats"}
      }
    }
  },
  "$defs": {
    "stats": {
      "type": "object",
      "required": ["corr", "mean_abs_gap_pp", "window"],
      "additionalProperties": false,
      "properties": {
        "corr": {"type": ["number", "null"], "minimum": -1, "maximum": 1},
        "mean_abs_gap_pp": {"type": ["number", "null"]},
        "window": {"type": "string"},
        "lead_lag": {"oneOf": [
          {"type": "null"},
          {"type": "object",
           "required": ["best_shift_months", "corr"],
           "additionalProperties": false,
           "properties": {
             "best_shift_months": {"type": "integer", "minimum": 0, "maximum": 6},
             "corr": {"type": "number", "minimum": -1, "maximum": 1}}}]}
      }
    }
  }
}
