HIGH fixes:
- H1: Gemini blocked-response detection in verifier (safety filter short-circuit)
- H2: Config load crash guard in app_web.py (st.stop instead of traceback)
- H3: Brace-escape user text in kb_meta.py prompts (prevent KeyError)
- H4: Web UI clarification state tracking (pending_clarification_question)
MEDIUM fixes:
- M1: Preserve leading zeros as TEXT in sql_ingest type inference
- M2: Deferred clearing in ingest.py prevents data loss on total failure
- M3: Strip markdown fences from LLM-generated SQL in sql_retriever
- M4: max_iterations=0 guard in verifier (skip verification, do not refuse)
- M5: Add clarification QA to conversation history for pronoun resolution
- M6: Remove hardcoded knowledge_base/ prefix in retriever source paths
Also adds CLAUDE.md, docs/plans/, full test suite (162 tests, 17 files),
and updates WORKLOG.md with audit results.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
fix: 6-agent debug audit β 8 bugs fixed across codebaseβ
Multi-agent systematic audit found and fixed:
HIGH:
- Empty model="" overrode provider defaults, causing API errors when no
model configured (llm/__init__.py + all 3 providers)
- Vector-to-SQL fallback was dead code β QU layer now preserves sql_query
regardless of route, and prompt asks LLM to generate fallback sql_query
- SQL validation strengthened with keyword blocklist (INSERT, DELETE, DROP,
ALTER, CREATE, ATTACH, DETACH, PRAGMA, LOAD_EXTENSION) β first layer
of two-layer SQL injection defense
MEDIUM:
- Verification prompt no longer leaks internal chunk ID naming (CHUNK-LOCAL,
CHUNK-SQL) into correction loop β uses user-facing language instead
- config_loader now gives friendly FileNotFoundError directing user to run
setup.py, instead of raw traceback
- config.yaml opened with explicit encoding="utf-8" for cross-platform safety
- OpenAI model filter narrowed from startswith("o") to startswith("o1","o3","o4")
153 tests pass (152 existing + 1 new SQL validation test).
β¦
fix: harden route parsing, column dedup, and column name accessβ
- Normalize QU route output (strip/lowercase) before validation
- Fix column name deduplication to handle suffix collisions
(e.g., 'Score_A', 'Score_A', 'Score_A_2' no longer produces duplicates)
- Use defensive .get() for column name access in SQL result formatting
Co-Authored-By: Claude Opus 4.6 <[email protected]>
feat: add KB meta overview for meta-question answering and LLM awarenessβ
Generate an LLM-powered high-level summary of the knowledge base at
ingestion time. The overview is stored as a ChromaDB chunk (enabling
vector search for meta-questions like "what data do you have?") and
injected into QU and system prompts (giving the LLM full KB awareness
for routing and contextualized answers).
New: src/kb_meta.py, tests/test_kb_meta.py (20 tests)
Modified: ingest.py, prompts.py, query_engine.py, verifier.py
Co-Authored-By: Claude Opus 4.6 <[email protected]>
feat: add SQL schema loading and route/sql_query parsing to query engineβ
- Add _escape_braces() to all prompt builders to prevent str.format() crash
when user documents contain {placeholder} patterns
- Fix app_web.py display_query fallback to preserve clarification context
- Add empty-response guards to all 3 LLM providers (openai, anthropic, gemini)
- Replace all remaining direct dict access with .get() + defaults
- Add 2 regression tests for curly-brace format injection
- Expand query engine tests with display_query coverage
- 62 tests pass across 13 test files
Co-Authored-By: Claude Opus 4.6 <[email protected]>
feat: add query understanding layer for better retrievalβ
Pre-retrieval LLM step that reformulates user queries into
search-optimized forms (expanded keywords, resolved pronouns,
domain-aware terms) and optionally asks clarification questions.
- New src/query_engine.py with understand_query() + JSON parsing
- New prompt template in src/prompts.py
- CLI: query understanding + conversation history + clarification flow
- Web UI: query understanding + pending_clarification state
- Config: query_understanding.enabled/max_history/max_clarifications
- 10 new tests (59 total, all passing)
Co-Authored-By: Claude Opus 4.6 <[email protected]>