Repository navigation
fix(daemon): consult native coalition reader when launchctl omits the header - #194106
Conversation
… 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
|
🦞👀 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. |
Allocates 68 net new test lines for the omitted-coalition-header describe block and three updated existing cases.
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).
|
Codex review: needs real behavior proof before merge. What this changesConsult 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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 optionsMaintainer options:
Provenance checked
TestingProof path: shipped entry point. SecurityNeeds attention: No concrete bypass or supply-chain regression was found, but the changed teardown admission path needs final-effect rejection evidence. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +62, Other +1. Total +63 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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 clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReview history (1 earlier review cycle)
Reviewed November 6, 2026, 12:37 PM ET / 17:37 UTC (Revision 2). |
|
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 No 2) The native reader returns a valid coalition for the same PID 3) User-visible effect 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 |
|
Thanks for the deterministic before-state, @davidchyi-beep — it matches the PR's described scenario exactly (exit 0 with zero 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: |
|
After check: the one-line change fixes Method note first, so the weight of the evidence is clear: I did not build the branch. I took the shipped 2026.11.1 ( Nothing outside that copy was touched; the installed package is unchanged. Before - installed 11.1, same Terminal window After - patched copy, same Terminal window, seconds later The service was genuinely stopped, and launchd's KeepAlive brought it back on its own; a follow-up check showed the Gateway running again ( Environment: Intel x86_64, macOS 15.8.1 (kernel 24.6.0), Node v26.12.1, 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 |
|
PR body updated with @davidchyi-beep's independent end-to-end verification on Intel macOS 15.8.1 — before ( The @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@steipete — flagging for review when you have a moment. The 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 |
|
Merged via squash.
|
|
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 This is on main and not in a release yet. |
… 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).
… 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)
What Problem This Solves
Fixes:
openclaw gateway stopis refused from external Terminal/SSH shells on macOS 15 hosts wherelaunchctl print pid/<pid>succeeds with a valid PID-domain record but omits theresource coalitionsection — 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 stopfrom 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 printsucceeds (status 0) with a valid PID-domain record but noresource coalitionheader, the no-header branch inreadResourceCoalitionreturnednull(absent) without consulting the native reader. The existingreadNativeResourceCoalition(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
src/daemon/service-process-membership.ts:98— the no-header branch now callsreadNativeResourceCoalition(pid)instead of returningnull. The function already exists (line 20) and is already used at line 64 for the launchctl-nonzero-exit fallback.service-process-membership.test.ts— three existing cases in the first describe block updated to reflect corrected semantics (unavailable native reader →unknown, notabsent/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.check-test-types-core-*(5/5) andcheck-prod-typesCI checks pass.gateway stop --forceto succeed; 91 tests pass including the extended native coalition test table. See the issue for full validation details.4ffdd20, Node v26.12.1) wherelaunchctl print pid/551exits 0 with zerocoalitionlines while the native reader returnscoalition id=691 name=ai.openclaw.gatewayfor the same PID. The PR's single behavioural delta was applied to the shipped dist module and run from the same Terminal window:openclaw gateway stop→Gateway stop failed: ServiceInspectionError: Process ancestry could not be fully inspected.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.config/test-lines-allocations/194082-launchctl-coalition-header.txt(value62) 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.