Repository navigation
fix(workers): recover interrupted stops without a Gateway restart - #188805
Conversation
Reuse the existing guarded final-save owner for idle draining placements during runtime recovery. Preserve claim and move ownership, retain offline results for reconnect, and record proven worker loss without replaying input or allocating a replacement. Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 05c699e2-4117-4513-9335-97c36d0c678d
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR lets background recovery finish interrupted cloud-worker Stops without restarting the Gateway. Example: Stop leaves a worker in draining before recording its final-save claim, with result.txt containing an unsaved edit.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this collaborator-authored PR open: it addresses a current recovery gap through the existing owner, with no definite introduced defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway placement recovery consumes durable placements, claims, moves, and environment facts, then delegates workspace saving and teardown to existing settlement owners. flowchart TD
A[Background sweep] --> B[Session recovery admission]
B --> C[Current placement and environment]
C --> D[Existing final-save owner]
D --> E[Pending workspace result]
E --> F[Save workspace and release worker]
Technical reviewBest possible solution: Retain this focused enrollment fix and let the existing pending-result owner save the workspace before releasing the exact attached worker. Do we have a high-confidence way to reproduce the issue? Source shows that Stop can leave an unclaimed draining placement while current-main runtime recovery skips that state; the PR reports baseline failure, but this review executed no reproduction. Is this the best way to solve the issue? The smallest complete fix is to enroll eligible interrupted drains through retainDrainingWorkspace and preserve existing claims, moves, attachment checks, and settlement ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 395cac71556a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +19, Tests +76, Docs 0, Other +2. Total +97 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 30, 2026, 7:12 PM ET / 23:12 UTC. |
Enroll exact attached draining workers independently of launch compatibility; existing recovery owns runtime qualification. Extend the file-preserving interrupted-drain regression for an old launch dialect. Co-authored-by: galiniliev <[email protected]>
|
Merged via squash.
|
…enclaw#188805) * fix(workers): recover interrupted stops without a Gateway restart Reuse the existing guarded final-save owner for idle draining placements during runtime recovery. Preserve claim and move ownership, retain offline results for reconnect, and record proven worker loss without replaying input or allocating a replacement. Co-authored-by: galiniliev <[email protected]> * fix(workers): recover interrupted stops without a Gateway restart Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 05c699e2-4117-4513-9335-97c36d0c678d * fix(workers): retain stale interrupted drain custody Enroll exact attached draining workers independently of launch compatibility; existing recovery owns runtime qualification. Extend the file-preserving interrupted-drain regression for an old launch dialect. Co-authored-by: galiniliev <[email protected]> --------- Co-authored-by: galiniliev <[email protected]>
…88805) * fix(workers): recover interrupted stops without a Gateway restart Reuse the existing guarded final-save owner for idle draining placements during runtime recovery. Preserve claim and move ownership, retain offline results for reconnect, and record proven worker loss without replaying input or allocating a replacement. Co-authored-by: galiniliev <[email protected]> * fix(workers): recover interrupted stops without a Gateway restart Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 05c699e2-4117-4513-9335-97c36d0c678d * fix(workers): retain stale interrupted drain custody Enroll exact attached draining workers independently of launch compatibility; existing recovery owns runtime qualification. Extend the file-preserving interrupted-drain regression for an old launch dialect. Co-authored-by: galiniliev <[email protected]> --------- Co-authored-by: galiniliev <[email protected]> (cherry picked from commit 408fe55) Co-authored-by: RomneyDa <[email protected]>
Related: #188796
What Problem This Solves
Fixes: a cloud worker can remain stuck stopping until the Gateway restarts when Stop is interrupted before its final workspace-save claim is recorded.
User Impact
User impact: background recovery can finish saving and releasing the same worker without a Gateway restart. Offline workers retain their final-save obligation until reconnection; recovery never replays input or allocates a replacement. Existing claims, moves, and replaced attachments remain protected. No configuration or schema changes are required.
Why This Change Was Made
Runtime sweeps previously skipped draining placements without a claim. Enroll those placements through the existing guarded workspace-recovery owner, then let normal pending-result recovery finish the save. Proven worker loss still records that unresolved changes are unverified.
This adapts the interrupted-drain portion of S4 to current main:
retainDrainingWorkspacealready owns the donor's proposed enrollment helper, so no second helper or recovery path is introduced. Retained-disk changes and provider-outage containment are deliberately excluded.Original implementation evidence (head
96b6dd8017c43d3171b46bae82ffb5f94aabd46d)CI attribution: the exact-head test-line check fails with 6,314,125 lines against a 6,313,100-line ceiling (1,025 excess). Read-only counting of its main parent
3111c36da03ae2932fffbac605628cbc5b66d525gives 6,314,049/6,313,024 (1,025 excess). This PR adds 76 test lines and exactly 76 allocated lines, preserving the inherited debt; no shared baseline was raised. The aggregate CI gate is therefore not green.Regression reproduced on base
563ba501dced074d9d282fb3a4cb48cfc31bcf9e: no pending final-save claim after a runtime sweep; proven worker loss remained draining.Corrected recovery suite: 37 tests passed, including actual temporary-file apply through the real placement/pending-result owners, offline retry, unchanged claim ownership, stale/replaced attachments, no replay/allocation, and proven-loss reporting. File wall time: 65.23 seconds (67.57 seconds including wrapper); native-worker compilation dominates the cold run. CI seconds are not yet available.
Final combined recovery, admission, Move, and targeted-recovery suites: 80/80 tests passed across 4 files in 96.96 seconds (99.53 seconds including wrapper).
Scoped typecheck, two-file lint, and three-file formatting passed in a task-isolated rootless container with frozen dependencies and normal supply-chain gates;
git diff --checkalso passed. Provider/tunnel I/O is fixture-backed; no live cloud-provider or model run was performed.Fresh independent P0–P3 review found two test-fixture issues, both corrected. Local autoreview (Codex/GPT-6.1 Sol, P0–P3) reviewed the complete final local snapshot against the pinned base with the unchanged ownership contracts supplied:
scoped-clean, no findings. Reviewed commit53c250e17f5feabda51186b0731547c5796556bdand managed publication head96b6dd8017c43d3171b46bae82ffb5f94aabd46dhave identical trees; the latter adds publication attribution only. Local ClawSweeper was unavailable; the hosted review is already queued, so no duplicate request was posted.Simplification: reuse the current enrollment and pending-result owners; no new state, schema, replay logic, or provider machinery. Delta: production +21/−2; tests +92/−16 (net +76, separately allocated for these regressions); documentation +1/−1.
Contributor credit: adapted from Galin Iliev's S4 source commit
9501dfaa8de7426a02badffd918e8eddc75c9e27at his request.Final review correction — October 31
Fresh independent P0–P3 review found that runtime recovery still required current launch compatibility before enrolling a claimless interrupted drain. An exactly attached worker with an older launch dialect remained draining without its final-save claim. The correction uses exact attachment ownership; the existing final-save owner still owns runtime qualification, save and teardown. No execution is resumed.
Published correction:
f0bedeb8628874a266a1f0cdd43f71b289e417a4, tree5ca0b969ad8ba6d9a5ea05a5c0346ed11d9bae4a. Current-head CI is pending; earlier failed CI remains historical evidence.Work sessions
Worked on by