Repository navigation
fix(update): reclaim retained updater runtimes on Windows - #192129
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesUse 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherUpdate 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +47, Tests +49, Docs +6. Total +102 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
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 November 3, 2026, 12:53 PM ET / 17:53 UTC. |
|
Merged via squash.
|
…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.
Related: #188868
What Problem This Solves
Fixes: every Windows update leaves an
openclaw-update-runtime-*directory behind, and neither the next update noropenclaw doctor --fixever removes it. Each one costs disk on every update.User Impact
On Windows,
openclaw doctor --fixnow reclaims abandoned updater runtimes. A lateropenclaw updatealso 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 throwsExact process command census is unavailable on win32before 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: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 createscratch-cleanupEPERMthat 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 completedbackup create --verifyfive times on native Windows with noEPERMand no leftover scratch, so this PR does not change backup code.Evidence
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.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 macOSincompletecensus path, which this PR does not touch.--type-awareandtsgo:coreare clean.Exact process command census is unavailable on win32doctor --fixon basedoctor --fixon 2026.10.11/readyzreadypids: [1104](1104 =service-child-windows-job-anchor.js, child of the Gateway); this head:pids: []pids: [<worker>], still blocksEvery 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:
$autoreviewis 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.