Repository navigation
fix(doctor): reclaim runtimes despite unrelated Node processes - #177407
Conversation
Treat exhausted package lookup as absent and keep unresolved process classification local to each PID. Preserve positive OpenClaw identities and runtime references, and continue inspecting remaining processes and module operands before deciding cleanup custody. Fixes #173082. Thanks @DonnieFi, @angeliti999, and @woshicby for the reports.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 020674ac6f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (classifyOpenClawArgv(argv, options).kind === "openclaw") { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Preserve active OpenClaw processes when package evidence is unreadable
When an active OpenClaw process uses a canonical entrypoint such as node /app/dist/index.js but its package.json is temporarily unreadable or malformed, classifyOpenClawArgv returns unclassified; this branch now ignores that result, the fallback classification is likewise discarded, and the census reports no holder. Both maintainRetainedUpdateRuntimes and noteLegacyPluginSourceCaptures interpret an empty census as permission to remove artifacts, so Doctor can delete captures or retained runtime files while that OpenClaw process is still using them. Keep unresolved canonical OpenClaw entrypoint evidence conservative without allowing unrelated manifest-free Node processes to abort the entire census.
Useful? React with 👍 / 👎.
Keep manifest absence distinct from unavailable process evidence. Retain unscoped unknown holders with a PID warning while allowing independent runtimes to be reclaimed. Resolve and combine argv, cwd, entrypoint, and preload paths before applying runtime-specific custody decisions. Preserve unresolved references when only runtime syntax is clarified, and keep strict identity admission at its existing package boundary.
|
Addressed the accepted P1 in @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Addressed the second accepted P1 at 9a1d12a. Restored the existing unavailable-cwd gate and exact foreign-owner/systemd/PAM exemptions for every process, including non-Node relative commands. The new regressions were red on 9140591; 268 tests and the Debian real-process cleanup proof now pass. Production delta for this correction: -1 line. PR evidence is current. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Addressed the third accepted P1 at 519941c: missing process command is explicitly unknown, retains candidates with a PID/reason warning, and does not stop inspection of later holders. The existing argvUnavailable/empty-argv behavior is unchanged. Regression red on 9a1d12a, green here; 249 affected tests passed (one Windows-native skip), targeted checks and Debian real-process cleanup proof passed. PR evidence is updated. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 519941cca5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const evidence = classifyOpenClawEntrypointPath(reference, options); | ||
| if (evidence.kind === "openclaw" && evidence.artifactPath) { | ||
| return [evidence.artifactPath]; | ||
| } | ||
| if (typeof position !== "number" && position.kind === "not-runtime") { | ||
| return false; | ||
| unknown ??= evidence.kind === "unclassified" ? evidence.reason : "runtime path is unresolved"; |
There was a problem hiding this comment.
Resolve file-URL artifact references before marking custody unknown
When a worker preloads a retained runtime using a supported option such as node --import=file:///tmp/openclaw-update-runtime-Held01/preload.js app.js, this prepass sends the file: URL directly to classifyOpenClawEntrypointPath, which treats it as a relative filesystem path and records could not resolve script. Although the later operand loop correctly converts the URL with fileURLToPath and finds the exact held runtime, the earlier unknown value is never cleared, so the process becomes an unscoped unknown and prevents Doctor from reclaiming every unrelated runtime. Local Node 24.15 node --help confirms that --import=... is a supported ES-module preload form; normalize module file URLs here or discard the provisional unknown once all references are resolved.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesDistinguish missing package manifests from unavailable process evidence and scope Doctor cleanup to each retained runtime. Example: A manifest-free
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep open: this maintainer-authored PR addresses a confirmed cleanup failure, but three actionable defects remain, including a path that can reclaim an in-use runtime. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherDoctor and update cleanup consume process-census custody decisions to preserve live artifacts and remove recognized abandoned runtime directories. flowchart TD
A[Doctor or update cleanup] --> B[Recognized runtime candidates]
B --> C[Process census]
C --> D[Package and path evidence]
D --> E[Per runtime custody decision]
E --> F[Preserve with diagnostics]
E --> G[Remove abandoned runtime]
Technical reviewBest possible solution: Keep classification in the existing census owner, require complete evidence before narrowing custody, normalize file URLs consistently, and preserve uncertainty diagnostics in both cleanup consumers. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the reported manifest-search-to-retention path, and the linked reports identify affected releases; this read-only review ran no target code. Is this the best way to solve the issue? The explicit absent-versus-unknown distinction uses the correct existing owners, but scoped custody must account for unavailable cwd and every diagnostic consumer. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c3656d831b80. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +73, Tests +103, Docs 0. Total +176 across 7 files. Added test files: 1. 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 October 19, 2026, 11:25 AM ET / 15:25 UTC. |
…law#177407) Doctor's update-runtime cleanup inspects running processes to decide which retained update runtimes are still in use. Any unrelated Node process whose script had no package.json anywhere up to the filesystem root (for example a workspace server.mjs, or a long-lived 'node -e' helper such as LM Studio's) made package identity resolution throw, which aborted the whole census and kept every runtime forever. Such processes are now classified as not OpenClaw when their working directory is readable and the manifest search is exhausted. Every case with missing evidence (missing command, unavailable working directory, permission or timeout errors, unresolved runtime paths) retains the candidate runtimes with a warning naming the PID, and the census continues instead of aborting; existing exemptions are unchanged. Fixes openclaw#173082
Fixes #173082
What Problem This Solves
Post-update Doctor indefinitely retains abandoned updater runtimes when an unrelated Node process has no ancestor
package.json, including LM Studio's long-livednode -ehelper.User Impact
A process with readable cwd, no package manifest through the filesystem root, and no OpenClaw or retained-runtime evidence no longer prevents cleanup. Unavailable cwd still means unknown custody for every process unless main's existing foreign-owner or standard systemd/PAM exemption applies. Unknown custody retains all candidates it cannot exclude, emits one warning naming the PID and reason, and does not abort the census.
Thanks @DonnieFi, @angeliti999, and @woshicby for the Debian, Ubuntu, and macOS reports.
Why This Change Was Made
The package-identity owner (
src/infra/gateway-process-argv.ts, also bundled into service-child anchoring) distinguishes a completed search with no manifest from unreadable or malformed metadata. The census keeps explicit holder, not-holder, and unknown outcomes; Doctor consumes them per candidate runtime. Known resolved runtime paths preserve their candidates, while unscoped uncertainty preserves all candidates. Incomplete process enumeration or ancestry still prevents cleanup. Strict identity admission and update-repair handoff contracts remain conservative.All three accepted autoreview P1s are addressed. The second correction restores main's unavailable-cwd gate and its exact exemption predicates for all processes, including non-Node commands and scriptless Node. The parent command again verifies the systemd PAM exemption. Redundant holder-path construction and runtime-syntax warning reset bookkeeping were removed without dropping unresolved artifact evidence. A missing process command is now explicitly unknown; only the reader-admitted unavailable/empty-argv shapes retain their previous exemption. Unrelated missing-command rows reach per-PID classification instead of aborting the census preflight; missing inspector identity and incomplete ancestry still fail conservatively.
Evidence
Head:
519941cca53a086d9109ca7d55fb12983de8b198.91405918:/bin/sh worker.shand scriptless/usr/bin/node -ewith unavailable cwd were omitted from retention and emitted no warning; an absolute foreign Node script was also incorrectly excluded after a partial Darwin cwd scan. The corrected census retains them with warnings and continues inspecting later holders. Tests also preserve systemd/PAM and foreign-owner exemptions, no-manifest cleanup, and per-runtime decisions.9a1d12aa: the census aborts withOpenClaw process census is incomplete. With the correction it retains the unknown PID, reportsprocess command is unavailable, and continues to the later known holder. The existing empty-argv, foreign-owner, and systemd/PAM tests still pass.node scripts/run-vitest.mjs src/infra/openclaw-process-census.missing-command.test.ts src/infra/openclaw-process-census.test.ts src/infra/windows-process-census.native.test.ts src/infra/update-retained-runtime.test.ts src/plugins/plugin-source-capture-recovery.test.ts src/plugins/plugin-source-capture-directory.test.ts src/flows/doctor-retained-runtime.settlement.test.ts src/flows/doctor-plugin-source-captures.test.ts src/flows/doctor-retained-runtime.test.ts --maxWorkers=1.node scripts/run-tsgo.mjs --noEmit -p .artifacts/tsconfig.l1701.json, scopednode scripts/run-oxlint.mjs --tsconfig tsconfig.jsonon this correction’s production and regression files, oxfmt,git diff --check, and Madge pass. The temporary typecheck config extends the root config and includes the touched sources/tests and canonical ambient declarations.9a1d12aa: production +9 / -6 (net +3), tests +34 / -0 (net +34). Full PR versus merge base: production +202 / -129 (net +73), tests +212 / -109 (net +103), docs +1 / -1. The three production lines restore the explicit missing-command distinction; the regression uses a separate file because the existing census suite is at its lint size budget. No new configuration, dependency, schema, or persistent state.Real-process proof
Re-ran the production census and Doctor cleanup owner in an isolated local OrbStack Debian 13 VM (
l1701-proof, Node 24.22.0), with real manifest-freenode -eand/standalone/dist/index.jsprocesses, a permission-denied manifest, and a relative-entrypoint runtime holder with an equals-form preload. HOME and state were isolated; all children and the VM were removed afterward. No remote lease or operator Gateway was used.Commands:
docker run --rm --entrypoint cat node:24-bookworm /usr/local/bin/node > .artifacts/node; bundle the isolated proof entry withnode_modules/.bin/esbuild .artifacts/census-ruling-final.mts --bundle --platform=node --format=esm --banner:js='import { createRequire as proofRequire } from "node:module"; const require = proofRequire(import.meta.url);' --outfile=.artifacts/third-p1-live.mjs; create the local VM withorb create --isolated --mount "$PWD/.artifacts:/proof" --cpus 2 --memory 2G --disk 4G debian:trixie l1701-proof; runorb -m l1701-proof env HOME=/proof/home OPENCLAW_STATE_DIR=/proof/state TMPDIR=/proof-data/tmp /proof/node /proof/third-p1-live.mjs; remove it withorb delete --force l1701-proof.Limitations: this exercises Doctor's production census/cleanup boundary, not a complete published-version upgrade. A previous native macOS probe stopped before classification on the host's
ProcSafeError: incomplete: unterminated Darwin environment; deterministic Darwin fixtures cover unavailable cwd and partial/time-out scans. Fullcheck:changed/SQLite inventory remains skipped under the campaign's local gate budget; PR CI supplies broad proof.