{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.wednesdaychat.com/contracts/runtime-corpus.schema.json",
  "title": "WEDNESDAY public documentation runtime corpus",
  "description": "Fail-closed contract for the public documentation corpus that may be retrieved into WEDNESDAY model context.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "corpus_id",
    "canonical_origin",
    "language",
    "corpus_hash",
    "chunk_count",
    "chunks"
  ],
  "properties": {
    "schema_version": {
      "const": "wednesday.docs.runtime_corpus.v1"
    },
    "corpus_id": {
      "const": "wednesday-public-docs"
    },
    "canonical_origin": {
      "const": "https://docs.wednesdaychat.com"
    },
    "language": {
      "const": "en"
    },
    "corpus_hash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "chunk_count": {
      "type": "integer",
      "minimum": 1
    },
    "chunks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/chunk"
      }
    }
  },
  "$defs": {
    "chunk": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "section",
        "url",
        "content",
        "content_hash",
        "tags",
        "lifecycle",
        "source_path",
        "ordinal"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 3,
          "maxLength": 160,
          "pattern": "^[a-z0-9][a-z0-9._-]*$"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "section": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "url": {
          "type": "string",
          "pattern": "^https://docs\\.wednesdaychat\\.com/(?:[^\\s#]+/?)?(?:#[A-Za-z0-9._~-]+)?$"
        },
        "content": {
          "type": "string",
          "minLength": 1,
          "maxLength": 12000
        },
        "content_hash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "tags": {
          "type": "array",
          "maxItems": 16,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[a-z0-9][a-z0-9._-]*$"
          }
        },
        "lifecycle": {
          "type": "string",
          "enum": [
            "stable",
            "preview",
            "deprecated"
          ]
        },
        "source_path": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._/-]*$"
        },
        "ordinal": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  }
}
