{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.michaeldariuseastwood.com/schemas/claim-governance-policy.schema.json",
  "title": "Claim governance policy",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "policyId",
    "dateModified",
    "source",
    "assertionQuarantine",
    "description",
    "identity",
    "defaults",
    "explicitFalsifierFields",
    "privateEvidencePrefixes",
    "correctionEntryIds",
    "outputs",
    "forbiddenWording",
    "publicCopyCorrections"
  ],
  "properties": {
    "schemaVersion": {"const": 1},
    "policyId": {"type": "string", "minLength": 1},
    "dateModified": {"type": "string", "format": "date"},
    "source": {"type": "string", "minLength": 1},
    "assertionQuarantine": {"type": "string", "minLength": 1},
    "description": {"type": "string", "minLength": 1},
    "identity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["personId", "programmeId", "claimsCollection"],
      "properties": {
        "personId": {"type": "string", "format": "uri"},
        "programmeId": {"type": "string", "format": "uri"},
        "claimsCollection": {"type": "string", "format": "uri"}
      }
    },
    "defaults": {
      "type": "object",
      "additionalProperties": false,
      "required": ["claimStatus", "evidenceStatus", "falsificationStatus"],
      "properties": {
        "claimStatus": {"type": "string", "minLength": 1},
        "evidenceStatus": {"type": "string", "minLength": 1},
        "falsificationStatus": {"type": "string", "minLength": 1}
      }
    },
    "explicitFalsifierFields": {"$ref": "#/$defs/nonEmptyStringArray"},
    "privateEvidencePrefixes": {"$ref": "#/$defs/nonEmptyStringArray"},
    "correctionEntryIds": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {"type": "string", "pattern": "^AQ-[0-9]{3}$"}
    },
    "outputs": {
      "type": "object",
      "additionalProperties": false,
      "required": ["claimsJsonl", "falsification", "corrections", "anchors"],
      "properties": {
        "claimsJsonl": {"type": "string", "minLength": 1},
        "falsification": {"type": "string", "minLength": 1},
        "corrections": {"type": "string", "minLength": 1},
        "anchors": {"type": "string", "minLength": 1}
      }
    },
    "forbiddenWording": {
      "type": "object",
      "additionalProperties": false,
      "required": ["note", "entries"],
      "properties": {
        "note": {"type": "string", "minLength": 1},
        "entries": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {"$ref": "#/$defs/forbiddenWordingEntry"}
        }
      }
    },
    "publicCopyCorrections": {
      "type": "array",
      "items": {"$ref": "#/$defs/copyCorrection"},
      "uniqueItems": true
    }
  },
  "$defs": {
    "nonEmptyStringArray": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {"type": "string", "minLength": 1}
    },
    "copyCorrection": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "path", "find", "replace", "expectedMatches", "reason"],
      "properties": {
        "id": {"type": "string", "pattern": "^COPY-[A-Z0-9-]+$"},
        "path": {"type": "string", "minLength": 1},
        "find": {"type": "string", "minLength": 1},
        "replace": {"type": "string", "minLength": 1},
        "expectedMatches": {"type": "integer", "minimum": 1},
        "reason": {"type": "string", "minLength": 1}
      }
    },
    "forbiddenWordingEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "phrase", "reason", "date", "enforcedBy"],
      "properties": {
        "id": {"type": "string", "pattern": "^FW-[0-9]{3}$"},
        "phrase": {"type": "string", "minLength": 1},
        "reason": {"type": "string", "minLength": 1},
        "date": {"type": "string", "format": "date"},
        "enforcedBy": {"type": "string", "minLength": 1}
      }
    }
  }
}
