{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://edpol.pro/schemas/science-catalog-v2.schema.json",
  "title": "EdPol science and editorial knowledge catalog",
  "description": "Public metadata-first catalog for research, standards, law, methods and practice. A record is not a truth verdict and raw evidence remains outside EdPol.",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "schema", "updated_at", "title", "coverage_note", "source_policy", "records"],
  "properties": {
    "$schema": {"const": "https://edpol.pro/schemas/science-catalog-v2.schema.json"},
    "schema": {"const": "edpol-science-catalog-v2"},
    "updated_at": {"type": "string", "format": "date"},
    "title": {"type": "string", "minLength": 1, "maxLength": 300},
    "coverage_note": {"type": "string", "minLength": 1, "maxLength": 4000},
    "source_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["public_mode", "truth_boundary", "tiers"],
      "properties": {
        "public_mode": {"const": "metadata-first"},
        "truth_boundary": {"type": "string", "minLength": 1, "maxLength": 2000},
        "tiers": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id", "label", "role", "limitations"],
            "properties": {
              "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._-]+$"},
              "label": {"type": "string", "minLength": 1, "maxLength": 200},
              "role": {"type": "string", "minLength": 1, "maxLength": 800},
              "limitations": {"type": "string", "minLength": 1, "maxLength": 1200}
            }
          }
        }
      }
    },
    "records": {
      "type": "array",
      "minItems": 1,
      "maxItems": 10000,
      "items": {"$ref": "#/$defs/record"}
    }
  },
  "$defs": {
    "record": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id", "title", "authors", "year", "era", "lens", "kind", "type",
        "evidence", "scope", "jurisdiction", "publisher", "status", "identifier",
        "languages", "summary", "tags", "url", "source_role", "applicability",
        "provenance", "relations"
      ],
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._:-]{1,160}$"},
        "title": {"type": "string", "minLength": 1, "maxLength": 1000},
        "authors": {"type": "string", "minLength": 1, "maxLength": 1000},
        "year": {"type": "integer", "minimum": 1800, "maximum": 2200},
        "year_label": {"type": "string", "maxLength": 80},
        "era": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._-]+$"},
        "lens": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._-]+$"}},
        "kind": {"enum": ["research", "standard", "legal", "practice", "tool", "dataset", "report", "case-study", "curriculum"]},
        "type": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]+$"},
        "evidence": {"enum": ["research", "standard", "legal", "practice"]},
        "scope": {"type": "string", "minLength": 1, "maxLength": 1000},
        "jurisdiction": {"type": "string", "minLength": 1, "maxLength": 200},
        "publisher": {"type": "string", "minLength": 1, "maxLength": 500},
        "status": {"enum": ["candidate", "imported", "screened", "reviewed", "superseded", "withdrawn", "unavailable"]},
        "legacy_status": {"type": "string", "maxLength": 120},
        "legacy_language": {"type": "string", "maxLength": 32},
        "identifier": {"type": "string", "minLength": 1, "maxLength": 500},
        "identifiers": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "doi": {"type": "string", "pattern": "^10\\.[^\\s/]+/.+", "maxLength": 300},
            "metadata_source": {"enum": ["crossref", "openalex", "unpaywall", "publisher-page", "manual"]},
            "metadata_verified_at": {"type": "string", "format": "date"}
          }
        },
        "languages": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"enum": ["ru", "kk", "en", "other"]}},
        "summary": {"type": "string", "minLength": 1, "maxLength": 4000},
        "tags": {"type": "array", "uniqueItems": true, "maxItems": 50, "items": {"type": "string", "minLength": 1, "maxLength": 120}},
        "url": {"type": "string", "pattern": "^https?://", "maxLength": 2048},
        "source_role": {"enum": ["primary-official", "peer-reviewed", "research-synthesis", "industry-practice", "legal-authority", "technical-standard", "regional-context", "discovery-context"]},
        "applicability": {
          "type": "object",
          "additionalProperties": false,
          "required": ["use", "limitations"],
          "properties": {
            "use": {"type": "array", "minItems": 1, "maxItems": 12, "uniqueItems": true, "items": {"type": "string", "minLength": 1, "maxLength": 500}},
            "limitations": {"type": "string", "minLength": 1, "maxLength": 2000}
          }
        },
        "provenance": {
          "type": "object",
          "additionalProperties": false,
          "required": ["canonical_url", "verification_state", "last_verified_at", "access"],
          "properties": {
            "canonical_url": {"type": "string", "pattern": "^https?://", "maxLength": 2048},
            "archive_url": {"type": "string", "pattern": "^https?://", "maxLength": 2048},
            "verification_state": {"enum": ["curated", "needs-refresh", "unavailable"]},
            "last_verified_at": {"type": ["string", "null"], "format": "date"},
            "access": {"enum": ["open-web", "open-access", "restricted", "unknown"]},
            "notes": {"type": "string", "maxLength": 1200}
          }
        },
        "relations": {
          "type": "array",
          "uniqueItems": true,
          "maxItems": 50,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["type", "target_id"],
            "properties": {
              "type": {"enum": ["supports", "contradicts", "extends", "supersedes", "applied-in", "about", "cites", "related-topic"]},
              "target_id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._:-]{1,160}$"},
              "note": {"type": "string", "maxLength": 800}
            }
          }
        }
      }
    }
  }
}
