Skip to content

fix(claimant): collect parked handoffs so handed-off tasks actually launch - #8066

Merged
dezren39 merged 1 commit into
mainfrom
fix/claimant-parked-handoff
Nov 9, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/claimant-parked-handoff

Conversation

@dezren39

@dezren39 dezren39 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

The defect

Queue tasks assigned the opencode execution lane were never launched. The cycle, traced live on tasks 14260 (#7907) and 11214 (#6533):

  1. A shift lane claims the task, assigns lane opencode, checkpoints stage handed_off.
  2. The same lane then parks the task as its handoff sink — verb_park clears the claim and stamps the default +20-minute timer.
  3. The opencode claimant discovers candidates only among claimed rows (broker /list with status: "claimed"). A handed-off task sits in claimed for seconds before the park, so the claimant (firing every 5 minutes) effectively never sees it.
  4. The park timer expires, the next shift wave re-claims the task, hands it off, and parks it again. Task 14260 ran ~35 of these cycles on 2026-11-09 alone; at the time of the fix 164 handed-off tasks sat parked in repo-health-code-pilot, each carrying progress.next: "claimant launches the bound opencode session" that never came.

The fix

Broker (fleet-queue, Turso backend): by-id claim. claim accepts an optional task_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 lane opencode, yield stage handed_off/launch_failed (top-level or last_checkpoint.stage), and no session bound. The handoff park's not_before is 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, and claimed event as the pick path (event detail carries by_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.py also reads each queue's parked rows 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 worker opencode-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 as parked_claim_mismatch_restored — nothing is ever launched over a guessed claim.

prompt.md documents the parked-candidate flow for the firing session.

Tests

  • cargo test -p fleet-queue --features queue-broker,secrets-broker — new by_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 — new TestIsHandoffParked (handoff park candidate; genuine wait park, bound row, claimed row, OpenChamber-UUID lane all refused) + full suite.

Deploy notes

  • Laptop install only for this path: rebuild fleet from merged main, copy to ~/.local/bin/fleet, restart queue-broker.service; the claimant runs from the primary clone, so it picks up poll.py/claimant.py when 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.
  • Rollback: the claimant change alone is inert against an old broker (by-id claims fail → skips logged); the broker change alone adds an opt-in request field no existing caller sends.

Refs #7907, #6533


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

…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
@dezren39
dezren39 requested a review from a team as a code owner November 9, 2026 23:33
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T23:33:11.304586Z
We couldn’t complete this review. Comment @codex review to try again.
1f45283 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit a1144d0 into main Nov 9, 2026
1 of 6 checks passed
@dezren39
dezren39 deleted the fix/claimant-parked-handoff branch November 9, 2026 23:33
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

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.

1 participant