Skip to content

fix(gateway): frozen worker processes never resume when the host ps stalls - #123976

Merged
clawsweeper merged 10 commits into
mainfrom
jesse/workspace-quiescence-thaw
Aug 23, 2026
Merged

clawsweeper merged 10 commits into
mainfrom
jesse/workspace-quiescence-thaw

Conversation

@jesse-merhi

@jesse-merhi jesse-merhi commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Workspace sync could leave worker processes frozen forever when the host's ps command stalled during an identity check. Because the workers were stopped with SIGSTOP, they could not recover themselves, stranding builds, deploys, or agent sessions. This PR bounds every identity probe, keeps the watchdog responsible until thaw succeeds, and releases empty leases without depending on ps. A stalled probe now fails visibly, while the watchdog resumes real workers once the host responds again.

Layer 2 of 3. #123975 is merged; #123979 depends on this PR.

Change breakdown

Part Files +LOC -LOC
Quiescence recovery 1 +54 -19
Tests and fixtures 2 +988 -754
Total 3 +1,042 -773

The test total includes a 797-line manifest-test block moved unchanged into its own file after the recovery coverage exceeded the repository's file-size limit.

Proof

Same real lease, stopped worker, and TERM-ignoring fake ps in both runs:

Before: direct base

identity probe: hung beyond 20s
resume exit: 124 (outer timeout)
worker state: T (stopped)

After: PR

stalled probe: killed after 2s; resume exits visibly
watchdog after lease expiry: alive and retrying
after ps recovers: worker state is non-T; lease removed

Empty shared-host leases are removed immediately because they own no frozen processes. Malformed or identity-bearing leases still fail closed.

How to verify

node scripts/run-vitest.mjs run \
  src/gateway/worker-environments/workspace-sync-scripts.test.ts \
  src/gateway/worker-environments/workspace-sync-manifest.test.ts

Exact head 7038a0b5bc2f8731fcf75b8ee3ca95acbd6273be: exact-head CI passed, and the stopped-worker recovery scenario passed in both Gateway projects (2/2 focused tests; 20 skipped).

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Aug 15, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 10:50 AM ET / 14:50 UTC.

ClawSweeper review

What this changes

The PR bounds and kills stalled remote ps probes, preserves the lease watchdog until stopped workers thaw, releases empty shared-host leases without probing ps, and reorganizes related tests.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: this MEMBER-authored, maintainer-labeled Gateway availability fix requires explicit maintainer handling. The locally available PR head has no discrete new correctness finding, but the checkout cannot read current main, history beyond the grafted head, or GitHub because network resolution failed, so final integrated-head verification remains unproven.

Priority: P1
Reviewed head: 7038a0b5bc2f8731fcf75b8ee3ca95acbd6273be

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The local PR-head implementation and boundary tests are coherent, but the unavailable current-main comparison and exact-integrated-head rerun leave material availability confidence unresolved.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless describes a real stopped-worker and TERM-ignoring-process-probe scenario, pending exact-integrated-head confirmation.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless describes a real stopped-worker and TERM-ignoring-process-probe scenario, pending exact-integrated-head confirmation.
Evidence reviewed 5 items Changed recovery owner: The generated script makes all three ps probes killable and bounds identity probing before any SIGCONT decision; watchdog retry retains the lease until it can complete recovery or the lease disappears.
Caller and lifecycle coverage: The common quiescence wrapper owns renewal and explicit resume; workspace-sync, Node tunnel recovery, finalization, and pending-result recovery call that shared owner rather than reimplementing recovery.
Boundary-level regression coverage: The test uses a real stopped Node worker and a TERM-ignoring fake ps, verifies that failed explicit resume leaves the watchdog alive, then verifies post-expiry recovery resumes the worker and removes the lease after ps recovers.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run src/gateway/worker-environments/workspace-sync-scripts.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs run src/gateway/worker-environments/workspace-sync-scripts.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-123976-brajoT/target$ node scripts/run-vitest.mjs run src/gateway/worker-environments/workspace-sync-scripts.te
st.ts
node scripts/run-vitest.mjs run src/gateway/worker-environments/workspace-sync-scripts.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-123976-brajoT/target

 ✓  gateway-server-isolated  ../../src/gateway/worker-environments/workspace-sync-scripts.test.ts (11 tests) 21886ms
     ✓ recovers a prior nonce without letting its watchdog own the next lease  350ms
     ✓ proves the lease is active and renews its watchdog deadline  412ms
     ✓ stops a writable process that appeared after the workspace was quiesced  627ms
     ✓ cleans up the initial watchdog when identity probing times out  2051ms
     ✓ releases an empty shared-host lease without depending on ps  2107ms
     ✓ thaws a real stopped worker and clears the lease  308ms
     ✓ keeps the watchdog resumer alive when the identity sweep aborts partway  2268ms
     ✓ recovers a frozen worker once a stalled ps answers again after lease expiry  13121ms


































Assertions:

  • PASS expect_output: workspace-sync-scripts.test.ts

How this fits together

Gateway workspace sync temporarily pauses remote worker processes through generated scripts and a lease-backed watchdog before reconciling workspace changes. The watchdog and explicit resume path probe process identity, thaw stopped workers, and remove the lease when recovery is complete.

flowchart LR
  A[Workspace synchronization] --> B[Quiesce remote worker]
  B --> C[Lease-backed watchdog]
  C --> D[Bounded process probe]
  D --> E[Resume or retry recovery]
  E --> F[Worker continues]
  E --> G[Lease removed]
Loading

Before merge

  • Resolve merge risk (P1) - The availability-sensitive behavior was proved in the PR body for an earlier head, but current main, the three-way integrated result, and an exact-current-head rerun could not be independently checked because this checkout is grafted and GitHub/network access failed.
  • Complete next step (P2) - A protected, MEMBER-authored availability PR needs maintainer review and exact-integrated-head recovery evidence; no narrow automated repair is identified.
Agent review details

Security

None.

PR surface

Source +35, Tests +234. Total +269 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 54 19 +35
Tests 2 988 754 +234
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 1042 773 +269

Review metrics

Metric Value Why it matters
Production vs test LOC production +54/-19; test files +988/-754, including a stated 797-line manifest-suite relocation Production growth is confined to the generated recovery owner; most test churn separates existing manifest coverage while adding process-recovery scenarios.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/workspace-sync-manifest.test.ts, durable storage schema: src/gateway/worker-environments/workspace-sync-scripts.test.ts, serialized state: src/gateway/worker-environments/workspace-sync-manifest.test.ts, unknown-data-model-change: src/gateway/worker-environments/workspace-quiescence-scripts.ts, unknown-data-model-change: src/gateway/worker-environments/workspace-sync-manifest.test.ts, unknown-data-model-change: src/gateway/worker-environments/workspace-sync-scripts.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Re-run integrated recovery proof (recommended)
    Before merging, run the real stopped-worker recovery scenario against the exact integrated head and confirm the worker leaves the stopped state after the process probe recovers.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run the stopped-worker stalled-process-probe recovery proof on the exact integrated head; require visible bounded resume failure during the stall, watchdog survival after expiry, then worker thaw and lease removal after probe recovery.

Technical review

Best possible solution:

Retain the shared lease/watchdog recovery owner and run the stopped-worker, stalled-ps recovery proof against the final integrated head before merge.

Do we have a high-confidence way to reproduce the issue?

No high-confidence current-main reproduction was possible: the available test defines a concrete real-process stopped-worker scenario, but local main and the PR’s final integrated proof could not be accessed.

Is this the best way to solve the issue?

Unclear: keeping bounded probing and recovery in the lease/watchdog owner is the narrowest observed design, but unavailable main/history evidence prevents a final best-fix conclusion.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ee6e0251b461.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp. Replaced prior rating: 🐚 platinum hermit.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A stalled process probe can leave Gateway-managed workers stopped, interrupting active builds, deploys, or agent sessions.
  • merge-risk: 🚨 availability: The branch changes the watchdog and resume lifecycle responsible for thawing stopped remote worker processes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp. Replaced prior rating: 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless describes a real stopped-worker and TERM-ignoring-process-probe scenario, pending exact-integrated-head confirmation.

Evidence

What I checked:

Likely related people:

  • Jesse Merhi: Git blame attributes the reviewed probe and resume-ordering lines on the available PR head to this author. (role: current recovery implementation author; confidence: high; commits: 7038a0b5bc2f; files: src/gateway/worker-environments/workspace-quiescence-scripts.ts, src/gateway/worker-environments/workspace-sync-scripts.test.ts)
  • ClawSweeper: The available-head blame records ClawSweeper as committer for the current recovery commit; deeper history was unavailable in this grafted checkout. (role: current commit committer; confidence: medium; commits: 7038a0b5bc2f; files: src/gateway/worker-environments/workspace-quiescence-scripts.ts)

Rank-up moves

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

  • Run the stopped-worker recovery scenario on the exact integrated head and retain redacted terminal output showing bounded probe failure, watchdog retry, worker thaw, and lease removal.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (25 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-19T01:27:26.424Z sha 53ed49a :: needs changes before merge. :: [P3] Clean up the stalled-probe watchdog
  • reviewed 2026-08-19T03:33:45.868Z sha 06cf123 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T04:23:02.459Z sha 06cf123 :: needs changes before merge. :: [P2] Clean up the initial watchdog when identity probing times out
  • reviewed 2026-08-19T05:08:13.518Z sha 484284f :: needs maintainer review before merge. :: none
  • reviewed 2026-08-20T14:58:23.147Z sha 484284f :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T14:29:37.476Z sha 825d0bd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T15:37:51.115Z sha 825d0bd :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T16:12:44.711Z sha 825d0bd :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 15, 2026
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 15, 2026
@jesse-merhi
jesse-merhi force-pushed the jesse/workspace-quiescence-thaw branch from 484284f to 825d0bd Compare August 21, 2026 14:14
@jesse-merhi
jesse-merhi marked this pull request as ready for review August 21, 2026 14:22
Copilot AI lite review requested due to automatic review settings August 21, 2026 14:22
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@clawsweeper

Copy link
Copy Markdown
Contributor

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 21, 2026
@clawsweeper

Copy link
Copy Markdown
Contributor

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Base automatically changed from jesse/tsgo-stall-timeout to main August 23, 2026 14:45
processIdentity() ran `ps` through execFileSync with no timeout, while its two
siblings in the same script (processes(), processStatus()) both pass
timeout: 2000. Every thaw path gates on it — resumeProcesses(), the watchdog
expiry loop, and REMOTE_WORKSPACE_RESUME_JS all call processIdentity before
each SIGCONT — so a host whose `ps` stalls leaves the entire lease frozen with
no remaining resumer. SIGSTOP cannot be caught, so those processes never run
again and never release their memory.

Bring processIdentity to parity with its siblings.

Measured with the exported scripts against a fixture whose `ps` stalls on the
identity lookup: unbounded resume was still hung when a 20s cap killed it
(exit 124); bounded resume fails in 2s with `spawnSync ps ETIMEDOUT`.
…tchdog

A bounded identity lookup still fails on a stalled host ps. Resume retired the
watchdog first, so an aborted sweep left the lease with no resumer at all and
the frozen workers stopped forever. Thawing first keeps the watchdog as the
recovery owner that clears the lease at expiry; the orphan sweep had the same
inverted order.
…y probe

At lease expiry the watchdog ran the same bounded ps lookup and its catch
retired the process on the first ETIMEDOUT, so a stall spanning expiry left the
frozen workers with no resumer at all. It now re-probes on a bounded schedule
and still verifies pid start time before every SIGCONT.
… can fire

execFileSync's timeout only sends killSignal and then waits for the child to
exit, so under the default SIGTERM a ps that ignores it blocked the thaw
forever and the added timeout bounded nothing. All three probes now kill the
stuck child; verified a TERM-ignoring ps returns in ~2s instead of hanging.
…try count

A fixed 150-attempt budget reinstated the permanent freeze for any ps stall
longer than five minutes. The watchdog now backs off up to 60s and keeps
retrying until its sweep completes or the lease file is gone, which is the
condition that actually means the workers no longer need a resumer.
… rollback

ClawSweeper on 0162987: the explicit resume path was reordered to thaw
before retiring its watchdog, but the initial quiescence sweep's rollback still
retired first. A bounded identity probe can throw inside resumeProcesses, and by
then the watchdog was already gone, leaving a stopped worker with no remaining
recovery owner and the lease still present.

Apply the same owner-preserving order to the rollback path, so the last resumer
outlives a failed thaw exactly as it does on explicit resume.

Production +3/-1: the resume call moves ahead of the watchdog retirement, plus a
two-line contract comment.
Review fixes on top of the killable-probe change, from one native pass and two
cold passes:

- The watchdog retried forever on an unparseable lease, leaving an immortal
  detached process. The pids to resume live in that file, so retrying cannot
  recover them; an unusable lease is now terminal.
- A missing ps binary throws ENOENT too, so the watchdog retired as if the
  lease were gone while its workers stayed SIGSTOPped. Only the lease path
  retires it now, discriminated on error.path.
- The thaw-first reorder stretched two unlink races. The resume script and the
  orphan sweep now tolerate a lease that another owner already removed, so a
  fully successful thaw cannot report the sync as failed.
- The stalled-ps recovery test polled 5s against a backoff that doubles to 8s
  and never resets; widened to outlast the retry ladder.

Test-file hygiene, required to land lint-clean: the additions pushed
workspace-sync-scripts.test.ts past the repo max-lines cap and introduced two
no-promise-executor-return errors, neither of which fires at the PR base. The
promise executors now use block bodies, and the file is split by subject rather
than suppressed: manifest transaction tests move to workspace-sync-manifest.test.ts,
quiescence tests stay. The moved block is byte-identical and no helper crosses
the boundary.

Proof gap: the gateway vitest project cannot run in this checkout (pre-existing
configureFsSafeNative import failure from stale node_modules), so the split and
the new tests are verified by git comparison, static analysis, oxlint, and
isolated execution of the embedded scripts rather than by a suite run.
Restore the healthy process probe after the expected failure, resume the lease, and wait for the detached watchdog to exit so repeated runs do not leak recovery processes.

Co-authored-by: jesse-merhi <[email protected]>
@clawsweeper
clawsweeper force-pushed the jesse/workspace-quiescence-thaw branch from 825d0bd to 7038a0b Compare August 23, 2026 14:45
@clawsweeper

Copy link
Copy Markdown
Contributor

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper
clawsweeper merged commit cd91a89 into main Aug 23, 2026
231 checks passed
@clawsweeper
clawsweeper deleted the jesse/workspace-quiescence-thaw branch August 23, 2026 14:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…talls (openclaw#123976)

* fix(gateway): bound quiescence identity lookups so thaw cannot hang

processIdentity() ran `ps` through execFileSync with no timeout, while its two
siblings in the same script (processes(), processStatus()) both pass
timeout: 2000. Every thaw path gates on it — resumeProcesses(), the watchdog
expiry loop, and REMOTE_WORKSPACE_RESUME_JS all call processIdentity before
each SIGCONT — so a host whose `ps` stalls leaves the entire lease frozen with
no remaining resumer. SIGSTOP cannot be caught, so those processes never run
again and never release their memory.

Bring processIdentity to parity with its siblings.

Measured with the exported scripts against a fixture whose `ps` stalls on the
identity lookup: unbounded resume was still hung when a 20s cap killed it
(exit 124); bounded resume fails in 2s with `spawnSync ps ETIMEDOUT`.

* fix(gateway): thaw frozen processes before retiring the quiescence watchdog

A bounded identity lookup still fails on a stalled host ps. Resume retired the
watchdog first, so an aborted sweep left the lease with no resumer at all and
the frozen workers stopped forever. Thawing first keeps the watchdog as the
recovery owner that clears the lease at expiry; the orphan sweep had the same
inverted order.

* fix(gateway): keep the quiescence watchdog retrying a stalled identity probe

At lease expiry the watchdog ran the same bounded ps lookup and its catch
retired the process on the first ETIMEDOUT, so a stall spanning expiry left the
frozen workers with no resumer at all. It now re-probes on a bounded schedule
and still verifies pid start time before every SIGCONT.

* fix(gateway): make the quiescence ps probes killable so their timeout can fire

execFileSync's timeout only sends killSignal and then waits for the child to
exit, so under the default SIGTERM a ps that ignores it blocked the thaw
forever and the added timeout bounded nothing. All three probes now kill the
stuck child; verified a TERM-ignoring ps returns in ~2s instead of hanging.

* fix(gateway): retire the quiescence watchdog on recovery, not on a retry count

A fixed 150-attempt budget reinstated the permanent freeze for any ps stall
longer than five minutes. The watchdog now backs off up to 60s and keeps
retrying until its sweep completes or the lease file is gone, which is the
condition that actually means the workers no longer need a resumer.

* fix(gateway): thaw before retiring the watchdog in initial quiescence rollback

ClawSweeper on 0162987: the explicit resume path was reordered to thaw
before retiring its watchdog, but the initial quiescence sweep's rollback still
retired first. A bounded identity probe can throw inside resumeProcesses, and by
then the watchdog was already gone, leaving a stopped worker with no remaining
recovery owner and the lease still present.

Apply the same owner-preserving order to the rollback path, so the last resumer
outlives a failed thaw exactly as it does on explicit resume.

Production +3/-1: the resume call moves ahead of the watchdog retirement, plus a
two-line contract comment.

* fix(gateway): harden quiescence recovery after two-phase code review

Review fixes on top of the killable-probe change, from one native pass and two
cold passes:

- The watchdog retried forever on an unparseable lease, leaving an immortal
  detached process. The pids to resume live in that file, so retrying cannot
  recover them; an unusable lease is now terminal.
- A missing ps binary throws ENOENT too, so the watchdog retired as if the
  lease were gone while its workers stayed SIGSTOPped. Only the lease path
  retires it now, discriminated on error.path.
- The thaw-first reorder stretched two unlink races. The resume script and the
  orphan sweep now tolerate a lease that another owner already removed, so a
  fully successful thaw cannot report the sync as failed.
- The stalled-ps recovery test polled 5s against a backoff that doubles to 8s
  and never resets; widened to outlast the retry ladder.

Test-file hygiene, required to land lint-clean: the additions pushed
workspace-sync-scripts.test.ts past the repo max-lines cap and introduced two
no-promise-executor-return errors, neither of which fires at the PR base. The
promise executors now use block bodies, and the file is split by subject rather
than suppressed: manifest transaction tests move to workspace-sync-manifest.test.ts,
quiescence tests stay. The moved block is byte-identical and no helper crosses
the boundary.

Proof gap: the gateway vitest project cannot run in this checkout (pre-existing
configureFsSafeNative import failure from stale node_modules), so the split and
the new tests are verified by git comparison, static analysis, oxlint, and
isolated execution of the embedded scripts rather than by a suite run.

* test(gateway): clean up stalled probe watchdog

Restore the healthy process probe after the expected failure, resume the lease, and wait for the detached watchdog to exit so repeated runs do not leak recovery processes.

Co-authored-by: jesse-merhi <[email protected]>

* fix(gateway): clean up failed watchdog startup

* fix(gateway): release empty quiescence leases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

3 participants