project-nomad/admin/app/services
Chris Sherwood 7c2282acf1 feat(KB): conditional warnings A + B on Stored Files (RFC #883 §6)
Surfaces two silent failure modes that the prior binary
"any-chunks-in-Qdrant ⇒ embedded" check could not distinguish from
healthy ingestion:

- **Warning A — Zero-chunk file** (file_size > 100 MB, chunks = 0)
  Fires on video-only / image-only ZIMs (`lrnselfreliance_en_all`,
  TED talks, etc.) that the pipeline completes "successfully" with no
  extractable text. AI Assistant literally cannot reference these.

- **Warning B — Partial-embed stall** (chunks < 50% of expected from
  the ratio registry). Surfaces the simple_wiki "266 of 600,000 chunks"
  case observed during NOMAD1 ingestion testing — previously these
  looked identical to fully-completed embeds in the UI.

Both warnings render only when their condition is met (silent by
default; noisy only on real problems).

Base is `feat/kb-ratio-registry` (#891) because Warning B's "expected
chunks" estimate comes from `KbRatioRegistry.estimateChunks()`. GitHub
fast-forwards to `rc` once #891 merges.

- `app/utils/kb_warning_decision.ts` — pure `decideWarnings(inputs)`
  with thresholds (`100 MB`, `0.5×`) as exported constants. 10 unit
  tests cover the healthy case, both warnings, the under/at/over
  boundary, the registry-miss suppression, and the video-only registry
  case (`expectedChunks: 0` correctly skips Warning B).
- `RagService.computeFileWarnings()` — single Qdrant scroll tallies
  chunks per source, filesystem walk fills in zero-chunk files,
  ratio registry estimates the expectation, decision function emits.
- New endpoint `GET /api/rag/file-warnings` returns
  `Record<source, FileWarning[]>` (sources with no warnings are
  omitted, so the frontend can `warnings[source] ?? []` for clean
  defaults).
- KB modal: warnings render inline under the file name as amber-tinted
  pills. Polled every 30s alongside the existing health check.

- Warning C — chunks skipped due to length. PR #890 (#881 fix) prevents
  the silent drop at the embed boundary, so the underlying condition
  shouldn't fire anymore. If we still want to surface "we truncated
  N chunks to fit", that needs separate `skipped_count` tracking in
  EmbedFileJob — a Phase 2 follow-up.
- Suppressing Warning B during active mid-ingestion. The user can cross-
  reference the Processing Queue to know it's in-flight; suppressing
  warnings while a job runs would mask real stalls where the job died
  mid-batch. Will revisit when per-card status is wired through.
- Use of `kb_ingest_state.chunks_embedded` (#888) as the chunk count
  source. This PR uses Qdrant scroll directly so it can land
  independently of #888.

- 10 new unit tests on `decideWarnings`, all pass
- Type-check clean
- Hot-patch + browser smoke test deferred until #891 lands (the ratio
  registry needs to exist in the DB for `estimateChunks()` to return
  non-null estimates — without it, only Warning A fires which is still
  useful but Warning B stays dormant)
2026-05-16 21:51:29 -07:00
..
benchmark_service.ts fix(AI): vendor-aware AMD HSA override + benchmark discrete-GPU detection 2026-05-05 12:11:56 -07:00
chat_service.ts fix(AI): qwen2.5 loading on every chat message (#649) 2026-04-17 11:37:44 -07:00
collection_manifest_service.ts fix: update default branch name 2026-03-01 16:08:46 -08:00
collection_update_service.ts feat(content-updates): show size, surface downloads in Active Downloads 2026-05-03 13:17:07 -07:00
container_registry_service.ts feat: support for updating services 2026-03-11 14:08:09 -07:00
countries_service.ts feat(Maps): regional map downloads via go-pmtiles extract (#780) 2026-05-03 13:47:53 -07:00
docker_service.ts fix(DockerService): improve volume logic and documentation in forceReinstall 2026-05-13 14:26:59 -07:00
docs_service.ts docs: add Community Add-Ons page with field manuals + W3Schools packs (#753) 2026-04-20 14:57:53 -07:00
download_service.ts feat(Maps): regional map downloads via go-pmtiles extract (#780) 2026-05-03 13:47:53 -07:00
kiwix_library_service.ts fix: prevent ZIM corrupt file crash and deduplicate Ollama download logs (#741) 2026-04-17 11:54:04 -07:00
map_service.ts feat(Maps): regional map downloads via go-pmtiles extract (#780) 2026-05-03 13:47:53 -07:00
ollama_service.ts fix(AI): add truncation DEBUG log 2026-05-15 23:09:59 -07:00
queue_service.ts fix(queue): singleton QueueService to stop ioredis connection leak 2026-05-13 13:48:21 -07:00
rag_service.ts feat(KB): conditional warnings A + B on Stored Files (RFC #883 §6) 2026-05-16 21:51:29 -07:00
system_service.ts fix(System): validate StartedAt with fallback to tail:500 (PR review) 2026-05-13 15:07:48 -07:00
system_update_service.ts fix(security): SSRF validation for map downloads and error sanitization (CWE-918, CWE-209) (#552) 2026-04-17 14:12:02 -07:00
zim_extraction_service.ts fix(RAG): report ZIM ingestion progress in overall-file frame 2026-05-13 16:10:51 -07:00
zim_service.ts fix(ZIM): preserve co-existing Wikipedia corpora on cleanup (#884) 2026-05-15 22:29:17 -07:00