Skip to content

fleet queue: pre-claim staleness check — auto-complete tasks whose linked issue is already closed / PR already merged, without burning a session #10626

Open

Description

@dezren39

Measured waste this attacks

From the outcome-taxonomy measurement (2026-11-16,
outcome-taxonomy-2026-11-16.md; trailing 7d, fleet-queue Turso +
GitHub closedAt/mergedAt vs first-claim times):

  • 652 of 2,344 non-triage completions (27.8%) were pre-done: the
    linked issue was already closed / the linked PR already merged
    before the task was claimed. No work remained when a lane picked
    the task up.
  • 625 of the 652 were already done before the task was created.
    Sampled packets carry payload.issue.state_checked_at of
    2026-10-25 — the filing pipeline emitted tasks from a ~3-week-old
    state snapshot and nothing re-checked issue state at enqueue or
    at claim. Median creation→claim wait is ~0h, so a claim-time
    check catches essentially the whole class regardless of which
    side (filing or queueing) introduced the staleness.
  • Cost shape: median disposition is ~1 minute (a session still
    spawns, verifies, and closes the task), 85.9% close <5 min after
    claim — and 72 tasks burned ≥30 minutes (max ~78h across park
    cycles) on work that no longer existed.
  • A further 155 completions (6.6%) were sibling_done — the work
    landed while the task ran. A claim-time check cannot catch
    in-flight races, but re-checking at claim (not at filing) shrinks
    the exposure window to the run itself.

Proposed mechanism

In the queue claim path (broker claim verb, before a task is
handed to a lane):

  1. Resolve the task's linked work from its packet:
    payload.issue (repo + number) and payload.prs[] /
    result.pr where present.
  2. One GitHub read for state: issue state/closedAt, PR
    state/mergedAt. (The work-failures recompute already
    maintains exactly this data in a landing-times cache —
    landing-times-cache.json, GraphQL batches of 50, terminal
    facts cached permanently, open items refreshed at 24h. Reuse
    the pattern; do not build a second fetcher.)
  3. If the issue is closed or a linked PR is merged with a
    timestamp at or before the task's creation time (strongest
    signal) — and in a second, separately-flagged tier, at or
    before claim time — complete the task immediately:
    • outcome already_done, with evidence recorded on the result
      (closed_at / merged_at, source ref, checked_at);
    • a dedicated event (e.g. staleness_autocomplete) so the
      daily measurement can count interceptions;
    • no session is bound, no lane slot is consumed.
  4. Fail open, always: any lookup error, timeout, rate limit, or
    missing linkage → the claim proceeds exactly as today. A failed
    or stale read never blocks or idles work (standing rule,
    2026-10-30). Bound the check with a short timeout and the cache
    so claim latency is unaffected in the common case.
  5. Apply the same state re-check at filing time for packet
    generators: a packet whose state_checked_at is older than a
    small bound (proposal: 1h) must re-verify issue state at enqueue
    or be stamped so the claim path checks it first. (The claim-path
    check in step 3 is the safety net and ships first; this step
    stops the stale-snapshot class at its source.)

Out of scope: tasks with no linked issue/PR (nothing to check —
they claim as today), and any change to what counts as a valid
packet (that is #5444's territory; this check runs on packets that
already pass validation).

Relation to existing issues

  • code#9178 (fleet queue: resume-by-session, claim-any-task,
    and manual-only items) — this is a claim-path behavior and
    belongs with its claim-semantics work: the staleness check is a
    pre-dispatch gate inside the same verb family, and its
    auto-complete outcome must compose with fleet queue: resume-by-session, claim-any-task, and manual-only items #9178's claim/override
    semantics (an owner override must be able to force-claim a
    staleness-completed task's successor deliberately).
  • code#5444 (packet-validation quarantine) — related only as
    the other large source of wasted claims (447 tasks currently
    frozen; 322 completions in 7d passed through a freeze). The two
    fixes are independent: repo-queue: claim can hand out a payload-null task, and list views cannot recover a live claim by lane #5444 rejects malformed packets, this
    check retires well-formed packets whose work is gone. Neither
    should be gated on the other.

Acceptance criteria

  1. A task filed for an issue that is already closed (or whose
    linked PR is already merged) completes via the staleness path:
    status done, outcome already_done with evidence fields, a
    staleness_autocomplete event, and no lane_session_bound
    event and no session
    attached to the task.
  2. A task whose issue closes between filing and claim is caught at
    claim (tier-2), with the same evidence trail.
  3. With GitHub unreachable or the lookup erroring, the same tasks
    claim and run normally (fail-open test).
  4. A task on a live, open issue claims byte-for-byte as today.
  5. Claim latency: p95 added latency < 2s with a warm cache; the
    check times out open rather than queueing behind GitHub.
  6. Measured effect: within 7 days of deployment, the daily
    work-failures recompute shows pre_done completions for tasks
    created after the fix trending to ~0, replaced by
    staleness_autocomplete events that consumed no session.

Activity

  1. developing-today commented on Nov 16, 2026

    @developing-today
    Contributor
  2. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    app/fleetpkgs/fleet multicall binary + platform crates
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    on Nov 16, 2026
  3. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up + triaged

  4. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    status/triagedTriaged and routed (see agent note)
    on Nov 17, 2026
  5. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Fresh revalidation — 2026-11-18: #10626 remains OPEN, and no matching open PR was found. The packet is a Rust queue claim-path implementation with cache reuse, fail-open latency behavior, event/no-session semantics, and an acceptance suite; its own timebox is 45 minutes. This requires a dedicated implementation session/worktree, so task 20661 is parked rather than started in the scheduled lane. backlog_updated: false.

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

  8. added
    queue/claimedQueue worker lifecycle state
    and removed
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/triagedTriaged and routed (see agent note)
    on Nov 18, 2026
  9. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: picked_up
    task: 20661
    lane: oc-code-06 (OpenChamber scheduled lane, worker repo-worker-code)
    stage: claimed -> verified

    Claimed task 20661 via the one-queue atomic claim (filter repo = code). Fresh GitHub verification: #10626 is OPEN; no matching open implementation PR found in the current issue history/current cross-repo search. No hard-stop labels (held, user/owned, do-not-merge, do-not-auto-edit). The issue is assigned to Drew; this task remains explicitly assigned in the queue, and I will not touch any Drew-owned PR. Resuming prior checkpoint: claim path files were located, landing-times fetcher was not; no branch/worktree was recorded. Next: locate prior work/branch and the landing-times cache, then proceed only if within the task lease.

  10. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    task: 20661
    lane: oc-code-06 (OpenChamber scheduled lane, worker repo-worker-code)
    stage: verified -> already_done

    Fresh terminal verification: issue #10626 remains OPEN; PR #11799 is MERGED at dcee647. Its merged implementation covers the claim-path staleness check, tier behavior, fail-open semantics, tests and #9178 override interaction. No code or competing PR was created by this lane. Important remaining scope: #11799 explicitly says the filing-time re-check (mechanism step 5) is not included; the follow-on issue required by task 20661 has not been located. Completing task 20661 as already_done based on the merged claim-path implementation; this remaining filing-time phase should be tracked separately.

  11. removed their assignment
    on Nov 20, 2026
  12. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    Builder's Advocate live evidence — 2026-11-20 23:00 CST

    Conductor session ses_e5e0386387affeulDO3uKn9rUZ found repo-queue task 20859 still queued (priority 20; age 1d 09:49) for developing-today/code#12063, while #12063 had already closed as status:done at 2026-11-21T04:08:40Z and its fix PR #12064 is merged. The conductor explicitly skipped dispatch rather than spend a session on the stale task. At 23:02 CST the task remained queued (age 1d 09:53). This directly reproduces the pre-claim staleness gap tracked here; no duplicate filed.

    Acceptance from this issue: before claim, auto-complete or otherwise make unclaimable a queued task whose linked issue is closed or whose linked fix PR is merged, without launching a session.

  13. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Merged work, still open. Every pull request that references this issue has merged (#11799, #11802) and none is open, but the issue kept status:in-review. Tasks that name it as a blocker have been waiting on it.

    status:in-review is removed. Whoever takes this next: run the issue's done check against main. Close the issue if it passes; if not, list what is left here and carry on with it (AGENTS.md, "Finishing work").

    By: Claude, 2026-11-22 flow review.


    Generated by Claude Code

  14. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · claim (verification/reconciliation pass)

  15. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · verification record (lane GG, archer)

    • Agent: archer, lane GG (sandbox fix lane) — shortlist pickup; premise check found the implementation already landed, so this pass verified it against the acceptance criteria on current main instead of re-implementing.

    Premise verdict: implementation landed via PR #11799 (merged 2026-11-18, dcee6477911) — pkgs/fleet/crates/fleet-queue/src/turso_queue/staleness.rs, wired into the claim path at lifecycle.rs (stale_pick → retire_stale before binding). Issue was still open with merged work (the 2026-11-22 note), so the open remainder was verification, not code.

    Acceptance criteria, verified on main @ 867f9cb71a3:

    1. ✅ Tier-1 retire at claim: status done, outcome already_done with evidence (closed_at/merged_at, tier, checked_at), one staleness_autocomplete event, no session bound — test closed_before_creation_is_tier_one + claim_path_checks_before_binding_and_only_on_the_default_pick.
    2. ✅ Tier-2 (closed between filing and claim) — test closed_between_filing_and_claim_is_tier_two; tier recorded separately in evidence; FLEET_STALENESS_TIER2=0 disables it.
    3. ✅ Fail-open — tests a_failed_lookup_stands_the_check_down, probes_without_landing_support_fail_open, no_probe_means_no_check.
    4. ✅ Live/open issue claims as before — test open_unknown_or_unlinked_claims_as_before.
    5. ✅ (code-level) Landed facts cached permanently (landed_facts_are_cached); the broker probe is bounded so a claim never queues behind GitHub (queue_broker.rs). p95 latency not independently measured in this pass.
    6. ⏳ Not yet due — 7-day post-deployment measurement; first confirmed broker build carrying the code is generation 4 (deployed 2026-11-22). Tracked in fleet queue: #10626 remainders — filing-time state re-check + criterion-6 deployment measurement #12966. (A live-event spot check this pass was inconclusive: the primary queue store was in its known session-proxy fault and on the GitHub fallback.)

    Test run (laptop worktree off origin/main): cargo test -p fleet-queue --features queue-broker staleness — 11 passed / 0 failed.

    Remainders → #12966: (a) proposal step 5, the filing-time state_checked_at re-check — generators write the stamp, nothing reads it; the claim-path net covers the class, so this is source-side hygiene; (b) the criterion-6 measurement, after which this issue can close.

    #10626 stays open on criterion 6 only; its implementation criteria (1–5) are verified landed.

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/lLarge: multi-day or open-ended; expect staged check-inskind/featureNew feature or capability requestpriority/normalOrdinary priority (the default)task/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