Skip to content

fix(pm-dispatch): session-list completeness probe asks for limit=1000, server caps at 200 — cleanup sweep can never list sessions #13149

Open

Description

@dezren39

Defect

pm-stack/dispatch/src/opencode.ts line 9:

const SESSION_LIST_LIMITS = [1_000, 10_000, 100_000] as const;

listSessions() probes the OpenCode server with GET /api/session?limit=<n> and treats a response shorter than the requested limit as the completeness proof. But the server caps limit at 200: the very first probe (1000) is rejected with HTTP 400 (Expected a value less than or equal to 200 at ["limit"]). So listSessions() always throws, on every call, in the currently deployed build.

Live evidence (2026-11-23, laptop journal, repeating)

[pm-dispatch] task worktree /home/user/git/fleet/dispatch-code-21301 retained: session list unavailable; cannot rule out a live session in the worktree: opencode GET /api/session?limit=1000 failed (HTTP 400): {"_tag":"InvalidRequestError","message":"Expected a value less than or equal to 200\n  at [\"limit\"]","kind":"Query"} — retained

Impact

The dispatch worktree cleanup sweep can never obtain the session list, so it can never rule out a live session in any dispatch worktree — every dispatch worktree is retained forever. ~/git/fleet/dispatch-* worktrees accumulate without bound (disk + clutter), and the sweep's retention log chatter drowns the pm-dispatch journal.

Fix shape

Probe at the server's actual ceiling: SESSION_LIST_LIMITS = [200]. Semantics preserved exactly: a response with fewer than 200 entries is complete; a response at the cap is unprovable and still throws (the sweep stays conservative and retains, with the error naming the cap). Update/extend the listSessions coverage in pm-stack/dispatch/test/opencode.test.ts to pin the 200 probe and the at-cap throw.

Found during the #6992 pm-dispatch 502 investigation (Lane PG, 2026-11-23).

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Hold — Lane PG (archer), 2026-11-23: platform execution-risk flag; awaiting Drew's item-specific go-ahead.

    This issue was filed during Lane PG's #6992 investigation with the defect verified live (the deployed build's own journal lines, quoted in the body). The fix is fully prepared and small:

    • pm-stack/dispatch/src/opencode.ts: SESSION_LIST_LIMITS = [1_000, 10_000, 100_000] → [200] (semantics preserved: a below-cap response is the completeness proof; an at-cap response still throws and the sweep stays conservative).
    • Pin it in pm-stack/dispatch/test/opencode.test.ts (the 200 probe; the at-cap throw).

    Execution is held because the worktree prepared for the #6992 work, ~/wt-lane-pg-6992 (branch lane-pg-6992, at main c2ce5364ef468b70dea48f0aa2ae793a4fc9c86f), failed a platform execution-risk check at creation; per the standing rule no git/build/test operations were run inside it afterward. On Drew's go-ahead for that worktree: apply the change, run the dispatch test suite (remotely dispatched), PR, merge, and record here — deployment still waits on the laptop primary unfreezing (#13137), since pm-dispatch deploys from the primary checkout.

  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Takeover claim — Lane YJ (archer), 2026-11-23. Adopting Lane PG's orphaned hold on #13149 under Drew's batch approval of the former flag holds (2026-11-23 07:35 CST).

    State verified first-hand by YJ: the shared worktree ~/wt-lane-pg-6992 (branch lane-pg-6992) is pristine at the hold record's base SHA c2ce5364ef468b70dea48f0aa2ae793a4fc9c86f — no code was written under the hold, so the prepared fix is applied fresh here alongside the #6992 scope: SESSION_LIST_LIMITS → [200] in pm-stack/dispatch/src/opencode.ts, pinned in pm-stack/dispatch/test/opencode.test.ts (the 200 probe; the at-cap throw). Verify with the dispatch test suite (remote dispatch first, laptop fallback), PR, merge, record here. Deployment of the merged fix still waits on the laptop primary unfreezing (#13137), as the hold record noted.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions