Repository navigation
fix(claimant): collect parked handoffs so handed-off tasks actually launch - #8066
Merged
Merged
Conversation
…aunch The opencode claimant discovered candidates only among claimed rows, but every lane handoff ends in a park seconds after the handed_off checkpoint (the park clears the claim and stamps the default timer). Handed-off tasks therefore cycled claim -> handoff -> park -> re-claim forever without a session ever launching (#7907 task 14260: ~35 cycles on 2026-11-09; #6533 task 11214 likewise; 164 handed-off rows sat parked in repo-health-code-pilot at fix time). Broker (Turso): claim accepts an optional task_id (CLI --task). A by-id claim takes exactly that row when it is a queued row under the ordinary pick predicate or a parked recorded handoff (progress lane opencode, yield stage handed_off/launch_failed, no session bound); it flows through the same guard, binding clear, lease and claimed event as the pick path. Genuine wait parks are never claimable by id. Claimant: poll.py also reads parked rows and surfaces recorded handoffs as candidates; claimant.py collects a parked candidate via the by-id claim (worker opencode-claimant) before the unchanged create/bind/prompt flow, and restores + skips on a wrong-row claim from a broker build without by-id support. Refs #7907, #6533
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed.
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. |
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
Queue tasks assigned the opencode execution lane were never launched. The cycle, traced live on tasks 14260 (#7907) and 11214 (#6533):
opencode, checkpoints stagehanded_off.verb_parkclears the claim and stamps the default +20-minute timer.claimedrows (broker/listwithstatus: "claimed"). A handed-off task sits inclaimedfor seconds before the park, so the claimant (firing every 5 minutes) effectively never sees it.repo-health-code-pilot, each carryingprogress.next: "claimant launches the bound opencode session"that never came.The fix
Broker (
fleet-queue, Turso backend): by-id claim.claimaccepts an optionaltask_id(CLI:repo-queue claim --task <id>). A by-id claim takes exactly that row when it is either a queued row under the ordinary pick predicate, or a parked recorded handoff: progress laneopencode, yield stagehanded_off/launch_failed(top-level orlast_checkpoint.stage), and no session bound. The handoff park'snot_beforeis the park verb's default timer, not a real wait, so it does not gate the by-id path. The claim flows through the same guard quarantine, binding clear, lease insert, andclaimedevent as the pick path (event detail carriesby_id: true); the conditional UPDATE re-checks the status read, so a competing claim loses cleanly. Genuine wait parks (gate/stage parks, direct lane, bound rows) are never claimable by id — pinned by unit tests.Claimant (
pm-stack/opencode-claimant):poll.pyalso reads each queue'sparkedrows and surfaces recorded handoffs as candidates (status: "parked"), through the same yield contract as claimed candidates; supervision stays claimed-only.claimant.py, for a parked candidate, first collects the claim by id as workeropencode-claimant, then runs the unchanged create → bind → prompt flow; the launched session works under--worker opencode-claimant. If the by-id claim fails, the candidate is skipped with the reason logged. If a broker build ignores--task(the PG fallback build claims the queue's top row instead), the wrong row is parked straight back and the skip is recorded asparked_claim_mismatch_restored— nothing is ever launched over a guessed claim.prompt.mddocuments the parked-candidate flow for the firing session.Tests
cargo test -p fleet-queue --features queue-broker,secrets-broker— newby_id_claim_*unit tests (parked handoff claimable incl. the last_checkpoint spelling and launch_failed; gated/direct/bound/claimed rows refused; queued rows keep the pick predicate) + full crate suite.python3 -m unittest test_poll test_claimant— newTestIsHandoffParked(handoff park candidate; genuine wait park, bound row, claimed row, OpenChamber-UUID lane all refused) + full suite.Deploy notes
fleetfrom merged main, copy to~/.local/bin/fleet, restartqueue-broker.service; the claimant runs from the primary clone, so it picks uppoll.py/claimant.pywhen the clone advances to the merge. The sandbox install (~/tools/fleet, root-owned provisioning) stays stale until its next provisioning pass — it is a client-only copy; the by-id surface is exercised from the laptop.Refs #7907, #6533
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.