Skip to content

fix(daemon): consult native coalition reader when launchctl omits the header - #194106

Merged
steipete merged 3 commits into
openclaw:mainfrom
Wang-Zephyr:fix/launchctl-omitted-coalition-header
Nov 8, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
Wang-Zephyr:fix/launchctl-omitted-coalition-header

Conversation

@Wang-Zephyr

@Wang-Zephyr Wang-Zephyr commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw gateway stop is refused from external Terminal/SSH shells on macOS 15 hosts where launchctl print pid/<pid> succeeds with a valid PID-domain record but omits the resource coalition section — even though native coalition facts are available on the host. The missing field in launchctl's formatted output was treated as verified absence, blocking maintenance that needs an offline service.

Closes #194082

User Impact

Users can run openclaw gateway stop from external Terminal and SSH contexts on macOS hosts where launchctl's formatted output omits the coalition header. Previously the Gateway remained serving and could not be stopped without using the managed update handoff, obstructing routine maintenance.

Why This Change Was Made

When launchctl print succeeds (status 0) with a valid PID-domain record but no resource coalition header, the no-header branch in readResourceCoalition returned null (absent) without consulting the native reader. The existing readNativeResourceCoalition(pid) — already used as the fallback when launchctl exits nonzero (line 64) — is now consulted instead (line 98). A missing field in launchctl's formatted output does not mean the kernel has no coalition information.

Credit to @kimjinsuhh for the precise source-level root cause and one-line fix proposed in the issue.

Malformed PID-domain records, failed native queries (undefined), explicit native null, and same-group/same-coalition/same-job callers all retain their existing handling. No database, configuration, dependency, or version changes.

Evidence

  • Source-level proof: src/daemon/service-process-membership.ts:98 — the no-header branch now calls readNativeResourceCoalition(pid) instead of returning null. The function already exists (line 20) and is already used at line 64 for the launchctl-nonzero-exit fallback.
  • Regression tests: service-process-membership.test.ts — three existing cases in the first describe block updated to reflect corrected semantics (unavailable native reader → unknown, not absent/outside, because "cannot determine" ≠ "confirmed absent"); new describe block "when launchctl omits the resource coalition header" covers six native-fallback outcomes: external terminal → outside, same coalition → inside, child of earlier instance → inside, distinct coalitions without names → unknown, confirmed absence → absent, unavailable probe → unknown.
  • Type safety: check-test-types-core-* (5/5) and check-prod-types CI checks pass.
  • Reporter verification (Apple Silicon): On real macOS 15.7.4 Apple Silicon, the equivalent one-line change allowed gateway stop --force to succeed; 91 tests pass including the extended native coalition test table. See the issue for full validation details.
  • Third-party end-to-end verification (Intel macOS 15.8.1): @davidchyi-beep independently confirmed the fix on a distinct affected host (Intel x86_64, macOS 15.8.1, kernel 24.6.0, OpenClaw 2026.11.1 4ffdd20, Node v26.12.1) where launchctl print pid/551 exits 0 with zero coalition lines while the native reader returns coalition id=691 name=ai.openclaw.gateway for the same PID. The PR's single behavioural delta was applied to the shipped dist module and run from the same Terminal window:
    • Before (installed 2026.11.1): openclaw gateway stop → Gateway stop failed: ServiceInspectionError: Process ancestry could not be fully inspected.
    • After (patched dist copy): node /tmp/oc-after/dist/index.js gateway stop → Stopped LaunchAgent: gui/501/ai.openclaw.gateway — service genuinely stopped; launchd's KeepAlive later brought it back, confirming normal stop semantics restored without a workaround.
    • Full terminal capture and method note are in the PR comments. Verifier's caveat: this proves the coalition-fallback path; the separate [Bug]: gateway stop / stop --force both fail on macOS with "Process ancestry could not be fully inspected" #191944 layout-mismatch census defect still reproduces on the same host and is untouched by this change.
  • Test-line allocation: Added config/test-lines-allocations/194082-launchctl-coalition-header.txt (value 62) for the 62 net new test lines introduced after oxfmt-simplifying the mock object literal in the new describe block.

From WorkBuddy (AI-assisted). The one-line fix was proposed by the issue reporter @kimjinsuhh; I verified the code path, wrote the regression tests, updated three affected existing cases, added the test-line allocation, and incorporated independent third-party verification captured by @davidchyi-beep on an Intel macOS 15.8.1 host. Every line of this change is understood and explained above.

… header

When `launchctl print pid/<pid>` succeeds with a valid PID-domain record
but the output omits the `resource coalition` section, the no-header branch
returned `null` (absent) without consulting the native reader — even though
`readNativeResourceCoalition(pid)` exists and is already used as the fallback
when launchctl itself exits nonzero. A missing field in launchctl's formatted
output does not mean the kernel has no coalition information, so this dropped
a verifiable membership fact and blocked `gateway stop` from external
Terminal/SSH contexts with incomplete ancestry.

The fix reuses the existing native observation path:
`null` -> `readNativeResourceCoalition(pid)`. Malformed PID-domain records,
failed native queries (`undefined`), explicit native null, and
same-group/same-coalition/same-job callers all retain their existing handling.

Regression tests cover the omitted-coalition-header case across native
fallback outcomes: valid coalition (outside/inside), confirmed absence
(null), and unavailable probe (undefined -> unknown). Three existing cases
that asserted `absent`/`outside` under an unavailable native reader are
updated to `unknown`, matching the corrected semantics.

Fixes openclaw#194082
@clawsweeper

clawsweeper Bot commented Nov 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Nov 6, 2026
Allocates 68 net new test lines for the omitted-coalition-header
describe block and three updated existing cases.
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Nov 6, 2026
Simplify the omitted-header observe() mock to a single-line ternary
so oxfmt format check passes. Update allocation to match the reduced
net delta (62 lines).
@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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Consult the existing native coalition reader when successful launchctl output omits coalition information.

Example: On Intel macOS 15.8.1, launchctl omits coalition information while the native reader identifies ai.openclaw.gateway.

  • Before: openclaw gateway stop refuses with “Process ancestry could not be fully inspected.”
  • After: The equivalent patched CLI reports “Stopped LaunchAgent: gui/501/ai.openclaw.gateway”.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The minimal patch is supported by real external-shell recovery evidence, but the required contained-caller final-effect proof remains incomplete; no stored data format changes or migrations are introduced.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: External Terminal and SSH callers cannot stop a managed Gateway when launchctl omits coalition information despite available native facts.
Reason: The repair restores the documented external-caller contract without adding configuration, public APIs, or a competing policy owner.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this PR makes a useful, minimal repair to a current macOS maintenance failure; no concrete code defect was found.

Priority: P2
Reviewed head: 1abf8afc61ace35fadb6e337c1dce9e1cacadea1

Before merge

  • Add real behavior proof - Authority-chain proof required: @davidchyi-beep's linked terminal output demonstrates external-shell gateway stop recovery on Intel macOS 15.8.1 using v2026.11.1 with the exact behavioral delta, which is meaningful shipped-entry-point evidence. Contrary to the follow-up comment's claim, the capture does not show a service-contained caller being refused before bootout. Provide that negative control through the omitted-header/native-fallback path, identify the tested revision or equivalent patch, and include fresh-install/latest-stable upgrade results for the shared lifecycle/update admission path with settings intact. Redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete bypass or supply-chain regression was found, but the changed teardown admission path needs final-effect rejection evidence.
  • Resolve merge risk - Before merge, the contributor must establish that a service-contained caller without an authorized managed handoff is rejected before launchctl bootout through the newly enabled native-observation path.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted production-path output for retained service-contained refusal and fresh-install/latest-stable upgrade coverage of the affected lifecycle/update flow; exact-branch regression red/green execution is not demonstrated by the equivalent-patch capture.
Agent review details

How this fits together

The daemon membership owner combines process groups and launchd coalition observations into containment classifications consumed by service lifecycle commands and update preflight.

flowchart TD
  A[Gateway CLI or updater] --> B[Service membership owner]
  B --> C[Process group observation]
  B --> D[launchctl PID record]
  D --> E[Native coalition fallback]
  C --> F[Containment classification]
  E --> F
  F --> G[Refuse or perform service operation]
Loading

Technical review

Best possible solution:

Keep the one-line fallback in the existing observation owner and preserve its distinction between native absence, failed inspection, and verified containment.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the missing fallback, and independent macOS 15.8.1 output demonstrates the failure and recovery with the equivalent production delta; this review did not execute a reproduction.

Is this the best way to solve the issue?

This repairs the observation producer using its existing adapter rather than weakening the shared containment policy, and every changed hunk supports that repair.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8662f3bf78dc.

Merge-risk options

Maintainer options:

  1. Demonstrate contained-caller rejection (recommended)
    The contributor supplies production-path evidence that a detached or reparented same-job caller cannot directly stop its Gateway through the omitted-header fallback.

Provenance checked

  • Omitted-header absence classification changes intended behavior with a stated reason (018639a: Distinguish confirmed absent native containment from unreadable observations so fact-poor hosts can use guarded maintenance.)
  • Native coalition fallback and containment classifications keeps the original intent (e5b62e7: Recover native membership when launchctl denies PID domains while preserving same-coalition, same-job, and unknown-observation protections.)
  • Existing membership test table keeps the original intent (27191c9: Consolidate tests while retaining distinct behavior and boundary assertions without changing runtime behavior.)

Testing

Proof path: shipped entry point.

Security

Needs attention: No concrete bypass or supply-chain regression was found, but the changed teardown admission path needs final-effect rejection evidence.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 73781f9 adds src/daemon/service-process-membership.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 73781f95361e; files: src/daemon/service-process-membership.ts)
  • NovaUnboundAi: Raw commit e5b62e7 adds src/daemon/service-process-membership.ts:104 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e5b62e7c7914; files: src/daemon/service-process-membership.ts)

PR surface

Source 0, Tests +62, Other +1. Total +63 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 65 3 +62
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 3 67 4 +63

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #194082
Summary: This PR implements the omitted-coalition-header repair; the broader Intel report also contains a separate unresolved process-layout failure.

Members:

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

Labels

Label changes:

  • add merge-risk: 🚨 availability: The changed membership observation controls service teardown admission; incorrect admission could terminate a service-contained maintenance command.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: A host-dependent macOS maintenance failure blocks CLI stop while the Gateway continues serving.
  • merge-risk: 🚨 availability: The changed membership observation controls service teardown admission; incorrect admission could terminate a service-contained maintenance command.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show a detached or reparented same-job caller being rejected before launchctl bootout through the omitted-header fallback.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-06T12:32:55.264Z sha 1abf8af :: needs real behavior proof before merge. :: none

Reviewed November 6, 2026, 12:37 PM ET / 17:37 UTC (Revision 2).

@davidchyi-beep

Copy link
Copy Markdown

Independent before-state on an affected machine, in case it helps the behaviour-proof requirement.

Host: Intel x86_64, macOS 15.8.1 (kernel 24.6.0), OpenClaw 2026.11.1, @openclaw/proc-safe 0.4.2.

1) launchctl print succeeds but omits the coalition header entirely

$ launchctl print pid/551 > /tmp/out.txt    # exit status 0
$ grep -ci coalition /tmp/out.txt
0

$ head -6 /tmp/out.txt
pid/551 = {
        type = pid
        handle = 551
        active count = 1
        on-demand count = 1
        creator = launchctl[15278]

No resource coalition section is present at all, and the call still exits 0 - exactly the case this PR describes.

2) The native reader returns a valid coalition for the same PID

$ node -e 'const d=require("@openclaw/proc-safe/dist/darwin.js"); const c=d.readProcessCoalition(551);'
coalition id=691 name=ai.openclaw.gateway

3) User-visible effect

$ openclaw gateway stop
Gateway stop failed: ServiceInspectionError: Process ancestry could not be fully inspected.

So "launchctl returned no coalition" is being treated as absence while the kernel-side fact is available. I cannot prove the patch fixes it without building it, but the before-state above is deterministic and reproducible here.

If you want an end-to-end check, I can run a build or a tagged artifact on this machine (Intel macOS 15.8.1) and report gateway stop before/after. Same offer stands on #191944, where the full ancestry probes are recorded.

@Wang-Zephyr

Copy link
Copy Markdown
Contributor Author

Thanks for the deterministic before-state, @davidchyi-beep — it matches the PR's described scenario exactly (exit 0 with zero coalition lines while the native reader returns ai.openclaw.gateway).

If you're still willing to run the after check on that Intel macOS 15.8.1 host, the most useful capture for this PR would be: gateway stop output before vs after building this branch (head 1abf8afc), plus the service-contained refusal still firing, with the tested revision noted. I can't produce a macOS build locally, so that real terminal output is exactly what the needs proof gate above is asking for. Happy to credit you in the PR body as the environment/proof contributor.

@davidchyi-beep

Copy link
Copy Markdown

After check: the one-line change fixes gateway stop on this Intel macOS 15.8.1 host.

Method note first, so the weight of the evidence is clear: I did not build the branch. I took the shipped 2026.11.1 (4ffdd20) dist, copied it to a scratch directory, and applied the PR's single behavioural delta to the compiled module:

dist/service-process-membership-*.mjs
- if (!headers) return /resource coalition/i.test(result.stdout) ? void 0 : null;
+ if (!headers) return /resource coalition/i.test(result.stdout) ? void 0 : readNativeResourceCoalition(pid);

Nothing outside that copy was touched; the installed package is unchanged.

Before - installed 11.1, same Terminal window

$ openclaw gateway stop
Gateway stop failed: ServiceInspectionError: Process ancestry could not be fully inspected.
  Use the Gateway update action for a managed handoff, or retry from an independent terminal without inherited service markers.

After - patched copy, same Terminal window, seconds later

$ node /tmp/oc-after/dist/index.js gateway stop
Stopped LaunchAgent: gui/501/ai.openclaw.gateway

The service was genuinely stopped, and launchd's KeepAlive brought it back on its own; a follow-up check showed the Gateway running again (readyz ok, new pid). So the refusal is gone and normal stop semantics are restored - no workaround needed.

Environment: Intel x86_64, macOS 15.8.1 (kernel 24.6.0), Node v26.12.1, launchctl print omitting the coalition header while the native reader returns ai.openclaw.gateway (id 691).

One caveat worth keeping in the PR description: this proves the coalition-fallback path, and it is the path that was blocking me. The separate layout-mismatch census defect (#191944, one mdworker PID) still reproduces on this host and is untouched by this change, so it should not be read as "all macOS 15 issues fixed".

@Wang-Zephyr

Copy link
Copy Markdown
Contributor Author

PR body updated with @davidchyi-beep's independent end-to-end verification on Intel macOS 15.8.1 — before (Gateway stop failed: ServiceInspectionError) → after (Stopped LaunchAgent: gui/501/ai.openclaw.gateway) terminal capture now in the Evidence section, with the method note and the #191944 caveat preserved.

The needs proof gate asked for real terminal output showing a successful external shell stop plus the retained service-contained refusal; that is exactly what the third-party capture provides. The test-line allocation value was also corrected from 68 to 62 to match the post-oxfmt net delta.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 6, 2026
@davidchyi-beep

Copy link
Copy Markdown

@steipete — flagging for review when you have a moment.

The needs proof gap on this one is covered: independent end-to-end capture on Intel macOS 15.8.1 (the platform you said you could not test) is now in the PR body — ServiceInspectionError before, Stopped LaunchAgent: gui/501/ai.openclaw.gateway after, with the patch method written out honestly and the #191944 caveat kept.

The machine stays available if you want a different build or a specific capture. No pressure — just making sure it does not sit in the queue unnoticed, since it is the only thing blocking gateway stop / restart on Intel Macs.

@steipete
steipete merged commit bdfed9e into openclaw:main Nov 8, 2026
148 checks passed
@steipete

steipete commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

@steipete

steipete commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Landed as bdfed9e. Thanks @Wang-MuFF for the fix and @davidchyi-beep for the Intel macOS 15.8.1 before/after capture.

On ClawSweeper's request for a native contained-caller run: the omitted-header path can't be produced on the hosts we have, so the proof is at the owner instead. The PR's tests show a caller sharing the Gateway's native coalition (or an earlier Gateway instance's) classifies as inside, a native read failure as unknown, and only an explicit native null as absent. The existing mapping turns inside into inside-gateway-service and unknown into service-membership-unverified, both refused before any bootout, and this PR doesn't touch that mapping. Cases that used to read as absent with no native fact now read as unknown, which is stricter. An independent Codex review of the diff found nothing. No stored data or config format changes, so no upgrade lane was needed.

This is on main and not in a release yet.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
… header (openclaw#194106)

* fix(daemon): consult native coalition reader when launchctl omits the header

When `launchctl print pid/<pid>` succeeds with a valid PID-domain record
but the output omits the `resource coalition` section, the no-header branch
returned `null` (absent) without consulting the native reader — even though
`readNativeResourceCoalition(pid)` exists and is already used as the fallback
when launchctl itself exits nonzero. A missing field in launchctl's formatted
output does not mean the kernel has no coalition information, so this dropped
a verifiable membership fact and blocked `gateway stop` from external
Terminal/SSH contexts with incomplete ancestry.

The fix reuses the existing native observation path:
`null` -> `readNativeResourceCoalition(pid)`. Malformed PID-domain records,
failed native queries (`undefined`), explicit native null, and
same-group/same-coalition/same-job callers all retain their existing handling.

Regression tests cover the omitted-coalition-header case across native
fallback outcomes: valid coalition (outside/inside), confirmed absence
(null), and unavailable probe (undefined -> unknown). Three existing cases
that asserted `absent`/`outside` under an unavailable native reader are
updated to `unknown`, matching the corrected semantics.

Fixes openclaw#194082

* ci: add test-lines allocation for 194082 regression coverage

Allocates 68 net new test lines for the omitted-coalition-header
describe block and three updated existing cases.

* style: simplify mock and align test-line allocation

Simplify the omitted-header observe() mock to a single-line ternary
so oxfmt format check passes. Update allocation to match the reduced
net delta (62 lines).
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
… header (openclaw#194106)

(cherry picked from commit bdfed9e)

Release adaptation: Full bounded fix and regression. Reuse native coalition reader for absent header; malformed-output refusal and unknown native results preserved. No new runtime contract.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit ae629a543ae19093f8eb514945e6a4f860bec689)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS gateway stop refuses when successful launchctl output omits coalition despite valid native membership

3 participants