{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/citedtravel-com/json-schema/citedtravel-com-change-feed-schema.json",
  "title": "ChangeFeed",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/citedtravel-com-openapi.json#/components/schemas/ChangeFeed",
  "type": "object",
  "required": [
    "since",
    "data"
  ],
  "properties": {
    "since": {
      "type": "string",
      "format": "date",
      "description": "Rows with changed_on on or after this date (inclusive)."
    },
    "dataset_version": {
      "type": "string"
    },
    "data": {
      "type": "array",
      "description": "Changes, newest first.",
      "items": {
        "$ref": "#/$defs/Change"
      }
    }
  },
  "$defs": {
    "Change": {
      "type": "object",
      "required": [
        "fact_id",
        "country",
        "category",
        "change",
        "changed_on",
        "detected_at"
      ],
      "properties": {
        "seq": {
          "type": "integer"
        },
        "dataset_version": {
          "type": "string",
          "description": "Dataset in which the change was detected."
        },
        "changed_on": {
          "type": "string",
          "format": "date",
          "description": "When OUR pipeline detected the change (the dataset's build date), not when the rule took effect. Same value as detected_at; kept for compatibility."
        },
        "detected_at": {
          "type": "string",
          "format": "date",
          "description": "When our pipeline detected the change (= changed_on). Not the date the rule took effect."
        },
        "effective_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "When the rule itself took effect, only if an official source states it; otherwise null."
        },
        "change_reason": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "source_update",
            "pipeline_fix",
            "rule_change",
            "new_coverage",
            null
          ],
          "description": "Why our data changed, when known: source_update = the cited official text changed; pipeline_fix = same official text, our extraction was corrected; rule_change = the source states a new rule (with effective_date); new_coverage = a fact we did not publish before; null = not determined."
        },
        "fact_id": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "category": {
          "type": "string"
        },
        "change": {
          "type": "string",
          "enum": [
            "added",
            "updated",
            "removed"
          ]
        },
        "old_value": {
          "description": "Previous value (null when added)."
        },
        "new_value": {
          "description": "New value (null when removed)."
        },
        "source_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Main source of the fact."
        }
      }
    }
  }
}