Repository navigation
fix(queue): queued publications starve behind stale batch probes and superseded rows - #1367
Conversation
Batch publication workflows refused to claim work whenever the eight-item selection changed between dispatch and claim, which under load was nearly always, so dispatched runs exited without publishing while hundreds of ready rows waited. Superseded publication revisions also sat pending until an operator ran reconciliation, and every enqueue re-probed target visibility against GitHub, so the queue fallback returned 503 exactly when direct publication was rate limited. - claim the still-valid subset of the dispatch-time probe instead of requiring an identical selection; unprobed arrivals wait for the next departure - cache successful public hosted-target admissions in durable KV with a 60s fresh tier and a 30 min stale fallback for retryable probes; terminal observations revoke the cache with a tokenized tombstone - prune superseded publication revisions in alarm housekeeping, bounded per alarm, excluding command-bearing rows - expire the review-start lease once a publication is queued so a maintainer re-review is not blocked for the full lease window Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed September 2, 2026, 9:16 PM ET / September 3, 2026, 01:16 UTC. ClawSweeper reviewWhat this changesThe PR makes exact-review publication batching tolerate queue churn, prunes stale publication rows, caches hosted-target admission for signed intake, and expires a queued review lease sooner. Regression provenancePossible regression — probable (failure trace; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain Keep this PR open: the introduced queue repair is focused and no blocking correctness defect was found, but its changed admission authority and production queue recovery still need real after-fix evidence before merge. Priority: P1 Review scores
Verification
How this fits togetherThe exact-review queue Durable Object receives signed review-publication work, batches it, and dispatches publishers that write review results to GitHub. Its admission checks decide whether work can enter the queue and whether credential-bearing publication work may proceed. flowchart LR
A[Signed review intake] --> B[Exact-review queue]
B --> C[Hosted-target admission]
B --> D[Batch reservation]
D --> E[Publication workflow]
B --> F[Stale publication cleanup]
E --> G[GitHub review comment]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The changed admission authority has focused fail-closed source coverage, but its required final-effect authorization evidence has not yet been demonstrated in a deployed path. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the focused queue repair only after a redacted deployed trace proves both publication recovery and final-effect rejection after target revocation. Do we have a high-confidence way to reproduce the issue? No high-confidence deployed reproduction is present in the reviewed evidence. The source path and focused harness describe a credible regression mechanism, but they do not independently establish the production before/after result. Is this the best way to solve the issue? Yes, conditionally: the patch narrows cache reuse to signed intake and preserves live checks before credential-bearing work, which is the appropriate boundary if deployment evidence confirms it. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8d76b82df542. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…et admission Only the signed intake routes may consume a cached public hosted-target observation. Review claims, dispatch, batch claims, and acknowledgement paths always perform a live public probe before handing out credential- bearing work, so a target that turns private is refused there immediately. A transient probe failure on those live paths keeps a still-valid cached observation for intake; only terminal observations revoke it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Consolidate cached admission checks, batch probe validation, stale-head reads, lease identity checks, regression fixtures, and docs. Preserve intake-only caching and all revocation, pruning, and lease fences. PR insertions against main: 1,124 before; 782 after (30.4% fewer).
Post-deploy proof (production
|
| Field | 2026-09-02 22:52Z (before) | 01:28Z (before deploy) | 02:45Z (45 min after redeploy) |
|---|---|---|---|
| pending / ready | 371 / 371 | 301 / 301 | 110 / 109 |
| oldest_pending_at | 2026-08-13T09:14Z | 2026-08-13T09:14Z | 2026-08-18T15:20Z |
| next_attempt_at | 2026-08-13T09:24Z | 2026-08-13T09:24Z | 2026-08-18T15:20Z |
| completed_total | 192,046 | 192,701 | 193,217 |
The 243 stale-revision rows reported by the maintenance dry run were pruned within the first alarm passes (301 → 81 pending at +45 s). A later dry run (https://github.com/openclaw/clawsweeper/actions/runs/33706395580) shows what remains eligible: 18 stale revisions with command context (kept for the operator path on purpose) and 13 legacy state-batch terminal candidates (need GitHub reads). Neither class blocks batching.
Batch workflow behavior
Baseline 22:00Z–01:29Z: 117 dispatches, 44 (38%) exited in under 60 s without claiming, 73 claimed, 17 of those failed (23%).
Redeploy window 01:59Z–02:45Z: 19 dispatches, 2 (11%) no-claim exits, 10 claimed and completed, 6 published successfully, 4 failed. Every post-redeploy batch that claimed carried a real batch (the exact-selection mismatch that previously retired reservations every 30 s is gone). The 4 failures were a single burst at 02:37–02:38Z: three client-side 20 s timeouts against the queue Worker during item preparation and one heartbeat that failed the same way. Worker logs in that period show Durable Object is overloaded. Requests queued for too long. and Internal error in Durable Object storage caused object to be reset; the object spends most of its CPU on /internal/state/records/export (about 24 s CPU in a 166 s window), which every batch's state hydration calls. Those are pre-existing platform/capacity classes; #1368 adds bounded retries for the heartbeat and post-effect requests, and export cost is a separate follow-up.
Handoff health stayed healthy for most samples; brief dispatcher_blocked and claim_stalled flips coincided with the review lane's workflow-state preflight and Actions claim latency, not the publication changes.
What Problem This Solves
Fixes an issue where a freshly reviewed pull request whose direct publication hit a GitHub rate limit was queued for durable publication but never published, while the review-lease placeholder kept blocking a maintainer
@clawsweeper re-reviewfor the full 41-minute lease.Observed on 2026-09-02 (UTC):
GitHubRateLimitError(credential scoperepository_actions), the workflow fell back toPOST /internal/exact-review/enqueue, attempt 1 returned HTTP 503target_visibility_unverified, attempt 2 succeeded. The review was never published before the PR merged at 22:01.GET /api/exact-review-queueat 22:36 showedlanes.publication: pending 382, ready 381, dispatching 0, leased 0, active 0, capacity 40, available_slots 40,oldest_pending_at2026-08-13T09:14:19Z,next_attempt_at2026-08-13T09:24:59Z. At 22:52: pending 371, ready 371, active 0, same oldest/next-attempt values.Why This Change Was Made
Three independent defects in the exact-review queue Durable Object (
dashboard/exact-review-queue.ts) combined into starvation:exact-review-batch-publish.yml, and stores the probe. When the workflow claimed ~30-60 s later it required the current eight-item selection to be byte-identical to the probe. Under load the selection changes almost every time (a fresh-lane arrival, a fresh item ageing past the 15-minute window, a revision bump, a superseded row), so the workflow retired the reservation, claimed nothing, and exited after ~30 s; the alarm re-dispatched 5 s later and the cycle repeated. Evidence: between 21:20 and 21:43 roughly ten batch runs were dispatched and each exited in 26-45 s without claiming (for example https://github.com/openclaw/clawsweeper/actions/runs/33686404002, https://github.com/openclaw/clawsweeper/actions/runs/33686365000, https://github.com/openclaw/clawsweeper/actions/runs/33686326722, https://github.com/openclaw/clawsweeper/actions/runs/33686280755, https://github.com/openclaw/clawsweeper/actions/runs/33686215783, https://github.com/openclaw/clawsweeper/actions/runs/33686143313), which is exactly the fresh-lane window of the review enqueued at 21:23. Producer https://github.com/openclaw/clawsweeper/actions/runs/33668772748 (review at 18:41) was only published at 22:03/22:22.execute=false) reportedscanned=352,staleRevisionEligible=243,legacyStateBatchTerminalCandidates=44. Those 243 rows have a source revision older than the target's publication head; they are excluded from batching but still count as pending/ready and pinnext_attempt_atto Aug 13. Only the manual maintenance workflow withexecute=trueremoved them, and it last ran successfully on 2026-08-08.hostedTargetAdmissioncalledGET /repos/{repo}on each/enqueue, claim, and alarm pass; under rate-limit pressure the probe is retryable and/enqueueanswered 503, exactly when the review workflow needed the queue as fallback.Secondary: when direct publication fails with a rate limit and the item is queued, sweep.yml deliberately keeps the review-start lease comment (the later publisher deletes it), so a re-review is refused until the 41-minute lease expires.
What Changed
[key, revision]pairs and the current candidates (filtered before the admission scan and the lease-size cut). Unprobed fresh arrivals wait for the next departure; an empty intersection keeps today's retire-and-repreflight behavior. Malformed or legacy probes fall back to the strict comparison./enqueue,/command-intake,/branch-authority,/source-authority) get a 60 s fresh tier without a probe and may reuse a public observation for up to 30 min when the live probe is retryable. Review claims, dispatch, batch claims, and acknowledgement paths always perform a live probe and fail closed, so a target that turns private is refused before any credential-bearing work is handed out. A terminal probe or terminal eligibility clears the entry and records a tokenized revocation so an out-of-order older probe cannot re-admit;EXACT_REVIEW_HOSTED_TARGET_ADMISSION_MAX_STALE_MS=0disables the cache.stale_revisionclass only, bounded byEXACT_REVIEW_STALE_PUBLICATION_PRUNE_LIMIT, default 100, oldest first, no GitHub reads, command-bearing rows excluded). Duplicate-lineage and legacy terminal classes stay on the operator workflow.expire-review-leaseCLI command rewrites onlylease_expires_atin the placeholder marker; sweep.yml calls it right after a successful queue handoff so a maintainer re-review is no longer blocked. The publisher still deletes the placeholder on terminal publication.docs/live-dashboard.md,docs/limits.md.No Durable Object binding, migration, SQLite table, or public
/api/exact-review-queuefield changed. OpenClaw Bay needs no change: it observes the same aggregate fields, which now reflect corrected pending/completed values.pr-behavior-proof
ExactReviewQueuealarm/claim/enqueue routes andsweep.ymlstep contract, through the existing in-memory SQLite Durable Object harness and workflow-definition tests.node --test <touched test files>pluspnpm run build:all,pnpm run lint,pnpm run format:check,pnpm run check:docs,pnpm run check:limits,pnpm run check:active-surface,pnpm run check:dashboard-queue-boundary,pnpm run check:dashboard-strict,git diff --check.pnpm run checksuite reports pre-existing, environment-caused failures in this worktree (agent-input-scanunsafe_pathrefusals because the worktree lives under a hidden directory); the same files pass from the main checkout path. Live before/after queue numbers must be captured after deployment.Regression tests added
test/exact-review-publication-batches.test.ts:batch claim after {fresh arrival | revision bump | all probed items gone | older retries become ready beyond the scan window} consumes only still-valid probed items;hosted admission cache: {fresh | stale fallback | terminal clears | too old | disabled};hosted admission rejects an older public probe after terminal revocation (cache 1800000 | 0);hosted admission fences an older public probe across same-millisecond revocations;terminal eligibility revokes cached admission and an overlapping {public | retryable} probe;alarm prunes stale publication revisions after batch expiry with limit {100 | 1};alarm preserves command acknowledgements after batch expiry while pruning ordinary stale publications.test/exact-review-publication-batches.test.ts(fail-closed follow-up):batch claim ignores cached public admission when the live probe is {terminal | retryable}.test/dashboard-worker-queue-runtime.test.ts:matching empty batch departures release their own fence and redispatch current work(updated to remove every probed member explicitly).test/review-comment-publication.test.ts:expireReviewStartStatusLease changes only the canonical expiry and releases the exact-head lease;expireReviewStartStatusLease leaves noncanonical markers and unrelated text byte-identical.test/command.test.ts:expire-review-lease patches the queued placeholder and preserves unrelated comments.test/sweep-workflow.test.ts:queued publication expires only its posted review lease after successful handoff.Before the fix the claim tests returned
claimed:false, the cache tests answered 503 on/enqueue, and the prune tests left the stale rows pending.Queue API before (2026-09-02T22:52Z, pre-deploy)
After-deploy numbers will be added once the Worker is deployed through
dashboard.yml.Review finding disposition
🤖 Generated with Claude Code