Skip to content

dispatch: an annotation failure note overwrites the lane-ledger failure on the task's last_error (PR #4231 residual) #10087

Closed

Description

@dezren39

Finding

PR #4231 gave each post-claim launch annotation its own guard and made its failure notes accumulate — but only within annotateLaunch itself. In launchSession, the lane-ledger step runs immediately before the annotations and records its own failure the same way, by PATCHing the task's last_error. When a lane-ledger failure and an annotation failure happen in the same launch, the annotation note overwrites the lane-ledger note, so the task record ends up naming only the annotation failure:

  1. launchSession (pm-stack/dispatch/src/server.ts, current main): the lane-ledger assignLane catch PATCHes last_error: "lane assignment failed (launch unaffected): …". It does not add the failure to the response warnings either, so the task note is the only record of it.
  2. annotateLaunch (pm-stack/dispatch/src/launch_annotations.ts:48-53): noteFailure PATCHes last_error: failures.join("; ") where failures starts empty for each call — it never reads or preserves the task's existing last_error.
  3. QueueClient.patchTask (pm-stack/dispatch/src/queue.ts:114) is a PostgREST PATCH (field set): the second write replaces last_error wholesale.

Net effect: a launch whose lane assignment failed (so a later completion cannot record the executed lane) and whose issue comment or labels then failed loses the lane-failure record entirely — the exact "final note names every failure" property #4231's design (#2668 phase 2) set out to provide holds only inside the helper, not across the launch sequence.

Evidence

Runtime verification (verification_class: runtime-gap/high-risk)

Result: reproduced.

  • Commit tested: 8e118461696624f2836657dab9083412e89a6fa6 (current main, detached worktree on the laptop, removed after the run).
  • Command: bun test test/probe-last-error.test.ts in pm-stack/dispatch (one-off probe test replaying the exact launchSession sequence — lane-ledger patchTask note, then the real annotateLaunch with a failing comment and a field-set stub queue; saved as probe-last-error.test.ts in the review evidence, not committed).
  • Environment: laptop (host amd) via the fleet laptop SSH route; the narrow probe only — no full suite, no CI changes, no application-code changes.
  • Result: 1 test, FAIL as predicted by the finding. Observed behavior: returned warnings were ["launch annotation failed (launch unaffected): issue comment: github comment 500"] and the task's final last_error was exactly that annotation string — the earlier "lane assignment failed (launch unaffected): ledger down" note was gone.

Why it matters

last_error is the task's diagnostic record for best-effort launch steps that must never fail the launch. The lane-ledger note is operationally the more important of the two: without the lane assignment, a later completion cannot record which lane executed the task. Two independent best-effort failures in one launch are most likely exactly when the surrounding services are degraded — which is also when the record is needed most. Today the second failure silently erases the first, and because the lane failure is not surfaced in warnings either, a wait:true caller sees a launch whose only recorded problem is a GitHub annotation.

Acceptance criteria

  • When a task already carries a last_error note (e.g. the lane-ledger failure) and an annotation then fails, the final last_error names both failures (or the annotation path otherwise preserves the earlier note, e.g. by appending to the existing value).
  • A regression test replays the sequence — pre-existing last_error on the task, then a failing annotation — and pins that both failures survive in the final note; the both-annotations-fail accumulation from fix(dispatch): guard post-claim GitHub annotations independently (#2660) #4231 keeps passing.
  • No behavior change to the launch itself: annotations and the lane ledger stay best-effort, the launch is never rejected for either failure, and the wait:true warnings response shape is unchanged (adding the lane failure to warnings as well is acceptable but not required).

Found by pr-diff-review lane B reviewing PR #4231 against current main. Dedupe: issue searches (last_error annotation lane, launch annotation, annotateLaunch) returned only #2660 (closed — the parent issue #4231 fixed) and unrelated items; no open or closed issue covers the cross-step last_error overwrite.

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
    priority/lowNice to have; do when convenient
    app/dispatchPackage/app: dispatch (pm-stack in this repo)
    on Nov 14, 2026
  2. developing-today commented on Nov 14, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 14, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    Agent: pr-diff-review-b
    State: filed
    Repo: developing-today/code
    Source PR: #4231 (#4231, merged 9456d01); closes #2660 (CLOSED)
    Finding: PR #4231's annotateLaunch accumulates failure notes only within itself (pm-stack/dispatch/src/launch_annotations.ts:48-53 on main); in launchSession the lane-ledger catch PATCHes the task's last_error first (pm-stack/dispatch/src/server.ts ~:167), and patchTask is a PostgREST field-set PATCH (src/queue.ts:114), so an annotation failure in the same launch overwrites the lane-ledger failure note — and the lane failure is never added to the response warnings either.
    Verified against main: 8e11846 (contents reads of server.ts, launch_annotations.ts, queue.ts on main; PR #4231 merge confirmed ancestor of main, compare behind). Runtime verification (runtime-gap/high-risk): REPRODUCED on the laptop at 8e11846 — bun test test/probe-last-error.test.ts, 1 test FAIL as predicted: final last_error named only the annotation failure ("github comment 500"); the pre-seeded lane-assignment note was gone; detached worktree removed after.
    Evidence: hidden_files/pr-review-b-2026-11-14-0918-code/issue-4231-lasterror-body.md + probe-last-error.test.ts + diff-4231.patch

  4. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    effort/sSmall: expected under 2 hours of work
    queue/claimedQueue worker lifecycle state
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 16, 2026
  5. 17 remaining items

  6. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Agent note — task 17494 claimed (lane code-i, openchamber scheduled lane, 2026-11-16)

    State: picked up

  7. 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 16, 2026
  8. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    Agent note — task 17494 parked (lane code-i, openchamber scheduled lane, 2026-11-16)

    State: parked — CI pending

  9. added a commit that references this issue on Nov 16, 2026
  10. dezren39 commented on Nov 16, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    task: 17494
    issue: #10087
    lane: code-c (Muse, repo-worker-code)
    stage: done

    Fixed and merged via PR #10792 (merge e6a8cd2), which another lane had already opened with this task's exact fix when this lane claimed task 17494. This lane verified it as the canonical PR instead of duplicating it: the diff touches only pm-stack/dispatch/src/launch_annotations.ts and its test — annotateLaunch now reads the task's existing last_error lazily on the first annotation failure and prepends it, so a lane-ledger note PATCHed earlier in the same launch survives; a missing reader or failed read degrades to the previous behavior, and the launch itself is never affected. 4 new regression cases cover pre-existing + failing comment, pre-existing + both failing, failed read, and no-read on the happy path (PR records bun test test/launch_annotations.test.ts: 9 pass; full suite 214 pass with 2 pre-existing github.test.ts timeouts proven identical on clean main). Codex review failed to run (usage limits, zero findings) and CodeRabbit was rate-limited; both dispositioned. This issue is closed by the merge.

  11. 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 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/dispatchPackage/app: dispatch (pm-stack in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/pr-diff-reviewFiled by the pr-diff-review 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