Repository navigation
fix: stop cloud work before unrelated provider inspection finishes - #133476
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 30, 2026, 6:13 PM ET / 22:13 UTC. ClawSweeper reviewWhat this changesThe PR makes cloud-session Stop cancel active work before unrelated provider inspection while preserving serialized teardown and later same-session move/dispatch ordering. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked by patch quality or review findings - 4 items remain Keep this PR open: the prior P1 remains. A preexisting shared lifecycle singleton lacks the newly required closure set, so an active cloud Stop can throw before it cancels the running work. Priority: P1 Review scores
Verification
How this fits togetherGateway cloud-worker placement manages remote session execution and worker teardown. A reclaim request must fence new work, cancel the active turn, then serialize provider and workspace cleanup without allowing a replacement worker to overtake Stop. flowchart LR
A[Active cloud session] --> B[Stop request]
B --> C[Close new session work]
C --> D[Cancel active turn]
D --> E[Serialize teardown]
E --> F[Provider and workspace release]
E --> G[Later move or dispatch]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +184, Tests +406, Docs +2. Total +592 across 18 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Initialize the new closure registry on an existing shared lifecycle state and add a regression that seeds the pre-field state before exercising active cloud Stop. Do we have a high-confidence way to reproduce the issue? Yes, from source: seed the existing process-global lifecycle state without the new field, then reclaim an active cloud placement; the new closure creation reaches an undefined Set before cancellation. Is this the best way to solve the issue? No. The cancellation ordering is coherent, but it must preserve the module's documented cross-chunk singleton invariant or enforce a restart boundary before accessing the new field. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 214deebc6698. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Merged via squash.
|
* origin/main: (55 commits) test: include v2026.8.1 release navigation (#133581) fix: stop cloud work before unrelated provider inspection finishes (#133476) fix(e2e): keep delete fixture target-compatible (#133526) fix(release): detect optional target E2E capability (#133525) fix(package): publish readable dist inventory (#133549) docs: add complete v2026.8.1 maintainer change index (#133585) fix(browser): preserve contextless worker and iframe sessions (#133571) fix(voice): discover configured provider candidates (#133507) refactor(ui): simplify chat rendering and lifecycle state (#133567) test: reduce maturity fixture cleanup time (#133566) improve: speed up legacy imports and transcript replacement (#133546) docs: add draft v2026.8.1 release notes (#133557) test: guard multi-project Vitest cache ownership (#133554) fix(memory): clarify default agent scope in command help (#133560) fix(clawdock): keep credentials out of diagnostic output (#133547) refactor(ui): avoid redundant presence work in avatar lists (#133548) fix(agents): recognize internal requester completion replies (#133543) fix: prevent duplicate queued user messages in chat clients (#133542) chore(ui): refresh control ui locales (#133544) fix(beam): restart delivery when the receiver changes (#133533) ...
…cked-delivery * origin/main: test: include v2026.8.1 release navigation (openclaw#133581) fix: stop cloud work before unrelated provider inspection finishes (openclaw#133476) fix(e2e): keep delete fixture target-compatible (openclaw#133526) fix(release): detect optional target E2E capability (openclaw#133525) fix(package): publish readable dist inventory (openclaw#133549) docs: add complete v2026.8.1 maintainer change index (openclaw#133585) fix(browser): preserve contextless worker and iframe sessions (openclaw#133571) fix(voice): discover configured provider candidates (openclaw#133507) refactor(ui): simplify chat rendering and lifecycle state (openclaw#133567) test: reduce maturity fixture cleanup time (openclaw#133566) improve: speed up legacy imports and transcript replacement (openclaw#133546) docs: add draft v2026.8.1 release notes (openclaw#133557) test: guard multi-project Vitest cache ownership (openclaw#133554) fix(memory): clarify default agent scope in command help (openclaw#133560)
…penclaw#133476) * fix: cancel cloud work before waiting for provider inspection * refactor: share cloud reclaim lifecycle contracts * refactor: keep reclaim start placement type private
Related: #133241
What Problem This Solves
Fixes an issue where stopping an active cloud session through
sessions.reclaimlets its agent keep working while an unrelated worker's provider inspection is slow. The request previously waited for the global placement queue before it could cancel the session. A second overlapping Stop of an already failed worker could also report an error after the first successfully returned it to local execution.Why This Change Was Made
The Gateway now closes session ingress and drains canonical cancellation before reserving serialized teardown. A lifecycle-owned admission closure keeps queued messages from reviving the worker without holding the mutexes that cancellation recovery needs. The coordinator retains every in-flight Stop for that session; later dispatches and moves wait outside the global fence, while recovery can finish the cancelled run. Workspace reconciliation, provider destruction, terminal persistence and move/recovery barriers retain their existing owners.
Caller authorization, session identity and lifecycle revision are checked across waits, with the exact worker owner rechecked immediately before cancellation. Failed-to-local completion uses the initial generation only to recognize that exact successful cleanup, never as authority to tear down replacement work. No configuration, protocol, schema, dependency or public tool surface is added. The cloud-worker documentation explains cancellation versus resource-release timing.
User Impact
An active cloud agent stops without waiting for unrelated provider inspection. Cleanup can still take time, but new work cannot overtake Stop or silently restart the worker. Concurrent Stops recognize an exact completed failed-worker cleanup. The existing two-step Control UI flow (stop the turn, then stop the idle worker) is unchanged.
Evidence
Exact candidate
0e8b476fc34892a1c7e0a8e196f3dbf2ca8a790fpassed hosted CI 33332652305 and the changed cancellation behavior through real cloud sessions created in the Control UI. The canonical package build and remote bootstrap identities matched this head; the native runtime was Codex 0.151.0.Three real native CUA click runs, fresh subsequent screenshots, and GUI turn Stop passed. The model screenshots, independent RFB images, and actual Chrome WebVNC all showed the same desktop counter advancing from 0 to 3. In the latest ordinary API Stop run, the exact active native turn emitted
TurnAborted/interrupted33 ms after the request and acknowledged execution close after 247 ms. Canonical history recorded that run as killed.Resource-release proof is separately failed, not converted to success: that same RPC later timed out in provider Stop, and the observer WebSocket closed much later. An unrelated allocation was still pending; stopping its task-owned warmup process was a separately recorded manual cleanup intervention. An earlier synthetic held-inspection attempt missed its strict coordination criterion and also failed provider cleanup. Those failed attempts are retained. They do not invalidate the independently observed prompt cancellation, but this PR does not claim that the complete cloud teardown flow is repaired. Broker ingress serialization is tracked in crabbox#1679 and crabbox#1680; the discovered producer-side provisioning cancellation gap is being repaired separately. The existing blocked-inspection RED/GREEN regression proves the precise queue-order invariant.
Production delta is +235/-56 (net +179); test/test-support delta is +450/-39 (net +411), with two documentation lines added. The growth establishes two necessary ownership boundaries: admission closure without a held lifecycle mutex, and same-session Stop ordering without a held global placement fence. Removing either reproduces a race or deadlock. Existing cancellation and teardown remain canonical; the old mutation-only admission-closure path is replaced by the shared closure owner. The type-only contract extraction is included in this raw count; moves do not add runtime behavior.
Review dispositions
The latest ClawSweeper finding and its first two rank-up moves ask for compatibility with an older in-process lifecycle singleton. We checked the producing and loading contracts and are not adding that shim:
tsdown.config.ts:776builds core, SDK and bundled runtimes in one graph;src/plugins/sdk-alias.ts:1371captures the host package root for the loader lifecycle; official plugin packaging leaves OpenClaw imports external (scripts/lib/plugin-npm-runtime-build.mts:101). The supported package-update flow stops the Gateway before replacement (docs/install/updating.md:207and:377), while plugin metadata changes require restart (docs/gateway/configuration.md:587). Duplicated modules from one build share the current shape. The historical adjacent fallback was accompanied by a same-source duplicate-module test, not proof of mixed-version support. Merely initializing the new Set would also leave an older admission implementation unable to honor the new fence. No supported mixed-version producer or observed affected installation was identified.The latest review’s two Rank-up moves concern the same old/new chunk premise; the source and history disposition above applies to both. Exact-candidate native cancellation and sibling desktop proof are recorded above; full provider cleanup remains a separately reported failure. Automated persistent-schema classification is not applicable: this change adds process-local cancellation ownership, with no schema or durable-store change. The production increase is justified above by the two separately tested ownership boundaries.
CI found and we corrected mechanical lint/style issues, then an unused type-only export. The export correction changes no runtime behavior. Final exact-head CI passed at 0e8b476 (run 33332652305), including the hosted full validation required by the native workflow. Fresh native cancellation proof is recorded above; a duplicate local full gate is not claimed.