{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://china-snapshot.com/data/events.schema.json",
  "title": "China Snapshot document events and relations",
  "description": "Typed dates and links extracted from official notices. Every event and relation carries the verbatim words it came from (span), the method, a confidence and needs_review. A date the notice does not state is absent, never inferred. Dates are calendar dates as the notice states them (Beijing). Pilot scope: MOFCOM export-control notices. Each document id resolves via GET /api/datasets?dataset=documents&id=<id>.",
  "type": "object",
  "required": ["schema_version", "generated_at", "documents", "events", "relations", "counts"],
  "properties": {
    "schema_version": {"const": 1},
    "parser_version": {"type": "string"},
    "generated_at": {"type": "string", "format": "date-time"},
    "scope": {"type": "string"},
    "dates": {"type": "string"},
    "documents": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "title"],
        "properties": {
          "id": {"type": "string", "pattern": "^documents:[0-9]+$"},
          "title": {"type": "string"}, "original_title": {"type": "string"}, "publisher": {"type": "string"},
          "source_url": {"type": "string", "format": "uri"}, "doc_number": {"type": ["string", "null"]},
          "first_seen": {"type": ["string", "null"]}, "text_status": {"type": ["string", "null"]}, "body_chars": {"type": "integer"}, "error": {"type": "string"}
        }
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "doc_id", "type", "date", "basis", "span", "confidence", "needs_review", "method"],
        "properties": {
          "id": {"type": "string"}, "doc_id": {"type": "string"},
          "type": {"enum": ["publication", "effective", "expiry", "consultation_end"], "description": "publication = issue date; effective = in force from; expiry = ends or suspension ends; consultation_end = comment deadline."},
          "date": {"type": ["string", "null"], "format": "date"},
          "basis": {"enum": ["issue_date_label", "listing", "posting_meta", "stated_date", "on_publication", "stated_term", "repeal_date", "model_extracted"]},
          "span": {"$ref": "#/$defs/span"},
          "confidence": {"type": "number", "minimum": 0, "maximum": 1},
          "needs_review": {"type": "boolean", "description": "True when confidence is below 0.7, the span is missing, or a model produced it."},
          "method": {"enum": ["rule", "llm"]}, "note": {"type": "string"}
        }
      }
    },
    "relations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "from_doc_id", "type", "target", "span", "confidence", "needs_review", "method"],
        "properties": {
          "id": {"type": "string"}, "from_doc_id": {"type": "string"},
          "type": {"enum": ["amends", "repeals", "implements", "cites"]},
          "target": {
            "type": "object",
            "properties": {
              "title": {"type": "string"},
              "doc_number": {"type": "object", "properties": {"raw": {"type": "string"}, "year": {"type": "integer"}, "seq": {"type": "integer"}}},
              "doc_id": {"type": ["string", "null"], "description": "Set only when the target is a record in this set."}
            }
          },
          "span": {"$ref": "#/$defs/span"},
          "confidence": {"type": "number", "minimum": 0, "maximum": 1}, "needs_review": {"type": "boolean"}, "method": {"enum": ["rule", "llm"]}, "note": {"type": "string"}
        }
      }
    },
    "counts": {"type": "object"}
  },
  "$defs": {
    "span": {
      "type": ["object", "null"],
      "description": "The verbatim words the value came from. field=page means the publisher's page metadata, with no text.",
      "properties": {
        "field": {"enum": ["body", "title", "page"]}, "text": {"type": ["string", "null"]},
        "start": {"type": ["integer", "null"]}, "end": {"type": ["integer", "null"]},
        "withheld": {"type": "boolean", "description": "True when the quoted sentence is not published because the record text is not approved for publication; start and end still locate it in the original."}
      }
    }
  }
}
