Skip to content

fix(queue): retry control-plane 5xx and propagate retryable admission failures - #1497

Merged
steipete merged 1 commit into
mainfrom
queue/retryable-control-plane-calls
Sep 8, 2026
Merged

steipete merged 1 commit into
mainfrom
queue/retryable-control-plane-calls

Conversation

@steipete

@steipete steipete commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where exact-review workflows fail or skip review after a single transient control-plane 5xx, and visibility admission failures lose their retry signal at webhook ingress.

Why This Change Was Made

The Worker now returns the Durable Object's structured retryable 5xx response intact at webhook enqueue; internal proxies already preserved it and now have explicit regression coverage. One shared shell helper retries connection failures and HTTP 5xx at most four times, honors Retry-After up to 60 seconds, and otherwise waits 2/4/8 seconds. Callers retain their final status, body, curl exit behavior, and explicit 409 handling and the existing one-time 400 deployment-skew fallback. Existing outer curl retry loops are removed.

Visibility admission and credential-bearing live probes are unchanged. Enqueue admission precedes delivery persistence, and earlier webhook gates already return 503; no GitHub redelivery contract depends on the previous opaque 500.

User Impact

Transient control-plane failures can recover within the same workflow attempt. Exhausted reservation and status-fence failures use the existing queue_completion_failure category, so a skipped review is attributed to queue infrastructure.

OpenClaw Bay Impact

No Bay code or public data-contract change is required. This corrects workflow failure attribution using an existing category; Bay's observer-only reads and canonical view links are unchanged. No browser calls or mutation controls are added.

Documentation Impact

Updated the active scheduler reference with shell retry limits and classification, and the active live-dashboard protocol reference with structured admission response propagation. Reviewed webhook delivery/deduplication behavior and the separate batch-publication retry policy; batch clients retain their existing policy. Added the Unreleased changelog entry.

Evidence

Node 24 / pnpm 11.10.0: build, build:repair, build:dashboard, static/documentation checks, formatting, lint, and diff checks passed. Focused Worker/helper/fence tests, loopback terminal-finalization/reconciliation tests, drift-refresh proof, and checkout audits passed.

The first full unit run reported 3 failures among 3,999 tests: stale curl/terminal-attempt fixture assumptions were corrected, and the separate locale/process-identity failure passed on an isolated rerun. The broader coverage check reported 5,608 passed, 13 skipped and 10 failures, including outdated checkout assumptions (now fixed) and separate subprocess/time-budget failures; every reported case has passed focused reruns. The rebased tree builds all bundles, passes 48 focused tests plus the 11-case completion/skew/classification audit, passes the committed-head real-behavior proof and static checks, and has a clean pre-commit review. The full-run failure summary is retained rather than described as a clean run. CI must validate the current head.

Real Behavior Proof

  • Claim: transient control-plane errors recover with bounded retries; admission 503 status, JSON, and Retry-After survive webhook and internal enqueue ingress; unexpected exceptions remain 500.
  • Surface: actual Bash/curl over loopback HTTP, plus Worker fetch through a SQLite Durable Object in local workerd.
  • Fixture: synthetic HTTP server returns 503 with Retry-After: 1 twice, then 200; separate 400 response. Workerd injects a retryable hosted-target probe with a retry timestamp, and separately an unexpected exception.
  • Reviewed source: 166bc7bd77baa7fb6ecfdcf91e8adfc85916ab8e (rebased onto current main; changelog entries and the existing terminal-reason deployment-skew fallback are retained).
  • Command and environment: node scripts/e2e/control-plane-retries.mjs, Node 24.20.0 on macOS, local Wrangler 4.107.0/workerd, Bash/curl. No remote lease or container image; provider is local-workerd.
  • Observed: 503/503/200 made exactly three requests with notices and at least one second between requests; 400 made exactly one request. Both ingress paths returned 503, the original target_visibility_unverified/retryable JSON, and Retry-After: 30. Both unexpected-exception cases returned 500 without Retry-After.
  • Artifact: executable proof driver in scripts/e2e/control-plane-retries.mjs; generated transcript and workerd logs in .artifacts/control-plane-proof/. Compact executed output below.
  • Limits: synthetic local failure, no production outage injection, external GitHub traffic, live redelivery exercise, or mutation.
503 -> 503 -> 200: attempts 1/4, 2/4, 3/4; waits 1s, 1s; final HTTP 200
400: attempt 1/4; no retry; final HTTP 400
POST /github/webhook: HTTP 503; Retry-After: 30
POST /internal/exact-review/enqueue: HTTP 503; Retry-After: 30
JSON: {"error":"target_visibility_unverified","retryable":true}
Unexpected webhook exception: HTTP 500; Retry-After absent
Unexpected internal exception: HTTP 500; Retry-After absent

Known Gaps

No production deployment or merge is performed by this PR. Shell retries do not add replay authority or change admission policy; the separately implemented batch clients remain outside this change.
Audited 32 control-plane curl sites.

Workflow Job Step Endpoint
sweep.yml legacy-event-queue-intake Enqueue legacy event through the durable control plane /internal/exact-review/enqueue, /branch-authority, or /source-authority
sweep.yml event-review-apply Claim exact-review queue lease /internal/exact-review/claim
sweep.yml event-review-apply Fence automatic review in progress /internal/exact-review/heartbeat
sweep.yml event-review-apply Release automatic review status fence /internal/exact-review/heartbeat
sweep.yml event-review-apply Review exact event item /internal/exact-review/heartbeat
sweep.yml event-review-apply Review exact event item /internal/exact-review/heartbeat
sweep.yml event-review-apply Fence automatic review completion /internal/exact-review/heartbeat
sweep.yml event-review-apply Release automatic review completion fence /internal/exact-review/heartbeat
sweep.yml event-review-apply Finalize direct exact review lifecycle /internal/exact-review/lifecycle/router-receipt
sweep.yml event-review-apply Finalize direct exact review lifecycle /internal/exact-review/lifecycle/terminal-disposition
sweep.yml event-review-apply Queue durable exact review publication /internal/exact-review/enqueue
sweep.yml event-review-apply Fence terminal automatic review failure /internal/exact-review/heartbeat
sweep.yml event-review-apply Release terminal automatic review status fence /internal/exact-review/heartbeat
sweep.yml event-review-apply Complete exact-review queue lease /internal/exact-review/complete
sweep.yml event-review-publish Claim durable exact review publication /internal/exact-review/claim
sweep.yml event-review-publish Replay committed direct lifecycle handoff /internal/exact-review/lifecycle/router-receipt
sweep.yml event-review-publish Replay committed direct lifecycle handoff /internal/exact-review/lifecycle/terminal-disposition
sweep.yml event-review-publish Record fallback canonical exact review lifecycle receipt /internal/exact-review/lifecycle/canonical-receipt
sweep.yml event-review-publish Queue deferred exact verdict router /internal/exact-review/lifecycle/router-receipt
sweep.yml event-review-publish Record deferred close-proof exact review lifecycle receipt /internal/exact-review/lifecycle/router-receipt
sweep.yml event-review-publish Record no-router exact review lifecycle receipt /internal/exact-review/lifecycle/router-receipt
sweep.yml event-review-publish Queue fresh review after source drift /internal/exact-review/enqueue
sweep.yml event-review-publish Complete durable exact review publication /internal/exact-review/complete
sweep.yml event-review-terminal-finalization Claim committed terminal finalization /internal/exact-review/claim
sweep.yml event-review-terminal-finalization Begin fenced terminal acknowledgement /internal/exact-review/terminal-finalization/attempt
sweep.yml event-review-terminal-finalization Update final command status once /internal/exact-review/lifecycle/command-ack/failed
sweep.yml event-review-terminal-finalization Record verified terminal acknowledgement receipt /internal/exact-review/lifecycle/command-ack/observed
sweep.yml event-review-terminal-finalization Complete locked terminal acknowledgement skip /internal/exact-review/terminal-finalization/skip
sweep.yml event-review-terminal-finalization Requeue unobserved terminal acknowledgement /internal/exact-review/terminal-finalization/retry
sweep.yml recover-review-failures Requeue eligible item terminals once /internal/exact-review/enqueue
exact-review-reconcile-run.yml reconcile Reconcile terminal run /internal/exact-review/reconcile
exact-review-dead-letter-reconcile.yml reconcile Verify live recovery guards /api/health

@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 11:27 AM ET / 15:27 UTC.

ClawSweeper review

What this changes

Adds bounded retries to workflow control-plane requests, preserves retryable admission responses at webhook ingress, and classifies failed review fences as queue infrastructure failures.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still loses retryable webhook admission responses and lacks the shared workflow retry behavior. The previous merge-conflict blocker is resolved, the supplied runtime proof covers the changed paths, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 166bc7bd77baa7fb6ecfdcf91e8adfc85916ab8e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused reliability change with meaningful production-path proof, targeted coverage, and no blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The current-head transcript exercises the production Bash/curl helper over real loopback HTTP and Worker ingress through local workerd’s SQLite Durable Object, showing bounded recovery and preserved retryable admission responses; production outage injection is outside its stated scope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The current-head transcript exercises the production Bash/curl helper over real loopback HTTP and Worker ingress through local workerd’s SQLite Durable Object, showing bounded recovery and preserved retryable admission responses; production outage injection is outside its stated scope.
Evidence reviewed 8 items Repository policy: Read the complete root AGENTS.md and checked tracked policy paths; no nested AGENTS.md or maintainer-note files were present. Applied the proposal-only boundary, runtime-proof requirement, and Bay impact guidance.
Pinned introduction and resolved integration: The verified test merge records the pinned main followed by the exact PR head as parents, and its tree has no difference from the reviewed head. This resolves the previous review’s merge-conflict concern.
Behavior remains absent from main: Pinned main parses the enqueue response and throws for every non-success status, discarding structured retry guidance at webhook ingress. The shared shell helper is newly introduced and is also absent from the supplied latest release, v0.3.0; no merged replacement was established.
Findings None None.
Security None None.

How this fits together

ClawSweeper workflows contact a Worker-backed durable queue to admit, claim, fence, and complete reviews. These changes let transient failures recover while preserving the queue’s existing ownership checks and reporting failures accurately.

flowchart TD
  A[GitHub events] --> B[Worker ingress]
  C[Review workflows] --> D[Bounded request retries]
  D --> B
  B --> E[Durable queue admission and lease checks]
  E --> F[Review and publication lifecycle]
  E --> G[Status and retry guidance]
  G --> D
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Net line growth Production/workflows +56; tests +276; proof drivers +204; docs +28 Production growth is justified by the shared retry helper and response propagation, with most additions supporting validation.

Technical review

Best possible solution:

Keep one bounded shell retry policy while preserving endpoint-specific lease conflicts, deployment compatibility, and structured admission responses.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: main throws away structured non-success enqueue responses, and affected workflow calls can fail on a single transient response. This read-only review did not execute a failing main reproduction.

Is this the best way to solve the issue?

Yes. A shared bounded helper removes repeated retry loops while the Worker change narrowly preserves existing response semantics; endpoint-specific conflict and deployment-skew handling remain intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f789a4a58f81.

Labels

Label justifications:

  • P2: This is a bounded reliability improvement for transient queue infrastructure failures, with no demonstrated emergency regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The current-head transcript exercises the production Bash/curl helper over real loopback HTTP and Worker ingress through local workerd’s SQLite Durable Object, showing bounded recovery and preserved retryable admission responses; production outage injection is outside its stated scope.
  • proof: sufficient: Contributor real behavior proof is sufficient. The current-head transcript exercises the production Bash/curl helper over real loopback HTTP and Worker ingress through local workerd’s SQLite Durable Object, showing bounded recovery and preserved retryable admission responses; production outage injection is outside its stated scope.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md and checked tracked policy paths; no nested AGENTS.md or maintainer-note files were present. Applied the proposal-only boundary, runtime-proof requirement, and Bay impact guidance. (AGENTS.md:1, 166bc7bd77ba)
  • Pinned introduction and resolved integration: The verified test merge records the pinned main followed by the exact PR head as parents, and its tree has no difference from the reviewed head. This resolves the previous review’s merge-conflict concern. (588b4eb34f31)
  • Behavior remains absent from main: Pinned main parses the enqueue response and throws for every non-success status, discarding structured retry guidance at webhook ingress. The shared shell helper is newly introduced and is also absent from the supplied latest release, v0.3.0; no merged replacement was established. (dashboard/worker.ts:7186, f789a4a58f81)
  • Bounded retry implementation: The helper makes at most four attempts, retries selected transport failures and HTTP 5xx, leaves HTTP 4xx terminal, caps Retry-After at 60 seconds, and emits only the final attempt’s stdout and curl exit code. Focused coverage includes exhaustion, transport resets, terminal 400/429 responses, delay parsing, and identical request bytes. (scripts/control-plane-curl.sh:5, 166bc7bd77ba)
  • Existing fencing and compatibility retained: Workflow callers retain explicit 409 handling and the one-time invalid_review_failure_reason fallback. Queue claim and heartbeat handlers continue checking live lease identity, run identity, revision, and applicable generation/head fields; retries do not introduce a new authorization path. (.github/workflows/sweep.yml:2418, 166bc7bd77ba)
  • Current-head runtime proof: The captured body for fix(queue): retry control-plane 5xx and propagate retryable admission failures #1497 identifies the reviewed head and records macOS Node 24.20.0, real Bash/curl, and local Wrangler/workerd execution. The supplied transcript reports 503/503/200 recovery in three requests with one-second waits, a single terminal 400 request, preserved admission JSON and Retry-After through both ingress routes, and unexpected exceptions remaining 500. The fully inspected driver exercises the production helper and Worker with a SQLite Durable Object and injected admission faults. This review did not execute it. (scripts/e2e/control-plane-retries.mjs:20, 166bc7bd77ba)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-08T15:21:38.664Z sha 8149a10 :: blocked before merge. :: none

@steipete
steipete force-pushed the queue/retryable-control-plane-calls branch from 8149a10 to 166bc7b Compare September 8, 2026 15:23
@steipete
steipete marked this pull request as ready for review September 8, 2026 15:23
@steipete
steipete requested a review from a team as a code owner September 8, 2026 15:23
@steipete
steipete merged commit 9da27d0 into main Sep 8, 2026
16 of 22 checks passed
@steipete
steipete deleted the queue/retryable-control-plane-calls branch September 8, 2026 15:43
steipete added a commit that referenced this pull request Sep 8, 2026
…dmission failures (#1497)" (#1498)

This reverts commit 9da27d0.

Reverts #1497: its helper checkout step leaves core.sparseCheckout enabled so the job's full checkout materializes only scripts/control-plane-curl.sh and setup-pnpm is missing (runs 34246655629, 34246581768). A corrected re-land follows.
steipete added a commit that referenced this pull request Sep 8, 2026
… failures (re-land) (#1503)

* fix(queue): retry control-plane 5xx and propagate retryable admission failures (#1497)

(cherry picked from commit 9da27d0)

* fix(queue): retry control-plane 5xx and propagate retryable admission failures (re-land)

Re-land the retry and structured admission failure behavior from reverted PR
#1497. The original early helper-only
sparse checkouts persisted sparse Git configuration into subsequent full
checkouts, omitting the local setup-pnpm action.

Fetch the helper at the workflow commit into RUNNER_TEMP before source checkout,
validate the download and function, and use the repository copy after full
checkout. Audit checkout ordering across workflows and full source checkout
before sweep setup-pnpm, with executable bootstrap failure coverage and a real
Git old/new checkout reproduction.

* fix(queue): keep lease cleanup independent of checkout

Address the current ClawSweeper finding on
#1503: direct lifecycle recovery skips
source checkout, while claimed-lease completion must still reach the queue.

Bind review completion, publication completion, and terminal retry to the actual
checkout outcome. Use the repository helper after success and the already
validated temporary helper after skipped, failed, or cancelled checkout.
Preserve existing admission, lease, and requeue guards.

Exercise the extracted cleanup shells over loopback HTTP for nine successful,
skipped, and failed checkout scenarios, including a poisoned partial checkout
and checkout-free direct-lifecycle requeue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant