Repository navigation
fix: Doctor skips capture cleanup when unrelated Node services run - #157102
Conversation
Verify runtime entrypoints against resolved package ownership and share explicit OpenClaw, unrelated, and unclassified outcomes across process consumers. Preserve captures and locks when ownership cannot be established. Fixes #156896. Thanks @xilopaint for the namespace reproduction.
|
🦞👀 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: needs real behavior proof before merge. Reviewed September 24, 2026, 2:56 AM ET / 06:56 UTC. ClawSweeper reviewWhat this changesThe branch makes Doctor and Gateway process discovery classify generic Node entrypoints by resolved package identity, with updated platform adapters, tests, and troubleshooting guidance. Merge readiness⛔ Blocked before merge - 5 items remain This PR addresses the reported Doctor false positive, and current main still contains it. The proposed classifier has a separate ownership gap on Linux: Doctor can read a live process’s package identity from the wrong mount namespace, then reclaim a capture that process still needs. Priority: P1 Review scores
Verification
How this fits togetherDoctor inspects legacy plugin captures before removing them during maintenance. A host process census supplies owner identities; its result also informs Gateway discovery and restart decisions. flowchart TD
A[Doctor maintenance] --> B[Legacy captures]
A --> C[Host process census]
C --> D[Process command and filesystem identity]
D --> E{OpenClaw owner or uncertain?}
E -->|Yes| F[Preserve captures]
E -->|No| G[Reclaim eligible captures]
Before merge
Findings
Agent review detailsSecurityNeeds attention: Cross-namespace package lookup can weaken the process-ownership guard for legacy capture deletion. PR surfaceSource +200, Tests +611, Docs +9. Total +820 across 31 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Resolve a Linux PID's script and package manifest through that PID's filesystem view, preserve an explicit unknown result when identity cannot be established, and prove the final Doctor deletion decision with colliding paths across mount namespaces. Do we have a high-confidence way to reproduce the issue? Yes for the reported defect: the reporter supplied a public Doctor reproduction on published 2026.9.6, and current main retains the same classifier. The cross-mount safety case identified in this review has source evidence but no observed final-effect run. Is this the best way to solve the issue? No as submitted: a shared classifier is the appropriate owner, but its Linux package check must use the target process's mount view before it can authorize capture removal. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a3210acd3db8. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…#157102) Verify runtime entrypoints against resolved package ownership and share explicit OpenClaw, unrelated, and unclassified outcomes across process consumers. Preserve captures and locks when ownership cannot be established. Fixes openclaw#156896. Thanks @xilopaint for the namespace reproduction.
Fixes #156896.
What Problem This Solves
Doctor can leave legacy plugin captures on disk indefinitely when an unrelated Node service runs
node dist/index.js.User Impact
Doctor can reclaim eligible captures when the process belongs to a verified unrelated package. Actual OpenClaw owners still prevent reclamation. Unclassifiable live PIDs, including missing or unreadable package metadata, preserve captures with an explicit PID and reason instead of being reported as OpenClaw. These remain maintenance warnings; updates continue best effort.
Why This Change Was Made
The shared process classifier accepted any argument ending in generic names such as
dist/index.js. It now identifies the runtime script, resolves relative paths using the observed process working directory, and checks the resolved installation's package identity. Doctor also reads the existing OpenClaw service marker; maintenance leases and SQLite capture custody remain authoritative and unchanged.The same classifier serves update/restart discovery, Gateway verification, and legacy lock recovery. On Windows, process control can fall back to verifying a relative entrypoint through the existing current Gateway lease, binding the listener PID, native creation identity, port, and selected service environment; it rechecks ownership before signaling. Unknown lock owners remain unknown. Windows stale cleanup warns and leaves unclassified listeners running; it never uses a live owner lease as evidence that its owner is stale. Linux uses procfs cwd; Darwin uses exact native argv and NUL-delimited cwd inspection. The separate port-error hint no longer treats generic script names as OpenClaw.
Thanks @xilopaint for the unmodified-package namespace reproduction and detailed diagnosis.
Evidence
The Linux importer run on Blacksmith Testbox
tbx_01m38sv9n2ftkxbc0gagn7xtzq(run) covered all 123 selected files in their original order: 4,454 passed, 35 existing skips, no failures (1,043.16 s total across 14 groups, including shared compiler preparation). The additional status-all diagnosis suite passed all 30 tests on Linux and locally.pnpm check:changedandpnpm buildpassed on Blacksmith Testboxtbx_01m38zmqvydsn0jy1cjcx3rrx5(run); command exit 0. The earlier lease expired during an earlier check attempt; only the completed replacement is claimed here.The public
openclaw.mjs doctor --fix --non-interactive --yes --no-workspace-suggestionsentrypoint passed all five Linux PID/mount/network-namespace cells with isolated state and ports:node dist/index.jsstill runningOn the same Testbox, unmodified published 2026.9.6 installed through pnpm reproduced the defect: control removed the capture (4.134 s); unrelated
node dist/index.jspreserved it and was incorrectly named as OpenClaw (3.738 s). No container or ownership guard was bypassed.The unmodified published 2026.9.6 updater → candidate cell passed on Blacksmith Testbox
tbx_01m3909bmvsfx5j0ph0wqbcs2x(run). Public command:node <published-root>/openclaw.mjs update --tag <candidate.tgz> --yes --json --no-restart, using the isolated install prefix, cached dependencies, and disconnected network namespace. Update reportedstatus: ok, exit 0, in 86.720 s; all 10,877 installed dist files matched the candidate artifact. The capture remained while the real updater parent was live. Afterward the installed candidate's public Doctor removed it in 3.898 s, with the unrelated Node child still alive.The source package's version metadata is 2026.9.5, so the existing first-hop fixture helper stamped only the isolated artifact's supported version metadata as
2026.9.99-first-hop.0; repository metadata and runtime code were unchanged. Original candidate SHA-256:fafc5974fe5916fd7249ca48caa2221392d6d2164b4ac08f11abd50558b213b2; fixture SHA-256:2861184e34a4042b15f73b49a0dabd42c4da172b06f2ce522285faf3c805e056. The first attempt stopped before installation because user-namespace UID remapping made root-owned ancestors appear unowned. The corrected harness preserved the runner UID/GID and root ownership; no product guard was weakened. A source-freeze retry after staging was also confined to harness preparation.Fresh Codex autoreview
--mode branch --base origin/mainon commit9458eeaec012d6b20d83fedec146c7f6a42f3aa8: scoped-clean, no actionable P0–P2 findings. The committed tree is identical to the tree used for importer, gate, build, and native proof:667be109dfe45ee44ff613b842bef5259b7a0b2d.The original census unit regression reproduced the false positive: an unrelated Node PID appeared as an OpenClaw owner. The two Windows Startup fallback failures encoded the same invalid assumption with nonexistent generic paths. Their fixtures now create real
dist/index.jsfiles beneath roots whosepackage.jsondeclaresname: "openclaw"; persisted-command mismatch, no-termination, and running/PID assertions are unchanged. All 87 Startup fallback tests pass; the Linux file accumulated 503.29 ms of test work.Production is +439/−239 lines (net +200). Tests/support are +939/−328; documentation is +10/−1. The shared classification owner contains runtime option arity, canonical CLI command selection, resolved package identity, native cwd inspection, and explicit ownership/uncertainty facts. Remaining call-site changes are:
Windows host-wide capture cleanup remains report-only. No new public options, dependencies, schemas, or baseline suppressions. macOS and Windows native live proof are not available from the Linux Testbox; their adapters have unit coverage.
The importer harness returned its timing-only exit 3 after all assertions passed; the maintainer overruled this timing gate and assigned the fixture-performance work separately. Existing slow but passing suites remain in importer coverage with their assertions and test tier unchanged:
update-cli.test.ts279.702 s,doctor-health.test.ts161.095 s, andupdate-command-original-service.test.ts121.576 s of accumulated test time. These repeated state/process fixture costs are tracked separately from this classifier change.Changed test-file cost
Measured on Linux with
pnpm test <file> --maxWorkers=1. Wall time includes shared transform/setup; test time is the accumulated measured test work. Hosted PR CI timings are pending.restart.test.tsports-format.test.tsschtasks.startup-fallback.test.tsdiagnostic-process-siblings.env.test.tsgateway-processes.test.tsrestart-stale-pids.cwd.test.tslifecycle.test.tsgateway-process-argv.test.tsopenclaw-process-census.test.tsgateway-lock.test.tsrestart-stale-pids.test.tsports.test.tsdarwin-process-command.test.tsdoctor-plugin-source-captures.test.ts