Skip to content

fix(daemon): clear self-referencing OPENCLAW_WRAPPER on macOS gateway install - #144053

Merged
obviyus merged 4 commits into
openclaw:mainfrom
chelsealong:fix-macos-gateway-install-wrapper-self-reference-144001
Sep 17, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
chelsealong:fix-macos-gateway-install-wrapper-self-reference-144001

Conversation

@chelsealong

@chelsealong chelsealong commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #144001

What Problem This Solves

macOS Gateway reinstall fails when OPENCLAW_WRAPPER points to OpenClaw's generated environment launcher.

User Impact

Reinstall restores the runtime and Gateway entrypoint instead of nesting the launcher. Genuine custom wrappers still work.

Why This Change Was Made

The shared install planner rejects generated launchers before selecting runtime arguments and environment. This setting has one writer. Production code shrinks by eight lines.

Evidence

On isolated macOS services, gateway install --force --runtime node --wrapper "$launcher" produced duplicate arguments, exit 2 and no health before the fix; afterward, health returned 200. Persisted-input and repeat reinstall, fresh install, a genuine custom wrapper, authentication and environment retention passed.

The unmodified published 2026.9.3 updater completed with a normal runtime definition plus the invalid persisted wrapper value. The installed candidate answered health and authenticated status. An already-recursive definition is unidentifiable to that old updater; direct candidate reinstall is the proven recovery. No package was published.

The installer patch is unchanged from these native observations at cebb120f.

Compatibility

Windows generated-script rejection is unchanged. No new configuration or migration.

Consumers

Install, startup repair, Doctor and setup share the planner.

Invalidation

Existing service owners regenerate arguments and environment.

Tests

Registered-command cases fail on the original main implementation. After integrating main, 657 installer/update tests and 600 current catalog/release/inventory tests pass. Full build, type-aware preflight, formatting, both line limits, unused-file/export and architecture checks pass.

Earlier CI run 35153572691 failed; the exact formatting repair from #150330 is included. New hosted checks must complete.

… install

buildGatewayInstallPlan already cleared OPENCLAW_WRAPPER when it pointed at
the generated Windows task script, but had no equivalent guard for macOS.
When OPENCLAW_WRAPPER (via --wrapper or a persisted env var) points at the
generated LaunchAgent env-wrapper script, resolveCliProgramArguments treats
it as a custom wrapper and substitutes it for the Node runtime + entrypoint.
prepareLaunchAgentProgramArguments then prepends another copy of the same
wrapper, producing a self-referencing ProgramArguments array that exits
immediately when launchd starts it (fixes openclaw#144001).
@clawsweeper

clawsweeper Bot commented Sep 10, 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 commands Command implementations size: S labels Sep 10, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 12:13 AM ET / 04:13 UTC (Revision 3).

ClawSweeper review

What this changes

Prevents macOS Gateway installation from selecting its generated environment launcher as a custom wrapper, with registered-command coverage for explicit, persisted, and legitimate custom wrappers.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and v2026.9.4 still lack the macOS guard. No actionable patch defects were found, and the recorded native installation and upgrade observations address the earlier proof gap.

Priority: P1
Reviewed head: 95835b039e7f6936ceb509cc9ba9cbab8fe2f381

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with useful registered-command coverage and relevant native installation and upgrade observations.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured PR body records the real macOS gateway-install path recovering from exit 2 to healthy HTTP 200, plus fresh, persisted, repeated, custom-wrapper, and published-updater cases; the changed planner is identical to the observed revision.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR body records the real macOS gateway-install path recovering from exit 2 to healthy HTTP 200, plus fresh, persisted, repeated, custom-wrapper, and published-updater cases; the changed planner is identical to the observed revision.
Evidence reviewed 8 items Introduced repair: The pinned introduced delta rejects the generated launcher before runtime selection and removes its OPENCLAW_WRAPPER value from the planned environment. Other wrapper paths retain their existing validation and behavior.
Actual failure mechanism: Custom wrappers replace the runtime-and-entrypoint prefix, while the LaunchAgent writer prepends its environment loader. Selecting that same loader as a custom wrapper therefore creates the reported malformed command; clearing it restores ordinary runtime selection.
Current main still needs the fix: Fetched main retains the Windows-only generated-script guard. Its additional runtime-path work does not supply the macOS rejection.
Findings None None.
Security None None.

How this fits together

The Gateway installer turns CLI options and existing service settings into a runtime command and environment. The macOS service writer wraps that command in an environment loader before handing it to launchd.

flowchart TD
  A[CLI options and saved settings] --> B[Shared install planner]
  B --> C{Generated launcher selected?}
  C -->|Yes| D[Select runtime and Gateway entrypoint]
  C -->|No| E[Preserve valid custom wrapper]
  D --> F[macOS environment loader]
  E --> F
  F --> G[launchd starts Gateway]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -8, Tests +129. Total +121 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 23 31 -8
Tests 1 129 0 +129
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 152 31 +121

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144001
Summary: This PR is the explicit implementation candidate for the reported generated-launcher self-reference.

Members:

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

Technical review

Best possible solution:

Keep generated-launcher rejection in the shared planner while preserving custom wrappers, private environment loading, and direct reinstall recovery.

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

Yes, from source: selecting the generated macOS launcher through --wrapper or persisted OPENCLAW_WRAPPER produces the malformed command on current main. This review did not execute that failure.

Is this the best way to solve the issue?

Yes. Extending the existing generated-script guard repairs command construction at its shared owner without replacing the documented custom-wrapper contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The reported macOS reinstall failure prevents the managed Gateway and its dependent channels from starting.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured PR body records the real macOS gateway-install path recovering from exit 2 to healthy HTTP 200, plus fresh, persisted, repeated, custom-wrapper, and published-updater cases; the changed planner is identical to the observed revision.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body records the real macOS gateway-install path recovering from exit 2 to healthy HTTP 200, plus fresh, persisted, repeated, custom-wrapper, and published-updater cases; the changed planner is identical to the observed revision.

Evidence

What I checked:

  • Introduced repair: The pinned introduced delta rejects the generated launcher before runtime selection and removes its OPENCLAW_WRAPPER value from the planned environment. Other wrapper paths retain their existing validation and behavior. (src/commands/daemon-install-helpers.ts:813, 95835b039e7f)
  • Actual failure mechanism: Custom wrappers replace the runtime-and-entrypoint prefix, while the LaunchAgent writer prepends its environment loader. Selecting that same loader as a custom wrapper therefore creates the reported malformed command; clearing it restores ordinary runtime selection. (src/daemon/launchd-service-files.ts:129, 95835b039e7f)
  • Current main still needs the fix: Fetched main retains the Windows-only generated-script guard. Its additional runtime-path work does not supply the macOS rejection. (src/commands/daemon-install-helpers.ts, c964f99a2444)
  • Latest release check: The v2026.9.4 source also retains only the Windows guard; the requested macOS repair is not present in that release. (src/commands/daemon-install-helpers.ts, 3a9d69db306c)
  • Native proof and review continuity: The supplied complete PR body, captured under sourceRevision b9e5e172517482f853d75f4dcb433799ced94f81289a313a7d28ead94b2b2b0d, records isolated macOS installation changing from duplicate arguments, exit 2 and unavailable health to HTTP 200. It also records persisted-input recovery, repeat and fresh installs, custom-wrapper preservation, authentication/environment retention, and the unmodified 2026.9.3 updater installing the candidate. Already-recursive definitions require direct candidate reinstall. Local comparison confirms both introduced files are unchanged from the previously reviewed native-proof revision. (95835b039e7f)
  • Existing contract and regression coverage: The documented custom-wrapper contract persists genuine wrappers across reinstall and repair. The new tests enter through registered gateway commands and check explicit and persisted generated-wrapper rejection, custom-wrapper retention, and unrelated environment retention. Existing Windows coverage remains. Tests were inspected, not executed during this read-only review. (src/cli/daemon-cli/install.wrapper.integration.test.ts:78, 95835b039e7f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-10T13:03:31.200Z sha b0a6d45 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-16T21:45:46.456Z sha cebb120 :: needs maintainer review before merge. :: none

@chelsealong

Copy link
Copy Markdown
Contributor Author

The 3 failing checks are unrelated to this diff — confirmed from job logs, not just the base-rate table:

  • checks-node-compact-small-39: test/official-channel-catalog.test.ts (docs-nav index drift)
  • checks-node-compact-small-46: test/scripts/docs-sync-publish.test.ts (docs-nav index drift)
  • checks-node-compact-small-8: src/gateway/server.sessions.reclamation.test.ts — timing flake, expected 1898ms to be less than 500ms

None touch src/commands/daemon-install-helpers.ts/.test.ts (the only two files this PR changes), and none exercise daemon/launchd/installer code at all.

On the requested native macOS proof: this session runs in a Linux sandbox with no macOS host, so I can't produce a real launchd install/reload run — the PR body already discloses that gap rather than papering over it. I won't fabricate that evidence. The available proof remains the regression test in daemon-install-helpers.test.ts (confirmed failing before the fix, passing after, against the exact generated wrapper path). Native launchd proof would need a maintainer or CI job with macOS runner access.

@obviyus obviyus self-assigned this Sep 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Sep 16, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@obviyus

obviyus commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-admin-merge
pr: 144053
head: cebb120
scope: owner-review

@obviyus

obviyus commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-admin-merge
pr: 144053
head: 95835b0
scope: owner-review

@obviyus
obviyus merged commit 977d571 into openclaw:main Sep 17, 2026
378 of 381 checks passed
@obviyus

obviyus commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks chelsealong!

Proof: Isolated macOS installs recovered explicit and persisted generated-launcher paths. Repeat reinstall, genuine custom wrappers, authentication and environment retention passed. The published 2026.9.3 updater passed from a normal runtime definition plus the bad persisted wrapper value. It cannot identify an already-recursive definition; direct candidate reinstall is the proven recovery.

  • Bug: Reinstall could nest the generated environment launcher instead of starting Node and the Gateway entrypoint.
  • Fix: The install planner rejects that generated launcher as a custom wrapper while preserving genuine wrappers.
Before After
Duplicate launcher arguments, exit 2 and no Gateway health Normal runtime arguments and Gateway health 200

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
… install (openclaw#144053)

Closes openclaw#144001

## What Problem This Solves
macOS Gateway reinstall fails when `OPENCLAW_WRAPPER` points to OpenClaw's generated environment launcher.

## User Impact
Reinstall restores the runtime and Gateway entrypoint instead of nesting the launcher. Genuine custom wrappers still work.

## Why This Change Was Made
The shared install planner rejects generated launchers before selecting runtime arguments and environment. This setting has one writer. Production code shrinks by eight lines.

## Evidence
On isolated macOS services, `gateway install --force --runtime node --wrapper "$launcher"` produced duplicate arguments, exit 2 and no health before the fix; afterward, health returned 200. Persisted-input and repeat reinstall, fresh install, a genuine custom wrapper, authentication and environment retention passed.

The unmodified published 2026.9.3 updater completed with a normal runtime definition plus the invalid persisted wrapper value. The installed candidate answered health and authenticated status. An already-recursive definition is unidentifiable to that old updater; direct candidate reinstall is the proven recovery. No package was published.

The installer patch is unchanged from these native observations at `cebb120f`.

## Compatibility
Windows generated-script rejection is unchanged. No new configuration or migration.

## Consumers
Install, startup repair, Doctor and setup share the planner.

## Invalidation
Existing service owners regenerate arguments and environment.

## Tests
Registered-command cases fail on the original main implementation. After integrating main, 657 installer/update tests and 600 current catalog/release/inventory tests pass. Full build, type-aware preflight, formatting, both line limits, unused-file/export and architecture checks pass.

Earlier CI run 35153572691 failed; the exact formatting repair from openclaw#150330 is included. New hosted checks must complete.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gateway install --runtime node duplicates env wrapper path instead of Node executable and entry point (macOS)

2 participants