feat: add offline text ingestion vertical slice #5
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 526 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.375
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5"
general
weight: 0.35
Xander-Xai
Problem
The repository has no validated path from raw source documents to the Qdrant text index consumed by online retrieval.
Phase 1 contract
This PR implements UTF-8 TXT → deterministic character chunks → text embedding interface → configured BGE adapter → Qdrant text points → existing online text reader and authorization filtering.
Storage contract
doc_idfrom source identity.chunk_idfrom source identity, content digest, chunk ordinal, and chunk digest.chunk_idplusdoc_version_epoch, so identical content can coexist safely across epochs.doc_id,chunk_id,chunk_index,content,source_path,content_hash,doc_type,embedding_type,role_mask,dept_mask,status,doc_version_epoch, and source metadata.active; epoch is explicit and matched by the online Qdrant filter.config.json(rag_text_768, 768 dimensions); cosine distance is validated.OFFLINE_INGESTION_LOCK_DIRto a shared private directory when processes have separate temp namespaces. Same-epoch replacement archives old points before upsert and removes stale IDs; different epochs remain intact; empty documents remove prior same-epoch points.top_kunique document IDs or exhausts the Qdrant results.BGE boundary
The production adapter lazily uses
EmbeddingService, the same configuredAutoTokenizer,AutoModel, and attention-mask-aware mean pooling used for online text queries. Ingestion uses the configured bounded embedding batch size (default 32). CI uses a deterministic test embedder; no BGE model is downloaded. A real BGE model smoke test was not run.Authorization
Every stored point includes valid role and department masks. The existing fail-closed
ParallelRecallManagerauthorization path allows matching users and rejects callers lacking either required permission. Qdrant filters active status and the configured epoch before retrieval.QDRANT_HOST,QDRANT_PORT, andQDRANT_GRPC_PORTenvironment settings are applied by the shared config used by both ingestion and the online reader.Bounded input and idempotence
By default the TXT slice accepts at most 131072 input bytes and 256 chunks per document, configurable through
knowledge_base.max_document_bytesandknowledge_base.max_chunks; oversized inputs fail before embedding or collection initialization. Repeating the same source content, chunk settings, and epoch creates the same physical point IDs. The same content in a different epoch has distinct physical IDs and coexists. Changed content is detected by its content hash; stale points are removed only within the replaced document/epoch. RRF scores a source document at most once per retrieval path and carries distinct top-ranked chunk evidence from different paths into the fused content.Validation
python3 -m pytest tests/test_offline_text_ingestion.py -q --tb=short— 37 passed.python3 -m pytest tests/ -q --tb=short— 631 passed.python3 -m pytest --collect-only -q— 631 collected.python3 scripts/check_repo_consistency.py,python3 -m compileall -q ., Ruff check/format, andgit diff --checkpassed.94d624f604e73e0af9baec1c53248db53843eecf: Python 3.10, Python 3.11, lint, pip-audit, and secret scan all succeeded.94d624f604and reported no major issues. Unresolved review thread count: 0.Out of scope
PDF, DOCX, XLSX, OCR, CLIP, Elasticsearch writer, scheduler, rebuild, feedback, RAGAS, fine-tuning, and frontend.
Part of #2