Skip to content

atlas-search(grouped): unbounded k wraps (k * 10) in grouped_output — huge --k silently truncates the grouped consideration window (debug builds panic) #5423

Closed

Description

@dezren39

Bug

Grouped search computes its consideration window as (opts.k * 10).max(opts.pool) with no bound on k anywhere in the stack (pkgs/atlas-search/crates/atlas-core/src/search.rs:451, grouped_output):

let consideration = &ranked[..(opts.k * 10).max(opts.pool).min(ranked.len())];

Evidence (verified this run, main d4539fc)

  • k = 5534023222112865485 — a valid i64, so reachable from the CLI as --k 5534023222112865485 and from any service client as JSON — gives (10 * k) mod 2^64 = 2 (modular arithmetic checked this run). The consideration window becomes max(2, pool): with --pool 10, the fused ranking can hold 20 candidates (10 FTS + 10 vector) but grouped output considers only 10, silently dropping sessions that should appear in the grouped results.
  • k = 9223372036854775808 (2^63, service-JSON reachable) wraps k * 10 to exactly 0; the window collapses to pool regardless of the ranking's size.
  • Nothing downstream notices: sorted.truncate(opts.k) is a no-op at these values and the envelope renders normally — the grouped answer is silently incomplete, not an error.

Why it matters

--group-by-session is the view operators use to see which sessions a search hit. A crafted or fat-fingered --k (the flag takes any positive integer today, and scripts generate it) turns that view silently partial in release builds and crashes the search outright in debug builds. The pool parameter right next to it has a design maximum (400, design section 2); k needs the same treatment, or the arithmetic needs to stop overflowing.

Acceptance criteria

  • A k above a stated maximum is refused with a clear error at both boundaries — the CLI's count() for --k and the service's validate_request — with the two kept in mirror (the atlas-search(CLI): --k/--pool 0 and negative (=form) counts silently clamp to 0 — standalone returns empty success where the service rejects the same request #5407 pinning test extended to the new bound), OR grouped_output computes the window with saturating arithmetic and a test pins the huge-k behavior. Either route must make the wrapped-window outcome impossible.
  • A regression test exercises grouped search with a k in the wrap range (e.g. 5534023222112865485) and shows all fused candidates are considered (or the request is refused up front).
  • Existing atlas-core / atlas-search test suites stay green (cargo test -p atlas-core -p atlas-search, run on the laptop or CI per fleet norms).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/atlas-searchpkgs/atlas-search (Atlas search service + atlas-embed)
    on Nov 4, 2026
  2. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a, run 2026-11-04T11:47Z
    • Found via: filed this run
    • Task: Filed after verifying on main d4539fc that grouped_output's (k * 10) wraps for k values the CLI and service both accept (validate_request and count() bound k only below); packet enqueued for a small fix.
    • Expectation: effort/s — done when a huge k is refused at both boundaries (or the window arithmetic saturates) with a regression test in the wrap range.
    • Links: body evidence in the issue; queue packet packet-5423-fix.json
  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 4, 2026
  4. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: picked_up
    task: task 9436 (repo-health-code-pilot; worker repo-worker-code; lane code-a)
    by: repo-worker-code (lane code-a shift)
    at: 2026-11-04T12:20:00Z
    state: claimed — direct execution lane
    action: implement the grouped_output k bound/saturating fix for issue #5423 on a laptop worktree branch, open a PR, and complete task 9436 at the first verified outcome

  5. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: parked
    task: task 9436 (repo-health-code-pilot; worker repo-worker-code; lane code-a)
    by: repo-worker-code (lane code-a shift)
    at: 2026-11-04T12:22:00Z
    state: parked 1200s — PR #5435 opened (branch queue/9436-5423-bound-k, commit e29c59a); PR checks queued and Codex review still running at park time, no findings posted yet
    verified: fix implemented on laptop worktree ~/git/fleet/9436 (saturating_mul window in grouped_output, acceptance route 2 for issue #5423); cargo test -p atlas-core -p atlas-search all green on the laptop including new grouped_wrap_range_k_considers_all_candidates regression test; changed files rustfmt-clean. Push went through the sandbox clone because the laptop gh token is invalid (gh auth status on amd-6: token in default is invalid) — branch SHA on GitHub verified identical to the laptop commit.
    resume: read PR #5435 fresh — disposition any Codex findings, and merge under the standing criteria once checks/Codex are settled; then complete task 9436 as fixed_merged
    links: #5435

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

    @dezren39
    MemberAuthor

    agent-note:v1
    task: 9436
    lane: code-w
    state: done
    artifact: PR #5435 (merged, squash merge commit 28cc850)
    note: Resumed task 9436 at stage pr_opened. Codex review on PR #5435: "didn't find any major issues" — no findings to disposition. Basic checks SUCCESS (production line limit, proxy port fallbacks). Merged under the standing criteria 2026-11-04T12:46:45Z; issue #5423 closed by the merge. Task 9436 completed as fixed_merged.

  8. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 4, 2026
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)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/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