Skip to content

fix: settle yielded child notices after a sibling resumes - #200581

Merged
steipete merged 1 commit into
mainfrom
codex/settle-wake-terminal-rejection
Nov 17, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/settle-wake-terminal-rejection

Conversation

@steipete

@steipete steipete commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A yielded child's pause notice can become stuck after a sibling resumes: delivery settlement rejects the changed batch membership, then the attempt to persist that rejection fails against the same snapshot. The wake remains armed and repeats the warning pair indefinitely.

The motivating incident began on November 16 at 18:12 PST on release a117ca50: roughly four warning lines per minute, 2,934 lines by 04:05 the next morning, and persistence across a Gateway restart. One requester had yielded batches of 35 and eight children; 25 of 56 recorded runs still had pending delivery. A representative child was terminal without an outcome, paused by sessions_yield, with a dispatching pause notice at attempt one and rearm generation one.

User Impact

A still-valid pause notice can finish its delivery bookkeeping exactly once when a sibling resumes. Its child's eventual final result remains owed, and another batch for the same requester can settle. No configuration, schema, timer, cache, or Doctor repair is added.

Why This Change Was Made

The reproduced first cause is src/agents/subagents/registry/subagent-registry-run-recovery.ts:466: adoption replaces a yielded sibling's run ID in requesterSettleWake.batchRunIds, including on other batch members (publication at line 558). An in-flight, child-only pause notice retains the old array. The full-array comparison in subagent-completion-admission.store.ts:575 on the base incorrectly treats that legitimate remap as loss of the paused child's settlement ownership. Lifecycle fallback then retries the same retained settlement at subagent-registry-lifecycle-wake.ts:633, so rejection itself cannot commit.

The existing completion store remains the sole settlement owner. Only settlement of the same yielded pause notice ignores full-cohort membership changes. Child/requester identity, runtime ownership, rearm generation, exact notice content, delivery generation, cancellation, and final-delivery policy checks remain. The mutation consumes the one-shot notice against the current row and preserves the updated cohort for final results; it preserves the actual observed delivery outcome instead of replacing success with a rejection.

Periodic re-entry is subagent-registry-sweeper.ts:300 → resumeRequesterSettleWake → scheduleRequesterSettleWake; retained settlements are also resumed at sweep completion. The periodic timer is 60 seconds (runTick, line 200), with additional lifecycle triggers. The reported four lines/minute does not establish a dedicated 30-second retry timer.

Related: #195275 addresses requester-run turnover and #194732 addresses independently resumed children/obsolete invocation authority. Their inspected heads (2d21efe629cd28f05ca36a2ccdd46aa8cfc2ac92 and a0abf6c69f9dbc9c2d3f22fab2c27ebb61be30d5) retain a byte-identical currentRequesterEntries guard and the membership remapping, so neither repairs this rejection loop. This change does not touch #195275's changed files. #170562 remains the Doctor recovery work. The older #161883 and #148076 were closed as duplicates, not as proof that every changed-source rejection was fixed; #137344 and the later changed-owner fix in #186443 established the existing terminal bookkeeping path.

The test establishes this exact field mismatch and failure class. The structural incident records alone cannot identify which guard failed in that historical process. Already-dispatching notices with this same child owner, generation and notice can settle on their next evaluation; this is not a claim that all historical stranded rows self-heal after deployment.

Evidence

Two regression cases exercise actual sibling replacement, lifecycle evaluation/sweeps, and SQLite commits, with delivered and refused notice outcomes. On base 3447bee3a310a3c69d1252dde8545f7db629c5a8, both fail after three repeated pairs of requester settle wake failed / failed to persist requester settle wake rejection, with Subagent requester wake owner changed before settlement. With the fix, both pass, consume the notice durably, dispatch it once, retain final-result obligations and permit a later independent batch to become delivered.

  • Regression: pnpm test src/agents/subagents/registry/subagent-registry-lifecycle-wake.source-change.test.ts --maxWorkers=1 — base: 2 failed; fix: 2 passed. Final standalone green run: 52.67 s wall, 1.61 s test bodies; cold worker compilation took 36.93 s. CI: 2 passed, 8.70 s shard wall / 1.412 s test bodies (checks-node-changed-2).
  • Focused regression and existing requester wake/receipt/retry suites: 3 files, 61 tests passed; 141.53 s wall. Existing cases cover cancellation ownership, retired/rearmed waves, known delivered outcomes, SQLite reopen, rejected writes and no redelivery.
  • Core typecheck and targeted agents-sessions test typecheck passed.
  • Targeted lint and format passed. Codex autoreview of the complete local candidate against the pinned base was scoped-clean through P2, with no accepted findings. The subsequent test-only lint correction removes an unused scoped-spy binding; no production logic changed after review.
  • Net test growth: 116 lines, two cases; production growth: seven lines. The growth names the existing child-only settlement invariant and adds boundary proof without new machinery.
  • No worker or lazy-import boundary changes; a build is not required. No production Gateway or live state was modified. CI run 44083518625 completed successfully, including the existing requester-wake E2E suite. GitHub merged the reviewed head as eea1d5a7ff8923449fd44900811365ac0aa1a6d4; no CI rerun or failure exception was needed.

A resumed sibling remaps requesterSettleWake.batchRunIds without replacing another yielded child\u0027s pause notice. Settle that same child-only notice against the current row while preserving its final-result cohort and existing identity and cancellation checks.
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling labels Nov 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T12:31:09.148269Z c6eb620 PR opened
ℹ️ 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 Nov 17, 2026
@steipete
steipete enabled auto-merge (squash) November 17, 2026 12:40
@steipete
steipete merged commit eea1d5a into main Nov 17, 2026
119 of 121 checks passed
@steipete
steipete deleted the codex/settle-wake-terminal-rejection branch November 17, 2026 12:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
)

A sibling resume legitimately remaps requesterSettleWake.batchRunIds while another yielded child's one-shot pause notice is being delivered. Full-cohort equality incorrectly rejects that child's settlement, and the retained rejection then fails against the same snapshot on every sweep.

Let the existing completion store settle the same child's pause notice against the current row despite changed sibling membership. Preserve runtime/requester identity, generation, notice content, delivery policy and cancellation checks, along with the observed delivery outcome and the cohort's future final-result obligation.

Two real lifecycle/SQLite regression cases fail with the repeated warning pair on the base and pass with the fix, including no duplicate dispatch and delivery of a later independent requester batch. All 61 focused tests, targeted typechecks, lint, format and Codex autoreview passed. No Doctor repair or schema change is included. Related: openclaw#195275, openclaw#194732, openclaw#170562.
RomneyDa added a commit that referenced this pull request Nov 19, 2026
A sibling resume legitimately remaps requesterSettleWake.batchRunIds while another yielded child's one-shot pause notice is being delivered. Full-cohort equality incorrectly rejects that child's settlement, and the retained rejection then fails against the same snapshot on every sweep.

Let the existing completion store settle the same child's pause notice against the current row despite changed sibling membership. Preserve runtime/requester identity, generation, notice content, delivery policy and cancellation checks, along with the observed delivery outcome and the cohort's future final-result obligation.

Two real lifecycle/SQLite regression cases fail with the repeated warning pair on the base and pass with the fix, including no duplicate dispatch and delivery of a later independent requester batch. All 61 focused tests, targeted typechecks, lint, format and Codex autoreview passed. No Doctor repair or schema change is included. Related: #195275, #194732, #170562.

(cherry picked from commit eea1d5a)

Companion audit: #200649 selected next; pause-notice settlement retains generation and exact notice matching.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c0824317fd65c47fb05a44d630712553219acd44)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…es, steer races and expiry (#200649)

## What Problem This Solves

A finished subagent's result could be lost even though the child did its work. Three paths dropped it on current `main`:

- **Access-policy outage:** a temporary "Gateway access policy is unavailable; retry the operation." during requester settlement was recorded as a permanent delivery failure. The parent never received the result, even after the policy recovered.
- **Steer race:** when a busy parent accepted the child's result by steering, and the delivery owner changed afterward, the run was recorded as intentional non-delivery. The parent had the result, but the record said it didn't. The run could later "expire" and send a misleading failure.
- **Expiry:** a suspended required completion was discarded after seven days with no notice in the requester conversation. Only an operator log line recorded it.

On one Gateway, the access-policy class alone accounted for 25 failed child results in a week.

## User Impact

A temporary access-policy outage now only delays a child's result; it is delivered after the policy returns. A result steered into a busy parent is recorded as delivered. A required result that finally expires records the existing visible failure notice ("The child result couldn't be delivered to this conversation…") instead of disappearing silently.

## Why This Change Was Made

Each fix is at the existing owner:

- **Settle wake:** a policy-unavailable error now joins the existing "no delivery was admitted, retry" class, alongside database-busy and overloaded errors, instead of the permanent-failure path.
- **Direct delivery:** an accepted, committed steer returns `delivered` before the delivery-owner check. Only an unconfirmed commit still depends on its owner.
- **Seven-day discard:** this path now calls the same failure-notice writer that other permanent failures already use (#198807).

Explicit stop, cancellation, requester deletion and real revocation are unchanged.

## Evidence

- **Regressions** drive the real lifecycle, announce, completion and SQLite owners: `subagent-result-owed.{policy-outage,expiry-discard}.test.ts`, plus the updated `steering $outcome after $change` direct-delivery contract (accepted-steer rows fail on base). Each fails on the base commit and passes with the fix:
  - policy outage: recorded `failed` before, owed and then delivered after;
  - steer race: receipt not delivered before, `{delivered: true, path: "steered"}` after;
  - expiry: no notice before, exactly one visible notice after.
- **Existing suites:** announce, settle, lifecycle, completion authority, store-replaced, steer-restart and yielded-run settlement all pass, 500+ tests. The `steering $outcome after $change` contract was updated: an accepted steer is now delivered after an owner change, and indeterminate steers keep the old outcome.
- **End to end (source tier, `ocx src`):** an isolated Gateway with a stub model. A busy parent received its finished child's result through a steer into the same run, and `subagent_runs` recorded `delivered/delivered`.
- **Not in this PR:** splitting settle batches that mix operator invocations (a separate fix with its own proof), and the session-store-switch suspension policy (#152828, unchanged).

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 3b61a7c)

Companion audit: #200581 included; existing authority outage classifier and completion failure owner are present.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit eadbf05817ce8aa5dc0c0e8daf8594486dc7e581)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant