fix(gateway): ignore inherited launchd env for respawn#85295
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 25, 2026, 12:49 PM ET / 16:49 UTC. Summary PR surface: Tests +29. Total +29 across 2 files. Reproducibility: no. high-confidence current-main reproduction remains. Source inspection shows current main ignores inherited Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance: Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the narrow test guardrail once the PR body and latest-head proof match current behavior, or close it if maintainers consider existing main coverage sufficient. Do we have a high-confidence way to reproduce the issue? No high-confidence current-main reproduction remains. Source inspection shows current main ignores inherited Is this the best way to solve the issue? Yes for a test-only guardrail: the patch is narrow and targets relevant gateway lifecycle coverage. The PR body should be refreshed because the runtime fix is already on current main and exact gateway launchd labels are intentionally still supervised. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 5cfa577778df. Label changesLabel justifications:
Evidence reviewedPR surface: Tests +29. Total +29 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
f4949de to
041c528
Compare
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
041c528 to
5cc0933
Compare
5cc0933 to
2030665
Compare
2030665 to
480be42
Compare
|
Verification before landing:
Thanks @YUHAO-corn! |
Summary
XPC_SERVICE_NAMEas proof that the gateway itself is launchd-supervised.OPENCLAW_LAUNCHD_LABEL.OPENCLAW_LAUNCHD_LABELnow triggers Darwin launchd respawn supervision.Motivation
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
XPC_SERVICE_NAME/LAUNCH_JOB_LABEL) as OpenClaw gateway supervision, while the OpenClaw-owned launchd marker still works.darwin, branchyuhao/fix-launchd-xpc-supervisor-85224, commit041c52846e611dd882328ae2a83bbd12538a7603.node --import tsx -e 'const { detectRespawnSupervisor } = await import("./src/infra/supervisor-markers.ts"); const cases = [{name:"inherited XPC only", env:{XPC_SERVICE_NAME:"ai.openclaw.mac"}}, {name:"generic launch job only", env:{LAUNCH_JOB_LABEL:"ai.openclaw.gateway"}}, {name:"openclaw launchd marker", env:{OPENCLAW_LAUNCHD_LABEL:"ai.openclaw.gateway"}}]; console.log(`platform=${process.platform}`); for (const item of cases) console.log(`${item.name}: ${detectRespawnSupervisor(item.env, "darwin") ?? "null"}`);'Terminal capture from the patched checkout:
XPC_SERVICE_NAMEandLAUNCH_JOB_LABELreturnnull, so update respawn will not take the supervised-exit path from inherited parent launchd state.OPENCLAW_LAUNCHD_LABELstill returnslaunchdfor real OpenClaw LaunchAgent services.XPC_SERVICE_NAMEalone matched the launchd hint list and returnedlaunchd.Root Cause (if applicable)
detectRespawnSupervisortreated generic launchd/XPC environment variables as evidence that the current gateway process was launchd-supervised.XPC_SERVICE_NAMEfrom a launchd-managed parent app.OPENCLAW_LAUNCHD_LABEL, which is the safer marker for respawn supervision.Regression Test Plan (if applicable)
src/infra/supervisor-markers.test.ts,src/infra/process-respawn.test.ts,src/daemon/service-env.test.ts.XPC_SERVICE_NAMEand generic launch job env do not trigger supervised restart; OpenClaw-owned launchd labels still do.User-visible / Behavior Changes
macOS gateways spawned from a launchd-managed parent no longer exit under the false assumption that launchd will restart them unless OpenClaw's own launchd service marker is present.
Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
darwin)XPC_SERVICE_NAME=ai.openclaw.mac,LAUNCH_JOB_LABEL=ai.openclaw.gateway,OPENCLAW_LAUNCHD_LABEL=ai.openclaw.gatewaySteps
Expected
null.OPENCLAW_LAUNCHD_LABELreturnslaunchd.Actual
Evidence
node scripts/run-vitest.mjs src/cli/gateway-cli/run-loop.test.ts src/infra/supervisor-markers.test.ts src/infra/process-respawn.test.ts src/gateway/server-methods/update-managed-service-handoff.test.ts src/daemon/service-env.test.tspnpm check:changedgit diff --check