Skip to content

fix(trace): preserve RRF source ranks - #2040

Merged
nicoloboschi merged 1 commit into
vectorize-io:mainfrom
zwcf5200:pr/fix-trace-source-ranks
Jun 8, 2026
Merged

nicoloboschi merged 1 commit into
vectorize-io:mainfrom
zwcf5200:pr/fix-trace-source-ranks

Conversation

@zwcf5200

@zwcf5200 zwcf5200 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve semantic_rank, bm25_rank, graph_rank, and temporal_rank in recall traces
  • accept both the flattened metadata currently emitted by the recall pipeline and the existing nested source_ranks shape
  • add a regression test for the flattened metadata path

SearchTracer.add_rrf_merged() currently reads rrf_meta["source_ranks"], while the recall pipeline expands MergedCandidate.source_ranks into 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.py
  • uv run pytest hindsight-api-slim/tests/test_search_trace.py::test_rrf_trace_preserves_flattened_source_ranks -q
  • uv 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)
  • pre-commit hooks: docs generation and lint passed

@nicoloboschi nicoloboschi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@nicoloboschi
nicoloboschi merged commit f625001 into vectorize-io:main Jun 8, 2026
69 checks passed
@zwcf5200
zwcf5200 deleted the pr/fix-trace-source-ranks branch July 4, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants