Repository navigation
fix(update): support Homebrew installs and preserve stable LaunchAgent paths - #141011
Conversation
|
🦞👀 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. |
|
Codex review: blocked before merge. Reviewed September 18, 2026, 7:06 AM ET / 11:06 UTC (Revision 10). ClawSweeper reviewWhat this changesThe PR gives Homebrew installations appropriate update guidance and generates stable service paths that survive formula version changes. Merge readiness⛔ Blocked before merge - 1 item remains This PR remains useful: current main and v2026.9.4 lack the Homebrew-specific repair. Earlier findings are resolved, and the previous data-model migration warning is unsupported by the actual diff. No blocking correctness defect was identified. Priority: P2 Review scores
Verification
How this fits togetherThe update CLI identifies the installation’s package manager before changing files. Gateway and node service installation generate the commands that operating-system services execute on startup. flowchart TD
A[Installed OpenClaw path] --> B[Homebrew formula recognition]
B --> C[Update admission]
C --> D[Skipped result and Brew guidance]
B --> E[Service command generation]
E --> F[Stable opt entrypoint]
F --> G[Gateway or node service]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +45, Tests +212, Docs +20. Total +277 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep Homebrew responsible for package replacement while one shared resolver supplies stable service paths and actionable skipped-update guidance. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main can retain a versioned Homebrew entrypoint in service arguments, which becomes invalid when that keg is removed. No current-main runtime reproduction was executed here. Is this the best way to solve the issue? Yes. The patch extends the existing update-admission and service-command owners without introducing another package executor or changing stored schema contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2db54d773ea7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ca0940d to
655a797
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
9de0f5a to
e43ef75
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Use UpdatePreMutationError with unmanaged-package-install reason for Homebrew install roots to ensure skipped update outcome reporting and clean exit.
Reuse Homebrew discovery for formula-prefix validation and map managed service entrypoints once to the stable opt path. Preserve npm, pnpm, Bun, Windows and source-checkout paths. Prove skipped guidance reaches existing update history, status JSON and the bounded report without creating state for fresh profiles. Follow-up to openclaw#141011. Preserve all six contributor commits, including the typed skipped outcome and corrected assertion. Homebrew execution remains deferred because the package executor requires staged validation and retained rollback ownership. Co-authored-by: Max Xu <[email protected]>
aaf669b to
a3caace
Compare
|
Merged via squash.
|
…t paths (openclaw#141011) Homebrew-managed installations now return the existing typed skipped-update outcome with guidance to run brew upgrade openclaw-cli and then openclaw gateway restart. Existing update history, status JSON, and reports retain that guidance without changing their data model. A shared formula-path resolver validates the Homebrew prefix and maps versioned Cellar entrypoints to the stable opt path used by Gateway and node services. Homebrew keeps ownership of package replacement, and ordinary npm, pnpm, Bun, Windows, and source paths retain their existing behavior. Thanks to @maxsxu for the Homebrew repair. Validation: 507 focused tests, changed-file checks, full build, scoped-clean Codex review, and green exact-head CI run 35337287646. The built-CLI fixture verified persisted guidance and entrypoint survival after simulated keg retirement; it did not run a real Homebrew upgrade or native-service restart. Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Max Xu <[email protected]>
Backport the Homebrew updater ownership and stable opt-path repair from upstream PR #141011 / commit 8db38db. Co-authored-by: Max Xu <[email protected]>
What Problem This Solves
Resolves two related issues affecting OpenClaw installations managed by Homebrew (
brew install openclaw-cli):Unhelpful Update Failure: Running
openclaw updateon a Homebrew-managed installation fails with:This misleads users into thinking their installation is broken or needs to be reinstalled via npm/pnpm/bun, rather than explaining that Homebrew manages the package lifecycle.
LaunchAgent Service Breakdown on Upgrade: When
openclaw gateway installsets up the macOS LaunchAgent (~/Library/LaunchAgents/ai.openclaw.gateway.plist),resolveCliEntrypointPathForService()resolves symlinks to physical realpaths. For Homebrew, this hardcodes the versioned Cellar path (e.g./opt/homebrew/Cellar/openclaw-cli/2026.7.1/...). When Homebrew subsequently upgrades the formula, the old Cellar version directory is deleted, causing the LaunchAgent service to fail on start/restart withENOENT, while leaving orphaned gateway processes crashing on lazy-loaded modules and holding SQLite locks.Why This Change Was Made
src/infra/brew.tsandsrc/cli/update-cli/shared.ts, we recognize Homebrew formula package roots (/Cellar/openclaw-cli/and/opt/openclaw-cli/) without altering the internalGlobalInstallManagerunion or SQLite state schema. Whenopenclaw updateruns against a Homebrew installation, it now provides clear, actionable instructions directing the user to runbrew upgrade openclaw-clifollowed byopenclaw gateway restart. Crucially, detection is scoped strictly to theopenclaw-cliformula layout to preserve global npm packages underHOMEBREW_PREFIX(such as/opt/homebrew/lib/node_modules/openclaw).src/daemon/program-args.ts, the shared Homebrew resolver rewrites version-pinned/Cellar/openclaw-cli/<version>/...entrypoints to the unversioned, stable Homebrew opt symlink (/<brew-prefix>/opt/openclaw-cli/libexec/...). Because Homebrew atomically updates this symlink on every upgrade, the service plist definition remains permanently valid across future formula upgrades.User Impact
brew upgrade openclaw-cliinstead of an obscure "package manager unknown" failure. Global npm installs underHOMEBREW_PREFIXcontinue to use npm.Evidence
Maintainer follow-up: a3caace. All six commits by @maxsxu were rebased with authorship preserved. This includes Max's corrected assertion (
f44bd5c8e, rebased as5dd4152246d) and typed skipped outcome (aaf669bea, rebased as3ec47e80732).Owner and regression coverage
The shared resolver in
src/infra/brew.tsvalidates the formula layout directly beneath a standard Homebrew prefix,HOMEBREW_PREFIX, or the prefix returned by the existing executable resolver'sbrew --prefix. The separate update detector and daemon-local matching policy are removed. Service argument construction applies the mapping once for both Gateway and node services; install, restart repair, and candidate handoff consume that owner.The added service regression failed on the previous code for two unrelated/nested Cellar paths and passes with the repair. Tests cover standard and custom prefixes, a fake
brewon PATH, failed prefix discovery, and unchanged npm, pnpm, Bun, Windows, and Git-checkout path shapes. Existing-profile coverage proves the contributor's typed outcome already recordsorigin.nextActionin history,update status --json, and the bounded 1,500-character report. Fresh skipped profiles remain free of a newly created database.Validation on this head
node scripts/run-vitest.mjs: 12 files, 507 tests passed across update/Homebrew helpers, program arguments, launchd, service install/reinstall, restart repair, candidate service commands, and the install-plan owner.pnpm check:changed: passed, including production/test typechecking, core lint, and repository guards. Two existing max-lines warnings remain in untouchedsrc/cron/service/timer.test.tsandsrc/infra/sqlite-worker-broker.ts.pnpm build: passed (full build, including declarations and Control UI).git diff --check: passed.--mode branch --base origin/main --max-priority P1: scoped-clean, no actionable P0/P1 findings.Built CLI boundary proof
Used this branch's built CLI in a temporary formula layout, with
HOMEBREW_PREFIXset to the fixture prefix, an isolatedOPENCLAW_STATE_DIR, and a free port. A simulated OS-account home and fakelaunchctlkept service installation inside the fixture; no host Gateway was started or changed.This is a simulated package/service boundary proof. A real
brew upgradecycle and real native-service restart were not exercised. Existing published updaters retain their installed behavior; the first Homebrew upgrade still uses Homebrew directly.Executor decision and change size
Automatic
brew upgrade openclaw-cliexecution is deferred. The existingrunPackageInstallUpdate/runGlobalPackageUpdateStepsseam requires private staging, candidate validation before activation, and a retainedPackageUpdateTransactionfor rollback and completion. Running Brew in place would bypass those contracts. Formula metadata, staged admission, keg/link activation and rollback, and candidate handoff are estimated at 180–300 production lines, beyond the approximately 60-line executor allowance; that estimate is not an implemented measurement.Final diff: production +46/−1 (net +45), tests +212/−0, docs +20/−0. The additional 21 production lines beyond the initial 24-line target supply prefix validation and bounded custom-prefix discovery while removing duplicate matching policy. No options, schema, dependency, suppression, or baseline changes.
ClawSweeper follow-up
The exact-head review (revision 10, review comment) reports no correctness findings. Its remaining “Add data-model compatibility proof” checklist item is skipped as inapplicable: this diff changes no SQLite schema, migration, manager union, or serialized record shape. Homebrew admission reuses the existing
UpdatePreMutationError,unmanaged-package-installreason, andorigin.nextActionfield. The existing-profile regression covers persisted skipped history, status JSON, and report guidance; the fresh-profile case verifies no database is created. The review's own technical analysis confirms the prior data-model warning is unsupported by the diff.Exact-head CI: run 35337287646, green with zero pending checks at
a3caace6b037dfa1404a2de0f7b8f7d6e7f6607b. No CI rerun was requested.