{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kb.local/wire/v1/ingest_report.schema.json",
  "title": "IngestReport v1",
  "description": "Stub schema — declares the schema_version label and the required fields per design §2.4.",
  "type": "object",
  "required": [
    "schema_version",
    "scope",
    "scanned",
    "new",
    "updated",
    "skipped",
    "unchanged",
    "errors",
    "duration_ms",
    "skipped_by_extension"
  ],
  "properties": {
    "schema_version": { "const": "ingest_report.v1" },
    "scope":          { "type": "object" },
    "scanned":        { "type": "integer", "minimum": 0 },
    "new":            { "type": "integer", "minimum": 0 },
    "updated":        { "type": "integer", "minimum": 0 },
    "skipped":        { "type": "integer", "minimum": 0 },
    "unchanged": {
      "type": "integer",
      "minimum": 0,
      "description": "p9-fb-23: assets whose checksum + parser_version + chunker_version + embedding_version all matched the existing record. Parse / chunk / embed / vector upsert all skipped."
    },
    "errors":         { "type": "integer", "minimum": 0 },
    "duration_ms":    { "type": "integer", "minimum": 0 },
    "skipped_by_extension": {
      "type": "object",
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      },
      "description": "p9-fb-25: per-extension skip count. Key = lowercase extension without leading dot (e.g. 'docx'). Files without extension key under '<no-ext>'."
    },
    "items": {
      "type": ["array", "null"],
      "items": {
        "type": "object",
        "required": ["kind", "doc_path"],
        "properties": {
          "kind":             { "type": "string", "enum": ["new", "updated", "skipped", "unchanged", "error"] },
          "doc_id":           { "type": ["string", "null"] },
          "doc_path":         { "type": "string" },
          "asset_id":         { "type": ["string", "null"] },
          "byte_len":         { "type": ["integer", "null"], "minimum": 0 },
          "block_count":      { "type": ["integer", "null"], "minimum": 0 },
          "chunk_count":      { "type": ["integer", "null"], "minimum": 0 },
          "parser_version":   { "type": ["string", "null"] },
          "chunker_version":  { "type": ["string", "null"] },
          "warnings":         { "type": "array", "items": { "type": "string" } },
          "pdf_ocr_pages":    { "type": ["integer", "null"], "minimum": 0, "description": "v0.20.0 sub-item 1: number of PDF pages 가 OCR pipeline 통과. null = OCR disabled or non-PDF asset." },
          "pdf_ocr_ms_total": { "type": ["integer", "null"], "minimum": 0, "description": "v0.20.0 sub-item 1: cumulative OCR engine wall-clock duration (ms). null = OCR disabled or non-PDF asset." },
          "error":            { "type": ["string", "null"] }
        }
      }
    },
    "skipped_gitignore":         { "type": "integer", "minimum": 0 },
    "skipped_kebabignore":       { "type": "integer", "minimum": 0 },
    "skipped_builtin_blacklist": { "type": "integer", "minimum": 0 },
    "skipped_generated":         { "type": "integer", "minimum": 0 },
    "skipped_size_exceeded":     { "type": "integer", "minimum": 0 },
    "skip_examples": {
      "type": "object",
      "properties": {
        "generated":         { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "size_exceeded":     { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "builtin_blacklist": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "gitignore":         { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      }
    }
  }
}
