“This is a single-store agentic RAG platform: Postgres holds the relational metadata, the pgvector embeddings, and the FTS index, so RBAC and freshness are enforced in the SQL WHERE clause — before ranking, not after. A 289-line state machine orchestrates plan → tool calls → retrieve → rerank → evidence check → generate → citation validation, with hard caps and sha256 loop detection. Quality is enforced by a CI gate over a 50-row golden set across six baselines: behavior 0.960 for the agentic path, Recall@k 0.943 hybrid, unauthorized citations gated to zero — all mock-provider numbers, labeled as such, with the LLM-judge layer implemented but blocked. The numbers are machine-checked against the artifacts by a script that fails CI on drift.”
src/ingestion/): cleaning → structure-aware chunking
(4 selectable strategies) → hashing/dedup → versioning → indexer.src/retrieval/): dense (pgvector) + lexical (FTS)
fused by RRF (k=60) — hybrid.py; freshness as-of semantics in the
WHERE clause (freshness.py); RBAC via rag.access_matches.src/agents/): classify → plan (sanitized against the
live tool registry) → execute tools (schema-validated args) → evidence
sufficiency → generate (XML-isolated evidence) → citation validation.src/security/): 10-pattern regex layer short-circuits
before any LLM call; output sanitizer; tool-arg bounds.evals/): 6 baselines × golden 50; deterministic
metrics only in CI; judge layer blocked and labeled.query → classify ──→ unsupported/ambiguous → safe refusal / clarify
│
▼
plan (≤4 steps) → tools (schema-validated, permissioned)
│ │
▼ ▼
WHERE access_matches ∧ freshness ∧ (dense ∥ lexical) → RRF
│
▼
rerank (candidates 50→5) → evidence sufficient? ──no→ replan (≤1)
│ yes
▼
generate ([N] markers, XML isolation) → citation validation
│ fail → withhold (HALLUCINATION_DETECTED / CITATION_MISMATCH)
▼
answer + citations + trace_id
Board rules worth saying while drawing: caps at every arrow (8 steps,
10 tool calls, 30 s), loops killed by args-hash, and every failure edge
lands in a named state from src/core/failures.py.