Skip to content

fix: preserve requester wakes after settlement publication failures - #160472

Merged
steipete merged 5 commits into
mainfrom
codex/requester-wake-worker-main-20260928
Sep 29, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/requester-wake-worker-main-20260928

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #159943, #160203, #160238, #160407

What Problem This Solves

Requester wake transitions still write SQLite on the Gateway thread. Moving those writes into the worker also requires preserving committed work when acknowledgement or host publication fails.

User Impact

Requester continuation and quiet child cleanup keep their existing behavior while their settlement writes run in the existing worker. Recovery does not repeat a committed write or send the requester result twice. Configuration, schema, and retention are unchanged.

Why This Change Was Made

The existing completion transaction owns transition, quiet completion, and reconciliation. Timers and retries retain their original database and wake owner. The existing pending wake episode keeps the native receipt until canonical facts are published and the remaining continuation settles.

Outcome settlement also retains committed system-event intents. The queue owner schedules matching pending intents and recognizes its compact terminal receipts. Missing or replaced intents are never recreated; if existing retention has removed a terminal receipt, the wake remains unsettled because completion cannot be established safely.

A native commit with unreadable receipt facts remains classified as committed and keeps the existing restoration fence. Neither retry nor source close can replay it; canonical restoration must first establish the current rows.

Quiet completion retains the existing ability to settle selected current members. Outcome-bearing settlement still requires the whole surviving frozen wave. Already-stale transition callbacks remain no-ops; current unpublished work still fails rather than allowing transport to continue.

A successfully retried transition now hands the remaining wake to the current retry caller, including a surviving sibling. The same pending episode owns the continuation until that caller claims it; committed replay budgets cannot leave a wake stranded behind an expired retry deadline.

Evidence

  • Broader receiving on canonical main 7972c353, before the final boundary correction, passed 370 worker, queue, registry/lifecycle, and source-replacement cases; 39 requester/lifecycle E2E cases; and an isolated public Gateway capsule using non-main sessions.create, real scheduled completion recovery, and post-publication sessions.describe.
  • A malformed-receipt regression observes a real committed SQLite transition, retains the original wake episode, counts only one command execution through retry, and verifies the fence survives close until canonical restoration. The causal pre-fix failure and 61 passing completion/queue/registry-owner sibling cases are retained.
  • On acf71ae1, the actual registered transition, outcome settlement, and quiet-completion callbacks ran while both observed wake windows recorded zero invocations across all eight host SQLite APIs. Dispatch and persisted-state assertions remain positive controls. The original whole-window baseline was 25; transition and quiet completion contributed 10 and 9 respectively. Initial requester-yield creation, other descendant readers, and native incognito preflight remain separate migration work.
  • The new four-case queue-receipt file passed alone with --maxWorkers=1: 51.52 seconds command wall time (41.31 seconds Vitest, about 6 seconds in the four cases) on Node 24.21.0 at 068615f9. Vitest attributed 71% of its duration to transformation. The over-30-second file is retained for its real SQLite worker and registered queue scheduler boundary: pending/completed intent recovery must not duplicate dispatch, and replaced/absent intents must refuse recovery. Those ownership and persistence checks cannot be established by the storage-mocked policy fixtures.
  • The original CI 48-file group reproduced an MCP-retirement timeout even though the runtime cache was already empty. The fixture now joins existing detached cleanup before checking its unchanged predicate. The same group passes 804 cases with four platform skips; the five-case lifecycle file also passes.
  • Storage-mocked registry fixtures now use the existing policy mutation adapter and persistence recorder. Retirement assertions inspect recorded deletion and authoritative map absence. A collector fixture joins its actual terminal persistence before observing detached completion; no timeout or outcome assertion was weakened.
  • The final boundary correction passes 63 recovery/worker cases, the original failed 25-file selector group (295 passed, three platform skips), and eight registered receipt/replacement/quiet cases. The restart fixture joins actual initial write acknowledgements while holding the same outstanding transport. An added outcome-settlement case rejects an omitted live sibling without changing durable or published rows.
  • The continuation regression uses an actual SQLite failure trigger and covers the original and surviving sibling owners. Retry-lifetime policy cases use the existing storage adapter. The original failed 25-file selector passes 525 cases; the final worker/lifetime selection passes 46 cases, with its two final-state observations separately passing after joining the actual completion callback. Blocked-write transport, durable replay count before dispatch, delivered state, and duplicate-sweep assertions remain enforced.
  • Fresh independent P0–P2 review is clean after repairing committed-receipt classification. The original review and source-backed dispositions for the existing unknown-write fence and compact terminal queue contract are preserved.

Selected static guards, core types, all 27 test type graphs, dead-export scans, formatting, lint, schema checks, and import/boundary guards passed on the reviewed continuation head e87be536. The previous Linux composition passed normal pnpm build with Node 24.19.0 and pnpm 12.5.1; its UI report measured 372318 bytes against the 372347-byte limit, with an earlier eight-byte advisory retained in the investigation. Current receiving used Node 24.21.0 and pnpm 12.5.1; the focused E2E checks exercise source runtime and do not claim a fresh packaged-artifact build. Runtime delivery uses synthetic isolated dispatch, not a live channel. The first CI run (36519299928) exposed the cleanup fixture race above and an inherited Cron fixture lint error. The latter is fixed on main by 743c2ceb72e7d1372845ea6f834bb82993fc9e0e; the next CI merge 3aeb0b07 includes its exact corrected blob and the lint job passed. Cancelled jobs are not counted as passing coverage.

CI 36523188069 then exposed six branch-caused recovery cases. The final correction restores stale no-op and quiet selected-member behavior, and makes the forced-restart fixture await the write whose committed state it asserts. These failures and cancelled coverage remain recorded; they are not treated as pre-existing exceptions.

CI 36526345182 exposed three policy fixtures still observing the retired synchronous write seam and a replay fault no longer injected into the native writer. Migrating that fault to SQLite exposed a real missed continuation after successful retry. The pending-episode handoff above fixes that ownership gap, including a sibling executing the retry. These branch-caused failures are retained; cancelled jobs are not passing coverage.

Fresh independent P0–P2 review and the selected changed gate pass for the continuation correction: core types, all 27 test type graphs, all three dead-export scans, typed lint, schema and boundary guards. Main then introduced a source conflict through its existing owner refactor. The normal merge with fixed main 46147f5e preserves its exact-entry Map and shared row reader. That composition passes 77 worker/queue/lifetime/codec cases, eight registered requester cases, core and owning test types, the full branch line-cap check, changed-file lint, and a fresh full-scope P0–P2 review. Manifests and lockfile are unchanged. Final reviewed head: a41dc8a766866414ad49a6d55056c20abaa77d54. Exact-head CI 36533084528 passed. Native merge verified and landed this head as 10e951e857488865ae3fcd85c83800b20c925431; native cleanup is complete. Earlier failed and cancelled runs remain recorded above.

@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@steipete
steipete marked this pull request as ready for review September 28, 2026 13:29
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 2:57 AM ET / 06:57 UTC (Revision 8).

ClawSweeper review

What this changes

Moves child-agent requester-wake writes into the SQLite worker and adds receipt-backed recovery when committed settlement cannot be published immediately.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. Current main still performs requester-wake persistence on the Gateway thread, so the branch has distinct work to land. The previously raised terminal-receipt lifetime limit is documented and was explicitly accepted by a repository administrator for this change. I found no discrete blocking defect in the pinned diff.

Priority: P1
Reviewed head: a41dc8a766866414ad49a6d55056c20abaa77d54

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has substantial owner-boundary recovery coverage and no identified blocking defect, while its size and delivery-sensitive path warrant normal exact-head gates.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Registered requester-wake tests exercise the production registry and real SQLite worker with injected publication failure, no-write-replay guards, and an observed single continuation; queue-scheduler tests observe one delivery or refusal for changed intents. A separate public Gateway client checks session composition. These are scoped synthetic boundary results, not live-channel delivery. No stored schema, serialized field, or retention contract changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Registered requester-wake tests exercise the production registry and real SQLite worker with injected publication failure, no-write-replay guards, and an observed single continuation; queue-scheduler tests observe one delivery or refusal for changed intents. A separate public Gateway client checks session composition. These are scoped synthetic boundary results, not live-channel delivery. No stored schema, serialized field, or retention contract changes require migration proof.
Evidence reviewed 10 items Current-main behavior: Current main still calls synchronous registry persistence from requester-wake transition and quiet completion; the PR's central change is not already implemented there.
Worker and publication path: The proposed path runs the completion mutation through the worker authority, retains the committed receipt, publishes current registry postimages, and schedules committed queue IDs.
Retry ownership: The wake owner retries a pending committed episode before admitting another requester continuation and hands a successfully retried transition back to the current caller.
Findings None None.
Security None None.

How this fits together

The subagent registry receives child completion events and decides when to resume the requesting agent. It persists wake state in SQLite, publishes the resulting registry facts, and schedules any resulting delivery intent.

flowchart LR
A[Child completion] --> B[Requester wake owner]
B --> C[SQLite worker transaction]
C --> D[Committed receipt]
D --> E[Registry publication]
E --> F[Requester continuation]
C --> G[Queue intent]
G --> H[System event delivery]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +786, Tests +1201, Docs +17. Total +2004 across 39 files.

View PR surface stats
Area Files Added Removed Net
Source 14 1209 423 +786
Tests 24 1679 478 +1201
Docs 1 17 0 +17
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 39 2905 901 +2004

Review metrics

Metric Value Why it matters
Production and test LOC production +1209/−423 (net +786); tests +1679/−478 (net +1201) Production growth implements worker custody and committed-result reconciliation; the larger test growth exercises recovery and delivery boundaries.

Technical review

Best possible solution:

Use the registry's existing worker and queue owners for wake settlement, preserving single delivery and explicit refusal when the existing retention contract can no longer prove an outcome.

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

Yes, from source: current main synchronously persists requester-wake transitions and quiet completion on the Gateway path. The PR reports a measured host-SQL baseline; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The branch uses the existing worker transaction, registry publication owner, and queue scheduler, with no new configuration or retention policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: Requester continuation is a core agent workflow, and synchronous settlement or mishandled recovery can delay or duplicate its result.
  • merge-risk: 🚨 message-delivery: The changed wake and queue-receipt sequencing governs whether a child result is resumed or delivered once; the documented receipt-retention limit is an accepted tradeoff.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Registered requester-wake tests exercise the production registry and real SQLite worker with injected publication failure, no-write-replay guards, and an observed single continuation; queue-scheduler tests observe one delivery or refusal for changed intents. A separate public Gateway client checks session composition. These are scoped synthetic boundary results, not live-channel delivery. No stored schema, serialized field, or retention contract changes require migration proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. Registered requester-wake tests exercise the production registry and real SQLite worker with injected publication failure, no-write-replay guards, and an observed single continuation; queue-scheduler tests observe one delivery or refusal for changed intents. A separate public Gateway client checks session composition. These are scoped synthetic boundary results, not live-channel delivery. No stored schema, serialized field, or retention contract changes require migration proof.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Mitchell Etzel: 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 (7 earlier review cycles)
  • reviewed 2026-09-28T13:38:04.256Z sha 958e43f :: blocked before merge. :: none
  • reviewed 2026-09-28T13:49:30.546Z sha 958e43f :: blocked before merge. :: none
  • reviewed 2026-09-29T02:33:38.468Z sha 958e43f :: blocked before merge. :: [P3] Record the new worker test's measured cost
  • reviewed 2026-09-29T04:08:43.666Z sha 068615f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-29T04:56:08.323Z sha acf71ae :: blocked before merge. :: none
  • reviewed 2026-09-29T05:37:20.887Z sha 9480e0e :: blocked before merge. :: none
  • reviewed 2026-09-29T06:45:34.513Z sha e87be53 :: blocked before merge. :: none

@steipete
steipete marked this pull request as draft September 28, 2026 13:41
@steipete
steipete changed the base branch from main to codex/native-run-cancellation-20260927 September 28, 2026 13:41
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Sep 28, 2026
Base automatically changed from codex/native-run-cancellation-20260927 to main September 29, 2026 02:25
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 29, 2026
Move requester transitions and quiet settlement through the existing SQLite worker transaction and registry publication owner. Retain committed receipts and reconcile current canonical rows and queue intents without repeating writes or transport.

Keep unreadable native commit receipts classified as committed while preserving the same source-and-row restoration fence. Carry original source and wake authority through timers, retries, and acknowledgement.

Refresh storage-mocked retirement fixtures and join the collector's actual terminal persistence before observing its detached completion. Preserve outcome and timing assertions.

Validation: canonical receiving 365 cases, requester/lifecycle 39, public sessions.create/recovery/describe, 61 receipt/fence siblings, zero all-eight host SQLite APIs in the registered wake windows, full selected static checks and fresh independent review.
@steipete
steipete force-pushed the codex/requester-wake-worker-main-20260928 branch from 958e43f to 068615f Compare September 29, 2026 03:52
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Sep 29, 2026
@steipete
steipete marked this pull request as ready for review September 29, 2026 03:55
Compose requester settlement with canonical main 7972c35. Its asynchronous
session-currentness check can finish MCP retirement after the registry
fixture's last notification. Join the existing finite cleanup work before
checking the unchanged cache predicate; retain the original timeout.

The exact CI group reproduces the timeout while the cache is already empty.
With the fixture correction, all 48 files pass (804 tests, 4 platform skips).
Requester receiving also passes 370 worker/registry/lifecycle cases, 39 E2E
cases and the public Gateway recovery capsule. Both observed wake windows
retain zero calls across all eight host SQLite APIs.
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 29, 2026
Keep already-stale transition callbacks as no-ops while current unpublished
work still fails and retains its existing receipt obligation. Restrict the
whole-wave omitted-member check to outcome settlement; quiet wake mutations
preserve the existing selected-member decision under exact row and source
admission.

Join actual initial transition acknowledgements before forcing restart in
the recovery fixture. Its outstanding transport and original assertions stay
unchanged. Extend the atomic outcome table to reject an omitted live sibling
without changing either durable or published rows.

Proof: the original six failures reproduce; the corrected recovery/worker
pair passes 63 tests, the original CI selector group passes 295 with three
platform skips, and eight registered receipt/replacement/quiet cases pass.
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer disposition on the terminal-receipt lifetime question: this PR preserves the existing queue owner's retention contract. If publication remains unresolved until the completed intent has been pruned, settlement deliberately refuses and the wake may remain pending. That limitation is accepted for this bounded worker-transfer change and is documented; it is not a claim of successful recovery. Missing proof must not be converted into delivery success, a replacement intent, repeated transport, or a replayed committed write.

Keeping completion facts beyond the existing retention window would be a separate durability/retention change with its own owner and upgrade proof. It is not an implicit prerequisite or an unapproved new policy in this PR. The real-worker tests cover matching pending and completed intents, and refusal for replaced or absent intents.

Current head a41dc8a also composes the main refactor while preserving exact-entry custody and the canonical row reader. Receiving proof passed 77 owner cases, eight registered requester cases, owning types/lint/ratchets, and fresh full-scope independent review. CI 36533084528 is still pending and is not being represented as passing.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 29, 2026
@steipete
steipete merged commit 10e951e into main Sep 29, 2026
233 of 234 checks passed
@steipete
steipete deleted the codex/requester-wake-worker-main-20260928 branch September 29, 2026 07:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…penclaw#160472)

* fix: preserve requester wakes after settlement publication failures

Move requester transitions and quiet settlement through the existing SQLite worker transaction and registry publication owner. Retain committed receipts and reconcile current canonical rows and queue intents without repeating writes or transport.

Keep unreadable native commit receipts classified as committed while preserving the same source-and-row restoration fence. Carry original source and wake authority through timers, retries, and acknowledgement.

Refresh storage-mocked retirement fixtures and join the collector's actual terminal persistence before observing its detached completion. Preserve outcome and timing assertions.

Validation: canonical receiving 365 cases, requester/lifecycle 39, public sessions.create/recovery/describe, 61 receipt/fence siblings, zero all-eight host SQLite APIs in the registered wake windows, full selected static checks and fresh independent review.

* fix(agents): preserve stale and partial requester wake decisions

Keep already-stale transition callbacks as no-ops while current unpublished
work still fails and retains its existing receipt obligation. Restrict the
whole-wave omitted-member check to outcome settlement; quiet wake mutations
preserve the existing selected-member decision under exact row and source
admission.

Join actual initial transition acknowledgements before forcing restart in
the recovery fixture. Its outstanding transport and original assertions stay
unchanged. Extend the atomic outcome table to reject an omitted live sibling
without changing either durable or published rows.

Proof: the original six failures reproduce; the corrected recovery/worker
pair passes 63 tests, the original CI selector group passes 295 with three
platform skips, and eight registered receipt/replacement/quiet cases pass.

* fix: resume requester wakes after persisted retries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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