{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.dorokas.africa/rules/v1.schema.json",
  "title": "Dorokas Rule Book, version 1",
  "description": "Every public rule in force on Dorokas. Cite a rule by its permanent address (/r/<RULE-ID>/). Fail closed: if schema_version or a status is one you do not know, do not use the file.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "locale",
    "site",
    "updated",
    "count",
    "rules"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "schema_version": {
      "const": "1.0"
    },
    "locale": {
      "const": "en"
    },
    "site": {
      "const": "https://docs.dorokas.africa"
    },
    "updated": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "The latest checked date among the rules."
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "rules": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "title",
          "summary",
          "status",
          "effective_from",
          "effective_to",
          "url",
          "page_url",
          "markdown_url",
          "audiences",
          "last_checked",
          "review_by",
          "source"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9]*(?:-[A-Z][A-Z0-9]*){0,2}-\\d{3}$"
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "summary": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "enum": [
              "in_force"
            ]
          },
          "effective_from": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "The date the current wording took effect; null where the record does not state it yet."
          },
          "effective_to": {
            "type": "null",
            "description": "Always null for a rule in force; superseded wordings live in the archive."
          },
          "url": {
            "type": "string",
            "pattern": "^https://docs\\.dorokas\\.africa/",
            "description": "Permanent citation address, /r/<RULE-ID>/."
          },
          "page_url": {
            "type": "string",
            "pattern": "^https://docs\\.dorokas\\.africa/",
            "description": "Where the rule is explained today; may move, so cite url instead."
          },
          "markdown_url": {
            "type": "string",
            "pattern": "^https://docs\\.dorokas\\.africa/",
            "description": "Raw Markdown copy of the rule page."
          },
          "audiences": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "last_checked": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "review_by": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "source": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "backend_sha",
              "web_sha",
              "checked_at"
            ],
            "properties": {
              "backend_sha": {
                "type": "string",
                "pattern": "^[0-9a-f]{7,40}$"
              },
              "web_sha": {
                "type": "string",
                "pattern": "^[0-9a-f]{7,40}$"
              },
              "checked_at": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              }
            }
          }
        }
      }
    }
  }
}
