feat: production RAG hardening (15-task plan) - #44
Closed
n0nuser wants to merge 19 commits into
Closed
Conversation
…D now actually governs /query)
ragas 0.4.3 removed the pre-instantiated `ragas.metrics.collections`
singletons from the classic `evaluate()` path; it now requires actual
Metric instances (isinstance(m, Metric)), raising:
TypeError: All metrics must be initialised metric objects, e.g:
metrics=[BleuScore(), AspectCritic()]
Import Faithfulness/AnswerRelevancy/ContextPrecision/ContextRecall from
ragas.metrics (the legacy-compatible classes, still available via a
deprecation shim) and construct instances for evaluate().
Also fixes a related break: EvaluationResult.__getitem__ now returns a
list of per-row scores instead of a scalar, so float(result["metric"])
raised TypeError. Added _mean_score() to average per-row scores (NaN-safe),
preserving the existing PASS_THRESHOLDS gating logic.
Modern ragas.metrics.collections classes require per-sample async .ascore() calls, not the deprecated singleton-style ragas.metrics imports; the judge LLM/embeddings now run against the same local Ollama instance LocalRAG itself uses (via Ollama's OpenAI-compatible /v1 endpoint and the openai client already a core dependency), so evals stay fully offline with no OPENAI_API_KEY required anywhere, including CI.
log_reasonings/ captures decisions made during the production-RAG-hardening plan rollout (ragas judge LLM choice, agent fan-out strategy, retry discipline) as lighter-weight session notes alongside the formal docs/adr/.
Retroactively documents three architecture decisions from the production- RAG-hardening plan rollout that were missing formal ADRs (only captured in log_reasonings/ session notes): resilient/uniformly-routed LLM providers (Task 13-14), optional cross-encoder reranking (Task 6), and the offline Ollama-backed ragas judge (Task 1). Also clarifies in evals/run_evals.py that AsyncOpenAI/OpenAIEmbeddings there are OpenAI-shaped clients pointed at local Ollama, not a dependency on the OpenAI service.
Owner
Author
|
Content already landed on main — PR #43's rebase-merge picked up this branch's commits (all 19, replayed with new SHAs) plus its own fix on top. Verified via file-level diff: origin/main and this branch's tree are identical except for #43's extract_sources/ingest_paths cleanup, which main already has. Closing as redundant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements all 15 tasks from
docs/superpowers/plans/2026-07-07-production-rag-hardening.md:where=) and BM25 retrieval pathssentence-transformers, off by default)RAG_MIN_CONTEXT_SCORE, off by default)heading_path/chunk_typeonSourceRefAUDIT_LOG_PATH)POST /ingest/directory/async)RAGEnginenow routed through the resilient provider abstraction —LLM_BACKENDactually governs/query(previously always hit Ollama regardless of setting)tenant_idmetadata tagging for shared-deployment query scopingrag//ingestion/, judge LLM running fully offline against local Ollama (noOPENAI_API_KEYanywhere)Also adds ADRs 007-009 documenting the resilient-provider-routing, reranking, and offline-ragas-judge decisions, plus
log_reasonings/session notes on the agent fan-out strategy used to implement this plan.Test plan
uv run pytest -m "not integration" -q— 141 passed, 9 deselectedruff check ./ruff format --check .— cleanLLM_BACKEND=openaiwith a bad key now produces a real401from the OpenAI SDK (proving routing actually works, not silently falling back to Ollama)https://claude.ai/code/session_01Md71iujmpvewiisGX5u33H