[RAG Retrieval] Add deterministic semantic and hybrid retrieval - #8
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new, dependency-free retrieval layer to generic-rag, implementing bounded semantic retrieval and deterministic rank-only hybrid fusion over caller-owned collaborators, while also extracting shared deterministic projection integrity algorithms into a dedicated module.
Changes:
- Introduces
generic_rag.retrievalwithretrieve_semanticandretrieve_hybrid, including strict contract validation, stale/current filtering, deduplication, deterministic tie-breaking, and score-free hybrid fusion (RRF with offset 60). - Extracts projection integrity derivation/validation into
generic_rag.projection_integrityand wires projection/retrieval to use it. - Updates public docs, module index, packaging boundary tests, and adds comprehensive behavioral + golden tests for retrieval and integrity.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_retrieval.py | New end-to-end behavioral matrix for semantic + hybrid retrieval, determinism, validation, dedup, truncation, and failure/stale precedence. |
| tests/test_retrieval_contracts.py | Extends contract tests to cover the new RetrievalLimits type and invariants. |
| tests/test_projection_integrity.py | New golden/validation tests for extracted v1 integrity algorithms and workflow parity with projection. |
| tests/test_package_boundaries.py | Updates module inventory, dependency graph, and export assertions for the new modules. |
| tests/support/verify_artifacts.py | Ensures built artifacts include the two new production modules. |
| src/generic_rag/retrieval.py | Implements bounded semantic retrieval and deterministic hybrid fusion with strict validation and content-free failure mapping. |
| src/generic_rag/projection.py | Replaces inlined integrity logic with calls to generic_rag.projection_integrity. |
| src/generic_rag/projection_integrity.py | New shared module owning deterministic v1 digest/ID/token derivation and checkpoint validation. |
| src/generic_rag/contracts.py | Adds RetrievalLimits contract type and exports it via __all__. |
| README.md | Updates package overview and guidance to include retrieval and links to the retrieval guide. |
| PYTHON_MODULE_INDEX.md | Expands indexed production units to 7 and documents responsibilities/dependencies for new modules. |
| docs/security-and-privacy.md | Documents retrieval-specific trust boundary, caller obligations, and collaborator data exposure. |
| docs/retrieval.md | New retrieval guide with an independent-consumer example and full host flow requirements. |
| docs/projection.md | Links projection lifecycle to retrieval usage and documents the extracted integrity helpers. |
| docs/lifecycle.md | Updates lifecycle guidance to include retrieval call scope and host operational ownership. |
| docs/api.md | Updates public API reference to include retrieval workflows and projection integrity helpers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7 tasks
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
Verification
git diff --checkCloses #4