Repository navigation
fix(process): classify macOS 27 system commands without an environment section - #185342
Conversation
…t section On macOS 27, hardened executables (Apple daemons, /bin/zsh, /bin/sleep, even when spawned with OPENCLAW_SERVICE_MARKER) expose argv but no envp in KERN_PROCARGS2, so requesting the service marker threw `incomplete` and the process census marked ~95% of same-user processes unknown custody, blocking Doctor runtime reclaim, update repair and update finalization. Re-read argv only when the marker read is incomplete. JS runtimes keep the error (unknown custody), since only they need the marker to classify, matching Linux where /proc environ is consulted only for runtime executables. Fixes #183957
|
🦞👀 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 changesThis PR falls back to exact argv for non-runtime macOS processes whose environment cannot be read, while preserving uncertainty for JavaScript runtimes. Example: On macOS 27.0.1, /bin/sleep 30 inherits OPENCLAW_SERVICE_MARKER=openclaw but exposes no environment section.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current macOS maintenance failure that remains on main, and review found no concrete introduced defect. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Darwin command adapter translates proc-safe observations into process facts consumed by runtime custody inspection, Gateway lock inspection and orphan cleanup. flowchart TD
A[Darwin process arguments] --> B[proc safe inspection]
B --> C[Darwin command adapter]
C --> D[Process custody census]
D --> E[Doctor runtime reclamation]
D --> F[Update maintenance]
Technical reviewBest possible solution: Keep this focused adapter fix, preserving native parser strictness, runtime uncertainty and existing artifact-reference checks. Do we have a high-confidence way to reproduce the issue? The dependency parser and current-main call path establish the failure, corroborated by the linked published-package reproduction; this review executed no target code. Is this the best way to solve the issue? The fallback belongs in the existing application adapter because proc-safe must report unavailable environment facts accurately while OpenClaw decides which processes require them. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4fa15de9e5d7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +30. Total +53 across 3 files. Added test files: 0. View PR surface stats
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, 10:51 PM ET / October 27, 2026, 02:51 UTC. |
|
Merged via squash.
|
…t section (openclaw#185342) On macOS 27, hardened executables (Apple daemons, /bin/zsh, /bin/sleep, even when spawned with OPENCLAW_SERVICE_MARKER) expose argv but no envp in KERN_PROCARGS2, so requesting the service marker threw `incomplete` and the process census marked ~95% of same-user processes unknown custody, blocking Doctor runtime reclaim, update repair and update finalization. Re-read argv only when the marker read is incomplete. JS runtimes keep the error (unknown custody), since only they need the marker to classify, matching Linux where /proc environ is consulted only for runtime executables. Fixes openclaw#183957
What Problem This Solves
Fixes #183957. On macOS 27, the process census marks almost every same-user process as unknown runtime custody. That blocks Doctor runtime reclaim,
openclaw update repair, and update finalization.On macOS 27.0.1,
KERN_PROCARGS2for hardened executables ends right after argv, with no envp section.@openclaw/proc-safetherefore throwsincomplete: unterminated Darwin environmentwheneverOPENCLAW_SERVICE_MARKERis requested. Since #178705 the census keeps going, but each such PID becomes "process command is unavailable", which is unknown custody and blocks.This is not limited to Apple daemons.
/bin/sleep,/bin/zshandcaffeinate, spawned from Node withOPENCLAW_SERVICE_MARKER=openclaw, all hide their environment too. So treating the missing section as an empty environment would be wrong: it would silently drop the marker from gateway child shells.Why This Change Was Made
readDarwinProcessCommandnow re-reads argv only when the marker read isincomplete.incompleteerror and stays unknown custody. It is the only kind of process whose OpenClaw identity can depend on the marker.This matches Linux, where
classifyOpenClawArgvreads/proc/<pid>/environonly for runtime executables. A non-runtime process carrying an inherited marker cannot run OpenClaw code unless its argv or cwd references the artifact, and that reference check is unchanged.Callers that skip the marker are unchanged.
reapOrphanedProcesses(plugin SDK) and the gateway lock argv read also stop failing on macOS 27 system commands.Production delta: +27/−4 in one file. No config, schema, protocol, or proc-safe change.
Evidence
inspectOtherOpenClawProcesses()directly:darwin-process-command.test.ts): a hardened non-runtime executable returns argv; node, bun and tsx keepincomplete;darwin-process-command.native.test.ts): reads/bin/sleep 30spawned with the marker.unterminated Darwin environment) and pass here.darwin-process-command{,.native}.test.tsplusopenclaw-process-census.test.ts: 77 tests pass.tsgo:corepasses, core oxlint shard passes, and oxfmt is clean.