Repository navigation
fix(update): prevent Gateway respawn during package replacement - #103537
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19704197e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eeaca4bfaa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e28b9dfd5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08f8367270
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c770f8be5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d14d7baae4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs changes before merge. Reviewed August 9, 2026, 6:55 PM ET / 22:55 UTC. ClawSweeper reviewWhat this changesThe PR makes managed package updates quiesce a loaded Gateway that may be between supervisor respawns before replacing its installation files. Merge readiness⛔ Blocked by patch quality or review findings - 5 items remain Keep open: the patch reintroduces an operator-disabled macOS LaunchAgent after a package-update failure. The pre-mutation quiescence fix is useful, but failure recovery must preserve the prior disabled state. Priority: P1 Review scores
Verification
How this fits togetherThe updater inspects the installed Gateway service before mutating package files, then uses the platform service adapter for stop and recovery. It must distinguish a supervisor respawn window from an operator’s intentionally disabled service. flowchart LR
A[Managed update] --> B[Inspect Gateway service]
B --> C{Respawn may occur}
C -->|yes| D[Verify installation ownership]
D --> E[Quiesce service]
E --> F[Replace package]
F --> G[Recover prior service state]
C -->|no| F
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +131. Total +136 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Make the launchd service owner capture and restore the exact prior disabled/loaded/running state for update recovery, while keeping the new owned respawn quiescence before mutation. Do we have a high-confidence way to reproduce the issue? Yes. Current source shows the new stopped-loaded Darwin branch reaching generic failed-update recovery, whose launchd restart explicitly enables the service. Is this the best way to solve the issue? No. The update flow needs owner-provided restoration of the original disabled state; generic restart is intentionally an explicit start operation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 810b99432c21. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
d14d7ba to
f1c644e
Compare
|
@clawsweeper re-review Exact head: f1c644e. The signal-exit blocker is fixed and its thread has exact-head Testbox/autoreview evidence. Final macOS and Windows live package proofs remain in progress; please re-review the code and deterministic evidence now. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1c644e062
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let canRestoreLoadedState = params.snapshot.disabled; | ||
| if (!params.snapshot.disabled) { | ||
| const enable = await execLaunchctl(["enable", params.serviceTarget]); |
There was a problem hiding this comment.
Enable disabled LaunchAgents before rollback bootstrap
When the pre-update snapshot was loaded and disabled, this branch treats the job as ready to restore while skipping the temporary launchctl enable, so the later rollback attempts to bootstrap a still-disabled service. The launchctl enable|disable contract says a disabled service cannot be loaded until it is enabled; in the openclaw gateway stop --disable case that can leave a loaded/stopped disabled job, a failed update after quiescence will report rollback failure and leave the job booted out/disabled instead of restoring the prior loaded state. Fresh evidence beyond the earlier disabled-LaunchAgent threads is that the current exact-state rollback still skips the enable step specifically on the snapshot.disabled path.
Useful? React with 👍 / 👎.
ed6f043 to
05ab514
Compare
05ab514 to
314dc89
Compare
|
Merged via squash.
|
…claw#103537) * fix(update): quiesce respawn-pending services * fix(update): preserve disabled launch agents
Closes #103447
Related: #85133
What Problem This Solves
A managed update could replace package or checkout files while a loaded supervisor was between Gateway process instances. On macOS, a loaded enabled LaunchAgent uses
KeepAlive; on Linux and Windows, the managed-update handoff records the same transition. The previous patch also risked restarting a persistently disabled LaunchAgent after a failed package replacement.Why This Change Was Made
The launchd service owner now reads the authoritative persistent enabled state through
launchctl print-disabled. The updater treats only loaded, enabled Darwin jobs as respawn-pending; a loaded but disabled job remains untouched, so generic failure recovery cannot revive it. Non-Darwin supervisors require the existing managed-update handoff marker. A definite foreign mutation root returns before any enabled-state probe or stop.The rewrite builds on
OwnedManagedUpdateContextand the existing service-control/recovery flow rather than introducing a second rollback owner. It deletes the stale PR's parallel signal, launcher-respawn, monolithic update, and exact-state snapshot machinery. The production surface is +64/-20 (net +44): the growth is required by the launchd service-control ownership boundary, which alone can authoritatively distinguish persistent operator disablement from a transient KeepAlive respawn window.User Impact
Managed updates no longer race a respawned Gateway against package replacement, and failed updates do not enable or start a Gateway the operator persistently disabled. Ordinary stopped systemd units, ordinary stopped Scheduled Tasks, unloaded LaunchAgents, and services belonging to another mutation root remain untouched.
Evidence
loadedimplies respawn-capable), the disabled-LaunchAgent failure test failed; the updater skipped the enabled-state probe and entered the stop/restart path.node scripts/run-vitest.mjs src/daemon/launchd.test.ts src/cli/update-cli.test.tspassed 159/159 daemon tests and 236/236 update CLI tests after the final rebase.print-disabledparsing/errors, and failed-update restart ordering.node scripts/check-changed.mjs -- <five changed paths>passed all selected typecheck, lint, boundary, database-first, import-cycle, env-count, and guard checks on Testboxtbx_01kzmxdbsfktzk17yrq88gtdhx; Actions run https://github.com/openclaw/openclaw/actions/runs/31354316652.