Skip to content

fix(ranker): dense_rank_decisions tiebreak parity + regression suite (post-7f9d5a9 follow-up)#9

Open
hang-in wants to merge 1 commit into
jaytoone:masterfrom
hang-in:feat/upstream-followup-dense-rank-and-tests
Open

fix(ranker): dense_rank_decisions tiebreak parity + regression suite (post-7f9d5a9 follow-up)#9
hang-in wants to merge 1 commit into
jaytoone:masterfrom
hang-in:feat/upstream-followup-dense-rank-and-tests

Conversation

@hang-in
Copy link
Copy Markdown
Contributor

@hang-in hang-in commented May 10, 2026

Summary

Two follow-ups to 7f9d5a9 — bundled into a single small PR for easy review:

  1. dense_rank_decisions tiebreak parity — the third sort site that 7f9d5a9'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:550 was still scored.sort(key=lambda x: -x[0]). Now uses (-x[0], hash_or_text_prefix) to match the other two sites.

  2. Regression suite — the re-skinned 5 test cases from the #5 close-comment offer, dropped in at tests/regression/test_deterministic_sort.py. Uses importlib.util to load bm25-memory.py (hyphenated filename rules out a normal import).

Sites covered by the new test suite

Test Site Tiebreak
test_dense_rank_decisions_no_emb_returns_empty dense_rank_decisions this PR
test_rrf_merge_idempotent_same_input rrf_merge 7f9d5a9
test_rrf_merge_equal_rank_tiebreak_independent_of_list_input_order rrf_merge 7f9d5a9
test_rrf_merge_equal_score_tiebreak_is_hash rrf_merge 7f9d5a9
test_bm25_rank_decisions_index_tiebreak bm25_rank_decisions 7f9d5a9

Validation

  • AST OK on both files
  • 5/5 regression tests PASS against the patched monolith

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.

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>
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.

1 participant