{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://terraevidence.com/evidence-record.schema.json",
  "title": "TerraEvidence Evidence Record",
  "description": "A machine-readable public evidence record that preserves a reviewed claim, its support, limits, sources, scope, and revision information without implying universal proof.",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "recordId", "version", "status", "topic", "title", "claim", "summary", "evidenceSupports", "doesNotEstablish", "sources", "scope", "useBoundary", "humanReadableUrl", "machineReadableUrl", "revision"],
  "properties": {
    "$schema": { "const": "https://terraevidence.com/evidence-record.schema.json" },
    "recordId": { "type": "string", "pattern": "^EP-PUB-[0-9]{3}$" },
    "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+$" },
    "status": { "$ref": "#/$defs/status" },
    "topic": { "type": "string", "minLength": 1 },
    "title": { "type": "string", "minLength": 1 },
    "claim": { "type": "string", "minLength": 1 },
    "summary": { "type": "string", "minLength": 1 },
    "evidenceSupports": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
    "doesNotEstablish": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
    "sources": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/source" } },
    "scope": { "$ref": "#/$defs/scope" },
    "useBoundary": { "type": "string", "minLength": 1 },
    "humanReadableUrl": { "type": "string", "format": "uri", "pattern": "^https://terraevidence\\.com/earth-project-reviewed-foundations#ep-pub-[0-9]{3}$" },
    "machineReadableUrl": { "type": "string", "format": "uri", "pattern": "^https://terraevidence\\.com/evidence-records/ep-pub-[0-9]{3}\\.json$" },
    "revision": { "$ref": "#/$defs/revision" }
  },
  "$defs": {
    "status": {
      "type": "object",
      "additionalProperties": false,
      "required": ["code", "label", "meaning"],
      "properties": {
        "code": { "const": "reviewed-for-stated-scope" },
        "label": { "const": "Reviewed for stated scope" },
        "meaning": { "type": "string", "minLength": 1 }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sourceId", "sourceType", "institution", "title", "url", "relevance"],
      "properties": {
        "sourceId": { "type": "string", "pattern": "^EP-PUB-[0-9]{3}-S[0-9]+$" },
        "sourceType": { "type": "string", "enum": ["institutional-guidance", "primary-study", "primary-publication", "peer-reviewed-review", "review", "archive-record", "other"] },
        "institution": { "type": "string", "minLength": 1 },
        "title": { "type": "string", "minLength": 1 },
        "url": { "type": "string", "format": "uri" },
        "relevance": { "type": "string", "minLength": 1 }
      }
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": ["reviewedPeriod", "applicability", "limitations", "openQuestion"],
      "properties": {
        "reviewedPeriod": { "type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$" },
        "applicability": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
        "limitations": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
        "openQuestion": { "type": "string", "minLength": 1 }
      }
    },
    "revision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "publishedDate", "lastReviewedPeriod"],
      "properties": {
        "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+$" },
        "publishedDate": { "type": "string", "format": "date" },
        "lastReviewedPeriod": { "type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$" }
      }
    }
  }
}
