Skip to content

pm-dispatch(sessions): a GitHub comment/label failure after the claim PATCH cancels a live session's queue task — the launched session keeps running untracked #2660

Closed

Description

@dezren39

Problem

In pm-dispatch (pm-stack/dispatch/src/server.ts, main 732ca26), the steps after a session is already launched and its queue task already claimed are not failure-isolated, so a GitHub API hiccup at the very end of a successful launch is reported — and acted on — as a launch failure:

  • launchSession creates the OpenCode session and sends the prompt (server.ts:117-123), registers the worker and PATCHes the task to status: claimed with the session id in progress (server.ts:130-143).
  • The lane-ledger call right after IS guarded: its failure is noted on the task with "launch unaffected" (server.ts:148-158).
  • But the final GitHub calls are NOT guarded: github.comment(...) (server.ts:161-165) and github.addLabels(...) (server.ts:166) throw straight out of launchSession. (GitHubClient.comment/addLabels in src/github.ts do fall back from the app route to the gh CLI, but a failure of both routes throws GitHubError.)

Consequences by caller mode:

  • wait: true (default): handleSessions treats any launchSession throw as a launch failure, calls cancelTask on the task (server.ts:253) and returns 502 {task_id, error}. The OpenCode session, however, was already created and prompted — it keeps running the work, now untracked: its queue task is cancelled, and the caller was told the dispatch failed, inviting a duplicate retry dispatch.
  • wait: false: the async continuation catches the same throw and PATCHes last_error: "dispatch launch failed: …" (server.ts:225-234) onto a task that is in fact claimed with a live, running session — the task record actively misstates the state of the work.

This also contradicts the README contract for POST /v1/sessions: "a task is never left queued for a session that launched, nor claimed without a session id" — the cancel path leaves a launched session with a cancelled task, which is the mirror-image violation.

Evidence

  • Code trace at main 732ca26 (file:line above): prompt is sent BEFORE the claim PATCH, the claim PATCH precedes the unguarded comment/label calls, and both caller paths treat a post-claim throw as launch failure. The guarded assignLane block (server.ts:148-158) shows the intended pattern for post-launch steps.
  • No test covers launchSession's failure ordering: pm-stack/dispatch/test/ contains only auth.test.ts, packet.test.ts, validate.test.ts — server.ts/queue.ts/github.ts have no tests.

Why it matters

pm-dispatch is the fleet's authenticated launch intake (merged 2026-10-30, PRs #2652/#2655/#2658). A transient GitHub failure at the last step converts a healthy, running session into a cancelled tracking task + a 502 that invites a duplicate dispatch of the same prompt — exactly the double-booking the service exists to prevent.

Acceptance criteria

  • A failure in the post-claim issue comment or label calls does NOT cancel the task and does NOT change the success response: the launch still returns 201/claimed (wait:true) with the failure surfaced as a warning and/or recorded on the task (e.g. last_error/progress note), mirroring the existing assignLane guard.
  • In the wait:false path, a post-claim note/label failure is not recorded as "dispatch launch failed" on a claimed task.
  • Cancellation + 502 remains reserved for failures before/at the actual launch and claim (session create, prompt send, claim PATCH).
  • A test (stubbed GitHub client failing on comment/addLabels after a successful claim) pins the behavior for both wait modes.
  • Existing dispatch tests still pass.

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)
    queue/queuedHas a queued task in the Supabase agent queue
    effort/xsTrivial: expected under 30 minutes of work
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Oct 30, 2026
  2. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (lane B, new-issue-creator-code-b)
    • Session / ID: new-issue-creator-code-b run 2026-10-30 04:20 CDT
    • Found via: filed this run
    • Task: Triage the post-claim failure ordering in pm-dispatch launchSession (server.ts): pin that post-claim GitHub note/label failures warn instead of cancelling a live session's task, then route a small_fix packet.
    • Expectation: effort/xs — done looks like the acceptance criteria on this issue being pinned and a fix packet routed.
    • Links: evidence in the issue body (file:line at main 732ca26); probe notes in the creator backlog entry.
  3. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — design-architect adoption (pass 19, 2026-10-30): this issue is Phase 2 (commit point) of design #2668, "pm-dispatch launch pipeline, staged". Design doc: files/designs/code-pm-dispatch-launch-pipeline.md in the keep-the-four-repos-healthy goal workspace.

    Recorded decision for triage (do not re-file, re-scope, or split this issue; record the phase structure instead): the claim PATCH is the launch's commit point. Every step after it (lane ledger — already conforming; issue comment; issue labels) is individually guarded: a failure is recorded as a response warning (wait: true) and a task note phrased as an annotation failure with the launch unaffected, and the remaining annotation steps still run. cancelTask + 502 stays correct only for failures at or before the commit point; the wait: false continuation stamps dispatch launch failed only for pre-commit failures. This phase also carries the truth-up: the README flow section gains the stage/failure table and its invariant sentence extends to "nor claimed-and-running reported as failed".

    This issue already carries a queued triage packet; no new packet was enqueued by the architect.

  4. 9 remaining items

  5. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: handed off

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 2, 2026
  7. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Lane E claimed task 5414: implementing the settled design — post-claim issue comment and label annotations independently guarded, each failure recorded as a task note, wait:true success responses carry a warning, remaining annotation steps still run. Worktree on laptop, branch queue/5414-2660-guard-post-claim-annotations.

  8. added a commit that references this issue on Nov 2, 2026
  9. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Done: PR #4231 merged (merge commit 9456d01); issue #2660 closed by the merge. Post-claim comment/label annotations are now independently guarded via annotateLaunch, failures noted on the task and surfaced as wait:true warnings, remaining steps still run; README stage/failure truth-up included. bun test 105 pass; Codex review on head 8500d47 clean.

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

Metadata

Metadata

Assignees

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect 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