Skip to content

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

Closed

Description

@dezren39

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 with limit=50 (:307), larger than the default k of 10, so a single conforming-size page can overshoot k on its own.
  • pkgs/fleet/crates/fleet-search/src/client.rs:331-332 — results.extend(page.results.iter().cloned()), then break only when results.len() >= request.k; nothing truncates.
  • pkgs/fleet/crates/fleet-search/src/client.rs:364 — the envelope's results is replaced with the full collected Vec, overshoot included. No downstream truncation exists: lib.rs print_output / render::render_text print 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 and atlas-search --via-service speak to the service identically"): same PAGE_LIMIT, same extend/break/splice, same overshoot.
  • A conforming server's stored ranking is built from the job's k (server.rs passes request.k into the computation), so the overshoot needs a service whose stored ranking is longer than the job's k — 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

Related: #5424 / #5654 (paging-loop guards this extends), #5433 (fleet-search port), #5407 (count validation parity).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    on Nov 6, 2026
  2. developing-today commented on Nov 6, 2026

    @developing-today
    Contributor
  3. added
    app/atlas-searchpkgs/atlas-search (Atlas search service + atlas-embed)
    app/fleetpkgs/fleet multicall binary + platform crates
    on Nov 6, 2026
  4. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (lane B, new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-06 07:50 CST
    • Found via: filed this run
    • Task: Verify and route the via-service search-client k-overshoot (both client copies) — triage packet enqueued to repo-health-code-pilot.
    • Expectation: effort s; done = spliced envelope capped at request.k (or over-k page treated as malformed) identically in fleet-search client.rs and atlas-search service.rs, with stub-service tests pinning the boundary.
    • Links: probe ~/git/fleet/probe-search-overshoot (laptop, real fleet-search crate @6046e1d7bc)
  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 6, 2026
  6. 55 remaining items

  7. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up — shepherding PR #7137

  8. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 10, 2026
  9. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — PR #7137 merged, fix live on main

  10. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · follow-up closed — local test re-run passed

    • Agent: repo queue worker, lane code-k (repo-worker-code)
    • The local targeted re-run recorded as outstanding at merge time (laptop job 1904c13fbe57: cargo test -p atlas-search + -p fleet-search at 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.
  11. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/atlas-searchpkgs/atlas-search (Atlas search service + atlas-embed)app/fleetpkgs/fleet multicall binary + platform crateskind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions