From 2bed30cf5aca20a96ad3a2f381bba1f9872401a5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 3 Nov 2026 10:59:49 +0100 Subject: [PATCH] read-floor: equal scores past the candidate cut keep the earliest ordinals (pins Reader::id_of's rows) Co-Authored-By: Claude Opus 5.5 --- crates/huginn-mind/src/query.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/huginn-mind/src/query.rs b/crates/huginn-mind/src/query.rs index 48e1d09..93217a5 100644 --- a/crates/huginn-mind/src/query.rs +++ b/crates/huginn-mind/src/query.rs @@ -2058,6 +2058,21 @@ mod tests { } } + /// Past the candidate cut the tie-break decides who is kept: equal scores arriving in reverse + /// keep the earliest ordinals, which a lookup that gives every hit one row does not. + #[test] + fn equal_scores_past_the_cut_keep_the_earliest_ordinals() { + let mut mind = seeded(); + let total = LIMIT_MAX + 3; + for n in 1..=total { + committed(admit(&mut mind, vec![question_n(n)])); + } + let key = |n: u32| id("question", &format!("Q{n}")); + let hits: Vec<_> = (1..=total).rev().map(|n| hit(K::Question, &key(n), 0.5)).collect(); + let page = rank_all(&mind, &Selection::default(), &asking(LIMIT_MAX), &hits).page; + assert_eq!(ids(&page), (1..=LIMIT_MAX).map(key).collect::>()); + } + /// Membership is the selection's alone: a kind, a key allowlist and a /// citation predicate each cut the candidates exactly as they cut a plain /// query, and the citation predicate sees the whole mind, not only the