Repository navigation
fix: restore managed Gateway after update stop failure - #136285
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: needs real behavior proof before merge. Reviewed September 7, 2026, 2:13 PM ET / 18:13 UTC. ClawSweeper reviewWhat this changesThe PR preserves observed Gateway service-stop state so failed updates can attempt recovery, classifies pre-activation stop failures, and clarifies when channel changes persist. Merge readiness⛔ Blocked before merge - 2 items remain The repair remains necessary on current main, and no blocking code defect was found. Earlier stop-state and channel-persistence concerns are resolved; native failed-stop recovery proof remains the merge blocker. Priority: P1 Review scores
Verification
How this fits togetherThe update CLI stages and validates an installation before stopping its managed Gateway service. If stopping fails after unloading the service, recovery verifies the original runtime and current service ownership before restarting it. flowchart TD
A[Update request] --> B[Validate candidate]
B --> C[Stop managed Gateway]
C --> D[Record observed service mutation]
D --> E{Stop succeeds?}
E -->|Yes| F[Activate update]
E -->|No| G[Verify original runtime and ownership]
G --> H[Restart and check readiness]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +9, Tests +30, Docs +3. Total +42 across 6 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: A failed pre-activation stop should restore the verified original Gateway when ownership still matches, preserve the prior channel, and report the observed recovery outcome. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the failure path: successful LaunchAgent bootout followed by a busy-port rejection loses the stop record on current main. Native reproduction was not executed during this read-only review. Is this the best way to solve the issue? Yes, retaining the native mutation observation and reusing verified recovery is a focused repair that preserves existing channel semantics; runtime confirmation remains outstanding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fae6778b125c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…lures Persist the requested update channel immediately after config validation, before schema preflight or service-stop attempts. Previously the channel was only saved in the finalize step, so any early failure (schema mismatch, stop timeout, etc.) silently discarded the operator's intent. Reclassify the managed-service stop failure in executeMutableUpdate as UpdatePreMutationError so the outer handler can safely recover the original runtime and re-enable the LaunchAgent instead of treating the untouched checkout as a failed mutation. Closes openclaw#127869 Co-authored-by: Cursor <[email protected]>
…top state through error boundary Address ClawSweeper P1 findings: 1. Channel persistence moved from before target resolution to after the downgrade consent gate. A refused downgrade no longer changes update.channel — preserving the existing no-side-effect contract tested at update-cli.test.ts:3255. 2. ManagedServiceStopFailure carries the inspected pre-stop state through the error boundary so recovery can restart a LaunchAgent that was bootout'd before the error. The caller extracts inspectedState and populates preManagedServiceStop before throwing UpdatePreMutationError, enabling maybeRestartServiceAfterFailedMutableUpdate to find the stopped-service record it requires. Co-authored-by: Cursor <[email protected]>
Retain native stop state before post-stop validation can fail, and classify failure before core activation so verified original-runtime recovery can run. Preserve success-only channel persistence documented by shipped releases. Replace constructor-only tests with update-level mutation boundary regressions.\n\nRelated: openclaw#127869 and openclaw#136285.
d3dcdc7 to
53f09a1
Compare
|
Merged via squash.
|
* fix: persist update channel before mutable work and classify stop failures Persist the requested update channel immediately after config validation, before schema preflight or service-stop attempts. Previously the channel was only saved in the finalize step, so any early failure (schema mismatch, stop timeout, etc.) silently discarded the operator's intent. Reclassify the managed-service stop failure in executeMutableUpdate as UpdatePreMutationError so the outer handler can safely recover the original runtime and re-enable the LaunchAgent instead of treating the untouched checkout as a failed mutation. Closes openclaw#127869 Co-authored-by: Cursor <[email protected]> * fix: delay channel persistence until after downgrade consent, carry stop state through error boundary Address ClawSweeper P1 findings: 1. Channel persistence moved from before target resolution to after the downgrade consent gate. A refused downgrade no longer changes update.channel — preserving the existing no-side-effect contract tested at update-cli.test.ts:3255. 2. ManagedServiceStopFailure carries the inspected pre-stop state through the error boundary so recovery can restart a LaunchAgent that was bootout'd before the error. The caller extracts inspectedState and populates preManagedServiceStop before throwing UpdatePreMutationError, enabling maybeRestartServiceAfterFailedMutableUpdate to find the stopped-service record it requires. Co-authored-by: Cursor <[email protected]> * fix: recover updates after an observed service stop Retain native stop state before post-stop validation can fail, and classify failure before core activation so verified original-runtime recovery can run. Preserve success-only channel persistence documented by shipped releases. Replace constructor-only tests with update-level mutation boundary regressions.\n\nRelated: openclaw#127869 and openclaw#136285. --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where a managed Gateway can remain unloaded after
openclaw updatefails while stopping the service. On macOS,launchctl bootoutcan succeed before the subsequent busy-port check fails. The updater then loses the stop record and classifies the exception as an unsafe update mutation, so recovery cannot restore the original service.Related: #127869.
Why This Change Was Made
The native service owner already reports lifecycle mutations. The updater now retains the stop record at that callback, before a later stop error can discard it, and classifies the failure before core activation. Recovery still verifies the original installation and revalidates current service ownership before restarting. A failed inspection or refused native stop produces no stopped-service claim.
The final change preserves the success-only channel-persistence contract documented in both current main and shipped versions 2026.8.1 and 2026.9.2. Failed core updates keep the prior channel. The release-channel guide now states that timing explicitly. The earlier catch-all stop-error wrapper and constructor-only tests were replaced by the native mutation callback and an update-level regression.
User Impact
An update that unloads its managed service and then fails before core activation can attempt verified recovery of the original Gateway. A stop failure before a lifecycle mutation does not trigger a restart. Requested update-channel changes remain persisted only after core update success.
Both contributor commits by @Schimuneck are preserved through rebase, followed by a maintainer repair commit.
Evidence
Baseline:
6aa09cbadb594c3d46d5bd49a28c514df1b256b0. Candidate:53f09a1af257e8fbf8357317faa73779bf1cfa42.update-failedwith unsafe recovery, and a recorded bootout never starts recovery. It covers both errors before mutation and errors after mutation, verifies the original package remains installed, and asserts no channel write.git diff --checkand documentation discovery passed.pnpm check:changed --base 6aa09cbadb594c3d46d5bd49a28c514df1b256b0 --head 53f09a1af257e8fbf8357317faa73779bf1cfa42, followed by the seven focused suites below andgit diff --check. 852 tests passed, 25 platform-dependent tests skipped, including both new stop-boundary cases. The test wrapper also built the runtime for the process suites. The complete proof command exited successfully.pnpm test src/cli/update-cli.test.ts \ src/cli/update-cli/update-command.test.ts \ src/cli/update-cli/update-command-service-maintenance.test.ts \ src/cli/update-cli/update-command-service.integration.test.ts \ src/cli/update-cli/update-command-post-update-recovery.test.ts \ src/cli/update-cli/update-command-lease.test.ts \ src/daemon/launchd.test.tsNative macOS LaunchAgent execution remains a proof gap. Source inspection confirms
bootout→ native mutation callback → port validation, and existing launchd unit tests cover a busy port after recorded bootout. Linux process tests and mocked launchctl tests do not establish live macOS service behavior. No operator Gateway was stopped or restarted.The earlier CI run's CLI failures were related to the removed early channel writes and catch-all error wrapping. Its protocol lane passed 210 tests and its guard lane completed checks before both failed on GitHub HTTPS authentication during cleanup; those infrastructure failures were unrelated to this patch.