Repository navigation
fix: finish early Git checkout updates automatically instead of asking for a rebuild - #204322
Merged
fuller-stack-dev merged 49 commits intoNov 24, 2026
Conversation
…hey cannot finish
…ase-schema-refusal
…ase-schema-refusal
…ase-schema-refusal
… a failed rebuild visible
…ld back after it starts
… single-flight, truthful messages
Contributor
|
🦞👀 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. |
readonly_shm cannot open a WAL store without its -shm, which a clean close removes. The early-release check then read state as unreadable and let the early updater through to its own refusing Doctor after switching the link. Read such a store immutably; it has no WAL content to miss.
When the release migrated and then fails, the runner says the service keeps starting it; reset the start limit so that is true.
…ew gaps - Put-back: stop the Gateway with the unit's TimeoutStopSec plus a minute, require the stop to succeed and the unit to be inactive or failed before the second schema comparison, and treat anything else as migrated. Remove the kept release only once the previous build is back and serves. - Not put back: record first, then reset-failed and start the release when the unit is not active; the text says failed/stopped and what systemd will do instead of claiming a start limit or endless restarts. - Readiness wait: also give up once systemd restarted the release as often as its StartLimitBurst allows, so a boot that crashes 30 s in does not hold the user without a Gateway for 20 minutes. - Schema reads: open a store immutably only when it has no -wal and no -journal and its header says WAL; rollback-journal stores are read with locks and a busy timeout. - Runner environment: pass OPENCLAW_STATE_DIR only when the check had it, so the reinstall does not write it into a unit that had none. - Start lock: release it only when this check owns it; move a dead check's lock to a name only it has, so two checks that saw it dead cannot move a live lock or leave two holders. The finishing step removes those names. - Record path: one run when another update holds the lock, not an extra skipped run.
…the CLI may fail until rebuilt
…d unit needs reset-failed
…ecord module to avoid an import cycle
Member
Author
|
Merged via squash.
|
obviyus
added a commit
that referenced
this pull request
Nov 24, 2026
Preserve #204322 recovery logic unchanged after merging current main. Document that its CLI-only repair run starts after one Gateway ready event and cleanup finishes after the next, so neither event can settle that distinct repair operation. No published Git release tag shipped the Nov 17–19 layout; retire the main-only bridge at the first regular stable cut after v2026.11.8, retaining code for in-flight recoveries.
This was referenced Nov 24, 2026
obviyus
added a commit
that referenced
this pull request
Nov 24, 2026
## What Problem This Solves An update could start successfully or roll back safely, but its saved result could still say it was interrupted. The old Gateway and startup recovery could publish conflicting terminal results before the serving Gateway read the launcher's trial. Related: #203925, #204215, #204054, #204253, #203994, #204063, #203981. ## User Impact The Gateway that is ready records the activation result from the trial, without an expired preparation lock overriding the same run. Existing report headlines, cause, next step, serving-version details, and the visible restarting phase are preserved. No schema or configuration change. A reused PID alone no longer makes an update fail: without a matching trial, the recorded lock deadline remains authoritative. ## Why This Change Was Made Preparation owns refusals, already-current results, and failures before publication. It checks for an active trial while holding the preparation lock, so a concurrent request cannot prepare across another request's newly published trial. Gateway readiness settles trial outcomes first, preserves active trial phases, and then settles only a dead lock whose row remains running. This removes the old Gateway's second terminal writer and startup's PID/uptime guess without comparing update correlation IDs. Restart is armed before its nonterminal progress write, and pending trials publish only after preparation bookkeeping. The notice and report paths share a pure serving-version projection, without importing backend ledger mutation code into Control UI. Status rendering is retained unchanged. A complete LSP audit found production readers for every remaining report export, so none was deleted only to meet a line target. Production code on this PR's six touched runtime files against integrated main `38e8b1e330a162ca7435dda27ca43d268fbc8017` (tests/support/harness excluded): **2,562 → 2,557 (−5)**. `tokei` measured 2,553 before the final four explicit no-op switch-case lines. The database-worker registry and synthetic-module test harness each add one test infrastructure line separately. ### Retained compatibility repair: #204322 The contributor's recovery code is unchanged. This is not a modern launcher-trial settlement path: - [Eligibility](https://github.com/openclaw/openclaw/blob/38e8b1e330a162ca7435dda27ca43d268fbc8017/src/infra/update-candidate-check-early-release.ts#L132-L176) is only moving-`main` Git updaters from November 17–19, with `releases/<id>/build` and the old `lib/node_modules/openclaw` link, when schemas must change or recovery is already in progress. Automatic recovery additionally requires a matching running Linux systemd user service. Current Git and npm/pnpm installs do not take it. - Both terminal-recording functions have one production caller: the [`cli-oneshot` worker mode](https://github.com/openclaw/openclaw/blob/38e8b1e330a162ca7435dda27ca43d268fbc8017/src/infra/update-migrated-finalize.worker.ts#L93-L108), which returns without entering Gateway startup. Gateway processes are separate children, not these workers. - The [first ready check precedes opening the repair run](https://github.com/openclaw/openclaw/blob/38e8b1e330a162ca7435dda27ca43d268fbc8017/src/infra/update-early-release-recovery.ts#L385-L404). The [second precedes finishing and cleanup](https://github.com/openclaw/openclaw/blob/38e8b1e330a162ca7435dda27ca43d268fbc8017/src/infra/update-early-release-recovery.ts#L442-L454). Its success means the checkout and PATH repair is complete, not merely that a Gateway booted. Failure can also be recorded when the migrated release never becomes ready. There is no current v2 trial handoff for that repair operation, so moving its record to either ready event would lose or prematurely finish it. **Published versions: none.** Published Git tags `v2026.11.5`, `v2026.10.33`, `v2026.11.6`, `v2026.11.7`, `v2026.11.8`, and `v2026.11.10-beta.1`–`.3` contain neither the early Git release-path module nor its runner. Earlier releases predate its introducing commit `6747b1ec5ae`; no published `v` tag lies between that commit and layout replacement `2ef6f7bade7`. The snapshots report a release-like version but belong to the moving `main` dev channel, not a published release. **Deletion trigger:** retire this main-only recovery family and its early-layout check at the first regular stable cut after published `v2026.11.8` (stable/dev are distinct in [release policy](https://github.com/openclaw/openclaw/blob/38e8b1e330a162ca7435dda27ca43d268fbc8017/docs/reference/RELEASING.md#release-channels)). Already-started recovery units retain their own code until they finish. ## Evidence - Base owner regression: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_31f06e4e9eeb9c36b954bef19ed05bad), base `a6893b815789aa305070547ad28a032c7c87500e` plus the regression. Both committed and rolled-back trials incorrectly became interrupted; the live reused-PID case also incorrectly failed (three expected failures, three passes). - Consumer proof for the earlier shape: 1,264 tests passed across 65 files, with one skipped file. The only two failures were the new preparation tests running without the host SQLite broker; [both passed after project registration](https://crabbox.openclaw.ai/portal/runs/run_5f8278182e180f2864a4103697ac117a). Existing report and UI tests are included. - Runtime patch head `48594843ded928e56eaf849ce6d156ce94065d2a`: [AWS proof](https://crabbox.openclaw.ai/portal/runs/run_494f1acc71169d7dd0313d8740a2b91c) passed **21 tests in both owner files and the session-identity ratchet**, including all three active-trial phases and the concurrent-publication race. No full consumer suite was rerun. - Integrated head `285de72e5bc3b2d617e2646d6124dacc997b822c` merges main `38e8b1e330a162ca7435dda27ca43d268fbc8017` and documents the verified bridge exception without changing its recovery code. Its 21 owner tests and ratchet passed. Its subsequent build failed before either matrix case started; no matrix pass is claimed. - The auth regression now uses real `prepareUpdate` with an injected lock-link failure, keeping the same failed-outcome assertions. Its [affected CI gate passed](https://github.com/openclaw/openclaw/actions/runs/45443743806/job/138623113263) on test-only commit `e8e54bfec0a09ea5d48d09f4638e0493711f7336`. - Qualification source `0fb086108808764c16e6f354cf1557478d9ff974`: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_d9922f2b7283a54e4c847e4f2b4e5799) passed **101 owner/report tests**, the session-identity ratchet, and full T/T+1 builds including Control UI. Canonical healthy schema **41→42** passed: committed trial, succeeded ledger row, two fixture rows retained, target build serving (165.095 s whole scenario, not a measured outage). - **Separate rollback-restore class RED, not addressed by this settlement cut:** the crash trial rolled back and `/readyz` returned success on schema41, but the actual SQL ledger row remained `running/restarting`; the serving Gateway could not read its restored database (`database disk image is malformed`) and deferred settlement. The CLI reported a read-only-worker rollback error. Trial, crash marker, actual ledger rows, schema/readiness summary, and bounded launcher/Gateway journal were captured. The rollback/state owner is investigating this separately; no unchanged retry or weakened assertion. - The UI import leak was ours, not inherited. It is fixed by the unchanged projection moving to the pure notice module; [UI E2E 1/2](https://github.com/openclaw/openclaw/actions/runs/45451818804/job/138651992698), [2/2](https://github.com/openclaw/openclaw/actions/runs/45451818804/job/138651992590), and [Control UI performance](https://github.com/openclaw/openclaw/actions/runs/45451818804/job/138651991532) now pass. No override is requested for UI or other owned failures. - Local ClawSweeper runtime review: **patch is correct, zero findings**, exact head `48594843ded928e56eaf849ce6d156ce94065d2a`. Subsequent changes are the current-main integration, compatibility documentation, auth fixture, and browser-safe projection ownership described above. - Final head `4f4c6a7bb68acde5a46edb40ab5a4e1c3405ec5e` differs from that qualification source only by the no-op exhaustive cases below and one fixture allowlist entry loading the **real** notice module instead of an unexpected-call stub. Outcome assertions remain unchanged. These are owned CI fixes; their checks must pass. The qualification remains behavior-equivalent. ```diff case "restoring": return; +case undefined: +case "committed": +case "rolled-back": + break; ``` - Remaining CI planner fixture red is **MAIN-ALSO**, superseding the earlier ci-triage OURS label: [one clean-main AWS run](https://crabbox.openclaw.ai/portal/runs/run_266010a78ce4d0e864cfa9f696fd7f68) at `269f88452ac261cec1d8e99e7b740cedfe341161` reproduced the same expected-four/actual-five assertion (**173 passed, one failed**). No planner or fixture change is included. The [scoped maintainer override](#204700 (comment)) covers only that main failure and its aggregate gate. Exhaustive lint and compact-small-6 both pass. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 25, 2026
…g for a rebuild (openclaw#204322) * fix(update): stop early Git release updaters before a schema change they cannot finish * fix(update): name a path-free rebuild and read every agent store * fix(update): rebind the service before Doctor in the printed rebuild * refactor(update): keep the rebuild text private to its check * fix(update): let the rebuilt Gateway migrate state instead of a racing Doctor * fix(update): finish early Git release updates with a detached rebuild * fix(update): restart the previous service only when the rebuild fails * fix(update): keep concurrent early updaters out while a recovery runs * fix(update): name a working next step when the kept release does not start * test(update): compact the early release recovery cases; document the automatic route * fix(update): leave PostgreSQL stores and live sidecars alone and keep a failed rebuild visible * fix(update): find the early updater by its renamed process title * test(update): restore the split separator after the merge * fix(update): wait for the release over HTTP and never put the old build back after it starts * fix(update): do not count the finishing runner as a user of the kept release * refactor(update): read recovery JSON without type assertions * fix(update): address review: readiness probe, self-exclusion, resume, single-flight, truthful messages * refactor(update): run the recovery through its production exports * fix(update): end the recovery modes without forcing process exit * fix(update): address review: hold the update lock, keep the port, verify before cleanup, release an interrupted build's lock * fix(update): release the update lock by its holder process * refactor(update): give the recovery's command helpers distinct export names * fix(update): finish the held recovery run, restore an unmigrated Gateway, check identity - Carry the run id through the finishing step's arguments, so the run the recovery holds is the run it finishes; no phantom running update is left. - When the new release never reports ready and every store's schema version still equals the plan's, stop it, restore the saved unit definition, restart the previous Gateway and check it serves. Stop waiting early when the unit keeps failing. - Record to the state database only once the schema moved; the release's writer would migrate state the previous build serves. Every failure prints its next step in the journal; the started message points failures there. - Wait for readiness before taking the update lock on resume; any throw now ends in a recorded failure or a put-back. - Require the service entry's and the PATH command's Git toplevel to be the checkout, refuse when identity cannot be established, and require the target to be on the branch's upstream. Refuse when the Gateway service is not running. - Keep one copy of the unit as it was before recovery and restore a disabled autostart. - Take the start lock before cleaning an earlier attempt's release; escape `$` for systemd; collect `.removing-*` leftovers; omit downtime a resume could not measure. * fix(update): pass the resolved state directory and close review gaps in the recovery - Pass the state directory the check read (resolved) and OPENCLAW_HOME to the runner. - Abandon instead of building when the branch moved past the target after the merge. - Treat the unit's own start-limit failure as the crash-loop signal; its burst is sized for a Gateway waiting out a previous one, so restart counts misjudge a healthy start. - Name a next step that fits when the restored previous build does not serve, and record failures once the runner holds a run; settle an interrupted runner's run. - reset-failed before restarting a start-limited release; restore a disabled autostart on abandon; say when the PATH command cannot be traced. - Take a dead check's start lock aside and confirm it before removing it. - Tests: real Git in the runner fixture, the Gateway running and autostart disabled at the end of every path, and a store that moves between the comparison and the stop. * refactor(update): keep the worker as the consumer of the recovery's entry points The dead-export scan rejects test-only exports. The worker again parses the recovery arguments (now carrying the run id) and calls the runner or the finishing step with the default dependencies; tests use the same exports. * fix(update): read schema versions of stores a stopped Gateway closed readonly_shm cannot open a WAL store without its -shm, which a clean close removes. The early-release check then read state as unreadable and let the early updater through to its own refusing Doctor after switching the link. Read such a store immutably; it has no WAL content to miss. * fix(update): keep starting a migrated release that hit its start limit When the release migrated and then fails, the runner says the service keeps starting it; reset the start limit so that is true. * fix(update): make the early release put-back race-free and close review gaps - Put-back: stop the Gateway with the unit's TimeoutStopSec plus a minute, require the stop to succeed and the unit to be inactive or failed before the second schema comparison, and treat anything else as migrated. Remove the kept release only once the previous build is back and serves. - Not put back: record first, then reset-failed and start the release when the unit is not active; the text says failed/stopped and what systemd will do instead of claiming a start limit or endless restarts. - Readiness wait: also give up once systemd restarted the release as often as its StartLimitBurst allows, so a boot that crashes 30 s in does not hold the user without a Gateway for 20 minutes. - Schema reads: open a store immutably only when it has no -wal and no -journal and its header says WAL; rollback-journal stores are read with locks and a busy timeout. - Runner environment: pass OPENCLAW_STATE_DIR only when the check had it, so the reinstall does not write it into a unit that had none. - Start lock: release it only when this check owns it; move a dead check's lock to a name only it has, so two checks that saw it dead cannot move a live lock or leave two holders. The finishing step removes those names. - Record path: one run when another update holds the lock, not an extra skipped run. * fix(update): keep the original trigger on the recovery's run and say the CLI may fail until rebuilt * fix(update): release the start lock by renaming it, and prove a failed unit needs reset-failed * refactor(update): keep the recovery's plan and outcome types in the record module to avoid an import cycle * test(update): drop a comment that restates its row's fixture * test(update): record the early release recovery's test-line allocation
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 25, 2026
…w#204700) ## What Problem This Solves An update could start successfully or roll back safely, but its saved result could still say it was interrupted. The old Gateway and startup recovery could publish conflicting terminal results before the serving Gateway read the launcher's trial. Related: openclaw#203925, openclaw#204215, openclaw#204054, openclaw#204253, openclaw#203994, openclaw#204063, openclaw#203981. ## User Impact The Gateway that is ready records the activation result from the trial, without an expired preparation lock overriding the same run. Existing report headlines, cause, next step, serving-version details, and the visible restarting phase are preserved. No schema or configuration change. A reused PID alone no longer makes an update fail: without a matching trial, the recorded lock deadline remains authoritative. ## Why This Change Was Made Preparation owns refusals, already-current results, and failures before publication. It checks for an active trial while holding the preparation lock, so a concurrent request cannot prepare across another request's newly published trial. Gateway readiness settles trial outcomes first, preserves active trial phases, and then settles only a dead lock whose row remains running. This removes the old Gateway's second terminal writer and startup's PID/uptime guess without comparing update correlation IDs. Restart is armed before its nonterminal progress write, and pending trials publish only after preparation bookkeeping. The notice and report paths share a pure serving-version projection, without importing backend ledger mutation code into Control UI. Status rendering is retained unchanged. A complete LSP audit found production readers for every remaining report export, so none was deleted only to meet a line target. Production code on this PR's six touched runtime files against integrated main `d0782abed304605ff96699085776fa447e3f4d54` (tests/support/harness excluded): **2,562 → 2,557 (−5)**. `tokei` measured 2,553 before the final four explicit no-op switch-case lines. The database-worker registry and synthetic-module test harness each add one test infrastructure line separately. ### Retained compatibility repair: openclaw#204322 The contributor's recovery code is unchanged. This is not a modern launcher-trial settlement path: - [Eligibility](https://github.com/openclaw/openclaw/blob/d0782abed304605ff96699085776fa447e3f4d54/src/infra/update-candidate-check-early-release.ts#L132-L176) is only moving-`main` Git updaters from November 17–19, with `releases/<id>/build` and the old `lib/node_modules/openclaw` link, when schemas must change or recovery is already in progress. Automatic recovery additionally requires a matching running Linux systemd user service. Current Git and npm/pnpm installs do not take it. - Both terminal-recording functions have one production caller: the [`cli-oneshot` worker mode](https://github.com/openclaw/openclaw/blob/d0782abed304605ff96699085776fa447e3f4d54/src/infra/update-migrated-finalize.worker.ts#L93-L108), which returns without entering Gateway startup. Gateway processes are separate children, not these workers. - The [first ready check precedes opening the repair run](https://github.com/openclaw/openclaw/blob/d0782abed304605ff96699085776fa447e3f4d54/src/infra/update-early-release-recovery.ts#L385-L404). The [second precedes finishing and cleanup](https://github.com/openclaw/openclaw/blob/d0782abed304605ff96699085776fa447e3f4d54/src/infra/update-early-release-recovery.ts#L442-L454). Its success means the checkout and PATH repair is complete, not merely that a Gateway booted. Failure can also be recorded when the migrated release never becomes ready. There is no current v2 trial handoff for that repair operation, so moving its record to either ready event would lose or prematurely finish it. **Published versions: none.** Published Git tags `v2026.11.5`, `v2026.10.33`, `v2026.11.6`, `v2026.11.7`, `v2026.11.8`, and `v2026.11.10-beta.1`–`.3` contain neither the early Git release-path module nor its runner. Earlier releases predate its introducing commit `c303d979c41`; no published `v` tag lies between that commit and layout replacement `8d7301e6086`. The snapshots report a release-like version but belong to the moving `main` dev channel, not a published release. **Deletion trigger:** retire this main-only recovery family and its early-layout check at the first regular stable cut after published `v2026.11.8` (stable/dev are distinct in [release policy](https://github.com/openclaw/openclaw/blob/d0782abed304605ff96699085776fa447e3f4d54/docs/reference/RELEASING.md#release-channels)). Already-started recovery units retain their own code until they finish. ## Evidence - Base owner regression: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_31f06e4e9eeb9c36b954bef19ed05bad), base `e48368087277475b47996815403ad103cd416089` plus the regression. Both committed and rolled-back trials incorrectly became interrupted; the live reused-PID case also incorrectly failed (three expected failures, three passes). - Consumer proof for the earlier shape: 1,264 tests passed across 65 files, with one skipped file. The only two failures were the new preparation tests running without the host SQLite broker; [both passed after project registration](https://crabbox.openclaw.ai/portal/runs/run_5f8278182e180f2864a4103697ac117a). Existing report and UI tests are included. - Runtime patch head `48594843ded928e56eaf849ce6d156ce94065d2a`: [AWS proof](https://crabbox.openclaw.ai/portal/runs/run_494f1acc71169d7dd0313d8740a2b91c) passed **21 tests in both owner files and the session-identity ratchet**, including all three active-trial phases and the concurrent-publication race. No full consumer suite was rerun. - Integrated head `285de72e5bc3b2d617e2646d6124dacc997b822c` merges main `d0782abed304605ff96699085776fa447e3f4d54` and documents the verified bridge exception without changing its recovery code. Its 21 owner tests and ratchet passed. Its subsequent build failed before either matrix case started; no matrix pass is claimed. - The auth regression now uses real `prepareUpdate` with an injected lock-link failure, keeping the same failed-outcome assertions. Its [affected CI gate passed](https://github.com/openclaw/openclaw/actions/runs/45443743806/job/138623113263) on test-only commit `e8e54bfec0a09ea5d48d09f4638e0493711f7336`. - Qualification source `0fb086108808764c16e6f354cf1557478d9ff974`: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_d9922f2b7283a54e4c847e4f2b4e5799) passed **101 owner/report tests**, the session-identity ratchet, and full T/T+1 builds including Control UI. Canonical healthy schema **41→42** passed: committed trial, succeeded ledger row, two fixture rows retained, target build serving (165.095 s whole scenario, not a measured outage). - **Separate rollback-restore class RED, not addressed by this settlement cut:** the crash trial rolled back and `/readyz` returned success on schema41, but the actual SQL ledger row remained `running/restarting`; the serving Gateway could not read its restored database (`database disk image is malformed`) and deferred settlement. The CLI reported a read-only-worker rollback error. Trial, crash marker, actual ledger rows, schema/readiness summary, and bounded launcher/Gateway journal were captured. The rollback/state owner is investigating this separately; no unchanged retry or weakened assertion. - The UI import leak was ours, not inherited. It is fixed by the unchanged projection moving to the pure notice module; [UI E2E 1/2](https://github.com/openclaw/openclaw/actions/runs/45451818804/job/138651992698), [2/2](https://github.com/openclaw/openclaw/actions/runs/45451818804/job/138651992590), and [Control UI performance](https://github.com/openclaw/openclaw/actions/runs/45451818804/job/138651991532) now pass. No override is requested for UI or other owned failures. - Local ClawSweeper runtime review: **patch is correct, zero findings**, exact head `48594843ded928e56eaf849ce6d156ce94065d2a`. Subsequent changes are the current-main integration, compatibility documentation, auth fixture, and browser-safe projection ownership described above. - Final head `4f4c6a7bb68acde5a46edb40ab5a4e1c3405ec5e` differs from that qualification source only by the no-op exhaustive cases below and one fixture allowlist entry loading the **real** notice module instead of an unexpected-call stub. Outcome assertions remain unchanged. These are owned CI fixes; their checks must pass. The qualification remains behavior-equivalent. ```diff case "restoring": return; +case undefined: +case "committed": +case "rolled-back": + break; ``` - Remaining CI planner fixture red is **MAIN-ALSO**, superseding the earlier ci-triage OURS label: [one clean-main AWS run](https://crabbox.openclaw.ai/portal/runs/run_266010a78ce4d0e864cfa9f696fd7f68) at `0ef684ebc6840c92d9ae493cfe64b390acd90e49` reproduced the same expected-four/actual-five assertion (**173 passed, one failed**). No planner or fixture change is included. The [scoped maintainer override](openclaw#204700 (comment)) covers only that main failure and its aggregate gate. Exhaustive lint and compact-small-6 both pass. Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 26, 2026
…g for a rebuild (#204322) * fix(update): stop early Git release updaters before a schema change they cannot finish * fix(update): name a path-free rebuild and read every agent store * fix(update): rebind the service before Doctor in the printed rebuild * refactor(update): keep the rebuild text private to its check * fix(update): let the rebuilt Gateway migrate state instead of a racing Doctor * fix(update): finish early Git release updates with a detached rebuild * fix(update): restart the previous service only when the rebuild fails * fix(update): keep concurrent early updaters out while a recovery runs * fix(update): name a working next step when the kept release does not start * test(update): compact the early release recovery cases; document the automatic route * fix(update): leave PostgreSQL stores and live sidecars alone and keep a failed rebuild visible * fix(update): find the early updater by its renamed process title * test(update): restore the split separator after the merge * fix(update): wait for the release over HTTP and never put the old build back after it starts * fix(update): do not count the finishing runner as a user of the kept release * refactor(update): read recovery JSON without type assertions * fix(update): address review: readiness probe, self-exclusion, resume, single-flight, truthful messages * refactor(update): run the recovery through its production exports * fix(update): end the recovery modes without forcing process exit * fix(update): address review: hold the update lock, keep the port, verify before cleanup, release an interrupted build's lock * fix(update): release the update lock by its holder process * refactor(update): give the recovery's command helpers distinct export names * fix(update): finish the held recovery run, restore an unmigrated Gateway, check identity - Carry the run id through the finishing step's arguments, so the run the recovery holds is the run it finishes; no phantom running update is left. - When the new release never reports ready and every store's schema version still equals the plan's, stop it, restore the saved unit definition, restart the previous Gateway and check it serves. Stop waiting early when the unit keeps failing. - Record to the state database only once the schema moved; the release's writer would migrate state the previous build serves. Every failure prints its next step in the journal; the started message points failures there. - Wait for readiness before taking the update lock on resume; any throw now ends in a recorded failure or a put-back. - Require the service entry's and the PATH command's Git toplevel to be the checkout, refuse when identity cannot be established, and require the target to be on the branch's upstream. Refuse when the Gateway service is not running. - Keep one copy of the unit as it was before recovery and restore a disabled autostart. - Take the start lock before cleaning an earlier attempt's release; escape `$` for systemd; collect `.removing-*` leftovers; omit downtime a resume could not measure. * fix(update): pass the resolved state directory and close review gaps in the recovery - Pass the state directory the check read (resolved) and OPENCLAW_HOME to the runner. - Abandon instead of building when the branch moved past the target after the merge. - Treat the unit's own start-limit failure as the crash-loop signal; its burst is sized for a Gateway waiting out a previous one, so restart counts misjudge a healthy start. - Name a next step that fits when the restored previous build does not serve, and record failures once the runner holds a run; settle an interrupted runner's run. - reset-failed before restarting a start-limited release; restore a disabled autostart on abandon; say when the PATH command cannot be traced. - Take a dead check's start lock aside and confirm it before removing it. - Tests: real Git in the runner fixture, the Gateway running and autostart disabled at the end of every path, and a store that moves between the comparison and the stop. * refactor(update): keep the worker as the consumer of the recovery's entry points The dead-export scan rejects test-only exports. The worker again parses the recovery arguments (now carrying the run id) and calls the runner or the finishing step with the default dependencies; tests use the same exports. * fix(update): read schema versions of stores a stopped Gateway closed readonly_shm cannot open a WAL store without its -shm, which a clean close removes. The early-release check then read state as unreadable and let the early updater through to its own refusing Doctor after switching the link. Read such a store immutably; it has no WAL content to miss. * fix(update): keep starting a migrated release that hit its start limit When the release migrated and then fails, the runner says the service keeps starting it; reset the start limit so that is true. * fix(update): make the early release put-back race-free and close review gaps - Put-back: stop the Gateway with the unit's TimeoutStopSec plus a minute, require the stop to succeed and the unit to be inactive or failed before the second schema comparison, and treat anything else as migrated. Remove the kept release only once the previous build is back and serves. - Not put back: record first, then reset-failed and start the release when the unit is not active; the text says failed/stopped and what systemd will do instead of claiming a start limit or endless restarts. - Readiness wait: also give up once systemd restarted the release as often as its StartLimitBurst allows, so a boot that crashes 30 s in does not hold the user without a Gateway for 20 minutes. - Schema reads: open a store immutably only when it has no -wal and no -journal and its header says WAL; rollback-journal stores are read with locks and a busy timeout. - Runner environment: pass OPENCLAW_STATE_DIR only when the check had it, so the reinstall does not write it into a unit that had none. - Start lock: release it only when this check owns it; move a dead check's lock to a name only it has, so two checks that saw it dead cannot move a live lock or leave two holders. The finishing step removes those names. - Record path: one run when another update holds the lock, not an extra skipped run. * fix(update): keep the original trigger on the recovery's run and say the CLI may fail until rebuilt * fix(update): release the start lock by renaming it, and prove a failed unit needs reset-failed * refactor(update): keep the recovery's plan and outcome types in the record module to avoid an import cycle * test(update): drop a comment that restates its row's fixture * test(update): record the early release recovery's test-line allocation (cherry picked from commit d015eff) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #204275, #203608, #203194, #201463, #201906
What Problem This Solves
Git checkouts whose installed updater was built from
mainbetween 2026-11-17 and 2026-11-19 (for example a checkout at8f80fe08cad) cannot finish an update that migrates the databases. Since #204275 the new release's check stops that update cleanly and prints a one-time rebuild to run by hand. Until someone runs it, the install stays on the old build and every lateropenclaw updatestops at the same point.User Impact
On Linux with a systemd user service, the update now finishes itself. The old updater still reports this one update as failed (it cannot be patched), but its output says the new release is finishing in the background and names a path-free command to follow it. About five minutes later the Gateway serves the new version from the rebuilt checkout,
openclawon PATH reports the new version, the leftovers of the early layout are gone, no update run is left active, and later updates run normally.TimeoutStopSeclets a migration in progress finish), puts the service definition back, restarts the previous build and checks it serves: 54 s outage when the release exits at start, 354 s when it crashes 30 s into each boot (it gives up once systemd restarted itStartLimitBursttimes; before, it waited the full 20 minutes). Once anything migrated, or when the stop does not finish, the previous build is never put back, and the release is removed only once the previous build serves.openclaw-gateway.service.before-update-recoverybeside it and named in the outcome. A disabled autostart stays disabled. Drop-ins survive.Why This Change Was Made
The installed updater (
8f80fe08cad) runs candidate code only inpnpm install/pnpm build, the read-only inspection workers,--versionand the candidate'supdate-migrated-finalize.worker --check. A failing install or build makes it walk back to older commits, so--checkis the only hook that can stop it cleanly and act.When
--checkrefuses (the #204275 marker: the check runs fromgit-install/releases/<id>/buildwhilegit-install/lib/node_modules/openclawis a link, and the release would migrate state), it now also:git rev-parse --show-toplevelequal the checkout (the PATH command is traced through symlinks and pnpm's# cmd-shim-target=line; an untraceable command, or the early launcher with noopenclawon PATH, is refused); 4 GiB free;pnpmand a user manager present; every store's schema version readable. It records the service's enabled state and every store's schema version in the plan.git worktree movetogit-install/recovery/openclaw), so the target is built once and a concurrent check cannot remove it.systemd-run --user --unit=openclaw-update-recovery --collect -p Restart=on-abnormal) from that release's code, with the resolved state directory only when the check's environment set one (the runner'sgateway install --forcewould otherwise write it into a unit that had none), and$escaped as$$, and exits 1 so the old updater stops before switching anything.The runner then:
openclaw-gateway.service.before-update-recovery, moves the service onto the kept release with its owngateway install --force --port <current port>, and waits on/readyz(over HTTP: the CLI's start check cannot open state the booting release holds). It stops waiting early when the unit fails, or once systemd restarted it as often as the unit'sStartLimitBurst(a boot that crashes slower than the start limit's window never trips the limit itself).TimeoutStopUSecplus a minute, requires the stop to succeed and the unit to beinactiveorfailed, compares again, writes the saved unit back,daemon-reload,reset-failed, starts the previous build, checks it serves, and only then removes the release. Otherwise it leaves the release unit, records the failure first, thenreset-failedand starts the release when the unit is not active.src/update/store.ts). A resumed runner waits for readiness first, so it never takes the lock while the boot migration holds state..removing-*leftovers, runsgit worktree prune, and finishes that same run.Every failure path prints its next step in the journal verbatim. A failure is written to the state database only once the schema moved or the runner holds a run: opening state for writing through the new release's code runs its forward migration (
ensureOpenClawStateRuntimeSchema; the guard inopenclaw-state-service-installation.tsapplies only to CLI processes that loaded the service installation), which would strand the previous build being put back. Any exception ends in a recorded failure or a put-back.The early-release check also reads schema versions of stores a stopped Gateway closed:
readonly_shmcannot open a WAL store without its-shm, so the check treated state as unreadable and let the early updater through to switch its link and fail its own Doctor (cell RF onf3711d6ed5a). A store with no-waland no-journalwhose header says WAL is now read immutably; a rollback-journal store (network filesystems) is read with locks and a busy timeout, so a writer's commit is waited out and a hot journal is seen.Why it survives where #201906's finisher did not. That finisher ran in a
systemd-run --scopeand was reaped with the caller's process tree. The runner here is a transient service in its own cgroup; neither the old updater's exit nor the Gateway restarts touch it.Update behavior. Only the early updaters with a pending schema change (or a recovery in progress) take this route. Same-schema updates through them, published npm/pnpm installs and current-main checkouts are untouched. No config key, stored field, schema, protocol, dependency, retention or permission change; the plan and the unit copy are transient files of the recovery. Removal: delete
update-early-release-recovery*.ts(including the-readyand-recordsiblings split out for the line cap) withupdate-candidate-check-early-release.tsonce no install can still run an updater from that window.What the unit preservation covers. Each
gateway install --forcerewritesopenclaw-gateway.service, so edits inside it (for exampleNice=) do not carry over to the live unit; the copy from before the recovery keeps them and is named in the outcome (RF2: copy hasNice=5, live unit not). Drop-ins underopenclaw-gateway.service.d/are separate files and keep applying (RF2:GRA_DROPIN=1in the service environment afterwards). Environment files the unit names are not copied. The existing definition-backup owner (service-definition-backup.ts) binds its receipt to an install transaction in one process through mutation hooks and rejects definitions changed outside them, so it cannot follow installs run by the release's and the checkout's CLIs.Evidence
Cells: Linux containers with systemd as PID 1, a user Gateway service from
openclaw gateway install, a 512 MiB agent database under 1 MiB/s of writes, 1,000 marker rows checked by count, SHA-256 andquick_check, and a node runner started from the checkout. The installed updater is a checkout at8f80fe08cad; state is synthetic. The update is plainopenclaw updatefrom PATH unless noted. Outage is measured by a client polling the Gateway. T+1/T+2 are throwaway version bumps on the head.759c5ea581bactiveRunnone, unit environment unchanged (OPENCLAW_STATE_DIRwas already in the user's unit), enabled stays enabled759c5ea581bexit-code); put back after 355 s ("restarted 10 times", start limit never hit); retry recoveredupdate.run(corrected harness)86e77be1e04update.runaccepted; recovery unit outlived the handoff unit and both restartsactiveRunnone, last run succeeded with triggerapib5fbfb4e12aactiveRunnone, copy kept, enabled stays enabledopenclaw updateafter the failure, then the journal's next stepf3711d6ed5aopenclaw updateis already current; kept release and old layout (9.7 GiB) stay on disk, as the record saysExecStartPre(the release's owngateway installrolls the unit back)f3711d6ed5aopenclaw updaterecoveredf3711d6ed5a(before the stopped-store read fix)b4c5308e73cb4c5308e73copenclaw updaterecovered/readyzdown), then T+1f3711d6ed5aactiveRunnone, downtime left outNice=5edit + a drop-inb4c5308e73cNice=5, drop-in applies,activeRunnoneupdate.runf3711d6ed5a,b4c5308e73cfetch-failed: a harness race (its ownopenclaw update statusfetched in the same checkout while the old updater fetched; Git trace shows "cannot lock ref"), not product; superseded by B5 on9132a642d2fand B6Linked worktree: with the service running from a linked worktree, the installed updater does not take its release-layout route at all; it updates in place, its own Doctor refuses the unmigrated state and it rolls back (end state 2026.11.4 on 40/42, serving). The identity refusal is unit-tested.
Code after each cell's head: N4 and A5 ran on
759c5ea581b. After it: the recovery's run takes the trigger of the run the early updater recorded (apion the Gateway route, proven by B6;cliin A5 and N4 either way), the span parser lost a type assertion, the readiness wait and run recording moved to sibling modules unchanged, the start lock is released by a rename, and the wording changed. None changes the put-back, crash-loop or reinstall behavior those cells measured. After B6's head: the plan and outcome types moved into the record module (an import cycle CI's madge check found; types only), and twomainmerges, which bring backup scratch code and #204676 (Doctor repair of a Git checkout after its first current-main update; it changes the service-entry resolution that T+1/T+2 and Doctor use, not the recovery's own checks, which read the entry index directly).Earlier cells that still stand: A4, G3, K and RF2 (success, failed build, killed runner, unit customizations) cover paths whose behavior this round did not change; A5 and B6 repeat the success path on the new code. N3 is superseded by N4. C, D and the dirty/local-commit refusals ran on
cf2cb89a577, as described before; their detection and cleanup paths are unchanged.Not run as a cell: holding a release inside its migration while the runner stops it. It needs the 20-minute readiness timeout to expire first, then a SIGSTOP/SIGCONT timed around a stop, so roughly 45 minutes of the shared Docker lock per run, and I could not place the SIGSTOP reliably inside the migration transaction without a test-only seam. The unit tests cover it instead: a stop that completes after the release commits one store, and a stop that does not finish, are both red on
9132a642d2fand green now.A user who runs
openclaw update statuswhile a Gateway-started update is fetching can make that update recordfetch-failed(both fetch the same checkout'sorigin/mainref). The updater that does that fetch is the unpatchable one, so this cannot be fixed here; the next update succeeds.What the old updater prints (head, started)
Refused with the Gateway stopped (RF2):
Automatic recovery did not start: the Gateway service is not running.followed by the one-time rebuild.Journal: failed build (G3) and release that never serves (N3)
Killed during the boot migration and resumed (K)
Recordings from the earlier head
764d667295d(RED on base8b167650d70, GREEN on the head; replays of the cells' raw output):red-base-8b16765.mp4
green-head-764d667.mp4
Full raw logs are not attached; the artifact store rejects uploads from this machine (
http 401).Review findings fixed this round (independent review of
9132a642d2f):TimeoutStopUSecplus a minute and must succeed with the unitinactiveorfailedbefore the second comparison; otherwise the stores count as moved. The release is removed only after the previous build is back and serves. End states: stop succeeds and nothing moved → previous build serves, release removed, journal only; stop succeeds and something moved → release kept, failure recorded, release started again; stop does not finish → same as moved, with "did not confirm it stopped"; stop succeeds, nothing moved, previous build does not serve → previous build's unit, release kept and named in the journal.StartLimitBurstrestarts (N4: 355 s instead of 20 minutes).OPENCLAW_STATE_DIRreaches the runner only when the check had it.From the Gateway route run: the recovery's run keeps the trigger of the run the early updater recorded (B6:
api); the printed text and docs say the checkout'sopenclawmay fail or refuse until the rebuild finishes.Tests. Red on
9132a642d2f(its production files with the new tests), green on the head:update-early-release-recovery.test.ts: the runner fixture now models systemd'sActiveState,TimeoutStopUSec, a stop killed at the client timeout, a failed unit that starts only afterreset-failed, and a previous build that refuses migrated data. New rows: a release that commits one store while it stops (replaces the old "one store moved during the stop" option, which it covers), a stop that does not finish, a previous build that does not serve, the branch moved past the target. Every row now also asserts the record comes before the release starts again and, where given, the journal text. New cases: a slow crash loop gives up at 10 restarts while a 15-minute migration without restarts is waited for; two checks that saw the same dead lock (the second moves nothing, no leaked directory); a lock that is no longer this check's stays; an unset state directory stays out ofsystemd-run; the finishing step removes dead-lock tombstones; the recovery's run takes theapitrigger. The concurrent-check test again asserts the second check's release stays.update-candidate-check-early-release.test.ts: a rollback-journal store held by a writer inside its migration transaction is read after the commit (red: the immutable read returned the old version).reset-failedin the migrated branch fails "never puts it back once migrated".--early-release-recovery <plan>undersystemd-runand the finishing step through<plan> finish <facts>("Rebuilt the checkout ..." in each journal).Test-line budget. The PR is at +478 net test lines;
config/test-lines-allocations/204322-early-release-recovery-review.txtrecords the 78 above the 400 allowance. They buy the regression tests for this round's review, each red on9132a642d2f: the put-back waiting out the stop and keeping the release (finding 1), the locked rollback-journal read (2), the slow crash loop giving up atStartLimitBurst(3), record before restart andreset-failed(5), start-lock ownership and the dead-lock race (6), and the recovery run's original trigger. Before recording it I removed the supersededlatefixture option and its row, compacted formatting, and dropped one comment restating its row's fixture; nothing else could go without losing proof. The worker argv dispatch test was not added (cells N4, A5 and B6 cover it). Wall time withpnpm test <file> --maxWorkers=1:update-early-release-recovery.test.ts51 s (Vitest 47.5 s, 42 tests),update-candidate-check-early-release.test.ts32 s (Vitest 33.4 s including startup, 7 tests; the rollback case waits on a child's 300 ms commit),update-migrated-finalize.worker.test.ts37 s (Vitest 28.6 s, 33 tests). CI seconds: the PR'schecks-node-*jobs.Checks on
25d07f0536d(the three test files and vitest suites, typecheck, lint, session ratchet, docs and diff check last ran on420132b97e5; since then only a removed test comment, the allocation record andmainmerges that touch none of the recovery, service or Git-release paths): the three test files (82 tests),update-restart-module-outcome+eager-import-closure(24),pnpm tsgo:core,pnpm tsgo:core:test, oxlint on the touched files, the session-identity ratchet,pnpm check:docs,git diff --check: exit 0.pnpm check:baseline-ratchets: exit 0 (test lines +478 with 78 allocated).node scripts/check-changed.mjs: only the dead-export scan fails, onBEAM_PACKET_ABIinextensions/beam/packet-contract/packet-v2.generated.ts, which came in withmainand is not part of this change (on the previous head it was two exports inscripts/lib/release-fast-track-publication.mts); this change adds no unused export.Review. A fresh independent reviewer of this round confirmed findings 1 to 6, the nit and both route-B findings closed, and traced the four not-ready end states above. Fixed from it:
reset-failedwas not proven by the fixture; the start lock's release could delete a lock another check had just published into the emptied directory; the rollback test could hang if its writer failed; docs claimed the outcome is always recorded after a stop that did not finish. Not changed: a put-back with a held run records after the previous build starts (only reachable after the release already opened state); when another update holds the lock the runner ends with a skipped and a failed run; a 20-minute readiness timeout still stops a healthy migration that runs longer, and the put-back then rolls it back (existing design).autoreviewdoes not run on this machine.Update proof rules (#203915), from the cells' raw logs and the landing checks.
cli. In B6 the old 2026.11.4 Gateway acceptedupdate.runand handed off toopenclaw update --yes(reason: managed-service-handoff-started), and the recovery's run kept triggerapi. In A5, T+1, T+2 and the no-op record triggerapi, with three[gateway] update.run <runId> actor=gateway-clientlines in the journal. NoOPENCLAW_UPDATE_PACKAGE_SPEC,--tag,--no-restartor shortened update--timeoutwas used. B6 saved the CLI-route environment.openclaw gateway install. The cells savedExecStartafter each step, and A5 savedsystemctl --user showwithNeedDaemonReload=noafter the refused update, the recovery, T+1 and the no-op.759c5ea581b(A5, N4) and86e77be1e04(B6).86e77be1e04to the final head25d07f0536d, the recovery and check modules changed only in type declarations moved to the record module and a local type forsystemctl show. The rest is a removed test comment, the test-line allocation record andmainmerges.328a43818a1(9 commits) touches none of the modules the recovery imports. fix(state): name the owner that revoked a session reader's receipt #204702 changes agent-database invalidation messages, not the schema contracts.npm view openclaw dist-tagsat landing:latest2026.11.8,beta2026.11.10-beta.3,extended-stable2026.10.33. Published packages never take this route.src/update/launcher.ts,run.ts,preflight.tsorconvert-service.ts. T+1 and T+2 still ran after the recovery.checks-node-changed-1:update-early-release-recovery.test.ts42 passed (42) andupdate-candidate-check-early-release.test.ts7 passed (7).checks-node-changed-2:update-migrated-finalize.worker.test.ts33 passed (33).Not proven
openclaw doctor --fixafter T+2 exits 1 ("the service belongs to a different OpenClaw installation") in A4 and at764d667295d: current main's release layout serves fromgit-install/releases/<id>/openclawwhileopenclawon PATH is the checkout link. Outside this change; the earlier body reported it as 0 in error.--portis reinstalled withgateway install --forcedefaults.