Skip to content

fix(queue): keep the correct follow-up review after publication - #1324

Merged
steipete merged 2 commits into
mainfrom
steipete/saved-lease-authority-2f6477
Aug 31, 2026
Merged

fix(queue): keep the correct follow-up review after publication#1324
steipete merged 2 commits into
mainfrom
steipete/saved-lease-authority-2f6477

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: issue 1245
Follow-up to PR 1251

What Problem This Solves

Resolves a queue ownership problem where a follow-up review could be discarded or scheduled without an authoritative requeue receipt when the current publication decision and the saved publishing lease disagreed. A superseded receipt could also accept a direct requeue completion.

The baseline already contains the original lost-completion recovery and workflow failure classification from PR 1251. This PR tightens the remaining receipt-authority boundary; it does not claim that earlier fix as new work. The inconsistent-state cases below are controlled synthetic regressions, not claims of observed production incidents.

Why This Change Was Made

Completion and terminal-run reconciliation now share one interpretation of the saved lease's direct lifecycle. Only its accepted/deduplicated requeue receipt establishes an owed follow-up. The existing requeue path also reads the producer decision and old target from that same lease rather than mutable current metadata.

There is no new recovery layer, endpoint, schema, retry policy, or model inference. The workflow implementation and failure gate are unchanged. Current-main terminal-outcome, error-correlation, and telemetry changes are preserved.

User Impact

An already-owed follow-up remains schedulable exactly once. Unsupported or superseded metadata cannot invent that obligation, later commands retain their prompt/marker/revision, and repeated or late callbacks do not create another review. Ordinary completion, failed/cancelled publication retry, parking, and incomplete-source behavior remain unchanged.

OpenClaw Bay Impact

No Bay schema, UI, or mutation control is added. The runtime proof exercises the existing public observer projection and SQLite Bay tables: the old fenced requeue fact is retained without invented review success/failure, router, or acknowledgement receipts. The newer command's lifecycle is not overwritten.

Documentation Impact

Active scheduler and state-storage documentation now state the saved-lease authority contract. The changelog records the follow-up and retains credit for the original contributor work.

The new public repro methodology and source is classified as proposed proof methodology, with its owner, source of truth, pinned baseline, requirements, and update triggers. It contains executable source, not raw logs, archives, credentials, or agent transcripts. Actual execution observations are recorded below.

Evidence

On the exact committed head:

  • Fresh pnpm run build:all and six focused suites: 445 passed, zero failed/skipped.
  • Complete pnpm run check: 4,187 passed, zero failed, eight skipped, plus 13/13 changed-coverage tests. Coverage: 82.83% lines, 75.80% branches, 88.06% functions.
  • Narrow lint, formatting, documentation, queue-boundary, and syntax checks passed.
  • Managed Codex review was scoped-clean at default P0 priority both before the proof-source commit and again on the exact committed range. Hosted CI and the current head/body ClawSweeper review remain merge gates.

Real Behavior Proof

Claim and exercised surface: real workerd/SQLite Durable Objects, signed public Worker forwarding, publication receipts, terminal disposition, completion/reconciliation, and the existing public Bay read model. The realistic sequence records terminal requeue before deliberately omitting /complete.

Source identity:

  • Behavior baseline: 659dee73d0706fee9776f7986d9861e82b897d24.
  • Executed head: 26cd5760da7e4d49465f86857b788ec022569f5d.
  • Executed Git tree: 2f517572276a5a1857f832af3abec5cdc3029070; tracked working-tree changes: [].
  • Before-source archive SHA-256: f1873d20690bbc76f53257949caf6f55301f47279a844c2e416a0ed637fafd07.
  • Complete executed-source manifest SHA-256: 3abab5ad0b52d366438f91b09de107eeb49f8acbaa2ae170737f144bee888906; source/index identity was reverified after validation.

Environment and execution: AWS Crabbox, Linux, c7a.8xlarge, eu-west-1, image ami-0461d919be7deb53c; lease cbx_b9877bf89798, run run_1b578feaa825, 2026-08-31 16:37–16:40 UTC, overall exit 0. Node 24.20.0, pnpm 11.10.0, Wrangler 4.107.0. No Actions hydration or ambient credential forwarding; the IMDS IAM credential endpoint returned 404. Only a scanned explicit payload and one exact public source commit were used, not local Git history or unrelated artifacts. Authenticated portal links are not required to inspect this proof.

Command (temporary directory prefixes normalized; the public driver contains the exact request sequence and assertions):

SAVED_LEASE_SOURCE_DIR="$PWD" SAVED_LEASE_OUTPUT=/tmp/saved-lease-results SAVED_LEASE_WRANGLER=/path/to/wrangler SAVED_LEASE_BASELINE_ARCHIVE=/tmp/saved-lease-baseline.tar bash docs/proof/saved-lease-authority/run-proof.sh

The README gives the exact baseline archive command and requirements. Worker harness, scenario driver, and workflow annotation driver are inspectable at the executed commit.

Observed results: all 17 baseline + 17 candidate scenarios satisfied their explicit before/after expectations. The four distinguishing controls produced:

Control Baseline observed Candidate observed
Superseded receipt, direct requeue completion HTTP 200, requeued: true, terminal rewritten to requeue HTTP 400, invalid_direct_lifecycle_requeue, terminal remains superseded
Missing saved lease decision Reconciled 1, requeued 1, completed 0 Reconciled 1, requeued 0, completed 1
Wrong saved source action Reconciled 1, requeued 1, completed 0 Reconciled 1, requeued 0, completed 1
Current plan changed after lease Reconciled 1, requeued 0, completed 1 Reconciled 1, requeued 1, completed 0

Accepted/deduplicated lost-callback controls already recover on the baseline and continue to recover on the candidate. Their observed reconciliation response is:

{"ok":true,"reconciled":1,"requeued":1,"completed":0}

The resulting queue contains exactly one pending revision 5, with its lease cleared and source action source_drift_requeue; the old revision 4 retains terminal requeue. Delivered-completion controls reach the same pending state. Repeated reconciliation returns zero reconciled/requeued/completed, and late old completion returns 409. Newer commands retain their exact decision/marker/prompt/revision. Wrong attempt/generation, ambiguous ownership, unsigned requests, failed/cancelled retries, receipt collections, counters, and Bay projections are asserted. Worker outbound attempts and unexpected alarms remain 0.

The unchanged workflow gate also passed 192 feasible Boolean contexts and 12 actual shell executions covering completion-only failure, typed deferral, exit-zero content failure, simultaneous failure, and review-only failure.

Limits: admission and malformed/canonical preconditions are seeded; terminal-run observations are supplied through the signed endpoint instead of real GitHub run lookup. Dispatch is suppressed only after pending-state inspection, and outbound Worker fetch is denied and counted. This proves the changed local runtime/persistence/forwarding boundary—not deployed-edge behavior, Actions admission, a complete hosted workflow, production load, or model inference. No live queue or GitHub mutation is performed by the repro.

Follow up on #1251 by reading direct-requeue authority from the saved lease decision. Preserve accepted and deduplicated receipt ownership, reject superseded completion authority, and keep newer command decisions intact. The original lost-completion fix is already upstream; retain its existing contributor credit.
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:57 PM ET / 16:57 UTC.

ClawSweeper review

What this changes

The PR makes follow-up review requeues depend on the saved lease’s accepted or deduplicated direct-publication receipt, with regression tests, operational documentation, and an inspectable proof harness.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main predates its saved-lease authority fix, and the patch has no actionable correctness finding. Its supplied real workerd proof directly exercises the changed completion and reconciliation paths with the expected before/after results.

Priority: P2
Reviewed head: 26cd5760da7e4d49465f86857b788ec022569f5d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow, well-covered queue reliability repair with strong exact-head behavior proof and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): At 26cd576, the changed ExactReviewQueue behavior was exercised through signed production Worker routes against workerd and isolated SQLite Durable Objects. The supplied Crabbox terminal trace records the candidate rejecting superseded authority, preserving accepted/deduplicated requeues, retaining newer commands, and leaving the Bay projection consistent; deployed-edge and GitHub lookup behavior remain outside that focused proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): At 26cd576, the changed ExactReviewQueue behavior was exercised through signed production Worker routes against workerd and isolated SQLite Durable Objects. The supplied Crabbox terminal trace records the candidate rejecting superseded authority, preserving accepted/deduplicated requeues, retaining newer commands, and leaving the Bay projection consistent; deployed-edge and GitHub lookup behavior remain outside that focused proof.
Evidence reviewed 7 items Saved receipt is the sole requeue authority: The new helper accepts only an artifact-publication lease whose lifecycle receipt is accepted or deduplicated, and exposes the old canonical target only from that saved decision.
Completion and reconciliation share the authority check: Both direct completion and lost-callback reconciliation now use the saved-lease helper; the requeue operation also reads the saved lease rather than mutable current metadata.
Focused regression matrix: Coverage exercises accepted and deduplicated receipts, superseded and missing authority, mutable current plans, newer commands, ownership mismatches, and failed/cancelled retries.
Findings None None.
Security None None.

How this fits together

The exact-review queue accepts publication results, keeps a lease for the original review, and later completes or reconciles that lease. This change decides whether that recovery creates one owed source-drift follow-up while preserving newer commands and the observer-only Bay status projection.

flowchart LR
  A[Artifact publication] --> B[Saved lease receipt]
  B --> C[Completion callback]
  B --> D[Lost-callback reconciliation]
  C --> E{Accepted requeue owed?}
  D --> E
  E -->|Yes| F[One follow-up review]
  E -->|No| G[Finish lease]
  F --> H[Observer-only status projection]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The proof covers the real local Worker and Durable Object recovery boundary, but not deployed-edge behavior or GitHub Actions run lookup; rollout monitoring should confirm recovered requeues remain healthy.
  • Complete next step (P2) - No repair task is needed because the review found no actionable patch defect; await the current review and check gates.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change footprint 11 files; runtime +21/−12; tests +418/−130 The production change is narrow relative to the focused lifecycle and workflow regression coverage.
Behavior proof matrix 34 workerd scenarios; 192 gate contexts; 12 shell executions The supplied proof covers both delivered and lost callbacks, receipt authority controls, and the unchanged workflow failure gate.

Merge-risk options

Maintainer options:

  1. Observe the recovery rollout (recommended)
    Accept the bounded automation rollout risk after current checks pass and verify that production reconciliation preserves exactly one owed follow-up review.

Technical review

Best possible solution:

Merge the focused saved-lease authority repair after the current review and check gates complete, then observe early production reconciliation and follow-up-review telemetry.

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

Yes. The supplied exact-head AWS Crabbox trace exercises the signed Worker completion and reconciliation paths against workerd/SQLite and shows the baseline and candidate outcomes for the authority controls.

Is this the best way to solve the issue?

Yes. Reading authority and the producer decision from the immutable saved lease is the narrowest solution because it prevents mutable current queue metadata from adding, removing, or redirecting the old lease’s requeue obligation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0baa4dbb4d12.

Labels

Label changes:

  • add P2: This is a bounded reliability fix for follow-up review scheduling rather than a demonstrated active production outage.
  • add merge-risk: 🚨 automation: The patch changes queue recovery behavior that controls automated review requeues after publication callbacks are lost.
  • add proof: sufficient: Contributor real behavior proof is sufficient. At 26cd576, the changed ExactReviewQueue behavior was exercised through signed production Worker routes against workerd and isolated SQLite Durable Objects. The supplied Crabbox terminal trace records the candidate rejecting superseded authority, preserving accepted/deduplicated requeues, retaining newer commands, and leaving the Bay projection consistent; deployed-edge and GitHub lookup behavior remain outside that focused proof.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): At 26cd576, the changed ExactReviewQueue behavior was exercised through signed production Worker routes against workerd and isolated SQLite Durable Objects. The supplied Crabbox terminal trace records the candidate rejecting superseded authority, preserving accepted/deduplicated requeues, retaining newer commands, and leaving the Bay projection consistent; deployed-edge and GitHub lookup behavior remain outside that focused proof.

Label justifications:

  • P2: This is a bounded reliability fix for follow-up review scheduling rather than a demonstrated active production outage.
  • merge-risk: 🚨 automation: The patch changes queue recovery behavior that controls automated review requeues after publication callbacks are lost.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): At 26cd576, the changed ExactReviewQueue behavior was exercised through signed production Worker routes against workerd and isolated SQLite Durable Objects. The supplied Crabbox terminal trace records the candidate rejecting superseded authority, preserving accepted/deduplicated requeues, retaining newer commands, and leaving the Bay projection consistent; deployed-edge and GitHub lookup behavior remain outside that focused proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. At 26cd576, the changed ExactReviewQueue behavior was exercised through signed production Worker routes against workerd and isolated SQLite Durable Objects. The supplied Crabbox terminal trace records the candidate rejecting superseded authority, preserving accepted/deduplicated requeues, retaining newer commands, and leaving the Bay projection consistent; deployed-edge and GitHub lookup behavior remain outside that focused proof.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Yuval Dinodia: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Martin Cleary: 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.

@steipete
steipete merged commit aba9826 into main Aug 31, 2026
19 checks passed
@steipete
steipete deleted the steipete/saved-lease-authority-2f6477 branch August 31, 2026 17:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged with maintainer approval as aba9826.

Validation applies to head 26cd5760da7e4d49465f86857b788ec022569f5d and the unchanged PR body: the public workerd/SQLite repro passed 17 baseline + 17 candidate scenarios, 192 workflow-gate contexts and 12 shell executions. Fresh focused validation passed 445 tests; the complete remote check passed 4,187 tests with eight skips, plus 13/13 changed-coverage tests. Pre-commit and committed-range managed reviews were scoped-clean at default P0 priority.

CI, CodeQL, and the current ClawSweeper review completed; proof was accepted as sufficient, with no actionable finding or contributor-facing blocker. The explicit skipped checks were manual-only, bot-label exclusions or the inactive CodeSmith app—not counted as passes.

The bounded queue-automation rollout risk is accepted for this landing. The main body and inspectable repro source retain the proof's limits: no deployed-edge, real GitHub run-lookup, full hosted-workflow or production-load claim. The existing queue/Bay telemetry remains the rollout observation surface; no synthetic production mutation is part of this verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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