Skip to content

fleet-queue: retire already-done tasks at claim, before any session (#10626) - #11799

Merged
dezren39 merged 1 commit into
mainfrom
feat/claim-staleness-check
Nov 18, 2026
Merged

dezren39 merged 1 commit into
mainfrom
feat/claim-staleness-check

Conversation

@dezren39

@dezren39 dezren39 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Before: a queued task whose linked issue had already closed, or whose linked PR had already merged, was still handed to a lane. A session spawned, found nothing to do and closed it. The 2026-11-16 measurement put this at 27.8% of non-triage completions, with 72 tasks burning 30 minutes or more.

After: the broker's default claim pick checks the picked row's linked work first. If it already landed, the row is retired as done with outcome already_done, its evidence on the result and a staleness_autocomplete event, and the pick moves on. No lease, session binding or claimed event is written for it.

How: a new turso_queue/staleness.rs resolves links from payload.pr / payload.prs[] / result.pr/pr_url, else payload.issue, under the task's repo. A linked PR decides on its own (a shepherd task for an open PR stays live even if its issue closed). The broker's GitHub probe gains probe_landing (issue closed_at, PR merged_at) with a 1.5s per-request timeout; other probes default to Unknown, which never retires anything.

  • Tiers: tier 1 landed at or before task creation, tier 2 before this claim. Both retire and the evidence names the tier. FLEET_STALENESS_TIER2=0 turns tier 2 off.
  • Fail open: no probe, no linkage, an error, a slow answer or a recent failure all claim exactly as before; a failure stands the check down for 60s. FLEET_STALENESS_CHECK=0 turns it off; a packet can set staleness_check: false.
  • Cache: landed facts kept for the broker's life, open states for 10 minutes, so warm claims add no GitHub reads.
  • Overrides: by-id, transfer and handoff claims don't run the check, so the fleet queue: resume-by-session, claim-any-task, and manual-only items #9178 force-claim path is unchanged.
  • Not in this PR: step 5 (re-verify at filing) and the PostgREST broker path. Acceptance 6 needs a week of the daily recompute after deploy.

Tests: cargo test -p fleet-queue --all-features --lib (436 pass), including tier 1/2, fail-open, PR-over-issue, opt-out, cache, stand-down and a source-order check that the retire happens before lease, binding and the claimed event.

Refs #10626


Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…10626)

The default claim pick now checks a picked row's linked work. When
its linked PR already merged, or (with no PR) its issue already
closed, the row is retired in place as done with outcome
already_done, the evidence on its result and a
staleness_autocomplete event, before any lease, session binding or
claimed event; the pick moves on to the next row.

Tier 1 is work that landed before the task was created, tier 2
work that landed before this claim; the evidence names the tier,
and FLEET_STALENESS_TIER2=0 turns tier 2 off. The check fails
open: no probe, no linkage, a lookup error or a lookup slower than
1.5s claims as before, and a failure stands the check down for a
minute. Landed facts are cached for the broker's life, open states
for ten minutes. FLEET_STALENESS_CHECK=0 turns it off and a packet
can opt out with staleness_check: false. By-id, transfer and
handoff claims are untouched, so the #9178 override path stays.

Refs #10626

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dezren39
dezren39 marked this pull request as ready for review November 18, 2026 12:10
@dezren39
dezren39 requested a review from a team as a code owner November 18, 2026 12:10
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 017b9630-177d-4511-8c4d-e23806e04e97
Commits

Reviewing files that changed from the base of the PR and between 6a87937 and ef05517.

Files selected for processing: 5

  • pkgs/fleet/crates/fleet-queue/src/queue_broker.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue/core.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue/staleness.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T12:11:51.121511Z ef05517 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants