fix(ranker): dense_rank_decisions tiebreak parity + regression suite (post-7f9d5a9 follow-up)#9
Open
hang-in wants to merge 1 commit into
Conversation
Two follow-ups to 7f9d5a9 (deterministic sort tiebreaks for PR-4 + PR-5): ## 1. dense_rank_decisions tiebreak (the missed third site) 7f9d5a9's commit message lists three sort sites: rrf_merge, bm25_rank_decisions, and dense_rank_decisions ("sort key adds text prefix as tiebreak"). The first two landed cleanly, but the dense site at `bm25-memory.py:550` was still `scored.sort(key=lambda x: -x[0])` — no tiebreak applied. This patch adds the same `(-x[0], hash_or_text_prefix)` form used by the other sites, restoring parity. Low blast radius (vec-daemon-gated path) but worth closing the loop. ## 2. Regression suite for all four sites Adds tests/regression/test_deterministic_sort.py with 5 cases: - rrf_merge idempotent (same input → same output) - rrf_merge equal-rank tiebreak independent of list_a/list_b order - rrf_merge equal-score tiebreak by hash - dense_rank_decisions no-emb sanity - bm25_rank_decisions index tiebreak Loader uses `importlib.util` because `bm25-memory.py` has a hyphen and can't be imported normally. Drops directly into upstream layout — no package layout assumptions. Validation: 5/5 PASS against the patched monolith. Refs: hang-in/tunaCtx#5 (Draft, closed) — re-skin offer accepted in the close comment thread. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Two follow-ups to
7f9d5a9— bundled into a single small PR for easy review:dense_rank_decisionstiebreak parity — the third sort site that7f9d5a9's commit message listed ("dense_rank_decisions: sort key adds text prefix as tiebreak") but didn't actually patch in the diff.bm25-memory.py:550was stillscored.sort(key=lambda x: -x[0]). Now uses(-x[0], hash_or_text_prefix)to match the other two sites.Regression suite — the re-skinned 5 test cases from the
#5close-comment offer, dropped in attests/regression/test_deterministic_sort.py. Usesimportlib.utilto loadbm25-memory.py(hyphenated filename rules out a normalimport).Sites covered by the new test suite
test_dense_rank_decisions_no_emb_returns_emptydense_rank_decisionstest_rrf_merge_idempotent_same_inputrrf_merge7f9d5a9test_rrf_merge_equal_rank_tiebreak_independent_of_list_input_orderrrf_merge7f9d5a9test_rrf_merge_equal_score_tiebreak_is_hashrrf_merge7f9d5a9test_bm25_rank_decisions_index_tiebreakbm25_rank_decisions7f9d5a9Validation
Why this is its own PR (not bundled into
7f9d5a9)The dense site was a parity miss in
7f9d5a9— calling it out as a separate PR keeps the credit/changelog clean and gives the test suite a natural landing point.Refs: closed PR #5 — re-skin offer mentioned in the close comment, accepted here.