chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
Code search's next page can repeat the last one's file
Closedchadtmiller.com mentioned this in searching_code is quarantined while code search's paging is made stable
Fixed by 45bb6590, "A code search's pages go on from the one before": every page now asks Zoekt for all 200 files and slices them in a fixed order (score, repository, path), so the next page no longer repeats a file from the one before. The searching_code quarantine that was meant to go with that fix is still in harness/quarantine.json, but it expires on 2026-11-10.
What happened
searching_codeincrates/knotless-serve/tests/web.rsfails now and then, on the spaces net. The second page ofneedle_&limit=1repeats the first page's repository:That line is
assert_ne!(next["files"][0]["repo"], first["files"][0]["repo"]).It failed once and then passed at one head of knotless-serve answers repositories' sites on their own domain, and failed twice in a row at its next head,
8c5a70cce2b3. Neither head touches code search.The cause is that the cursor is an offset into an ordering that is not stable:
Code::search(crates/knotless-serve/src/code.rs) asks Zoekt forMaxDocDisplayCount = skip + limitfiles, andweb/search.rsskipsskipof them.needle_files are, come back in whatever order its shards finish.How to see it
Run
searching_codea few times on the spaces net, or read thetestlog of that pull at8c5a70cce2b3. It's quarantined meanwhile inharness/quarantine.json.What you expected
Each page continues the last, with no file shown twice. That takes a stable order: score, then repository and path. A tie at a page's edge is settled only by seeing every file that ties, so a fix asks past
upto(toDEEPEST, or until the score drops), then sorts and slices. Measure what that costs first.Where
knotless-serve's
dev.knotless.searchCode, as main has it at54981405.