Skip to content

Queue semantics: lease expiry strands tasks at attempt cap in 'queued' forever (142 silent zombies in code queue) #6463

Closed

Description

@dezren39

Problem

Tasks in agent.tasks can die silently at their attempt cap: they sit in queued forever, unclaimable, invisible to terminal-state counts, with no failed event. Measured 2026-11-06 (dead-at-cap evaluation): in queue repo-health-code-pilot, 142 of 172 queued tasks have attempts >= max_attempts and can never be claimed again. Only 2 tasks in the whole queue are in terminal failed.

Root cause (in the queue's own SQL, pm-stack/opencode-claimant/migration-0023.sql)

  • claim_repo_task increments attempts at claim time and only selects queued rows with attempts < max_attempts.
  • fail_repo_task is the only path that marks a task failed at cap — but it only runs when a worker actively calls fail.
  • expire_leases() returns a claimed task to queued when its lease lapses without checking attempts. So every claim that evaporates (bound session never launches, lane dies, backend flaps, quota wall kills the session) burns exactly one attempt and, at the cap, parks the task in queued permanently: never claimable, never failed, no terminal event.

Worked example: task 9553 (triage for #5459) burned 24/24 attempts on documented claim→handoff→evaporation cycles (agent notes on #5459, 2026-11-05 17:43Z → 2026-11-06 02:31Z) without the work ever being attempted.

Fix shapes (either or both)

  1. expire_leases: when the expiring claim's task is already at attempts >= max_attempts, transition it to failed (with a lease_expired_at_cap event) instead of queued — mirror fail_repo_task's terminal branch.
  2. A reaper in the fleet monitor's dead-in-queue pass that terminally dispositions queued rows at cap (it already detects them — it currently only raises caps, which feeds the same burn loop when the underlying launch failure persists).

Also worth deciding while here: whether claim-time attempts increment is the right accounting for claims that never bind a session (a bind that never happens arguably shouldn't consume the budget the cap is meant to enforce).

Evidence

Acceptance criteria

  • expire_leases (or an equivalent reaper) transitions a queued task whose expiring claim is already at attempts >= max_attempts to a terminal failed state with a lease_expired_at_cap event, instead of returning it to queued.
  • The claim-accounting question is decided and recorded on this issue: whether a claim that never binds a session should consume attempt budget.
  • A regression test or migration-level verification covers the at-cap expiry path, and the 142 silent zombies in repo-health-code-pilot are dispositioned (failed, requeued with a fresh packet, or explicitly kept) with the count recorded.

Activity

  1. developing-today commented on Nov 6, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/highImportant and time-sensitive
    effort/mMedium: expected under 1 day of work
    app/fleetpkgs/fleet multicall binary + platform crates
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 6, 2026
  3. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    Intake review

    Related: Worked example: issue #5459 / task 9553 (task 9553 was cancelled by this monitor run — its issue had closed — so it is no longer the live example; the census stands). Outage that compounded it: issue #6464. The fleet monitor's interim cap-raising rule (Duty 1 addendum, 2026-11-03) is the stopgap this issue critiques.

    Notes: Evidence-complete filing: root cause is named in the queue's own SQL (migration-0023) with a measured census (142/172 queued at cap, 2 failed total). This run's digest independently counted 146 dead-in-queue in code (135 of them already at the 24 self-repair ceiling) — consistent with the filing. Verified still live: no merged PR touches expire_leases semantics. Risks: making expiry terminal could fail tasks whose work actually landed via a PR during the lease window — the disposition pass should join open PRs first (the monitor's Duty 1B data is the join). Suggested approach: fix shape 1 (expire_leases terminal branch) plus the one-time zombie disposition; shape 2 (monitor reaper) only if shape 1 cannot ship promptly.

    — fleet monitor intake (protocol §5), 2026-11-06.

  4. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 6, 2026
  5. 105 remaining items

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

    @dezren39
    MemberAuthor

    agent-note: task 14617 parked by lane code-h — PR #8157 still awaiting CI.

  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task: 14617
    issue: #6463
    lane: code-k
    stage: parked
    reason: CI pending on PR #8157 — 7 basic checks still QUEUED after a fresh 5-minute poll (17:17-17:21Z, runner backlog); 1 check skipping (CodeRabbit).
    state: PR #8157 OPEN, MERGEABLE, branch queue/14617-6463-expire-at-cap; targeted tests previously passed (cargo test -p fleet-queue --lib --all-features: 136 passed incl. expiry_disposition_fails_only_at_cap). Codex review failed on usage limits with no findings or review comments posted — dispositioned.
    resume: merge PR #8157 when its basic checks go green, then complete task 14617.

  9. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — state: parked (task 14617, lane code-y)

  10. added 2 commits that reference this issue on Nov 11, 2026
  11. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Agent note — task 14617 done: PR #8157 merged (lane code-w)

  12. 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 11, 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/fleetpkgs/fleet multicall binary + platform crateseffort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivestatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions