Repository navigation
feat(retrieval): rrf fusion with hybrid_rrf mode wiring (T10) - #10
Merged
Merged
Conversation
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.
Task T10 from docs/ARCHITECTURE.md §14.2 (spec §7.5, §9.3).
What
retrieval/fuse.py(new, pure):rrf(vector_list, fts_list, k=60)— textbook Reciprocal Rank Fusionscore(d) = Σ 1/(k + rank_i(d)), 1-based ranks, dedup by chunk id, ties broken by ascending chunk_id. No I/O, no config, no db.retrieval/__init__.py(dispatch-only touch): wires thehybrid_rrfmode per §7.5 — vec0 KNN top-vector_top_k(20) + FTS5 BM25 top-fts_top_k(20) → RRF (k=rrf_k=60) → top-final_k(5). Passages getscore= RRF score (higher = more relevant) andstage = "rrf". T09's frozen public API (retrievesignature,Passage,RetrievalError) and the vector path are unchanged. Rerank pass-through untouched (T18).Decisions
chunk_idcolumn — id selected asrowid AS chunk_id(external-content,content_rowid='chunk_id');ORDER BY score, chunk_idfor deterministic bm25 ties.hybrid_rrfwithfts_top_k < 1orrrf_k < 1raisesRetrievalError(defense in depth; §11.4 validators already reject it).Verification
uv run pytest -q— 187 passed (166 baseline + 21 new: 9 RRF unit tests incl. hand-computed fused scores, 12 hybrid-mode integration tests on a fixture DB with sqlite-vec).uv run ruff check,uv run ruff format --check,uv run mypy(strict) — all clean.§14.4 notes
Touches T09-owned
retrieval/__init__.pydispatch only; frozen API unchanged. Dependents to re-run tests before merging: T11 (consumes passages) and T18 (rerank wiring — note: the hybrid path cuts tofinal_kbefore returning; the reranker needs the fusion candidate pool preserved).