Repository navigation
fix(doctor): unrelated macOS processes block updater runtime cleanup - #185359
fuller-stack-dev wants to merge 1 commit into
Conversation
…time cleanup The Darwin process census read OPENCLAW_SERVICE_MARKER for every process. Many same-user platform binaries (webprivacyd, mdworker_shared, ssh, sleep) have an argument image whose environment is unterminated, so proc-safe failed the whole read with `incomplete` and the census recorded unknown custody. Doctor and post-update cleanup then retained every openclaw-update-runtime directory. The marker only identifies Node/Bun/tsx runtimes, as on Linux. When only the environment is unbounded, re-read exact argv and classify the process normally; runtime executables keep unknown custody. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🦞👀 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 changes before merge. What this changesRetry incomplete macOS environment inspection without environment data for non-runtime processes while preserving uncertain custody for Node, Bun, and tsx. Example: On macOS 27, /bin/sleep 62 runs outside /tmp/openclaw-update-runtime-Held01 and its environment cannot be inspected.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authored PR addresses a current cleanup failure, but the fallback should use the existing shared Darwin command reader. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherDoctor and updater cleanup consume the process census, which combines native command observations, working directories, package identity, and artifact references to decide whether disposable runtimes remain held. flowchart TD
A[Darwin process observations] --> B[Shared Darwin command reader]
B --> C[Census fallback added here]
C --> D[Artifact custody classification]
D --> E[Doctor and updater cleanup]
B --> F[Gateway lock inspection]
B --> G[Orphan process cleanup]
Technical reviewBest possible solution: Consolidate the fallback in the shared Darwin command reader, retaining runtime uncertainty and the distinct custody regressions from this PR. Do we have a high-confidence way to reproduce the issue? The dependency parser and current-main census establish the cleanup-blocking path, corroborated by native results in this PR and the published-package reproduction at #183957; this review ran no target code. Is this the best way to solve the issue? The runtime-preserving fallback is appropriate application policy, but placing it in the existing Darwin reader provides one implementation for affected consumers, as demonstrated by #185342. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9ef140709309. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +30, Tests +46. Total +76 across 4 files. Added test files: 0. 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. 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 26, 2026, 11:08 PM ET / October 27, 2026, 03:08 UTC. |
|
Superseded by #185342 (merged as a9e413e), which applies the same fallback in the shared |
What Problem This Solves
Fixes: on macOS,
openclaw doctor --fixand post-update cleanup never remove retainedopenclaw-update-runtime-XXXXXXdirectories. Hundreds of unrelated system processes are reported as holders with "Could not verify runtime custody for PID N: process command is unavailable".User Impact
User impact: on macOS, unrelated processes like
webprivacyd,mdworker_shared,ssh, orsleepno longer block runtime cleanup. A retained runtime is kept only while a Node/Bun/tsx runtime, an OpenClaw process, or a process whose argv, cwd, or executable points into the runtime might still hold it. On one affected Mac this left 3–4 retained runtimes (~10.5 GB) that Doctor could not reclaim.Why This Change Was Made
To identify OpenClaw services, the Darwin census reads
OPENCLAW_SERVICE_MARKERfrom every process. On current macOS, many same-user platform binaries have an argument image whose environment section is unterminated. proc-safe then fails the whole read withincomplete, even though argv reads fine without the environment, and the census records "command unavailable" (unknown custody), which blocks removal.On Linux the marker can only identify Node/Bun/tsx runtimes. This change applies the same rule on Darwin. When only the environment is unbounded, the census re-reads exact argv and classifies the process normally. Runtime executables still fail closed, because their marker can change identity. The runtime predicate now lives in one place,
isServiceMarkerRuntime, shared by both platforms.Accepted edge case: a non-runtime process whose environment is unbounded and that carries
OPENCLAW_SERVICE_MARKER=openclawis classified by its argv and cwd alone. That matches Linux. Its marker-bearing runtime children still block.Evidence
Reproduced on macOS 27.2 (arm64), real census, no mocks, before editing (base
ce069f9f837; rechecked atf0e7a65c63cand rebased onto4fa15de9e5d; neither range touches the census, process, or classification paths):webprivacyd,/bin/sleep, andmdworker_sharedwithincomplete: unterminated Darwin environment. Reading the same PIDs without the environment returns exact argv.maintainRetainedUpdateRuntimes(the Doctor retirement path) with the live census on an isolated, planted, marker-valid runtime that nothing references:f0e7a65c63cOn this PR, the remaining 36 blockers on that host are OpenClaw processes (fleet
node runservices, gateway, supervisor relays, OpenClaw.app), Node test runs inside OpenClaw worktrees, and two third-party Node processes whose script could not be resolved. Those intentionally stay fail-closed, so the full "Removed abandoned updater runtime" outcome was not observed on a host with OpenClaw running.Tests (red on base, green here):
openclaw-process-census.test.ts› "classifies other Darwin processes by exact argv when their environment is unbounded". Base retains thewebprivacydfixture with "process command is unavailable". The same case keeps a/bin/sleepwhose cwd is inside the runtime, and a process whose executable image is inside the runtime, as holders.openclaw-process-census.native.test.ts› "retains a runtime only for real processes working inside it". Uses real orphaned/bin/sleepprocesses on macOS. Base reports the unrelated sleep along with 335 other PIDs; this PR reports only the one working inside the runtime./bin/sleeprow, which asserted the bug, was replaced by the test above.Checks: focused
pnpm testover the census, retained-runtime, process-custody, Darwin command, argv classification, and plugin source-capture suites: 149/150 passed. The one failure is the existing native handoff test "finds a real non-Node process holding retained handoff paths". It flakes on the unmodified base too (1 of 6 runs failed with "Host process census is incomplete"). This change does not touch the handoff path, which already reads argv without the environment. After rebasing, the census, Darwin command, and missing-command suites pass 79/79.pnpm tsgo:coreis clean, oxlint and oxfmt are clean on the changed files, andgit diff --checkis clean.🤖 Generated with Claude Code