{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://theredthread-stories.com/metadata/public-evidence.schema.json",
  "title": "The Red Thread Public Evidence Register",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "name",
    "version",
    "canonicalPersonId",
    "lastVerified",
    "publicDisclaimer",
    "claims",
    "namesakeExclusions",
    "sourceClassifications"
  ],
  "properties": {
    "$schema": {"const": "./public-evidence.schema.json"},
    "name": {"const": "The Red Thread Public Evidence Register"},
    "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
    "canonicalPersonId": {"type": "string", "format": "uri", "pattern": "^https://theredthread-stories\\.com/"},
    "lastVerified": {"type": "string", "format": "date"},
    "publicDisclaimer": {
      "type": "object",
      "required": ["en", "ar"],
      "additionalProperties": false,
      "properties": {
        "en": {"type": "string", "minLength": 20},
        "ar": {"type": "string", "minLength": 20}
      }
    },
    "claims": {
      "type": "array",
      "minItems": 10,
      "items": {"$ref": "#/$defs/claim"}
    },
    "namesakeExclusions": {
      "type": "array",
      "minItems": 3,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["recordId", "displayName", "sourceURL", "reasonExcluded", "verificationDate"],
        "properties": {
          "recordId": {"type": "string", "pattern": "^namesake-[a-z0-9-]+$"},
          "displayName": {"type": "string", "minLength": 2},
          "sourceURL": {"type": "string", "format": "uri"},
          "reasonExcluded": {"type": "string", "minLength": 20},
          "verificationDate": {"type": "string", "format": "date"}
        }
      }
    },
    "sourceClassifications": {
      "type": "object",
      "minProperties": 6,
      "additionalProperties": {"type": "string", "minLength": 20}
    }
  },
  "$defs": {
    "claim": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "claimId",
        "claim",
        "arabicEquivalent",
        "category",
        "sourceURL",
        "sourceOwner",
        "sourceType",
        "controlStatus",
        "verificationDate",
        "confidence",
        "permittedWording",
        "prohibitedWording",
        "privacyClassification",
        "publicationEligibility",
        "externalActionRequired"
      ],
      "properties": {
        "claimId": {"type": "string", "pattern": "^[a-z][a-z0-9-]+$"},
        "claim": {"type": "string", "minLength": 5},
        "arabicEquivalent": {"type": "string", "minLength": 2},
        "category": {"type": "string", "enum": ["identity", "professional", "literary", "academic", "identifier", "profile", "public-event"]},
        "sourceURL": {"type": "string", "format": "uri", "pattern": "^https://"},
        "supportingURLs": {"type": "array", "items": {"type": "string", "format": "uri"}, "uniqueItems": true},
        "sourceOwner": {"type": "string", "minLength": 2},
        "sourceType": {"type": "string", "enum": ["author-controlled-source", "professional-platform-source", "academic-platform-source", "identifier-registry", "independent-event-source"]},
        "controlStatus": {"type": "string", "enum": ["author-controlled", "self-controlled", "mixed", "independent"]},
        "verificationDate": {"type": "string", "format": "date"},
        "confidence": {"type": "string", "enum": ["high", "medium", "low"]},
        "permittedWording": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 2}},
        "prohibitedWording": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 2}},
        "privacyClassification": {"type": "string", "enum": ["public", "public-with-boundary", "internal-only"]},
        "publicationEligibility": {"type": "string", "enum": ["public", "public-with-boundary", "not-for-publication"]},
        "externalActionRequired": {"type": "string", "minLength": 2}
      }
    }
  }
}
