Repository navigation
fix(subagents): avoid Gateway blocking while Stop saves state - #160203
Conversation
Move native cancellation reads and writes through the existing worker owners while retaining exact run, session, queue and source authority. Join claim publication, terminal settlement and cleanup, preserve earlier completion, and fence uncertain writes without replay. Validated registered Stop with real SQLite, public Gateway create/turn/Stop/describe, native lifecycle and scheduler controls, all changed checks, archive E2E and the full build.
Preserve current main recovery and pre-read sharing acquisition alongside native cancellation. Keep the existing generation reducer with its canonical type owner and retain public Gateway creation proof with nondestructive fixture seeding.
|
🦞👀 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: blocked before merge. Reviewed September 28, 2026, 10:15 PM ET / September 29, 2026, 02:15 UTC (Revision 18). ClawSweeper reviewWhat this changesMoves file-backed subagent Stop persistence to existing SQLite workers and holds cancellation authority and queue reservations until the writes settle. Merge readiness⛔ Blocked before merge - 2 items remain Keep open. Current main still performs synchronous persistence during subagent Stop, while this PR has a distinct, tested repair. The prior config/default upgrade concern is unsupported by the pinned diff. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway receives Stop requests for child agents and passes them to subagent control. That control updates the child run and session records, then publishes the result to the requester. flowchart LR
A[Stop request] --> B[Subagent control]
B --> C{Current run and session?}
C -->|Yes| D[SQLite worker writes]
C -->|No| E[Refused result]
D --> F[Published run and session state]
F --> G[Stop result]
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep Stop writes with the existing worker owners while preserving exact run, session, and caller checks through commit and publication. Do we have a high-confidence way to reproduce the issue? Yes, from current-main source: Stop still uses synchronous session persistence, and the branch documents a registered-tool before/after observation. I did not execute code in this read-only review. Is this the best way to solve the issue? Yes. Reusing the existing SQLite worker and retaining source, session, and caller authority is a focused repair for the blocking Stop path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 80597756d891. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (17 earlier review cycles; latest 8 shown)
|
Keep an acknowledged kill intent when session storage is unavailable, and publish the final deletion refresh without revoking unrelated session generations. Preserve keyless coalescing and join the existing lifecycle publication owners in cancellation fixtures.
Merge the fixed main snapshot while retaining native spawn depth and ACP parent/session-start facts in the same sharing projector. Receiving proof: 80 sharing, generation, registered Stop and public Gateway cases; core types and scoped typed lint pass. Independent integration review found no actionable issues. Full changed checks remain blocked by the independently reproduced main UI shard budget (721 roots, cap 720); no guard or coverage exception is added.
Take the exact landed shard repair so the native Stop branch retains all compiler roots under the unchanged budget. No native cancellation source changes. Receiving proof passes 35 routing cases, both UI type graphs, selected changed checks, and independent review. The original 721-root baseline failure remains attributed to main. (cherry picked from commit 52ae7e3)
Replace resident-only run seeding and no-op persistence with awaited canonical registration. Preserve owner, foreign-run, generation-replacement, and real ACP interrupt assertions.
Keep real controller resolution in tool tests and register the orphaned child through real session and registry persistence. Preserve all original cancellation assertions and isolate the running-child wait transport.
Update the held model fixture to recognize the batch-scoped completion prompt introduced by #158642. Preserve the two-active, third-queued, ordinary-probe, runtime-budget, and cleanup assertions. Verified on the exact native cancellation CI merge: the original four-case order reproduced three passes and the stale-marker failure, then all four passed with this single-line correction. Owning changed checks and independent review passed.
Use the exact helper postimage from d64568e (#160266). The canonical committed-size wait supersedes this branch's layout quiet-window variation while preserving every geometry assertion and viewport order. Validation: canonical Linux native-plugin E2E six cases and exact-head CI pass; helper and layout-owner source bindings verified; formatting, diff checks, and independent P0-P2 review pass. Native cancellation production is unchanged. Co-authored-by: Kimi Yu <[email protected]>
Keep protocol fixtures on their existing controlled deadline clock and measure unattended denial from the review-required hook to the actual decline. Preserve model, transport, history and approval assertions, the existing bounds, and all production clock and executable-integrity behavior. Validation: identical latency controls change four failures to four passes; the original six-file envelope passes 34 tests, with eight deadline and three no-approval-request siblings. Selected changed checks and independent P0-P2 review pass. The original Unix 120-second stall was not independently reproduced; current-head CI remains required.
Merge main at 447fb86 while preserving awaited native termination and finite root-work settlement. Keep the canonical lifecycle and collector test consolidation, carry its held and settled root assertions into the surviving native helper, and remove the redundant timing helper. The exact combined tree passes 181 receiving tests, core types, the owning agents test graph, selected guards, all dead-export scans, and typed lint. Independent review has no accepted findings after checking the pinned Vitest reset contract against source and the passing held-write case.
Take the private result-alias cleanup from b4d93d2 (#159588) without importing unrelated main changes. Keep the canonical input declaration position while preserving the native selector, request fields, and distributive prepared-input union. The emitted runtime is unchanged. Core and worker-owner test types, scoped lint, formatting, and independent review pass; the qualified native runtime proof remains applicable.
|
Merged via squash.
|
…aw#160203) * fix(subagents): await native Stop persistence Move native cancellation reads and writes through the existing worker owners while retaining exact run, session, queue and source authority. Join claim publication, terminal settlement and cleanup, preserve earlier completion, and fence uncertain writes without replay. Validated registered Stop with real SQLite, public Gateway create/turn/Stop/describe, native lifecycle and scheduler controls, all changed checks, archive E2E and the full build. * fix(subagents): preserve optional snapshot owner shape * test(subagents): await finite lifecycle settlement * ci: consume canonical UI component type shard Take the exact landed shard repair so the native Stop branch retains all compiler roots under the unchanged budget. No native cancellation source changes. Receiving proof passes 35 routing cases, both UI type graphs, selected changed checks, and independent review. The original 721-root baseline failure remains attributed to main. (cherry picked from commit e7f5a85) * test(agents): register native cancellation fixtures through real owner Replace resident-only run seeding and no-op persistence with awaited canonical registration. Preserve owner, foreign-run, generation-replacement, and real ACP interrupt assertions. * test(subagents): preserve canonical controller and abort fixtures Keep real controller resolution in tool tests and register the orphaned child through real session and registry persistence. Preserve all original cancellation assertions and isolate the running-child wait transport. * test(agents): match restored requester batch wake messages Update the held model fixture to recognize the batch-scoped completion prompt introduced by openclaw#158642. Preserve the two-active, third-queued, ordinary-probe, runtime-budget, and cleanup assertions. Verified on the exact native cancellation CI merge: the original four-case order reproduced three passes and the stale-marker failure, then all four passed with this single-line correction. Owning changed checks and independent review passed. * test(gateway): keep abort append faults connection-local * fix(subagents): retire superseded timing reads without false warnings * fix(subagents): retain finite completion reconciliation work * test(gateway): preserve real descendant abort fixture custody * test(ui): await settled native composer layout Wait for the existing layout-settled contract after viewport changes before measuring native composer footer clearance. ResizeObserver updates transcript width asynchronously while the footer follows its container immediately. Preserve every geometry formula, threshold, and variant order. Validation: six native-plugin UI cases, UI E2E types, scoped lint, formatting, and isolated review passed. Linux baseline passed; candidate remote attempts stopped during source synchronization before test execution. * test(subagents): use real abort persistence and publication barriers * fix(agents): fence collector adoption during cancellation Pending Swarm collectors can receive an aborted Gateway response while Stop is still persisting cancellation. Begin the existing kill claim immediately after native admission drains, then refuse launch adoption while its write is pending. This preserves cancellation publication before provisional-session cleanup and retains the current caller, session, generation, and database authority checks. Cover queued and already-started collectors whose acknowledgment races a pending kill write. Preserve the original three Gateway preaccept Stop cases and their publication, rollback, and timeout assertions. Validation: causal regression RED/GREEN; 273 focused and sibling tests; original 18-file shard with 264 tests; full check-changed including all 26 core test type graphs; independent P2 review with no actionable findings. * test(subagents): join canonical registry completion before assertions Reuse existing finite lifecycle/root-work settlement in collector-yield and completion-before-kill fixtures. Preserve their original assertions, order, and timeouts. Validation: original-order regression diagnosis; twenty standalone and two original 33-file replays passed; unchanged completion siblings reuse the qualified timing shard receipt; owning changed checks and independent component/combined P2 reviews passed. A third stress replay was interrupted by provider shutdown and is not counted as a test result. Current-head hosted CI remains required. * fix(tooling): stop reporting lazy imports as duplicate exports (openclaw#160558) Recognize transparent literal dynamic-import forwarders in the shared export-collision guard while preserving member, argument and body restrictions. Both variable and inline forwarding paths use the same predicate; runtime behavior is unchanged. Validation: original guard reproduces nine repository false positives and fails all three new positive fixtures. Candidate passes the repository guard and all 54 fixtures, including six new rejection cases, under a 7 GiB process-tree limit with swap disabled. Script types and formatting pass. Independent and exact-head ClawSweeper reviews identify no actionable findings. (cherry picked from commit 34f3dab) * fix(agents): join registry writes before follow-up adoption A child follow-up can reach source replacement while its ended-hook stamp is still in the registry worker. Join the existing write owner before the exact durable comparison, retaining uncertain-write errors and rechecking the selected source and admitted caller after every await. Carry sessions.send session authorization through the same boundary. Cover held real writes, caller retirement, and source replacement. * test(ui): consume canonical composer readiness check Use the exact helper postimage from 47c33fe (openclaw#160266). The canonical committed-size wait supersedes this branch's layout quiet-window variation while preserving every geometry assertion and viewport order. Validation: canonical Linux native-plugin E2E six cases and exact-head CI pass; helper and layout-owner source bindings verified; formatting, diff checks, and independent P0-P2 review pass. Native cancellation production is unchanged. Co-authored-by: Kimi Yu <[email protected]> * test(codex): separate protocol timing from startup cost Keep protocol fixtures on their existing controlled deadline clock and measure unattended denial from the review-required hook to the actual decline. Preserve model, transport, history and approval assertions, the existing bounds, and all production clock and executable-integrity behavior. Validation: identical latency controls change four failures to four passes; the original six-file envelope passes 34 tests, with eight deadline and three no-approval-request siblings. Selected changed checks and independent P0-P2 review pass. The original Unix 120-second stall was not independently reproduced; current-head CI remains required. * refactor(config): align canonical worker result types Take the private result-alias cleanup from 886db07 (openclaw#159588) without importing unrelated main changes. Keep the canonical input declaration position while preserving the native selector, request fields, and distributive prepared-input union. The emitted runtime is unchanged. Core and worker-owner test types, scoped lint, formatting, and independent review pass; the qualified native runtime proof remains applicable. --------- Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Kimi Yu <[email protected]>
Regression from the L5 absorb (a8e96ea), found only by locally filling a Mode-B batch that is cancelled at the 90-minute job timeout every run. Upstream's session-utils.queued-collector-admission.test.ts ("cancels real preaccept admission and joins cleanup") recorded "failed" instead of "killed"; it passes at upstream 6d06be1 and at the deployed fleet build. Mechanism: upstream fd1467d (openclaw#160203) made Stop's kill-intent publish asynchronous behind a row-unchanged check (subagent-registry-persistence publishSubagentRunPostimages). Our accepted-spawn rollback (69dc864) is recorded synchronously in the collector's start-failure catch and rewrites the live row (acceptedSpawnRollback, suppressCompletionDelivery, execution). Recorded while Stop's publish is pending, it makes Stop fail with "Subagent mutation lost its original registry row"; with no kill on the row, settleFailedLaunch takes the generic failure path and the collector settles "failed". Fix: when Stop's kill scope is publishing for this row (registrationScope.waitForRetirementPublication() !== undefined), the catch holds the failure reason and settleLaunchFailure records the rollback after the existing claim/publication waits, still before terminateAcceptedCollectorRun. With no Stop in flight the record happens in the catch exactly as before. Record and error handling moved unchanged into a shared recordRollbackOwner helper. New fork test subagent-spawn-collector.stop-rollback.test.ts pins record -> abort -> release -> settle for both orders; upstream's test alone passes even if the rollback record is dropped. Pre-fix control: admission test 3 failed ("expected 'failed' to be 'killed'"); deferral case fails. Verified: admission 3/3; registry + session-cleanup 71 files / 1288 tests; spawn + sessions-spawn 46 files / 549 tests; tsgo core 0; oxlint/oxfmt clean; line-cap and assertion-safety ratchets OK against 6b229ad. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK
Regression from the L5 absorb (a8e96ea), found only by locally filling a Mode-B batch that is cancelled at the 90-minute job timeout every run. Upstream's session-utils.queued-collector-admission.test.ts ("cancels real preaccept admission and joins cleanup") recorded "failed" instead of "killed"; it passes at upstream 6d06be1 and at the deployed fleet build. Mechanism: upstream fd1467d (openclaw#160203) made Stop's kill-intent publish asynchronous behind a row-unchanged check (subagent-registry-persistence publishSubagentRunPostimages). Our accepted-spawn rollback (69dc864) is recorded synchronously in the collector's start-failure catch and rewrites the live row (acceptedSpawnRollback, suppressCompletionDelivery, execution). Recorded while Stop's publish is pending, it makes Stop fail with "Subagent mutation lost its original registry row"; with no kill on the row, settleFailedLaunch takes the generic failure path and the collector settles "failed". Fix: when Stop's kill scope is publishing for this row (registrationScope.waitForRetirementPublication() !== undefined), the catch holds the failure reason and settleLaunchFailure records the rollback after the existing claim/publication waits, still before terminateAcceptedCollectorRun. With no Stop in flight the record happens in the catch exactly as before. Record and error handling moved unchanged into a shared recordRollbackOwner helper. New fork test subagent-spawn-collector.stop-rollback.test.ts pins record -> abort -> release -> settle for both orders; upstream's test alone passes even if the rollback record is dropped. Pre-fix control: admission test 3 failed ("expected 'failed' to be 'killed'"); deferral case fails. Verified: admission 3/3; registry + session-cleanup 71 files / 1288 tests; spawn + sessions-spawn 46 files / 549 tests; tsgo core 0; oxlint/oxfmt clean; line-cap and assertion-safety ratchets OK against 6b229ad. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK (cherry picked from commit 7893b1e)
What Problem This Solves
Moves file-backed native subagent Stop persistence off the Gateway thread while preserving cancellation through storage failures and session changes.
User Impact
Active and queued children keep their original queue holds until cancellation settles. A collector cancelled during launch cannot be revived by a late launch response. Child completion retains its existing admission while required worker reads finish. Replacement sessions or runs cannot inherit an older Stop. Follow-up turns join pending completion bookkeeping before adopting the child. If child storage becomes unavailable after the kill claim commits, the durable intent remains fenced. Deleting the parent while Stop finishes no longer invalidates the unchanged child's committed cancellation.
Why This Change Was Made
Cancellation consumes the existing registry and session worker owners, staged publication, uncertain-outcome tracking, and terminal-state lock. A lost acknowledgement keeps the affected row fenced until canonical recovery instead of replaying a possibly committed write.
The storage contract is unchanged: workers persist the same run and session fields through the existing codecs, and existing databases require no migration. The change adds no configuration option or default and preserves public Gateway and tool response shapes.
Single-session deletion already publishes its exact physical/key removal. Its final list refresh now preserves that publication rather than invalidating every session's facts. Group sweeps and unknown changes retain normal invalidation; access revisions and keyless notification coalescing remain intact.
This is an incremental conversion. Process-held incognito, prepared native deletion/reset transport, ordinary announcement cleanup, and reactivation’s existing synchronous atomic replacement remain separately owned follow-ups. The earlier-success test still observes host SQL from ordinary cleanup; the zero-SQL claim covers the asserted active/queued file-backed Stop windows.
Evidence
Current head
46b6f52f0e40takes only the canonical private result-type cleanup from #159588 to resolve the next verified conflict. The native selector, request fields, and distributive prepared-input union remain unchanged, and the runtime code is unchanged. Core and worker-owner test types, scoped typed lint, formatting, and fresh independent review pass; the exact merge with pinned maine02f5358afbeis clean. The 181-case runtime proof is reused. Current-head CI completed successfully: 137 jobs passed, 21 were skipped, and none failed, including build, security-fast, and the aggregate CI gate. Native merge admission remains required.After the green
134751ce7cb8run, canonical main447fb86fb9f3consolidated registry tests that overlapped the awaited Stop fixtures. Integrationd3e978f563bemerges that fixed main, preserves the consolidated assertions and finite root-work settlement, and removes the redundant helper. The exact combined tree passed 181 receiving cases across the registry, steer restart, query topology, registered native Stop, and follow-up replacement; core types, the owning test graph, selected guards, three dead-export scans, and typed lint also passed. Independent review completed; its one mock-reset finding was disproved by pinned Vitest 5.0.1 behavior and the executed held-write case. Those scoped results remain retained for the following type-only successor.The prior receiving run passed the repaired source-contract check, then exposed a follow-up admission race: the ended-hook fact was present in memory while its SQLite stamp was still pending. Follow-up replacement now joins those existing writes and rechecks the original source, row, and caller before the unchanged strict comparison. The original 26-file parallel group passes with its original deadline. Hosted receiving CI also passed all 15 fallback proof cases, including both formerly failing direct follow-ups.
An earlier hosted run stopped on nine existing daemon lazy-forwarder false positives in the export-collision checker and cancelled the remaining jobs. This branch includes the exact already-landed fix from #160558 by @vincentkoc, with unchanged runtime code; the subsequent receiving run passed that check.
The current repair stack has component-level Linux regression, sibling, type/lint, and independent review evidence. Receiving CI on
6a7b34a59bdbpassed the six native-plugin UI cases, the original Skills refresh case, and all 15 fallback proof cases. The run ended with 135 successful jobs, 20 skipped jobs, and four Codex fixture failures in one plugin row plus its aggregate gate. Those failures remain recorded. The two-file fixture correction separates protocol progress from setup wall time and measures unattended denial from the actual review-required hook to the decline; production budgets and executable integrity checks are unchanged. Identical controlled latency gives four failures before and four passes after, and the original six-file envelope passes 34 tests. The original Unix 120-second timeout was not independently reproduced; receiving CI at134751ce7cb8passed that row. Final companion qualification passed the 34-test envelope, eight deadline cases, three no-Gateway-request approval cases, extension-test types, all selected guards and dead-export scans, typed lint, and independent review. Prior-head CI completed successfully at134751ce7cb8: 135 successful jobs, 21 skipped, and no failures, including build, security, and the aggregate CI gate.A later real conflict arose when #160266 independently repaired the same UI readiness boundary. This branch takes that exact canonical helper, credited to Kimi Yu, and removes its superseded quiet-window variation. Geometry assertions and viewport order are unchanged. The canonical helper has six observed Linux E2E passes, successful exact-head upstream CI, and a fresh scoped review; native production is unchanged. Receiving CI at
134751ce7cb8was successful.94cbd1335dfb. The resolution keeps canonical queued-test helpers together with native awaited claims, and preserves current session-owner publication and requester authority. All 123 receiving cases pass, including stale-owner refusal/current-owner acceptance and the 12 native worker controls; core and four owning test graphs, selected conflict checks, sharing lint/format, and fresh P0–P2 integration review pass. The hosted run at134751ce7cb8was successful.c79e8576df42, integrated with main69a2b5094bad, passed 128 runtime cases: 24 cancellation/reset/delete regressions, 28 native/public-composition controls, 74 deletion/publication siblings, and two keyless-coalescing controls. The original failing Gateway pair changed from 19 passed / 5 failed to 24 passed; no timeout or expected outcome was weakened.526f67dc6382preserves native spawn depth together with canonical ACP parent/session-start facts. All 80 receiving sharing, generation, native Stop, and public Gateway cases pass; core compilation, scoped typed lint, and fresh integration review also pass. Its changed check first stopped on an independently reproduced main issue: the unchangedui-othertype shard contained 721 test roots against its 720 limit. Clean main and the candidate produced the same ordered root list. The exact already-landed four-file repair52ae7e314dc2is included with provenance; 35 routing cases, both resulting UI type graphs, and its selected changed checks pass. The cap and test coverage remain unchanged.1dacfd7passed 98 runtime cases and the unchanged 199-case lifecycle suite. Earlier fixed-base proof passed 216 native siblings and 25 archive cases. A separate receiving E2E correction passed its original 32-case pair while preserving the 15-second grace, output cap, and no-RPC assertions. These are earlier scoped receipts, not a claim that every hosted test ran on the new head.Measured Linux registered-command wall time for the c79 repair: Gateway regressions 54.2s, native/public controls 100.9s, deletion/publication siblings 119.4s. These include runner/bootstrap work and do not measure Stop latency. Full changed checks took 29m21s; full build took 10m23s. Source hashes were verified after each phase and after commit, and the owned Testbox was stopped after verified evidence export.