{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://china-snapshot.com/data/monitor-event.schema.json",
  "title": "China Snapshot monitor event",
  "description": "One watched change. The same object appears on /monitor/export-controls, in the sample alert email, as the event of a webhook delivery, in the events array of GET /api/changes?watch=..., and in the MCP get_changes result.",
  "type": "object",
  "required": ["schema", "id", "event_type", "detected_at", "match", "document", "dates", "links"],
  "properties": {
    "schema": {"const": "china-snapshot.monitor-event/1"},
    "id": {"type": "string", "pattern": "^documents:[0-9]+#(new|newly_discovered|revised)$", "description": "Stable per document and change type."},
    "event_type": {"enum": ["new", "newly_discovered", "revised"], "description": "new: published and collected the same day. newly_discovered: older than our collection. revised: the text changed."},
    "detected_at": {"type": ["string", "null"], "format": "date-time", "description": "When the archive first saw it (UTC)."},
    "match": {
      "type": "object",
      "required": ["watchlist", "terms", "fields", "reason"],
      "properties": {
        "watchlist": {"type": "string"},
        "terms": {"type": "array", "items": {"type": "string"}, "description": "Listed terms the record's own title contains. Empty means no match, and the monitor does not publish it."},
        "fields": {"type": "array", "items": {"enum": ["title", "original_title"]}},
        "reason": {"type": "string"},
        "terms_reviewed_on": {"type": ["string", "null"], "format": "date"}
      }
    },
    "document": {
      "type": "object",
      "required": ["id", "title", "publisher", "kind", "source_url"],
      "properties": {
        "id": {"type": "string"}, "title": {"type": ["string", "null"]}, "original_title": {"type": ["string", "null"]},
        "publisher": {"type": ["string", "null"]}, "kind": {"enum": ["official", "press"]},
        "published_at": {"type": ["string", "null"], "format": "date"}, "source_url": {"type": ["string", "null"], "format": "uri"},
        "language": {"type": ["string", "null"]}, "acquisition_route": {"type": ["string", "null"]}, "text_status": {"type": ["string", "null"]}
      }
    },
    "dates": {
      "type": "array",
      "description": "Dates the notice states. A date a notice does not state is absent, never inferred.",
      "items": {
        "type": "object",
        "required": ["type", "date", "evidence"],
        "properties": {
          "type": {"enum": ["publication", "effective", "expiry", "consultation_end"]},
          "date": {"type": "string", "format": "date", "description": "Calendar date as written (Beijing)."},
          "basis": {"type": ["string", "null"]}, "confidence": {"type": ["number", "null"]}, "needs_review": {"type": "boolean"},
          "evidence": {
            "type": ["object", "null"],
            "properties": {
              "quote": {"type": ["string", "null"], "description": "The source sentence, where the archive may republish it."},
              "withheld": {"type": "boolean"},
              "reason": {"type": "string", "description": "text_rights_not_approved or sentence_not_extracted."},
              "locator": {"type": ["string", "null"]},
              "deep_link": {"type": ["string", "null"], "format": "uri", "description": "Publisher page, scrolled to the passage by browsers that support text fragments."},
              "chars": {"type": "array", "items": {"type": ["integer", "null"]}}
            }
          }
        }
      }
    },
    "links": {"type": "object", "properties": {"record": {"type": "string"}, "dates": {"type": "string"}, "monitor": {"type": "string"}}}
  }
}
