{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "schema/source.schema.json",
  "title": "Source card YAML header",
  "description": "One card per outside source. Cards hold a summary and short quotes only, never a full copy.",
  "type": "object",
  "additionalProperties": false,
  "required": ["type", "id", "title", "url", "publisher", "subject", "category", "authority",
               "source_type", "published", "retrieved", "http_status", "archive_url", "sha256", "supports_fields"],
  "properties": {
    "type": {"const": "source"},
    "id": {"type": "string", "pattern": "^[a-z]{2}-\\d{2}$"},
    "title": {"type": "string", "minLength": 1},
    "url": {"type": "string", "pattern": "^https://[^\\s]+$"},
    "publisher": {"type": "string", "minLength": 1},
    "subject": {"type": "string", "minLength": 1, "description": "Provider or topic the source is about."},
    "category": {"type": "string", "minLength": 1},
    "authority": {"enum": ["official", "third-party"], "description": "official = published by the provider or standards body it describes."},
    "source_type": {"enum": ["official-doc", "support", "announcement", "repo", "terms", "news", "independent-test", "prior-art"]},
    "published": {"type": "string", "pattern": "^(\\d{4}-\\d{2}-\\d{2}|unknown.*)$"},
    "retrieved": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
    "http_status": {"type": "integer"},
    "fetch_method": {"enum": ["direct", "reader-proxy", "webfetch"]},
    "archive_url": {"oneOf": [{"const": "unknown"}, {"type": "string", "pattern": "^https://[^\\s]+$"}]},
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$", "description": "Fingerprint of the normalized text retrieved on `retrieved`; used to detect changes."},
    "supports_fields": {"type": "array", "items": {"type": "string"}},
    "use": {"enum": ["evidence", "leads-only"], "description": "leads-only sources (prior art, competitors) may not back a provider field."}
  }
}
