{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://octenidine.org/data/source-registry.schema.json",
  "title": "Octenidine.org Source Registry",
  "type": "object",
  "required": [
    "title",
    "publisher",
    "description",
    "generatedAt",
    "canonicalData",
    "recordCount",
    "tierDefinitions",
    "useForDefinitions",
    "dateFields",
    "recordGuidance",
    "sources"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "publisher": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "generatedAt": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "canonicalData": {
      "type": "string"
    },
    "recordCount": {
      "type": "integer",
      "minimum": 0
    },
    "tierDefinitions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "tier",
          "label",
          "use"
        ],
        "additionalProperties": false,
        "properties": {
          "tier": {
            "enum": [
              "tier_1_identity_regulatory_safety",
              "tier_2_evidence_synthesis_guideline",
              "tier_3_primary_literature",
              "tier_4_product_supplier_document",
              "tier_5_context_only"
            ]
          },
          "label": {
            "type": "string"
          },
          "use": {
            "type": "string"
          }
        }
      }
    },
    "useForDefinitions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "useFor",
          "meaning"
        ],
        "additionalProperties": false,
        "properties": {
          "useFor": {
            "enum": [
              "chemical-identity",
              "regulatory-context",
              "safety-context",
              "clinical-evidence",
              "microbiology",
              "formulation-context",
              "search-discovery"
            ]
          },
          "meaning": {
            "type": "string"
          }
        }
      }
    },
    "dateFields": {
      "type": "object",
      "required": [
        "lastChecked",
        "reviewCadenceMonths",
        "nextReviewDue"
      ],
      "additionalProperties": false,
      "properties": {
        "lastChecked": {
          "type": "string"
        },
        "reviewCadenceMonths": {
          "type": "string"
        },
        "nextReviewDue": {
          "type": "string"
        }
      }
    },
    "recordGuidance": {
      "type": "object",
      "required": [
        "useFor",
        "notFor",
        "citationNote",
        "editorialNotes"
      ],
      "additionalProperties": false,
      "properties": {
        "useFor": {
          "type": "string"
        },
        "notFor": {
          "type": "string"
        },
        "citationNote": {
          "type": "string"
        },
        "editorialNotes": {
          "type": "string"
        }
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "title",
          "publisher",
          "url",
          "tier",
          "sourceType",
          "lastChecked",
          "reviewCadenceMonths",
          "nextReviewDue",
          "useFor",
          "notFor",
          "citationNote",
          "editorialNotes"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]*$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "publisher": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "pattern": "^https://.+"
          },
          "tier": {
            "enum": [
              "tier_1_identity_regulatory_safety",
              "tier_2_evidence_synthesis_guideline",
              "tier_3_primary_literature",
              "tier_4_product_supplier_document",
              "tier_5_context_only"
            ]
          },
          "sourceType": {
            "type": "string",
            "minLength": 1
          },
          "lastChecked": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "reviewCadenceMonths": {
            "type": "integer",
            "minimum": 1
          },
          "nextReviewDue": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "useFor": {
            "type": "array",
            "minItems": 1,
            "items": {
              "enum": [
                "chemical-identity",
                "regulatory-context",
                "safety-context",
                "clinical-evidence",
                "microbiology",
                "formulation-context",
                "search-discovery"
              ]
            }
          },
          "notFor": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "citationNote": {
            "type": "string",
            "minLength": 1
          },
          "editorialNotes": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    }
  }
}
