Repository navigation
feat(queue): reclaim exact-review leases via worker heartbeats and scheduled reconciliation - #620
Conversation
…heduled reconciliation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 688a3bcb9b
ℹ️ 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".
| if [ "$heartbeat_status" = "409" ]; then | ||
| echo "::notice::Exact-review heartbeat lost its lease tuple." | ||
| return |
There was a problem hiding this comment.
Stop stale reviews when heartbeat loses the lease
When /heartbeat returns 409, the queue has already reclaimed or superseded this lease, but this branch only stops the background heartbeat and lets the foreground review continue. Because the later publication enqueue is gated on the review step succeeding rather than on the heartbeat still owning the lease, a long-running review that loses its lease can still enqueue and publish an artifact after the item has been requeued to another worker, defeating the heartbeat reclamation and risking duplicate or stale review output.
Useful? React with 👍 / 👎.
…heduled reconciliation (openclaw#620)
Why
Jul 14-15 incident: dead exact-review workers pinned all 64 lease slots (oldest pending 15h) because lease release depends on run completion events plus a 130-minute execution-lease expiry. A hung worker holds a slot for the full lease; a missed
workflow_runevent or a failed event-driven reconcile job (they fail under API rate limits) leaves only that slow expiry path.What
/claimand/complete— the Codex-adjacent step never sees the webhook secret). After the first beat, effective lease expiry becomesmin(leaseExpiresAt, lastBeat + EXACT_REVIEW_HEARTBEAT_GRACE_MS)(default 20 min, floor 7 min so a misconfigured grace can never reclaim a healthy lease between 5-minute beats). Leases that never heartbeat keep today's 130-minute behavior, so in-flight leases survive the deploy.workflow_dispatch), fetch the queue's claimed run tuples (bounded, <=64), check actual run status via the Actions API (actions: readonly), and batch-reconcile completed ones. Covers missedworkflow_runevents and failed event-driven reconciles; partial lookup failures (rate limits, retention-expired runs) log and retry next sweep instead of failing the job.Proof
node --test test/dashboard-worker.test.ts test/sweep-workflow.test.ts— 181 pass (heartbeat endpoint happy path + tuple mismatch 409, heartbeat-stale lease requeue before execution expiry, legacy no-heartbeat behavior preserved, claimed-runs snapshot -> tuple-safe terminal reconciliation, workflow assertions incl. no-secret-in-review-step).node --input-type=module(stdin ESM).pnpm run check:limitsgreen; autoreview (Codex Sol, xhigh) clean after addressing two findings: webhook secret must not enter the Codex process tree (now tuple-auth, no secret in the step), and heartbeat-grace floor must exceed the beat interval (now 7 min).