Skip to content

fix(workers): recover interrupted stops without a Gateway restart - #188805

Merged
roboclaw-bot merged 3 commits into
mainfrom
openclaw/s4-interrupted-drain-recovery
Oct 31, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
openclaw/s4-interrupted-drain-recovery

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

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: retainDrainingWorkspace already 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 3111c36da03ae2932fffbac605628cbc5b66d525 gives 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 --check also 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 commit 53c250e17f5feabda51186b0731547c5796556bd and managed publication head 96b6dd8017c43d3171b46bae82ffb5f94aabd46d have 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 9501dfaa8de7426a02badffd918e8eddc75c9e27 at 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.

  • The added stale-dialect case fails on the published production code with zero pending results instead of one, then passes with the one-line correction. The final six interrupted-drain/ownership controls pass (40.84 seconds including the runner).
  • Full recovery suite: 36 passed, two failed. Both failures are the existing startup/runtime pending-result retirement cases; both reproduce identically with the production file restored to the prior published version (87.50 seconds). They retain an active pending claim rather than the asserted failed placement. Their underlying cause remains unresolved; this is not claimed as a fully passing suite or a fix for those failures.
  • Gateway test typecheck, two-file type-aware lint, formatting and whitespace checks pass. The dedicated allocation is now exactly 84 net regression lines; shared scalar unchanged.
  • Fresh canonical autoreview / Codex GPT-6.1 Sol, P0–P3, reviewed the complete corrected candidate. Its only finding was the old INDEX version of the repaired gate; it explicitly judged the working-tree repair correct with no additional actionable findings. Staging the exact reviewed changes resolved that INDEX-only finding. The run itself is not labeled scoped-clean.
  • Simplification: one existing predicate changed; the existing file-save test table gains one case, with no new state or recovery path.

Published correction: f0bedeb8628874a266a1f0cdd43f71b289e417a4, tree 5ca0b969ad8ba6d9a5ea05a5c0346ed11d9bae4a. Current-head CI is pending; earlier failed CI remains historical evidence.

Work sessions

Worked on by

roboclaw-bot and others added 2 commits October 30, 2026 22:52
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
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 30, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 30, 2026 22:54
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Runtime sweeps skip the placement until a Gateway restart or another Stop attempt.
  • After: Background recovery records the final-save obligation, saves result.txt after reconnection, and releases the same worker.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch preserves existing ownership and has meaningful integration coverage; behavioral evidence remains limited to a fixture-backed harness.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; its supplied evidence exercises real placement and file owners with fixture-backed provider and tunnel I/O, rather than a live cloud-worker flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An interrupted Stop can leave a cloud worker stopping indefinitely while its final workspace save waits for a Gateway restart or manual retry.
Reason: The collaborator-authored direction repairs a concrete lifecycle gap without new options or owners; Related appropriately denotes its limited contribution to the extraction umbrella.

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
Reviewed head: 96b6dd8017c43d3171b46bae82ffb5f94aabd46d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not exercise an interrupted Stop and reconnection through a shipped Gateway with the real worker transport.
Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

  • Interrupted-drain custody keeps the original intent (9344233: Preserve file and resource integrity while retiring execution reconstruction after graceful restarts.)
  • Per-session recovery ordering keeps the original intent (b81e04f: Read current recovery facts inside session ordering and retain pending-result, move, then placement recovery sequencing.)
  • Stop durability documentation keeps the original intent (a08f2aa: Keep the final workspace-save obligation across restarts and updates rather than destroying unsaved worker edits.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +19, Tests +76, Docs 0, Other +2. Total +97 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 21 2 +19
Tests 1 92 16 +76
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 116 19 +97

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +21/−2; tests +92/−16 The production growth enrolls one missing lifecycle case; tests extend the existing owner suite with file preservation, retry, and distinct ownership exclusions.

Labels

Label changes:

  • add P2: Interrupted cloud-worker Stops can retain machines and delay workspace settlement, with limited scope and existing recovery alternatives.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Interrupted cloud-worker Stops can retain machines and delay workspace settlement, with limited scope and existing recovery alternatives.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide a redacted Gateway trace showing interrupted Stop recovery, worker reconnection, workspace preservation, and release without a Gateway restart.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

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]>
@roboclaw-bot
roboclaw-bot merged commit 408fe55 into main Oct 31, 2026
132 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/s4-interrupted-drain-recovery branch October 31, 2026 15:23
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant