Skip to content

fix(update): reclaim retained updater runtimes on Windows - #192129

Merged
steipete merged 5 commits into
mainfrom
codex/issue-188868-win-runtime
Nov 3, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/issue-188868-win-runtime

Conversation

@steipete

@steipete steipete commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #188868

What Problem This Solves

Fixes: every Windows update leaves an openclaw-update-runtime-* directory behind, and neither the next update nor openclaw doctor --fix ever removes it. Each one costs disk on every update.

User Impact

On Windows, openclaw doctor --fix now reclaims abandoned updater runtimes. A later openclaw update also reclaims earlier runtimes while the Gateway keeps running, as #191284 made possible on Linux and macOS. Runtimes that a live process could still use are kept, and Doctor names that process's PID. There is no config, schema, or migration change.

Why This Change Was Made

The runtime census read processes through readProcessGroupMembers, which throws Exact process command census is unavailable on win32 before it classifies anything. Every Windows cleanup therefore kept every runtime. The update handoff path already uses the native Windows census, so runtime mode now uses it too:

  • Readable command lines are classified exactly as they are on Linux and macOS.
  • Rows owned by another account do not hold runtimes. That includes positively foreign owners and rows that deny even limited query (no identity at all). This matches the existing treatment of unreadable foreign argv on macOS. The handoff census already relies on the same rule: every same-account process grants limited query at any integrity level.
  • Same-account rows with a hidden command line are classified by their image, the same way Linux treats unrelated processes with an unreadable cwd. Non-runtime images do not block; Node.js, Bun, OpenClaw, or unknown images keep runtimes and produce a warning.
  • An exited ancestor ends the inspector's ancestry walk, because Windows never reparents. Before, it aborted the census.
  • The Gateway's Windows job anchor (service-child-windows-job-anchor) joins the spawn broker as a non-creator when it has no artifact evidence. Native runs showed that only this process kept blocking in-update reclamation while the Gateway ran. Only the Gateway task supervisor and the TUI's local shell launch it.

Accepted edge, named in code: a same-account process whose own DACL denies limited query counts as foreign. OpenClaw never launches one, and update locks and Doctor maintenance already exclude a concurrent updater.

The backup create scratch-cleanup EPERM that the Windows manual-procedure lane reported came from the 2026.10.4 CLI. That rename-onto-reservation bug was fixed by #176836, which shipped from 2026.10.6. Published 2026.10.9 and this build both completed backup create --verify five times on native Windows with no EPERM and no leftover scratch, so this PR does not change backup code.

Evidence

  • Regression test in src/infra/openclaw-process-census.windows.test.ts. On base it fails with the exact production message: Could not inspect OpenClaw processes: Error: Exact process command census is unavailable on win32. It passes with the fix. The case covers path-scoped holders, foreign and denied rows, opaque system and Node images, cwd evidence, the installed Gateway, and its job anchor. Without the anchor exemption, the anchor PID blocks the case.
  • Focused suites: the census suites (runtime, Windows, missing-command, native) and the Doctor retained-runtime suites pass, 119 tests. openclaw-process-census.native.test.ts ("finds a real non-Node process holding retained handoff paths") fails on this macOS host only in the combined run, and identically on unmodified base. It is the macOS incomplete census path, which this PR does not touch.
  • Lint and types: oxfmt, oxlint --type-aware and tsgo:core are clean.
  • Native Windows (Crabbox AWS m7i.large, Windows Server, OpenSSH, Node 24.22.1, Scheduled Task Gateway). All hops below ran from published 2026.10.9:
Step Driver Result
10.9 → base build 10.9 runtime retained: Exact process command census is unavailable on win32
doctor --fix on base base runtime retained, same error
base → fix (2026.10.10) base both runtimes retained
fix → fix relabelled 2026.10.11 fix census runs; in-update passes are blocked only by live update processes and one Gateway-owned PID
doctor --fix on 2026.10.11 fix removed all three runtimes; Gateway restarted, /readyz ready
Native census against a fresh runtime with the live Gateway fix vs. this head fix: pids: [1104] (1104 = service-child-windows-job-anchor.js, child of the Gateway); this head: pids: []
The same, plus a same-account worker running from the runtime this head pids: [<worker>], still blocks

Every hop ended with the Gateway healthy (ready, coreReady). The "First restoration refusal observed … databases changed after snapshot capture" line on the second hop also appears on main, is unrelated to this change, and is tracked separately.

Gap: the Crabbox Windows image runs every token at High integrity, so a medium-integrity (UAC) inspector was not exercised natively; the policy for rows it cannot read is covered by the unit case above.

Production code +58/−11 (one owner file); tests +58/−9; docs +7/−1.

Review: $autoreview is scoped-clean on the final branch. An independent Codex review of the first head raised the access-denied rule (P1). That rule is kept and named as the accepted edge above. A second independent pass traced the job anchor's spawners and found nothing.

@clawsweeper

clawsweeper Bot commented Nov 3, 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 size: S labels Nov 3, 2026
@steipete
steipete marked this pull request as ready for review November 3, 2026 17:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T17:36:43.798274Z dfd2e8b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Use the native Windows process census to reclaim abandoned updater runtimes while preserving live holders.

Example: Run openclaw doctor --fix on Windows with three abandoned updater runtimes.

  • Before: All three remain because process inspection reports that the exact command census is unavailable on win32.
  • After: The reported native run removes all three runtimes and restarts a healthy Gateway; a runtime with a live worker remains protected.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair supported by native Windows behavior and distinct holder regressions, with no actionable correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied native Windows results exercise real update and Doctor entry points, report removal of three abandoned runtimes with Gateway readiness restored, and supplement the final job-anchor change with native census output showing both release and live-worker retention; medium-integrity inspection remains an explicitly disclosed coverage limit.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Windows updates leave retained updater runtimes that subsequent updates and Doctor cannot reclaim.
Reason: The repair restores documented cleanup through an existing owner, and the maintainer-authored PR records the intended Windows policy and accepted edge.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a confirmed Windows cleanup failure that remains on main. No introduced correctness defect was found; exact-head CI is still running.

Priority: P2
Reviewed head: dfd2e8b768bcf042854a695cca767dcc5261ee4c

Before merge

None.

Findings

None.

Agent review details

How this fits together

Update preparation and Doctor ask the shared process census whether retained runtime directories have live holders; the temporary-artifact owner consumes that result before deletion.

flowchart TD
  A[Update or Doctor] --> B[Temporary artifact owner]
  B --> C[Shared process census]
  C --> D[Native Windows observations]
  D --> E[Artifact custody classification]
  E --> B
  B --> F[Retain or remove runtime]
Loading

Technical review

Best possible solution:

Keep Windows observation in the existing shared census and retain the current artifact-owner checks before cleanup.

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

Current-main source deterministically reaches the unsupported Windows census, and the supplied native base run reports that exact failure; no target code was executed during this review.

Is this the best way to solve the issue?

This is a focused repair using the existing observation and cleanup owners; every production hunk supports Windows reclamation without introducing another state store or cleanup path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 85404c545bfa.

Provenance checked

  • Windows native census admission changes intended behavior with a stated reason (9d2ef5e: The original capability supplied native Windows evidence for handoff recovery while preserving existing default-census decisions.)
  • Gateway worker exemption keeps the original intent (7fd2b43: Release only positively identified non-creating Gateway processes without artifact evidence; keep possible updater creators conservative.)
  • Opaque process custody changes intended behavior with a stated reason (fix(update): unblock Windows repair around protected processes #173783: Protected unrelated Windows processes should not block repair, while positive artifact references and unresolved surviving work remain protected; this PR explains its runtime-mode access-denied policy.)
  • Unrelated non-runtime images keeps the original intent (9e9e1bf: Unrelated non-runtime processes should not hold disposable runtimes solely because inspection is incomplete; positive references and unresolved runtime identities still block.)
  • Inspector ancestry changes intended behavior with a stated reason (4797b07: Unavailable observations remain unknown custody rather than aborting enumeration; the Windows extension explains why an exited, unreparented ancestor can end the walk.)
  • Windows unsupported-platform regression changes intended behavior with a stated reason (34ce51e: The consolidated suite retained conservative unsupported-platform behavior; the patch replaces that obsolete expectation with native Windows custody coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +47, Tests +49, Docs +6. Total +102 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 58 11 +47
Tests 2 58 9 +49
Docs 2 7 1 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 123 21 +102

Review metrics

Metric Value Why it matters
Production versus test changes Production +58/-11; tests +58/-9 Growth stays in the shared census owner and one regression covering distinct Windows custody outcomes.

Labels

Label changes:

  • add P2: Repeated Windows updates accumulate disposable runtime directories, consuming disk without preventing an otherwise successful update.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: Repeated Windows updates accumulate disposable runtime directories, consuming disk without preventing an otherwise successful update.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 November 3, 2026, 12:53 PM ET / 17:53 UTC.

@steipete
steipete merged commit 7d828be into main Nov 3, 2026
212 of 214 checks passed
@steipete
steipete deleted the codex/issue-188868-win-runtime branch November 3, 2026 17:57
@steipete

steipete commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 4, 2026
…92129)

Related: openclaw#188868

## What Problem This Solves

Fixes: every Windows update leaves an `openclaw-update-runtime-*` directory behind, and neither the next update nor `openclaw doctor --fix` ever removes it. Each one costs disk on every update.

## User Impact

On Windows, `openclaw doctor --fix` now reclaims abandoned updater runtimes. A later `openclaw update` also reclaims earlier runtimes while the Gateway keeps running, as openclaw#191284 made possible on Linux and macOS. Runtimes that a live process could still use are kept, and Doctor names that process's PID. There is no config, schema, or migration change.

## Why This Change Was Made

The runtime census read processes through `readProcessGroupMembers`, which throws `Exact process command census is unavailable on win32` before it classifies anything. Every Windows cleanup therefore kept every runtime. The update handoff path already uses the native Windows census, so runtime mode now uses it too:

- **Readable command lines** are classified exactly as they are on Linux and macOS.
- **Rows owned by another account** do not hold runtimes. That includes positively foreign owners and rows that deny even limited query (no identity at all). This matches the existing treatment of unreadable foreign argv on macOS. The handoff census already relies on the same rule: every same-account process grants limited query at any integrity level.
- **Same-account rows with a hidden command line** are classified by their image, the same way Linux treats unrelated processes with an unreadable cwd. Non-runtime images do not block; Node.js, Bun, OpenClaw, or unknown images keep runtimes and produce a warning.
- **An exited ancestor ends the inspector's ancestry walk**, because Windows never reparents. Before, it aborted the census.
- **The Gateway's Windows job anchor** (`service-child-windows-job-anchor`) joins the spawn broker as a non-creator when it has no artifact evidence. Native runs showed that only this process kept blocking in-update reclamation while the Gateway ran. Only the Gateway task supervisor and the TUI's local shell launch it.

Accepted edge, named in code: a same-account process whose own DACL denies limited query counts as foreign. OpenClaw never launches one, and update locks and Doctor maintenance already exclude a concurrent updater.

The `backup create` scratch-cleanup `EPERM` that the Windows manual-procedure lane reported came from the 2026.10.4 CLI. That rename-onto-reservation bug was fixed by openclaw#176836, which shipped from 2026.10.6. Published 2026.10.9 and this build both completed `backup create --verify` five times on native Windows with no `EPERM` and no leftover scratch, so this PR does not change backup code.

## Evidence

- **Regression test** in `src/infra/openclaw-process-census.windows.test.ts`. On base it fails with the exact production message: `Could not inspect OpenClaw processes: Error: Exact process command census is unavailable on win32.` It passes with the fix. The case covers path-scoped holders, foreign and denied rows, opaque system and Node images, cwd evidence, the installed Gateway, and its job anchor. Without the anchor exemption, the anchor PID blocks the case.
- **Focused suites:** the census suites (runtime, Windows, missing-command, native) and the Doctor retained-runtime suites pass, 119 tests. `openclaw-process-census.native.test.ts` ("finds a real non-Node process holding retained handoff paths") fails on this macOS host only in the combined run, and identically on unmodified base. It is the macOS `incomplete` census path, which this PR does not touch.
- **Lint and types:** oxfmt, oxlint `--type-aware` and `tsgo:core` are clean.
- **Native Windows (Crabbox AWS m7i.large, Windows Server, OpenSSH, Node 24.22.1, Scheduled Task Gateway).** All hops below ran from published 2026.10.9:

| Step | Driver | Result |
|---|---|---|
| 10.9 → base build | 10.9 | runtime retained: `Exact process command census is unavailable on win32` |
| `doctor --fix` on base | base | runtime retained, same error |
| base → fix (2026.10.10) | base | both runtimes retained |
| fix → fix relabelled 2026.10.11 | fix | census runs; in-update passes are blocked only by live update processes and one Gateway-owned PID |
| `doctor --fix` on 2026.10.11 | fix | **removed all three runtimes**; Gateway restarted, `/readyz` ready |
| Native census against a fresh runtime with the live Gateway | fix vs. this head | fix: `pids: [1104]` (1104 = `service-child-windows-job-anchor.js`, child of the Gateway); this head: `pids: []` |
| The same, plus a same-account worker running from the runtime | this head | `pids: [<worker>]`, still blocks |

Every hop ended with the Gateway healthy (`ready`, `coreReady`). The "First restoration refusal observed … databases changed after snapshot capture" line on the second hop also appears on main, is unrelated to this change, and is tracked separately.

Gap: the Crabbox Windows image runs every token at High integrity, so a medium-integrity (UAC) inspector was not exercised natively; the policy for rows it cannot read is covered by the unit case above.

Production code +58/−11 (one owner file); tests +58/−9; docs +7/−1.

Review: `$autoreview` is scoped-clean on the final branch. An independent Codex review of the first head raised the access-denied rule (P1). That rule is kept and named as the accepted edge above. A second independent pass traced the job anchor's spawners and found nothing.
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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