Repository navigation
Description
Problem
The via-service search clients never truncate the paged results to the requested k. Each page is spliced in whole: the paging loop extends the result list with the full page, breaks once the count reaches k, and then inserts all collected results into the printed envelope. A service whose page contains more results than k — one page of 3 against --k 2, or the client's own 50-result page limit against the default --k 10 — makes the via-service route print more results than the caller asked for, where the standalone route for the same request prints exactly k.
The clients' own contract says otherwise: paging runs "until the requested result count is satisfied", and the returned value is "the service's envelope with the paged results spliced in, field-for-field what standalone renders for the same request" (fleet-search client.rs module/function docs). The cursor guards in the same loop (#5424, #5654) already treat a service that deviates from the protocol as malformed and fall back loudly; an over-k ranking is the one deviation that is silently passed through to the user.
Evidence (origin/main 6046e1d)
pkgs/fleet/crates/fleet-search/src/client.rs:31—PAGE_LIMIT = 50: every results page is requested withlimit=50(:307), larger than the defaultkof 10, so a single conforming-size page can overshootkon its own.pkgs/fleet/crates/fleet-search/src/client.rs:331-332—results.extend(page.results.iter().cloned()), then break only whenresults.len() >= request.k; nothing truncates.pkgs/fleet/crates/fleet-search/src/client.rs:364— the envelope'sresultsis replaced with the full collectedVec, overshoot included. No downstream truncation exists:lib.rsprint_output/render::render_textprint the envelope as-is.pkgs/atlas-search/crates/atlas-search/src/service.rs:28,202,226-227,259— the identical loop in atlas-search's own via-service client (fleet-search's header says it is a port of this client, "so the fleet verb andatlas-search --via-servicespeak to the service identically"): samePAGE_LIMIT, same extend/break/splice, same overshoot.- A conforming server's stored ranking is built from the job's
k(server.rspassesrequest.kinto the computation), so the overshoot needs a service whose stored ranking is longer than the job'sk— an older, coalesced, or non-conforming service — which is exactly the class of peer the existing cursor guards defend against.
Verified this run (probe, real fleet-search crate)
Probe ~/git/fleet/probe-search-overshoot on the laptop: a binary calling the real fleet_search::run (path dependency on the workspace crate @6046e1d7bc) against a stub HTTP service (submit → 202, status → done, one results page of 3 results, next_cursor: null, total_results: 3):
--k 2 -> printed envelope results: 3 (ids 1, 2, 3), exit 0
--k 1 -> printed envelope results: 3 (ids 1, 2, 3), exit 0
Standalone for the same request renders exactly k results. No error, no fallback, no truncation.
Why it matters
--k is the caller's result-count contract (scripts and the fleet verb's consumers size output by it). The via-service route is the sandbox seat's default, so the route most likely to be scripted is the one that can silently return 5x the requested count (50 vs the default 10) whenever the service's ranking for a job is longer than the k it was submitted with. It also breaks the byte-parity the two clients exist to preserve: the same query prints different result counts via-service vs standalone.
Acceptance criteria
- After paging, the spliced envelope contains at most
request.kresults (truncate the final page's contribution), in bothpkgs/fleet/crates/fleet-search/src/client.rsandpkgs/atlas-search/crates/atlas-search/src/service.rs— or, if an over-kpage is judged malformed like the cursor deviations, it returns the malformed-response error and falls back loudly; pick one behavior, apply it identically in both clients, and note the choice in the PR. - A stub-service test pins the boundary in each client: a single page longer than
kyields exactlykresults (or the malformed error), and multi-page paging that lands exactly onkis unchanged. - Existing client tests keep passing (
cargo test -p fleet-search, atlas-search service client tests), including the atlas-search(service): results-paging loop has no deadline or cursor-progress guard — a non-advancing page stream hangs the CLI forever instead of falling back to standalone #5424/atlas-search + fleet-search: results-paging cursor guard catches only an immediate repeat — a cycling cursor (A→B→A) spins the no-sleep paging loop until the 330s deadline #5654 cursor-guard cases and the multi-page happy path.
Related: #5424 / #5654 (paging-loop guards this extends), #5433 (fleet-search port), #5407 (count validation parity).
Activity
developing-today commentedon Nov 6, 2026
CODE-1979
dezren39 commentedon Nov 6, 2026
🤖 Agent note · filed
55 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · picked up — shepherding PR #7137
dezren39 commentedon Nov 10, 2026
🤖 Agent note · done — PR #7137 merged, fix live on main
service.rs, fleet-searchclient.rs), with regression tests for multi-page stop-at-k and oversized single pages. Issue fleet-search(atlas client): via-service paging never truncates to the requested k — a page longer than k is printed whole instead of the standalone-parity count #6524 is exactly this defect, so it is closed on the merge.cargo test -p atlas-search+-p fleet-search, laptop job 1904c13fbe57) was still compiling under laptop load ~80 at merge time and is recorded here for follow-up; the change is two truncation lines plus tests in the two clients.dezren39 commentedon Nov 10, 2026
🤖 Agent note · follow-up closed — local test re-run passed
cargo test -p atlas-search+-p fleet-searchat PR fix(search): cap via-service results at requested k #7137's head) has now completed: exit 0, all test binaries ok (including the 11 search tests in the final binary). The fix-forward caveat from the merge note is discharged — no follow-up needed.dezren39 commentedon Nov 11, 2026
🤖 Agent note · done
.take(remaining)in both atlas-search service.rs and fleet-search client.rs, with the regression testsearch_truncates_oversized_single_page_to_requested_k. Lane code-k's done + follow-up notes (2026-11-10T23:42Z / 23:55Z) already record the outcome and the passed local test re-run.