{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://terminalweather.com/developers/schemas/station-event.schema.json",
  "title": "Terminal Weather station event preview",
  "description": "Non-production schema proposed for station-level integrity and report-condition events during the private technical preview.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "event_id",
    "type",
    "basis",
    "detected_at",
    "station",
    "data"
  ],
  "properties": {
    "schema": {
      "const": "terminal-weather.station-event.preview.v1"
    },
    "event_id": {
      "type": "string",
      "pattern": "^evt_[A-Za-z0-9_-]{12,}$"
    },
    "type": {
      "type": "string",
      "enum": [
        "terminal-weather.integrity.aligned",
        "terminal-weather.integrity.content-difference",
        "terminal-weather.integrity.source-lag",
        "terminal-weather.integrity.incomplete",
        "terminal-weather.report.correction-present",
        "terminal-weather.report.nil-present"
      ]
    },
    "basis": {
      "const": "current-snapshot"
    },
    "detected_at": {
      "type": "string",
      "format": "date-time"
    },
    "station": {
      "type": "string",
      "pattern": "^[A-Z]{4}$"
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": ["integrity_state", "latest_observed_at"],
      "properties": {
        "integrity_state": {
          "type": "string",
          "enum": ["aligned", "content-difference", "source-lag", "incomplete"]
        },
        "latest_observed_at": {
          "type": ["string", "null"],
          "format": "date-time"
        },
        "available_path_count": {
          "type": "integer",
          "minimum": 0
        },
        "expected_path_count": {
          "type": "integer",
          "minimum": 1
        },
        "lagging_path_ids": {
          "type": "array",
          "items": { "type": "string" },
          "uniqueItems": true
        },
        "missing_path_ids": {
          "type": "array",
          "items": { "type": "string" },
          "uniqueItems": true
        },
        "canonical_variant_count": {
          "type": "integer",
          "minimum": 0
        },
        "representation_fingerprints": {
          "type": "object",
          "additionalProperties": {
            "type": ["string", "null"],
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      }
    },
    "derived_from": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    }
  }
}
