Repository navigation
fix(update): warn when Git updates replace a live Gateway runtime - #193242
Conversation
Reuse persisted Gateway ownership at the Git publication boundary so an unmanaged live consumer is refused before checkout or runtime replacement. Keep database capture and rollback in the existing transaction, preserve owned-service stopping and disjoint installations, and document that the installed updater must contain the repair. Refs #193163.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR warns when Git updates replace files used by an undiscovered Gateway and preserves that warning in update history. Example: A foreground Gateway uses /opt/openclaw while another terminal runs a Git update.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this PR open: it adds a useful warning missing from main, preserves existing refusal paths, and has no identified code defects. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe update CLI checks installation consumers before publication, then sends step advisories to terminal output, JSON results, and the bounded SQLite update ledger. flowchart TD
A[Git update CLI] --> B[Publication checks]
B --> C[Persisted Gateway owner]
B --> D[Managed service guards]
B --> E[Post stop advisory]
E --> F[Terminal and JSON]
E --> G[Bounded update history]
Technical reviewBest possible solution: Keep the warning in the existing publication advisory and ledger owners while preserving package, managed-service, and database safeguards. Do we have a high-confidence way to reproduce the issue? Source establishes the missing-warning path on current main, and the PR reports a real built-Gateway CLI run; no target code was executed during this review. Is this the best way to solve the issue? The patch is a small, coherent fix for the warning omission, using existing owners without claiming to repair the broader shutdown failure. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 97b24c9d15d5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +17, Tests 0, Docs +12. Total +29 across 9 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 5, 2026, 2:59 AM ET / 07:59 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…, when PostgreSQL backup cannot run (#193190) Related: #193163 Companion: #193242 ## What Problem This Solves `openclaw update` can replace a serving installation before discovering that PostgreSQL backup cannot acquire exclusive state ownership, for example when a custom service owns the Gateway. ## User Impact The update now refuses with `database-engine-preflight` before activation when PostgreSQL capture cannot acquire ownership. The previous installation remains unchanged and the Gateway keeps serving. The message names the next step: stop the Gateway through its service owner, then rerun `openclaw update`. Stopped-service updates still proceed, and updates with no PostgreSQL family keep their existing behavior. This preserves the update contract: refuse only for the named backup-ownership risk, preserve the previous Gateway on refusal, and provide an actionable retry path. ## Why This Change Was Made The shared pre-activation callback probes the same ownership used by database capture. The actual backup still reacquires and checks ownership after activation; a Gateway starting between the two checks retains the existing backup-time refusal. This change deliberately does not introduce a new custody protocol. This is the narrow PostgreSQL part of #193163. A separate companion handles the generic Git persisted-owner check; neither change claims to reproduce or fix the reported 0.372-second worker exit or missing-chunk shutdown chain. The installed updater must contain this repair; when upgrading with an older driver, stop the unmanaged Gateway first. The original commits and contributor credit remain with @etzelm. The maintainer follow-up merges main without rewriting that history and consolidates existing capture fixtures. ## Evidence - On main `69d6eae050e`, the six preflight scenarios produce exactly two intended failures: Git and package updates replace the install while PostgreSQL ownership is held. Both stopped-service controls and both SQLite held-ownership controls pass. Vitest 22.99 s; complete command 128.95 s including compilation. - With the fix, 68 focused tests pass across update execution and capture/retention. Complete command 148.48 s; the execution suite checks refusal before mutation, the next-step message, service stopping, and unchanged non-PostgreSQL behavior. The retention suite still exercises both real transaction owners, snapshot cleanup, late-write retention, first-writer diagnostics, and package rollback. - Scoped lint, update-CLI typechecking, formatting, and all baseline/line-cap ratchets pass. The shared test ceiling is unchanged; the allocation is removed. Production +51/-13 = +38 lines for the shared probe and call site; tests +139/-140 = -1 line. - Independent Codex autoreview: scoped-clean through P2 for `69d6eae050e` → `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`; no accepted/actionable findings. The review inspected supplied source and did not run tests. Limitations: macOS local boundary proof with synthetic I/O, not an end-to-end PostgreSQL deployment or native custom LaunchDaemon. The earlier real serving-process Git proof belongs to the companion scope. No inference model is involved in this maintenance-path proof. ClawSweeper reviewed `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`: no code findings; its remaining hold requests real CLI/PostgreSQL/latest-stable and stored-data compatibility proof. Those environment/upgrade cells remain unrun; this PR changes no schema or data format. Exact-head [CI](https://github.com/openclaw/openclaw/actions/runs/41975816063) and `openclaw/ci-gate` passed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario. Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Continue for live or unverifiable persisted owners that native service discovery misses. Record PID, root, and restart guidance through the existing update advisory, JSON result, and history. Preserve package and managed-service refusal behavior. Related: #193163
# Conflicts: # src/cli/update-cli/update-command-database-retention.test.ts # src/cli/update-cli/update-command-execution.test.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…, when PostgreSQL backup cannot run (openclaw#193190) Related: openclaw#193163 Companion: openclaw#193242 ## What Problem This Solves `openclaw update` can replace a serving installation before discovering that PostgreSQL backup cannot acquire exclusive state ownership, for example when a custom service owns the Gateway. ## User Impact The update now refuses with `database-engine-preflight` before activation when PostgreSQL capture cannot acquire ownership. The previous installation remains unchanged and the Gateway keeps serving. The message names the next step: stop the Gateway through its service owner, then rerun `openclaw update`. Stopped-service updates still proceed, and updates with no PostgreSQL family keep their existing behavior. This preserves the update contract: refuse only for the named backup-ownership risk, preserve the previous Gateway on refusal, and provide an actionable retry path. ## Why This Change Was Made The shared pre-activation callback probes the same ownership used by database capture. The actual backup still reacquires and checks ownership after activation; a Gateway starting between the two checks retains the existing backup-time refusal. This change deliberately does not introduce a new custody protocol. This is the narrow PostgreSQL part of openclaw#193163. A separate companion handles the generic Git persisted-owner check; neither change claims to reproduce or fix the reported 0.372-second worker exit or missing-chunk shutdown chain. The installed updater must contain this repair; when upgrading with an older driver, stop the unmanaged Gateway first. The original commits and contributor credit remain with @etzelm. The maintainer follow-up merges main without rewriting that history and consolidates existing capture fixtures. ## Evidence - On main `6df4b062a20`, the six preflight scenarios produce exactly two intended failures: Git and package updates replace the install while PostgreSQL ownership is held. Both stopped-service controls and both SQLite held-ownership controls pass. Vitest 22.99 s; complete command 128.95 s including compilation. - With the fix, 68 focused tests pass across update execution and capture/retention. Complete command 148.48 s; the execution suite checks refusal before mutation, the next-step message, service stopping, and unchanged non-PostgreSQL behavior. The retention suite still exercises both real transaction owners, snapshot cleanup, late-write retention, first-writer diagnostics, and package rollback. - Scoped lint, update-CLI typechecking, formatting, and all baseline/line-cap ratchets pass. The shared test ceiling is unchanged; the allocation is removed. Production +51/-13 = +38 lines for the shared probe and call site; tests +139/-140 = -1 line. - Independent Codex autoreview: scoped-clean through P2 for `6df4b062a20` → `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`; no accepted/actionable findings. The review inspected supplied source and did not run tests. Limitations: macOS local boundary proof with synthetic I/O, not an end-to-end PostgreSQL deployment or native custom LaunchDaemon. The earlier real serving-process Git proof belongs to the companion scope. No inference model is involved in this maintenance-path proof. ClawSweeper reviewed `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`: no code findings; its remaining hold requests real CLI/PostgreSQL/latest-stable and stored-data compatibility proof. Those environment/upgrade cells remain unrun; this PR changes no schema or data format. Exact-head [CI](https://github.com/openclaw/openclaw/actions/runs/41975816063) and `openclaw/ci-gate` passed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario. Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…enclaw#193242) * fix(update): preserve live Git runtimes missed by service discovery Reuse persisted Gateway ownership at the Git publication boundary so an unmanaged live consumer is refused before checkout or runtime replacement. Keep database capture and rollback in the existing transaction, preserve owned-service stopping and disjoint installations, and document that the installed updater must contain the repair. Refs openclaw#193163. * fix(update): preserve the original command in publication refusal guidance * fix(update): warn when Git updates leave a Gateway running Continue for live or unverifiable persisted owners that native service discovery misses. Record PID, root, and restart guidance through the existing update advisory, JSON result, and history. Preserve package and managed-service refusal behavior. Related: openclaw#193163 * docs(update): note foreground runtime replacement retirement * fix(update): retain publication warnings in update history
…, when PostgreSQL backup cannot run (#193190) Related: #193163 Companion: #193242 ## What Problem This Solves `openclaw update` can replace a serving installation before discovering that PostgreSQL backup cannot acquire exclusive state ownership, for example when a custom service owns the Gateway. ## User Impact The update now refuses with `database-engine-preflight` before activation when PostgreSQL capture cannot acquire ownership. The previous installation remains unchanged and the Gateway keeps serving. The message names the next step: stop the Gateway through its service owner, then rerun `openclaw update`. Stopped-service updates still proceed, and updates with no PostgreSQL family keep their existing behavior. This preserves the update contract: refuse only for the named backup-ownership risk, preserve the previous Gateway on refusal, and provide an actionable retry path. ## Why This Change Was Made The shared pre-activation callback probes the same ownership used by database capture. The actual backup still reacquires and checks ownership after activation; a Gateway starting between the two checks retains the existing backup-time refusal. This change deliberately does not introduce a new custody protocol. This is the narrow PostgreSQL part of #193163. A separate companion handles the generic Git persisted-owner check; neither change claims to reproduce or fix the reported 0.372-second worker exit or missing-chunk shutdown chain. The installed updater must contain this repair; when upgrading with an older driver, stop the unmanaged Gateway first. The original commits and contributor credit remain with @etzelm. The maintainer follow-up merges main without rewriting that history and consolidates existing capture fixtures. ## Evidence - On main `69d6eae050e`, the six preflight scenarios produce exactly two intended failures: Git and package updates replace the install while PostgreSQL ownership is held. Both stopped-service controls and both SQLite held-ownership controls pass. Vitest 22.99 s; complete command 128.95 s including compilation. - With the fix, 68 focused tests pass across update execution and capture/retention. Complete command 148.48 s; the execution suite checks refusal before mutation, the next-step message, service stopping, and unchanged non-PostgreSQL behavior. The retention suite still exercises both real transaction owners, snapshot cleanup, late-write retention, first-writer diagnostics, and package rollback. - Scoped lint, update-CLI typechecking, formatting, and all baseline/line-cap ratchets pass. The shared test ceiling is unchanged; the allocation is removed. Production +51/-13 = +38 lines for the shared probe and call site; tests +139/-140 = -1 line. - Independent Codex autoreview: scoped-clean through P2 for `69d6eae050e` → `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`; no accepted/actionable findings. The review inspected supplied source and did not run tests. Limitations: macOS local boundary proof with synthetic I/O, not an end-to-end PostgreSQL deployment or native custom LaunchDaemon. The earlier real serving-process Git proof belongs to the companion scope. No inference model is involved in this maintenance-path proof. ClawSweeper reviewed `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`: no code findings; its remaining hold requests real CLI/PostgreSQL/latest-stable and stored-data compatibility proof. Those environment/upgrade cells remain unrun; this PR changes no schema or data format. Exact-head [CI](https://github.com/openclaw/openclaw/actions/runs/41975816063) and `openclaw/ci-gate` passed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario. Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 1db0343) Stable adaptation: preserve v2026.11.5 capture/boot-write settlement and existing retention fixtures; share only capture ownership acquisition with the pre-activation check. Allocate 69 net regression lines without importing later cohort/rollback features. Co-authored-by: RomneyDa <[email protected]>
Related: #193163
Companion: #193190 (merged)
What Problem This Solves
Git updates can replace checkout and runtime files beneath a foreground or custom-supervised Gateway that native service discovery misses, without a specific warning to restart that process.
User Impact
The update continues and warns that the Gateway keeps running its previous runtime and may fail on lazily loaded chunks until restarted. The warning names the PID and installation root when known and gives the next step through the actual service manager or original terminal. It reaches human output, the JSON result, and recorded update history. Positively identified disjoint installations stay silent. The existing replacement monitor may retire a foreground Gateway when its on-disk runtime changes; it still needs a manual relaunch in that case.
Existing refusals for a live owned service that the update did not stop, a discovered overlapping service, and PostgreSQL capture remain intact. Package update behavior is unchanged. No new configuration, schema, dependency, or protocol.
Why This Change Was Made
The existing persisted-owner probe supplies a recoverable advisory to the existing post-stop update step. That step already owns progress output, JSON, and history; no separate warning or service-discovery mechanism was added. The warning is also retained by the existing bounded history codec, so diagnostic floods cannot silently remove its restart instruction. The foreground
update.runhandoff still parks its parent before publication.Published-driver × candidate: source inspection of latest stable
v2026.10.10shows that its updater lacks this warning. A fixed candidate cannot change that already-running driver. The compiled-driver × synthetic Git-candidate cells below exercise the new behavior; they are not a published-binary upgrade proof. The reported 0.372-second worker exit is not claimed fixed.Evidence
pnpm openclaw update --yes --json --timeout 600: exit 0 / statusokin 349.915 s. JSON includes PID 91935 and the installation root; persisted history preserves the exact warning with canonical path redaction, and humanupdate statusrenders it. Manual relaunch changed PID 91935 to 35676 and protocol hello from fixture runtime .2 to .3. The old PID was retired by the existinggateway.installation_replacedpolicy from fix: restart Gateway after manual package replacement #153078, so the requested old-PID-keeps-serving cell did not pass. No fake build identity was used to suppress it.update.runalso passed end to end in 361.431 s: the handoff recordedforegroundOriginandcompletionOwner: gateway-restart, the child exited 0, the run finishedsucceeded, PID 40401 became 69024, and protocol hello changed from fixture runtime .3 to .4. The child did not treat its own parent as a blocking owner.pnpm buildpasses (final rebuild phase time 3m 56s), as do scoped types/lint, formatting, and all ten final-head baseline ratchets. No test allocation or ceiling increase; the inherited tree is 29 lines above its ceiling and this patch's delta is zero.openclaw/ci-gatepassed oncf0af5c74fa646766a7f02b3a485712581a00c2c: exact-head run, 50 successful jobs and 27 skipped.cf0af5c74fa646766a7f02b3a485712581a00c2c, including the history codec fix, documentation caveat, and shipped replacement-policy context; no actionable findings. Supplied diff/source context reviewed; reviewer did not execute tests.Production +44/-27 = +17 lines; tests +39/-39 = 0. The test changes retain the managed/disjoint controls and main's shared Git/package retention matrix, reset reused step receipts, preserve filesystem retention proof, and extend the existing bounded-history regression. Only redundant presence/uniqueness assertions were removed.
Local limitation: two existing source-publication heartbeat cases failed with the same
OPENCLAW_STATE_LEASE_LOST/state lease heartbeat is not runningsignature on the original patch and unmodified main. Their tests and timeouts remain unchanged. Platform proof is macOS only; native custom-service/PostgreSQL deployment and published-driver binary upgrade cells are not claimed.ClawSweeper reviewed this exact head with no findings and no “Before merge” items. Its proof note predates completion of the final terminal/history and foreground evidence above. A published-stable binary upgrade remains unclaimed for the driver/candidate reason above. This PR remains unmerged for maintainer review.