Repository navigation
fix(trace): preserve RRF source ranks - #2040
Merged
nicoloboschi merged 1 commit intoJun 8, 2026
Merged
Conversation
nicoloboschi
approved these changes
Jun 8, 2026
nicoloboschi
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Confirmed the bug: the recall pipeline flattens source_ranks into the top level of rrf_meta (memory_engine.py:4142/4246 via **mc.source_ranks), so the old rrf_meta.get("source_ranks", {}) always returned empty. The fallback correctly harvests the *_rank keys. Fast deterministic regression test is the right call for pure serialization logic. Minimal scope — no fusion/ranking/ordering changes.
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
semantic_rank,bm25_rank,graph_rank, andtemporal_rankin recall tracessource_ranksshapeSearchTracer.add_rrf_merged()currently readsrrf_meta["source_ranks"], while the recall pipeline expandsMergedCandidate.source_ranksinto the metadata top level. The trace therefore reports an empty source-rank map even though fusion computed the ranks correctly.This change only fixes trace serialization; it does not change fusion, reranking, strategy boosts, or result ordering.
Validation
uv run ruff check hindsight-api-slim/hindsight_api/engine/search/tracer.py hindsight-api-slim/tests/test_search_trace.pyuv run pytest hindsight-api-slim/tests/test_search_trace.py::test_rrf_trace_preserves_flattened_source_ranks -quv run pytest hindsight-api-slim/tests/test_interleave_fusion.py hindsight-api-slim/tests/test_fusion_cap.py hindsight-api-slim/tests/test_recall_boost.py -q(29 passed)