Skip to content

fix(subagents): stop requester wakes retrying changed owners - #186443

Merged
steipete merged 4 commits into
mainfrom
codex/settle-wake-owner-changed-loop
Oct 28, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/settle-wake-owner-changed-loop

Conversation

@steipete

@steipete steipete commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes requester subagent completions retrying forever when cleanup or recovery changes the child's completion owner between wake admission and settlement.

User Impact

An already delivered result can finish its bookkeeping after child cleanup. A wake refused before dispatch records failed delivery and attempts one deduplicated notice in the requester transcript. Distinct ordinary failed waves receive distinct notices; retries and batched delivery retain their shared notice identity. Retained wakes converge on their next evaluation without manual database edits or a migration.

If the requester transcript is unavailable, the notice failure is logged and settlement still finishes. Notice append and settlement are deliberately separate: a crash between them may leave a failure notice followed by a later successful delivery.

Why This Change Was Made

Dispatch and terminal bookkeeping previously shared the child's strict execution-custody check. After custody changed, both the original write and its failure settlement rejected the same captured row; retained callbacks and the durable wake kept the loop alive.

Terminal bookkeeping now resolves the current row while preserving the run, requester, cancellation ownership, delivery generation, wake generation, frozen cohort, pause notice, and delivery policy. Dispatch keeps strict authority checks. Quiet completion also checks observed progress, and stale quiet decisions release their pending receipt instead of consuming newer work. Permanent owner rejection no longer retains a dispatch replay. If settlement commits but publication fails, its retained receipt reconciles through the existing transaction owner against acknowledged postimages, instead of comparing against the obsolete pre-turnover child snapshot.

The change reuses the existing settlement, cancellation comparison, transcript idempotency, and persisted wake owners. There is no new state store, schema, configuration, or retry mechanism. Production code grows by 95 lines for the explicit settlement boundary and failure notice; test lines stay flat, replacing obsolete custody-rejection assertions with behavior proof. The lifecycle owner remains at its existing 700-line cap.

Evidence

  • Two lifecycle-turnover regressions failed against base 7c0f75ece787e7be7248ea712b9c1df3aacfa814, reproducing both the wake failure and the repeated failure-settlement rejection. They pass with the fix, including database reopen, a second sweep, and no duplicate dispatch.
  • The two-wave notice regression failed on the previous published head: two distinct rejected waves produced only one notice. It passes with the corrected notice identity, checking one notice per wave across reopen/sweep.
  • Final suites after receipt reconciliation: 40 requester admission, 13 expiry-receipt, 231 lifecycle, and 39 isolated requester-wake product-flow tests passed. The three-shard command took 329.90 s, including a 191 s isolated runtime build; Vitest phases took 36.23 s for admission/expiry, 16.19 s for lifecycle, and 63.56 s for product flow. Product-flow tests use synthetic model/delivery fixtures; no production Gateway or external model was used.
  • Core and agents/session test typechecks, targeted lint/format, changed-source line-cap ratchet, one-page MDX validation, and git diff --check passed.
  • A further hosted finding reproduced in both existing committed-publication cases after adding child lifecycle turnover: 2 failed, 38 skipped on the preceding head, then 2 passed, 38 skipped after repair. The four-line test enhancement keeps net test-line growth at zero.
  • Independent Codex autoreview of the final staged candidate, including committed-receipt reconciliation, against the base above: P1 scope, complete, no actionable findings. An earlier quiet-progress finding was fixed and covered before this review.

The first CI run caught two expiry-receipt regressions: accepting an old receipt after cancellation or a delivery-generation change. Both reproduced locally and were fixed by retaining the existing cancellation/generation checks; the six focused lifecycle/progress/expiry cases passed afterward. No CI rerun or baseline exception was used to hide these failures. Subsequent CI runs 40621198053 and 40624609743 passed for their respective preceding heads; the final-head CI run passed for 5d554f966a9ae857921e8df2b180820bb22e8296 (41 successful jobs, 28 skipped). Both required openclaw/ci-gate contexts passed, and the exact-head native watcher returned GREEN.

The supplied incident logs establish the repeated rejection but do not identify the exact production field that changed. The regression proves the lifecycle-turnover mechanism; deployment verification remains separate.

Separate terminal wake bookkeeping from child execution custody while retaining requester and cohort identity. Record a deduplicated failure notice for a rejected dispatch, preserve newer quiet-completion progress, and let retained wakes converge on their next evaluation.
@clawsweeper

clawsweeper Bot commented Oct 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Oct 28, 2026
@steipete
steipete marked this pull request as ready for review October 28, 2026 02:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T03:27:17.165443Z 5d554f9 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9eb12154c

ℹ️ 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".

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR lets requester wakes finish terminal bookkeeping after child ownership changes and records a notice when dispatch is rejected.

Example: Child run completion-a changes lifecycle generation after its requester wake is admitted.

  • Before: Dispatch and failure settlement both reject the captured owner, leaving the durable wake unsettled.
  • After: Terminal bookkeeping resolves the current row and clears the wake while preserving the delivery outcome.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has focused owner-level regression evidence and preserves existing storage shapes, but its persistent notice identity has a definite correctness defect.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises the lifecycle controller and SQLite with synthetic delivery and makes no live Gateway claim.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A child result can leave its requester completion retrying indefinitely after cleanup or recovery changes child execution custody.
Reason: The source-backed failure affects completion convergence, and the maintainer-authored direction preserves dispatch checks while repairing terminal bookkeeping.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this PR open: it addresses a source-backed settlement loop, but the new notice key suppresses notifications for distinct rejected completion waves.

Priority: P2
Reviewed head: d9eb12154c369c5f0366249a22ea08c773ca2e58

Before merge

  • Include the rejected run or wave in the notice key (P2) - For ordinary wakes created by markRequesterSettleWakePending, batchRunIds and rearmGeneration may both be absent. requesterSettleWakeScope then reduces to requester scope, so rejected runs completion-a and completion-b in the same requester session receive the same idempotency key. The transcript writer scans persisted keys and silently suppresses the second notice, while failure settlement still clears that run's wake. Include stable affected-run or frozen-wave identity, retaining deduplication for retries of the same rejection. This also confirms the existing discussion at fix(subagents): stop requester wakes retrying changed owners #186443 (comment).
  • Explain or restore the original intent of Requester evaluation scope - 36e277d: Serialize evaluations by requester and frozen cohort; this scheduling scope did not promise persistent notice identity.

Findings

  • [P2] Include the rejected run or wave in the notice key — src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts:675

Provenance

  • Requester evaluation scope changes intended behavior without addressing why it exists (36e277d: Serialize evaluations by requester and frozen cohort; this scheduling scope did not promise persistent notice identity.)

Tests

  • Missing end-to-end proof: The supplied lifecycle and SQLite regressions use synthetic delivery and do not demonstrate the turnover scenario through a production Gateway.
Agent review details

How this fits together

The subagent lifecycle controller evaluates durable requester wakes, dispatches parent continuations, and commits their delivery outcomes through the existing SQLite completion owner.

flowchart TD
  A[Terminal child run] --> B[Requester wake controller]
  B --> C[Strict dispatch admission]
  C --> D[Requester continuation]
  D --> E[Completion settlement]
  C --> F[Rejection notice]
  F --> E
  E --> G[SQLite registry]
Loading

Technical review

Best possible solution:

Keep the existing settlement owner and give each rejection notice a stable identity for its affected run or frozen wave.

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

Source shows both the original strict-custody settlement rejection and the introduced notice-key collision; the PR reports red-on-base lifecycle regressions, but this read-only review ran no target code.

Is this the best way to solve the issue?

Separating terminal facts from dispatch custody is appropriate and reuses existing owners; the notice needs wave-specific persistent identity rather than the broader scheduling scope.

Full review comments:

  • [P2] Include the rejected run or wave in the notice key — src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts:675
    For ordinary wakes created by markRequesterSettleWakePending, batchRunIds and rearmGeneration may both be absent. requesterSettleWakeScope then reduces to requester scope, so rejected runs completion-a and completion-b in the same requester session receive the same idempotency key. The transcript writer scans persisted keys and silently suppresses the second notice, while failure settlement still clears that run's wake. Include stable affected-run or frozen-wave identity, retaining deduplication for retries of the same rejection. This also confirms the existing discussion at fix(subagents): stop requester wakes retrying changed owners #186443 (comment).
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Requester settlement custody changes intended behavior with a stated reason (3f761a8: Ordered registry mutations reject genuine owner replacement while replanning benign concurrent changes.)
  • Interrupted cleanup settlement changes intended behavior with a stated reason (9230715: Permit retirement of the recovery marker only when cleanup receipts and the interrupted terminal outcome match.)
  • Retained requester mutation receipts keeps the original intent (10e951e: Preserve committed writes across failed acknowledgement or publication without replaying requester delivery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/subagents/completion/subagent-completion-admission.requester-wake.test.ts --maxWorkers=1
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts src/agents/subagents/completion/subagent-completion-admission.requester-wake.test.ts
  • pnpm exec oxfmt --check src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts src/agents/subagents/completion/subagent-completion-admission.requester-wake.test.ts
  • git diff --check

What I checked:

PR surface

Source +95, Tests -6, Docs +8. Total +97 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 113 18 +95
Tests 1 105 111 -6
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 226 129 +97

Labels

Label changes:

  • add P2: The repair addresses retained completion bookkeeping, with a focused introduced defect affecting rejection notices.
  • add merge-risk: 🚨 message-delivery: Distinct rejected completion waves can silently lose their requester transcript notices because they share a persistent deduplication key.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The repair addresses retained completion bookkeeping, with a focused introduced defect affecting rejection notices.
  • merge-risk: 🚨 message-delivery: Distinct rejected completion waves can silently lose their requester transcript notices because they share a persistent deduplication key.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 27, 2026, 10:45 PM ET / October 28, 2026, 02:45 UTC.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b573ee16ba

ℹ️ 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".

@steipete
steipete merged commit 6671f14 into main Oct 28, 2026
135 of 137 checks passed
@steipete
steipete deleted the codex/settle-wake-owner-changed-loop branch October 28, 2026 03:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…w#186443)

* fix(subagents): stop requester wakes retrying changed owners

Separate terminal wake bookkeeping from child execution custody while retaining requester and cohort identity. Record a deduplicated failure notice for a rejected dispatch, preserve newer quiet-completion progress, and let retained wakes converge on their next evaluation.

* fix(subagents): retain cancellation and delivery settlement ownership

* fix(subagents): distinguish rejected requester wake notices

* fix(subagents): reconcile committed requester wake receipts
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 28, 2026
… line caps

U9 brought subagent-registry-queries.ts to 698 counted lines (openclaw#186389)
and subagent-registry-lifecycle-wake.ts to 700 (openclaw#186443). The fork's
additions pushed them to 738 and 703, past the 700 cap.

- The continuation-only reads (child-run liveness for orphan reap,
  requester ancestry) move to subagent-registry-queries.continuation.ts;
  subagent-registry-read and work-dispatch-execution import them there.
- The requester-turn binding folds into upstream's existing window
  predicate as one ternary: a child bound to the requester turn
  matches by id, otherwise upstream's window applies. Bounds exist only
  for a requester run, so the result equals the fork's former filter.
- The spawn-custody guard joins upstream's owner early-return; `entry`
  is computed first and has no side effects, so behaviour is unchanged.

RED at 3178f4f: check:line-cap-ratchet, lifecycle-wake 700 -> 703,
queries 700 -> 738. GREEN: ratchet bare and --base 8ea3ef8 0 (both
files at 700); tsgo:core 0; oxlint clean; queries (incl.
requester-window, raw-owner), registry-read, run-liveness,
lifecycle-wake retry and work-dispatch suites green.

Refs karmaterminal/openclaw-bootstrap#1727
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 28, 2026
…rejection-write mock

Upstream openclaw#186443 made the requester settle wake classify
SubagentCompletionSourceChangedError and
SubagentRequesterWakeProgressChangedError in its catch path. The
fork's rejection-write suite mocked the completion-admission store
with only its two write functions, so the strict mock threw on the
missing classes inside that catch and the wake never reported
"requester settle wake failed". The mock now forwards the real module
and overrides only the two writes.

RED at e5c7bb0 (and the merge): 1/1 failed, expected warnings to
include "requester settle wake failed". GREEN: rejection-write 1/1
plus lifecycle-wake retry, 19/19.

Refs karmaterminal/openclaw-bootstrap#1727
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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant