{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/ai-agent-engineer/source-record.schema.json",
  "title": "知识库来源记录",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "tenant_id",
    "document_id",
    "source_sequence",
    "source_uri",
    "source_version",
    "content",
    "allowed_groups"
  ],
  "properties": {
    "tenant_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "pattern": "^\\S(?:.*\\S)?$"
    },
    "document_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "pattern": "^\\S(?:.*\\S)?$"
    },
    "source_sequence": {
      "type": "integer",
      "minimum": 1
    },
    "source_uri": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000,
      "pattern": "^\\S(?:.*\\S)?$"
    },
    "source_version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "pattern": "^\\S(?:.*\\S)?$"
    },
    "content": {
      "type": "string",
      "minLength": 1,
      "pattern": "\\S",
      "x-maxUtf8Bytes": 100000,
      "description": "应用层必须另行执行 UTF-8 字节上限；JSON Schema maxLength 统计字符而非字节。"
    },
    "allowed_groups": {
      "type": "array",
      "minItems": 1,
      "maxItems": 128,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200,
        "pattern": "^\\S(?:.*\\S)?$"
      }
    }
  }
}
