From 090fdfaf1015e4dce163d50eb073bdebb76c3d52 Mon Sep 17 00:00:00 2001 From: Vaishnavi Desai Date: Fri, 10 Jul 2026 10:43:17 +0530 Subject: [PATCH] Remove unused test-only retrieval helpers Removes DenseRetriever.retrieve_dense_only() and retrieve_with_threshold(), which were only exercised by unit tests and never used in production code. Per maintainer decision in #12, removing rather than documenting as public API. --- src/nexusrag/retrieval/dense.py | 8 -------- src/nexusrag/retrieval/hybrid.py | 3 +-- tests/unit/test_retrieval.py | 9 +-------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/nexusrag/retrieval/dense.py b/src/nexusrag/retrieval/dense.py index 409a663..df6e412 100644 --- a/src/nexusrag/retrieval/dense.py +++ b/src/nexusrag/retrieval/dense.py @@ -42,11 +42,3 @@ def retrieve( return [RetrievalResult(chunk=r.chunk, score=r.score, source="dense") for r in results] - def retrieve_with_threshold( - self, - query: str, - top_k: int = 5, - min_score: float = 0.3, - ) -> list[RetrievalResult]: - results = self.retrieve(query, top_k) - return [r for r in results if r.score >= min_score] diff --git a/src/nexusrag/retrieval/hybrid.py b/src/nexusrag/retrieval/hybrid.py index 60c32a6..238e647 100644 --- a/src/nexusrag/retrieval/hybrid.py +++ b/src/nexusrag/retrieval/hybrid.py @@ -75,8 +75,7 @@ def retrieve_with_dense_top( """Fused results plus the top dense cosine score, from one dense pass.""" return self._run(query, top_k, depth) - def retrieve_dense_only(self, query: str, top_k: int = 10) -> list[RetrievalResult]: - return self.dense.retrieve(query, top_k) + class AdaptiveHybridRetriever(HybridRetriever): diff --git a/tests/unit/test_retrieval.py b/tests/unit/test_retrieval.py index e928b7f..067a581 100644 --- a/tests/unit/test_retrieval.py +++ b/tests/unit/test_retrieval.py @@ -86,10 +86,6 @@ def test_retrieve_passes_through_store(self, retriever): assert [r.chunk.id for r in results] == ["chunk2", "chunk1"] assert all(r.source == "dense" for r in results) - def test_threshold_filters_low_scores(self, retriever): - results = retriever.retrieve_with_threshold("q", top_k=5, min_score=0.8) - assert len(results) == 1 and results[0].score >= 0.8 - class TestHybridRetriever: @pytest.fixture @@ -122,10 +118,7 @@ def test_negative_weight_rejected(self, dense, sparse): with pytest.raises(ValueError): HybridRetriever(dense, sparse, dense_weight=-0.1, sparse_weight=0.3) - def test_single_retriever_paths_skip_fusion(self, dense, sparse): - hybrid = HybridRetriever(dense, sparse) - assert all(r.source == "dense" for r in hybrid.retrieve_dense_only("q", 3)) - sparse.retrieve.assert_not_called() + def test_empty_results(self, dense, sparse): dense.retrieve.return_value = []