Skip to content

fix(process): classify macOS 27 system commands without an environment section - #185342

Merged
steipete merged 1 commit into
mainfrom
codex/issue-183957
Oct 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/issue-183957

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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_PROCARGS2 for hardened executables ends right after argv, with no envp section. @openclaw/proc-safe therefore throws incomplete: unterminated Darwin environment whenever OPENCLAW_SERVICE_MARKER is 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/zsh and caffeinate, spawned from Node with OPENCLAW_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

readDarwinProcessCommand now re-reads argv only when the marker read is incomplete.

  • A JS runtime (node, bun, or tsx) keeps the original incomplete error and stays unknown custody. It is the only kind of process whose OpenClaw identity can depend on the marker.
  • Every other executable is classified from its exact argv, executable and cwd, as before.

This matches Linux, where classifyOpenClawArgv reads /proc/<pid>/environ only 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

  • Real census on this macOS 27.0.1 (26A434) arm64 host, calling inspectOtherOpenClawProcesses() directly:
    • main: 705 blocking PIDs, 664 of them "process command is unavailable";
    • this branch: 37 blocking PIDs, 0 unavailable. The rest are real Node/OpenClaw processes with unresolved scripts or package names.
  • Regressions:
    • unit table (darwin-process-command.test.ts): a hardened non-runtime executable returns argv; node, bun and tsx keep incomplete;
    • native test on Darwin (darwin-process-command.native.test.ts): reads /bin/sleep 30 spawned with the marker.
    • Both fail on main (unterminated Darwin environment) and pass here.
  • darwin-process-command{,.native}.test.ts plus openclaw-process-census.test.ts: 77 tests pass.
  • tsgo:core passes, core oxlint shard passes, and oxfmt is clean.

…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
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 27, 2026 02:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T02:37:28.192919Z 3ba54d0 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The marker read throws incomplete, leaving the process with unknown custody and potentially blocking maintenance.
  • After: The reader returns /bin/sleep and its exact argv; existing artifact-reference checks determine custody.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and has relevant native and regression evidence; confidence in the complete maintenance flow is limited to direct census evidence.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor-proof gate does not apply to this maintainer-authored PR; supplied evidence reports a real macOS 27 census and native child inspection, rather than a shipped Doctor or update command run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ordinary macOS 27 processes can prevent Doctor and update maintenance from completing because their unavailable environments become unknown runtime custody.
Reason: The maintainer-authored direction repairs a concrete failure through the existing owner without adding configuration, changing the native contract or weakening runtime-marker uncertainty.

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
Reviewed head: 3ba54d0db4e941588d4c3c9ed876772ce1919bea

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Darwin command inspection keeps the original intent (698cac4: The native-package cutover moved OS parsing into proc-safe while retaining application lifecycle policy and conservative unknown observations.)
  • Marker-free callers and regression coverage keeps the original intent (45314c9: Handoff inspection needs argv and cwd but cannot rely on macOS exposing environments; callers explicitly skipping the marker avoid that read.)
  • Incomplete-environment custody changes intended behavior with a stated reason (4797b07: Continue observing later processes without treating an unavailable service marker as absent; the PR explains why non-runtime classification can instead use exact argv while runtimes retain uncertainty.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 698cac4 adds src/process/supervisor/darwin-process-command.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 698cac4c78b8; files: src/process/supervisor/darwin-process-command.ts)

PR surface

Source +23, Tests +30. Total +53 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 27 4 +23
Tests 2 39 9 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 66 13 +53

Root-cause cluster

Relationship: same_root_cause
Canonical: #183957
Summary: This PR addresses the reported missing-envp custody failure; the earlier census repair addressed global abortion while retaining uncertain processes.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P1: The reported macOS process-inspection failure blocks Doctor reclamation and update maintenance on affected hosts.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The reported macOS process-inspection failure blocks Doctor reclamation and update maintenance on affected hosts.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 10:51 PM ET / October 27, 2026, 02:51 UTC.

@steipete
steipete merged commit a9e413e into main Oct 27, 2026
209 checks passed
@steipete
steipete deleted the codex/issue-183957 branch October 27, 2026 03:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant