Repository navigation
fix: preserve subagent results under each requester turn - #200873
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Merged via squash.
|
…0873) * fix: keep subagent results owed under their requester authority * test: keep restored notices pending until requester admission * fix: retry unavailable settle wakes only before execution * refactor: keep retained completion admission in the registry owner
… path or operator authority (#200760) ## Problem Finished subagent results were dropped by identity checks that run after the work is done: - **Store-path veto.** Each result recorded the requester's session store path at spawn. If the path resolved differently later (for example after a config reload republished the resolver), the result was suspended as "store replaced" and never delivered. Delivery never used that path: it finds the requester by agent and session key. - **Operator-authority refusals.** A settle turn refused to run when a child's retained operator custody was missing or revoked. The parent then saw "authority is no longer active" and the result was lost. Previous fixes exempted one case at a time. ## Fix Delete both refusal classes. A finished result is delivered to the requester chat by `(requesterAgentId, requesterSessionKey)`. - Removed the store-path comparison as a delivery veto: settle-wake `isStoreCurrent` / `retireReplacedStore`, the store branch in `isSubagentCompletionDeliveryAllowed`, `suspendReplacedStoreNotifications` and its store-owner registration, the post-announce store block, and the `storeReplaced` plumbing through the completion mutation kernel and receipt admission. - Removed `requiredCompletionEntries` and the authority throws. #200873 already splits settle batches by retained operator turn; within a batch, `runWithSubagentCompletionBatchAuthority` now runs under retained custody only when every member has the same live source and permission ceiling, and otherwise at the System write-only baseline, which settle turns already use after every Gateway restart. It never borrows a sibling's permissions. - Kept: explicit stop/cancel, requester deletion, cancellation-notice callers, and the temporary access-policy outage retry. ## User impact Subagent results no longer disappear after config edits or Gateway restarts. A continuation turn that lost its original operator custody runs at the baseline permission instead of being dropped; this already happens after every restart. ## Accepted tradeoffs (maintainer decision) - **Revoked requester.** If the operator who spawned a child loses access before the child finishes, the result still wakes the requester session, at the System write-only baseline. It is no longer dropped. Gateway admission still checks the requester session. - **Different physical store, same session key.** If `session.store` is changed to a different database that has its own session with the same key, a pending result from the old store is delivered to that session. This reverses the automatic suspension from #152828. Delivery has no stored identity that separates a moved store from an unrelated one; adding one is a schema change and is out of scope here. ## Evidence - Regression in `subagent-registry.requester-delivery.test.ts`, red on the merge base (zero settle turns) and green with the fix: a finished child with a mismatched recorded `requesterStorePath` and a live requester is delivered through the real in-process dispatcher. - `subagent-control.publication.test.ts` now asserts that a revoked owner's result is delivered at the baseline. - Affected registry, announce, completion, sweep-settle and restart-custody suites pass after rebasing on #200873 (189 tests across 8 files). - `test/gateway-subagent-completion-restart.e2e.test.ts` (real Gateway restart): 8 of 9 cases pass. `announcing-crash` fails identically on the merge base when run alone; #200873 documents the same pre-existing failure. - Full build and packed install smoke pass. - Production: 46 lines added, 271 removed; tests: net -439 lines. Known follow-ups, not changed here: a deleted requester can leave an owed wake retrying (pre-existing); `ensureSubagentControllerOwnsRun` still compares the recorded store path for kill/steer control.
…delegate before the sweeper Upstream openclaw#200807/openclaw#200873 fail a child the earlier Gateway process left running from the sweeper, and send its requester that failure once the root's resume re-admits completion custody. The fork settles an ownerless continuation delegate at registry activation instead, with no notice: the root's resume input (or the user, after a crash) reconciles. 🌊 kept that precedence on the condition of a restart test that proves the ordering and that the requester receives no second outcome. The case runs the real sequence on one state directory: graceful shutdown, a new lifecycle's activation, `resumeMarkedSessions` with a Gateway context that can re-admit custody, then sweeps. Both children were created before this process started and are owed to the requester: - right after activation the delegate already carries the fork's interruption receipt; a sweep at that point fails nothing, because retired custody still owes the plain child's notice; - after the root's resume and a sweep, the plain child (the live control) is failed with upstream's message and announced; - the delegate keeps the activation receipt, upstream's settle never logs it, no announce or wake names it, and the requester's only input is the root's one resume input. Negative controls (temporary edit, restored byte-exact): with the activation settle removed the case is red at the post-activation receipt (`expected { status: 'running' } to match { status: 'terminal' }`); with that assertion also lifted it is red at the delegate's receipt, and the run shows upstream's sweeper failing the delegate with its own message, logging "Settling subagent interrupted by Gateway restart" and announcing it: the second outcome this pin forbids. No production change. The narrow guard is unchanged. Refs: openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… path or operator authority (openclaw#200760) ## Problem Finished subagent results were dropped by identity checks that run after the work is done: - **Store-path veto.** Each result recorded the requester's session store path at spawn. If the path resolved differently later (for example after a config reload republished the resolver), the result was suspended as "store replaced" and never delivered. Delivery never used that path: it finds the requester by agent and session key. - **Operator-authority refusals.** A settle turn refused to run when a child's retained operator custody was missing or revoked. The parent then saw "authority is no longer active" and the result was lost. Previous fixes exempted one case at a time. ## Fix Delete both refusal classes. A finished result is delivered to the requester chat by `(requesterAgentId, requesterSessionKey)`. - Removed the store-path comparison as a delivery veto: settle-wake `isStoreCurrent` / `retireReplacedStore`, the store branch in `isSubagentCompletionDeliveryAllowed`, `suspendReplacedStoreNotifications` and its store-owner registration, the post-announce store block, and the `storeReplaced` plumbing through the completion mutation kernel and receipt admission. - Removed `requiredCompletionEntries` and the authority throws. openclaw#200873 already splits settle batches by retained operator turn; within a batch, `runWithSubagentCompletionBatchAuthority` now runs under retained custody only when every member has the same live source and permission ceiling, and otherwise at the System write-only baseline, which settle turns already use after every Gateway restart. It never borrows a sibling's permissions. - Kept: explicit stop/cancel, requester deletion, cancellation-notice callers, and the temporary access-policy outage retry. ## User impact Subagent results no longer disappear after config edits or Gateway restarts. A continuation turn that lost its original operator custody runs at the baseline permission instead of being dropped; this already happens after every restart. ## Accepted tradeoffs (maintainer decision) - **Revoked requester.** If the operator who spawned a child loses access before the child finishes, the result still wakes the requester session, at the System write-only baseline. It is no longer dropped. Gateway admission still checks the requester session. - **Different physical store, same session key.** If `session.store` is changed to a different database that has its own session with the same key, a pending result from the old store is delivered to that session. This reverses the automatic suspension from openclaw#152828. Delivery has no stored identity that separates a moved store from an unrelated one; adding one is a schema change and is out of scope here. ## Evidence - Regression in `subagent-registry.requester-delivery.test.ts`, red on the merge base (zero settle turns) and green with the fix: a finished child with a mismatched recorded `requesterStorePath` and a live requester is delivered through the real in-process dispatcher. - `subagent-control.publication.test.ts` now asserts that a revoked owner's result is delivered at the baseline. - Affected registry, announce, completion, sweep-settle and restart-custody suites pass after rebasing on openclaw#200873 (189 tests across 8 files). - `test/gateway-subagent-completion-restart.e2e.test.ts` (real Gateway restart): 8 of 9 cases pass. `announcing-crash` fails identically on the merge base when run alone; openclaw#200873 documents the same pre-existing failure. - Full build and packed install smoke pass. - Production: 46 lines added, 271 removed; tests: net -439 lines. Known follow-ups, not changed here: a deleted requester can leave an owed wake retrying (pre-existing); `ensureSubagentControllerOwnsRun` still compares the recorded store path for kill/steer control.
… H1 custody against the sweeper (O3) 🌊's O3 ruling pins, carried to the pure candidate (stage 2): upstream's restart sweeper settle (openclaw#200807/openclaw#200873) arrives with the 41bdde2 merge, and the fork's activation settle (subagent-registry-restart-custody.ts) is the same code here, so the precedence is kept only with its restart test. - 0019d35 (verbatim): activation settles an earlier process's delegate before the sweeper, and its requester gets no second outcome; a plain sibling is the live-sweeper control. - decc47c: the T3d H1 rows, inserted without the staging-only T3b/T3c chain pins that preceded them there. On this tree: the new restart case passes; with the activation settle call removed it is red at the post-activation receipt (expected terminal, got running). The H1 file is 24/24 solo twice; T9/T9b showed the documented 1-of-2 load-timing flake in one paired run and were green on the rerun. Cases 1 and 3 of the restart-custody file stay red on the separate upstream openclaw#201544 shutdown-outcome change, held for 🌊's ruling. (cherry picked from commit 0019d35) (cherry picked from commit decc47c) Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fix: keep subagent results owed under their requester authority * test: keep restored notices pending until requester admission * fix: retry unavailable settle wakes only before execution * refactor: keep retained completion admission in the registry owner (cherry picked from commit f444d3b) Release adaptation: port only requester-turn batch selection and safe uncommitted retry, the prerequisite consumed by #200760. Retain baseline absent restart-interrupted sweep and its unrelated recovery tests; do not resurrect that separate behavior. Follow-up: #200760 selected next replaces strict batch admission with System-baseline delivery. Bounded companion audit requested; no later #200873 mentions through pinned main besides #200760. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 21b77b640fa48258014c1513f907e3aec0c81557)
… path or operator authority (#200760) Finished subagent results were dropped by identity checks that run after the work is done: - **Store-path veto.** Each result recorded the requester's session store path at spawn. If the path resolved differently later (for example after a config reload republished the resolver), the result was suspended as "store replaced" and never delivered. Delivery never used that path: it finds the requester by agent and session key. - **Operator-authority refusals.** A settle turn refused to run when a child's retained operator custody was missing or revoked. The parent then saw "authority is no longer active" and the result was lost. Previous fixes exempted one case at a time. Delete both refusal classes. A finished result is delivered to the requester chat by `(requesterAgentId, requesterSessionKey)`. - Removed the store-path comparison as a delivery veto: settle-wake `isStoreCurrent` / `retireReplacedStore`, the store branch in `isSubagentCompletionDeliveryAllowed`, `suspendReplacedStoreNotifications` and its store-owner registration, the post-announce store block, and the `storeReplaced` plumbing through the completion mutation kernel and receipt admission. - Removed `requiredCompletionEntries` and the authority throws. #200873 already splits settle batches by retained operator turn; within a batch, `runWithSubagentCompletionBatchAuthority` now runs under retained custody only when every member has the same live source and permission ceiling, and otherwise at the System write-only baseline, which settle turns already use after every Gateway restart. It never borrows a sibling's permissions. - Kept: explicit stop/cancel, requester deletion, cancellation-notice callers, and the temporary access-policy outage retry. Subagent results no longer disappear after config edits or Gateway restarts. A continuation turn that lost its original operator custody runs at the baseline permission instead of being dropped; this already happens after every restart. - **Revoked requester.** If the operator who spawned a child loses access before the child finishes, the result still wakes the requester session, at the System write-only baseline. It is no longer dropped. Gateway admission still checks the requester session. - **Different physical store, same session key.** If `session.store` is changed to a different database that has its own session with the same key, a pending result from the old store is delivered to that session. This reverses the automatic suspension from #152828. Delivery has no stored identity that separates a moved store from an unrelated one; adding one is a schema change and is out of scope here. - Regression in `subagent-registry.requester-delivery.test.ts`, red on the merge base (zero settle turns) and green with the fix: a finished child with a mismatched recorded `requesterStorePath` and a live requester is delivered through the real in-process dispatcher. - `subagent-control.publication.test.ts` now asserts that a revoked owner's result is delivered at the baseline. - Affected registry, announce, completion, sweep-settle and restart-custody suites pass after rebasing on #200873 (189 tests across 8 files). - `test/gateway-subagent-completion-restart.e2e.test.ts` (real Gateway restart): 8 of 9 cases pass. `announcing-crash` fails identically on the merge base when run alone; #200873 documents the same pre-existing failure. - Full build and packed install smoke pass. - Production: 46 lines added, 271 removed; tests: net -439 lines. Known follow-ups, not changed here: a deleted requester can leave an owed wake retrying (pre-existing); `ensureSubagentControllerOwnsRun` still compares the recorded store path for kill/steer control. (cherry picked from commit 714129c) Release adaptation: retain baseline deleted session identity allowlist and omit incoming unrelated restored-running-child test since baseline has no restart-interrupted sweep owner. Requester batch dependency #200873 selected immediately before. Follow-up: no later #200760 mention through pinned main; store kill/steer authority checks remain intentionally unchanged. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit d361b6ff3c0a18a6a3f4431c67ddf2f0129c352b)
* fix: keep subagent results owed under their requester authority * test: keep restored notices pending until requester admission * fix: retry unavailable settle wakes only before execution * refactor: keep retained completion admission in the registry owner (cherry picked from commit f444d3b) Co-authored-by: RomneyDa <[email protected]>
…licy subagent-registry-lifecycle-wake.rejection-write is green at the pure candidate bc7e568 and red from the stage-2 merge ddd0ec7, on Bun and Node 24: "subagentRuns.selectCompletionAuthorityBatch is not a function" at subagent-registry-lifecycle-wake.ts:352. Upstream openclaw#201563 (5724f95) admits the requester wake's batch through that registry method, which upstream openclaw#200873 (f444d3b) added. The test replaces the process-wide subagentRuns with { confirmRetirement } only, so the wake threw before it reached settlement. The fixture's subagentRuns now delegates selectCompletionAuthorityBatch to the real policy with no completion custody, which is what this row holds. That admits the single-member batch, as the real registry does here. The product behavior the test pins is unchanged: the failed wake still records its rejection through settlement with outcome { delivered: false, path: "none" }. A probe that admits an empty batch turns it red ("expected vi.fn() to be called 1 times, but got 0 times"). Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…0873) * fix: keep subagent results owed under their requester authority * test: keep restored notices pending until requester admission * fix: retry unavailable settle wakes only before execution * refactor: keep retained completion admission in the registry owner Release adaptation: Split reviewed partition cluster: existing authority owner selects source/scopes/canonical Gateway/retirement; memory index extraction unchanged. Wake caller selection prepared with lifecycle selection. (cherry picked from commit f444d3b) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Successful subagent results could disappear when children from separate requester turns finished together. A sandbox preparation failure or a restart-interrupted child's terminal notice could also retire an owed result without telling the requester.
User Impact
Each requester receives its results under the authority of the turn that spawned them. Uncommitted preparation failures remain retryable, and children stopped by a Gateway restart deliver their interruption notice after fresh requester admission. No configuration, schema, or protocol changes are required.
Why This Change Was Made
The registry remains the single custody owner. Settle-wave selection now partitions both frozen and unfrozen cohorts by the retained source, invocation, and scopes before dispatch (
subagent-announce.requester-settle-wake.ts:164–180). The original authority comparisons are unchanged and moved into the registry's sibling policy module to keep the existing 700-line module limit. The retained-custody check remains in the registry owner and is invoked at the same point; the identity allowlist is unchanged. Each group preserves FIFO order and cannot borrow a sibling's authority.The delivery classifier previously treated sandbox provisioning and non-retryable-tagged
UNAVAILABLEerrors as permanent failures (subagent-announce-delivery-retry.ts:165–178). Typed sandbox failures are retryable for requester settlement; genericUNAVAILABLEretries require the existing pre-execution replay-safe fact. Failures after tool effects or sends retain their original no-replay outcome. Send evidence, permanent authorization failures, real Stop handling, and committed-input no-replay remain intact.Restart settlement previously required retired completion custody, then attempted the terminal notice through the guard that correctly rejects that custody. It now waits for the existing startup custody owner to admit the requester afresh before settling an old, non-live, non-queued execution (
subagent-registry-sweep-settle.ts:149–174). The retired-store guard is unchanged.Evidence
On base
c97a173b040bce3a3553911a1be0f971e853e724, the authority/preparation regressions report 4 failed: both frozen/unfrozen batches throwSubagent completion batch has incompatible operator authority, and both typed preparation errors returnpermanent_failure. The native SQLite startup/sweep regression separately reports 1 failed because the requester receives no interrupted-child notice. With the fix, all five regressions pass; the complete focused authority/dispatch/restart suites report 116 passed.Core typecheck, all 29 affected test-type shards, the final owning typecheck leaves, production/test lint, formatting, line-cap ratchet, and
pnpm buildpassed. Independent Codex autoreview is scoped-clean through P2. The full subagent sibling run reported 2,209 passed, 1 failed, 1 skipped; its sole stale expectation required immediate terminal settlement under retired custody. That expectation is corrected to require the child and notice to remain owed before fresh admission; the complete affected store-replacement suite then reports 23 passed. CI caught an overly broadUNAVAILABLEcondition after tool effects or sends. Narrowing it to pre-execution failures preserves the existing real-Gateway side-effect boundary; the complete transcript-conflict suite and requester-dispatch suite pass together. CI also caught the relocated authority refusal in the identity ratchet. Keeping its custody check in the registry owner passes that ratchet without an allowlist change; the affected authority/dispatch suites report 106 passed, and a fresh independent Codex review is scoped-clean through P2. The plugin-reload continuation case also reported a CI startup timeout; all three continuations passed locally through the original product entry. CI on the updated head supplies broad proof.The test budget for this repair is raised from zero to exactly +134 net test lines: real retained-invocation dispatch in frozen/unfrozen cohorts, two preparation-error representations in the existing retry table, and the native SQLite custody/sweep receiver proof. The old metadata-only queued-collector fixture is consolidated into the existing scheduler-owner integration test, which now proves a stale queued collector survives a sweep before its real reservation is withdrawn. No extra Gateway boot is added. Production growth is bounded to authority selection and the unchanged admission-policy extraction.
The existing
(announcing)and(announcing-crash)restart e2e cases are intentionally out of scope here. Both reproduce red on the base above: 2 failed, 8 skipped, usingpnpm test test/gateway-subagent-completion-restart.e2e.test.ts --maxWorkers=1 -t 'restart \(announcing(-crash)?\)'. The graceful case expectspendingwhere delivered-on-commit semantics recorddelivered; the crash case encountersInput completion retry conflicts with the committed inputand missesHUB_RECEIVED_RESTART_COMPLETION. They need Gateway-owned continuation from committed input, a separate follow-up; this PR preserves delivered-on-commit semantics and does not replay consumed completion input. The same two failures reproduce on this PR head4aabf5c9a1439e97e5bc7501ad31e7bef2185083: 2 failed, 8 skipped (80.85s Vitest; 190.76s including runtime preparation). Related: #200823, #200807, #200249.