Repository navigation
feat(opencode-claimant): retry error-stopped queue sessions - #12879
Conversation
|
Warning Review limit reachedYou'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 7 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d41a9ee61f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "--launched-by", | ||
| LAUNCHED_BY_RECOVERY_ERROR_STOPPED, |
There was a problem hiding this comment.
Implement backend recovery support before using the new marker
For an expired-lease error session, this deletes the session and then sends a recovery marker that neither checked-in backend supports. The CLI forwards launched_by unchanged to /bind; its help describes bind as “Binds a worker to a task” (client/support.rs:245). The Turso implementation in pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs:1272-1287 rejects expired leases and never compare-clears bindings, while migration-0026.sql:77-80 recognizes only the two older recovery markers. Consequently, the new recovery path deletes the session but leaves its queue binding intact instead of making the task retryable. Add the corresponding atomic backend recovery operation before invoking this marker.
Useful? React with 👍 / 👎.
| error_outcome = _session_error_outcome(_session) | ||
| if error_outcome: | ||
| # A terminal provider/session error is safe to retry | ||
| # only after the lease has expired; until then the | ||
| # owning worker may still be reconciling it. | ||
| lease_ms = poll.parse_lease_ms(task.get("lease_until")) | ||
| if lease_ms is None or lease_ms > now_ms: | ||
| continue |
There was a problem hiding this comment.
Check authoritative activity before recovering error sessions
When a session resumes after an error, its stored outcome can remain error-valued while it is actively executing; poll.py:475-488 explicitly handles this by letting active-set membership override terminal markers. This new branch ignores the fetched active_ids and authorizes deletion as soon as the task lease expires, so it can delete a running resumed session and even terminally fail its task when attempts are exhausted. Preserve the authoritative activity check, including failing closed when activity cannot be read, before treating the stored error outcome as terminal.
Useful? React with 👍 / 👎.
| queue = [a for a in planned if a["kind"] in ("retry", "nudge", "escalate")] | ||
| queue.sort(key=lambda a: (a.get("nudges_sent") or 0, a["session_id"])) | ||
| overflow_ids = {id(a) for a in queue[MAX_QUEUE_INTERVENTIONS_PER_ROUND:]} |
There was a problem hiding this comment.
Keep non-actionable retries out of the stall intervention cap
With ten bound error sessions whose leases are still live or unreadable, supervision leaves them bound, but these new retry actions consume all ten intervention slots. The production call in claimant.py:1927-1932 never supplies recover_error, so those actions always fail and re-plan; because retry actions omit nudges_sent, they also sort ahead of every stalled session already nudged once. Consequently, real second nudges and escalations remain deferred on every fire while those error sessions persist, even though no retry intervention occurs. Exclude these non-actionable retries from the shared cap or otherwise prevent them from repeatedly displacing executable stall interventions.
Useful? React with 👍 / 👎.
Summary
error-stoppedwith task/queue/issue/repo bindingRefs #1656
Refs #2140
Evidence
python3 -m unittest pm-stack/opencode-claimant/test_babysitter.py pm-stack/opencode-claimant/test_nudges.py— 47 tests passedTestSupervisionStep— 12 tests passed, including expired error-stopped requeue and compare-and-clear orderingpython3 -m py_compile pm-stack/opencode-claimant/babysitter.py pm-stack/opencode-claimant/nudges.py pm-stack/opencode-claimant/claimant.pygit diff --checkMerge Danger
Low. Recovery is gated on a verified terminal error, an expired task lease, successful session deletion, and the existing atomic compare-and-clear queue bind. Unknown session/lease state remains fail-closed.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.