Repository navigation
fix: stop queued cloud work and persist canceled turns - #133241
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 10:33 AM ET / 14:33 UTC. ClawSweeper reviewWhat this changesThe branch fences queued cloud-worker work during Stop/reclaim, persists cancelled turn outcomes, pauses a provisioning draft before teardown, and reorders recovery to avoid reclaim deadlocks. Merge readinessNo discrete introduced correctness defect was found in this review. This maintainer-owned PR remains necessary, but its own evidence says the full native Stop/restart matrix is pending, so it needs explicit maintainer release judgment before merge. Priority: P1 Review scores
Verification
How this fits togetherA Control UI Stop action reaches the Gateway session lifecycle, which must close new admissions, cancel and persist existing work, reconcile the remote workspace, and reclaim the worker. The UI draft handoff must also prevent a late provisioning response from sending an initial message after Stop. flowchart LR
UI[Control UI Stop] --> Draft[Pause held draft]
UI --> Gateway[Gateway reclaim]
Gateway --> Admission[Close and cancel session work]
Admission --> Terminal[Persist stopped turn]
Gateway --> Recovery[Reconcile workspace result]
Recovery --> Teardown[Destroy cloud worker]
Teardown --> State[Durable placement state]
Decision needed
Why: Focused source and regression coverage supports the design, but the remaining native scenarios exercise the worker teardown and restart boundary that unit and harness evidence cannot fully replace. Before merge
Agent review detailsSecurityNone. PR surfaceSource +485, Tests +1617, Docs +4. Total +2106 across 65 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single Gateway lifecycle mutation as the cancellation owner and obtain exact-head native evidence for active API/UI Stop, provider-error recovery, and restart cleanup before landing. Do we have a high-confidence way to reproduce the issue? No live reproduction was run in this read-only review. The new owner-boundary tests provide a concrete source-level path for queued-admission, terminal-write, and recovery ordering failures, but the full packaged native matrix remains unexecuted here. Is this the best way to solve the issue? Yes, subject to native acceptance evidence. The implementation repairs the shared session lifecycle and canonical abort owner instead of adding a downstream retry or duplicate cancellation path. AGENTS.md: found but not applied because it conflicted with ClawSweeper's review contract. Codex review notes: model internal, reasoning high; reviewed against 0bd5c6a43b7d. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
3d0b284 to
8e0f7ec
Compare
|
@clawsweeper re-review The candidate now includes the provisioning-draft pause and recovery-owner repairs proven by the failed native run, plus the canonical terminal-ownership fix for a late setup failure. The integrated head is 8e0f7ec; 1,959 tests across 82 files, complete type checks, source-bound repository guards, and managed P0–P2 review pass. Exact-package native Stop/restart proof and exact-head CI are still required before merge. Previous native failures remain recorded as failures. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Keep pending session admission owned across cloud worker Stop and route active cancellation through canonical terminal persistence before teardown. Preserve fresh post-Stop input and the existing two-step UI flow.
Pause held initial UI drafts before cloud Stop so a late dispatch reply cannot send them. Preserve explicit Retry and uncertain-delivery custody. Hand accepted workspace cleanup to the existing tracked recovery owner after reclaim releases its fence. Coordinate fresh targeted and coalesced full sweeps through ordered owners so provisioning recovery cannot wait on its own placement fence. Remove forced controller cleanup so setup failures cannot bypass an owned terminal write. Lifecycle drains reject unfinished terminal ownership even when maintenance has retired its registration. Retain the provider error, canonical cancellation, and terminal persistence contracts, with regressions for the observed ordering and cleanup siblings.
Pass canonical recovery functions through the synchronous Stop boundary without importing schema validators into the startup bundle. Keep pause-before-reclaim ordering and preserve the held initial draft. Update the sidebar Stop fixture to expose its actual placement owner and read responsive layout geometry in one animation frame.
8e0f7ec to
4bc8c08
Compare
|
@clawsweeper re-review The current head is |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Updated head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* fix: stop queued cloud work and persist canceled turns Keep pending session admission owned across cloud worker Stop and route active cancellation through canonical terminal persistence before teardown. Preserve fresh post-Stop input and the existing two-step UI flow. * fix: pause provisioning sends and unblock reclaim recovery Pause held initial UI drafts before cloud Stop so a late dispatch reply cannot send them. Preserve explicit Retry and uncertain-delivery custody. Hand accepted workspace cleanup to the existing tracked recovery owner after reclaim releases its fence. Coordinate fresh targeted and coalesced full sweeps through ordered owners so provisioning recovery cannot wait on its own placement fence. Remove forced controller cleanup so setup failures cannot bypass an owned terminal write. Lifecycle drains reject unfinished terminal ownership even when maintenance has retired its registration. Retain the provider error, canonical cancellation, and terminal persistence contracts, with regressions for the observed ordering and cleanup siblings. * fix(ui): keep cloud stop recovery behind lazy action owners Pass canonical recovery functions through the synchronous Stop boundary without importing schema validators into the startup bundle. Keep pause-before-reclaim ordering and preserve the held initial draft. Update the sidebar Stop fixture to expose its actual placement owner and read responsive layout geometry in one animation frame. * fix(cloud): recover accepted reclaim results after restart
Problem
Stopping a cloud worker could let accepted queued work restart it, leave a cancelled native turn marked running across restart, or send the held initial message after provisioning completed. A provider cleanup failure also exposed a reconciliation self-wait that blocked reclaim, later dispatch and Gateway shutdown. After provider destruction, an accepted reclaim result could remain stranded because restart recovery recognized only the turn-before-drain generation order.
Owner-level repair
The session lifecycle now reserves pending admission before its first wait and closes that boundary throughout Stop. Pending owners are cancelled before awaited cancellation or persistence can fail. Both active and failed reclaim use the authorized Gateway cancellation and durable terminal owner; fresh explicit input after Stop remains allowed. The old internal forced controller-cleanup path is removed, and lifecycle drain checks the recorded terminal owner even after bounded maintenance retires a registration.
The existing UI startup owner pauses the selected held draft before Stop, including before its lazy runtime loads. A late dispatch response cannot send it or trigger duplicate reclaim; Retry remains explicit. The documented GUI policy stays two-step: stop the chat turn, then stop its worker. Active
sessions.reclaimis a separate API path. The shared pause reason now covers both cloud and device workers.Accepted results retain tracked same-Gateway recovery, but reclaim releases the fence before that recovery runs. Ordered recovery owners preserve full-sweep coalescing, fresh targeted passes and provisioning joins. One shared generation predicate recognizes both claim-before-drain and claim-after-drain result orders under the exact durable tuple, without reviving live turn authority. No new cancellation registry, retry, timeout, configuration, protocol, dependency or database schema is added.
Current proof
Candidate:
763714331b3d49673de606f8f6e2d876d67c96e4. Exact-head CI passed: 186 successful jobs, 12 workflow-selected skips, no rerun. The canonical full build, fresh UI build and strict package integrity passed; all 35,493 Git blobs/modes and the frozen dependency graph match the packaged source. Managed P0–P2 reviews are clean for the source-bound stack and final six-file follow-up.Local proof includes captured pre-fix owner failures, 1,959 earlier owner/integration cases, 868 frozen-main composition cases including 16 browser E2E cases, and 536 final follow-up cases covering result recovery/publication/abandonment and rendered UI Stop. These are successive source-bound sets, not a unique-test total. Core/UI production types, all 16 core-test type shards and canonical guards pass on the independently attested fresh graph. Separate from the native phases below, loopback WebSocket/RFB and compiled-owner fixtures pass 68 idle/backpressure/revocation and execution/shutdown scenarios across eight processes. UI startup remains below the unchanged budget (345,991 gzip bytes versus 346,761 on the measured composition).
The exact package with Codex 0.151.0 passed the following native phases:
turn_aborted, successful nonignored computer-close acknowledgment and durablekilled/abortedLastRun:truestate. The worker remained usable; idle worker Stop was shown and canceled.API timing limit: the timing and source ordering are consistent with an already-running provider inspection delaying cancellation behind the existing global placement fence; the exact sweep owner was not directly instrumented. Four screenshots occurred after RPC ingress, and the native rollout ended with normal
task_complete, notturn_aborted. This API case proves activity at request, later owned closure, durable killed state and safe reclaim/release/restart; it does not prove API-triggered native interruption or zero work immediately after ingress. The separate GUI case proves actual native interruption. The 1012 claim applies to the fresh observer; an older UI viewer closed earlier with 1005 when its desktop source became unavailable.Preserved failures and dependency boundary
The earlier package's late-send/deadlock and forced-shutdown failures, and the subsequent provider-cleanup and claimless-result restart failures, remain preserved. Final testing also retained two operator-window misses (the native execution finished before the intended GUI/API stop), a correctly rejected running-history sample, and a task PTY input truncation that issued no reclaim. Local terminal tests fixed the launch mode without changing product code, model prompt, deadlines or assertions. An initial approval expired before it was accepted; that failure was preserved, and the actual GUI Allow once path later worked. No GUI approval defect is claimed.
One API attempt had a real provider Stop failure: its RPC returned an error after 64.597 seconds and immediate inspection still showed an active lease. Without a second reclaim or manual provider retry, normal Gateway recovery later reclaimed it and retired the pending result. That is recovery after an error, not success of the original RPC. Process samples are not an HTTP-phase trace.
Native proof used a separately validated, still-uncommitted Crabbox cleanup candidate. It changes reliability inside the existing
stopimplementation, not any command, flag, output schema, API or configuration consumed by OpenClaw. Its review and landing remain separate. This PR does not claim to fix unpatched Crabbox cleanup, and OpenClaw does not require a new dependency interface to land independently. Exact-source native evidence and its dependency qualification are retained together.Earlier CI exposed and led to fixes for an eager recovery-schema import that exceeded the UI budget, two missing sidebar test capabilities, and an animation-frame race in a layout test. The shared checkout's preexisting
pakodeclaration failure and one missing E2E video-encoder setup failure remain recorded; identical complete commands passed on the fresh graph/installed browser cache without weakened assertions or suppression.Review disposition and follow-ups
The latest ClawSweeper review at this head found no discrete correctness or security defect. Its rank-up asks for redacted exact-head traces of active API/UI reclaim, provider-error recovery and restart cleanup; the native evidence above addresses those cases with the explicit API limitation. Its storage heuristic is not a schema change: no DDL, index, migration or storage layout changes; the coordinator is in-memory ordering and the result predicate consumes existing durable records.
Production is +563/-276 (net +287); tests/support +2476/-661; docs +6/-2. Growth supplies continuous admission ownership and canonical terminal cancellation (+180), per-session UI pause and callers (+74), ordered recovery owners (+4), retained terminal ownership (+14), the lazy action boundary (+9), and the shared result-generation rule (+6). Obsolete force cleanup and inline recovery paths are removed. A downstream retry, repeated pending scans or provider-cleanup bypass would not repair these owner boundaries.
Named follow-ups: Stop responsiveness behind in-flight provider reconciliation; CLI least-privilege tool discoverability; Sessions-page provisioning Stop visibility; runner-accurate sidebar/list device confirmations; and original Stop error reporting after later successful recovery. Never-attempted browser outbox rows or submissions still awaiting Blob storage have not entered server custody and are outside server reclaim. No native scheduling claim replaces the deterministic hostile-order regressions.
Visual evidence
Before: the held provisioning message entered Sending after Stop and teardown remained blocked.
After: the same scenario stays Not sent/Retry after Stop and reload.
Native computer results and actual WebVNC show the synthetic counter at 3 after three clicks.