ARM ONLY, NEVER MERGE: sort the fused union by retrieval score

Replaces the rank-interleaved fusion with a straight merge of the union
sorted by each candidate's raw retrieval score, ties still falling to
declaration order, cut at limit. This is the depth-quota candidate: within
one database rank order and raw-score order coincide, so the whole
difference from the tie-break fix is the cross-database interleaving.

This branch exists to be measured and discarded. The rank-dominance tests
in tests/multi_db/test_search.py pin the behaviour this deliberately
inverts, so the root suite FAILS here by design. If the arm wins, the
shipping implementation belongs to the session that owns client/search.py,
with its own tests.

Claude-Session: https://claude.ai/code/session_01WhudUtZm6qqiuv8Y1sbwSc
This commit is contained in:
Yiorgis Gozadinos 2026-08-31 13:47:04 +03:00
parent 33bd0be702
commit a19f2c96b1
No known key found for this signature in database

View file

@ -193,10 +193,13 @@ async def _fuse(
scored: list[tuple[float, HaikuRAG, Chunk]] = []
for client, candidates in zip(clients, per_source, strict=True):
for rank, (chunk, _) in enumerate(candidates):
scored.append((1.0 / (_RRF_K + rank + 1), client, chunk))
scored.sort(key=lambda item: item[0], reverse=True)
return [(client, chunk, score) for score, client, chunk in scored[:limit]]
for rank, (chunk, score) in enumerate(candidates):
scored.append((1.0 / (_RRF_K + rank + 1), score, client, chunk))
# ARM ONLY, NEVER MERGE: merge the union and sort by the raw retrieval
# score, discarding the rank interleaving entirely. Measures whether the
# depth quota costs more than it buys.
scored.sort(key=lambda item: (item[1],), reverse=True)
return [(client, chunk, fused) for fused, _, client, chunk in scored[:limit]]
# Reciprocal rank fusion's smoothing constant, the value the literature uses.