{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://autotel.dev/schemas/eventcatalog/drift-summary/v0.2.0.json",
  "title": "Autotel EventCatalog Drift Summary v0.2.0",
  "description": "Machine-readable summary written by `autotel-eventcatalog drift --summary-output`. Downstream tooling (GitHub Actions, dashboards, Slack bots) should read this. Major-version bumps are breaking; minor-version bumps add optional fields only.",
  "type": "object",
  "required": ["spec", "mode", "shouldFail", "reason", "counts"],
  "additionalProperties": false,
  "properties": {
    "spec": {
      "type": "string",
      "const": "autotel-eventcatalog-drift-summary/v0.2.0"
    },
    "mode": {
      "type": "string",
      "enum": ["all", "new-only"],
      "description": "Which policy was applied. `all` = fail on any drift; `new-only` = fail only on drift introduced vs a baseline snapshot."
    },
    "shouldFail": {
      "type": "boolean",
      "description": "True iff the configured policy considers the current state a CI failure."
    },
    "reason": {
      "type": "string",
      "description": "Short human-readable line explaining why shouldFail is what it is."
    },
    "counts": {
      "type": "object",
      "required": [
        "total",
        "observedButUndocumentedEvents",
        "documentedButUnseenEvents",
        "fieldDriftEvents",
        "fieldDriftPaths",
        "typeDriftPaths",
        "valueDriftPaths",
        "undocumentedServices",
        "undocumentedChannels"
      ],
      "additionalProperties": false,
      "properties": {
        "total": {
          "type": "integer",
          "minimum": 0,
          "description": "Sum of all individual drift findings. Matches the dashboard's `drift findings` badge."
        },
        "observedButUndocumentedEvents": { "type": "integer", "minimum": 0 },
        "documentedButUnseenEvents": { "type": "integer", "minimum": 0 },
        "fieldDriftEvents": {
          "type": "integer",
          "minimum": 0,
          "description": "Distinct events with at least one field-path mismatch."
        },
        "fieldDriftPaths": {
          "type": "integer",
          "minimum": 0,
          "description": "Sum of extra + missing field paths across every event with field drift."
        },
        "typeDriftPaths": {
          "type": "integer",
          "minimum": 0,
          "description": "Count of field paths where observed runtime types do not match declared schema types."
        },
        "valueDriftPaths": {
          "type": "integer",
          "minimum": 0,
          "description": "Count of field paths where observed primitive values fall outside declared enum values."
        },
        "undocumentedServices": { "type": "integer", "minimum": 0 },
        "undocumentedChannels": { "type": "integer", "minimum": 0 }
      }
    }
  }
}
