Repository navigation
fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database - #201463
Conversation
…after a candidate opened state
|
🦞👀 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. |
…e-inconclusive-state-check
…e-inconclusive-state-check
|
Codex review: needs maintainer review before merge. What this changesThis PR prevents inconclusive live-database reads from falsely blocking Git checkout updates as data at risk and recovers matching failures recorded by older updaters. Example: A Git checkout update encounters a continuously written 2.1 GiB agent database at schema 42 while installing a release using schema 43.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a Git-release update failure still present on main, and source review found no discrete introduced correctness defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe update CLI stages and selects a candidate release, inspects database schemas, and passes its result to candidate finalization, which owns restart, verification, and terminal reporting. flowchart TD
A[Installed update CLI] --> B[Stage and select release]
B --> C[Inspect database schemas]
C --> D[Candidate finalizer]
D --> E[Recheck matching recorded hold]
E --> F[Restart and verify Gateway]
F --> G[Record update outcome]
Technical reviewBest possible solution: Keep schema inspection in its existing owner, use direct Git-release reads, preserve package migration captures, and clear recorded holds only after matching rereads. Do we have a high-confidence way to reproduce the issue? Current-main source retains the failing copy-and-hold path, and the supplied isolated CLI trace reproduces it with a continuously written 2.1 GiB database; no target code was executed during this review. Is this the best way to solve the issue? The patch fixes the inspection owner and uses candidate finalization to recover observed older-updater failures while retaining package artifact protection and genuine schema-change holds. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a4be1ae09e3e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +145, Tests +203, Docs +19. Total +367 across 8 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 Reviewed November 18, 2026, 5:04 PM ET / 22:04 UTC. |
…nservative inspection route
…e-inconclusive-state-check
…e-inconclusive-state-check
…e-inconclusive-state-check
…a recovered restart
…e-inconclusive-state-check
|
Merged via squash.
|
…s on a schema change or a busy database (openclaw#201463) * fix(update): report an inconclusive schema read as data at risk only after a candidate opened state * fix(update): keep a shipped updater's hold unless the reread confirms the baseline * test(update): assert the recovered verdict carries no data-at-risk mark * fix(update): keep recorded risk and the in-place Git runner on the conservative inspection route * fix(update): fall back only to a release of the serving build before a recovered restart * test(update): finalize an unmatched in-place checkout hold unchanged * test(update): share the release build fixture and record the test-line allocation * refactor(update): narrow to the installed updater's Git release inspection
- main's #201579 gives a Git release no pre-migration snapshot check: it takes no database image and migrates at Gateway start. Every Git install is a release here, so remove the check from updateGitInstall, the runner's beforeGitStaging hook, the snapshot-source parameters, and the test of that check. - main's #201463 treats a Git release as opening no state before its restart; with no in-place runner that is every Git update. - Format the work-directory prefix line in state-upgrade-activity.ts.
…s on a schema change or a busy database (openclaw#201463) * fix(update): report an inconclusive schema read as data at risk only after a candidate opened state * fix(update): keep a shipped updater's hold unless the reread confirms the baseline * test(update): assert the recovered verdict carries no data-at-risk mark * fix(update): keep recorded risk and the in-place Git runner on the conservative inspection route * fix(update): fall back only to a release of the serving build before a recovered restart * test(update): finalize an unmatched in-place checkout hold unchanged * test(update): share the release build fixture and record the test-line allocation * refactor(update): narrow to the installed updater's Git release inspection (cherry picked from commit 2183caf) Release adaptation: Source patch applies unchanged across execution, migrated schema, result, and command owners. Preserve positive schema-change holds and package-in-place refusal. Source regression and docs retained; proof pending. Release line-cap repair: Normal parent precommit rejected introduced execution-owner growth (702 -> 705 counted lines, cap 700). Extracted Doctor context validation/construction into the existing package Doctor owner without changing the candidateOpenedState condition or live-authority check ordering. Separate two-file delta requires independent review; original approved tree and artifacts retained. Release Git identity adaptation: Core typecheck exposed an absent prerequisite, not a missing optional field: 6747b1e introduced the 45-file Git release-link producer/launcher/runner and identity contract. This baseline has only in-place mutable Git and separately dispatched adopted immutable installs. Remove unreachable release-only branches, fixtures and docs; retain conservative in-place Git, package pre-Doctor warning, recorded-risk handling and baseline artifact preservation. Do not import the release-layout feature or widen types. Prior extraction is retained. Source fix needs independent review and parent physical-dependency typecheck/native proof. Co-authored-by: RomneyDa <[email protected]>
…aw#194058) Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139. Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact. Co-authored-by: TorstenW <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: steipete <[email protected]> (cherry picked from commit 7c702c3) Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression. Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109) Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd) (cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
…s on a schema change or a busy database (#201463) * fix(update): report an inconclusive schema read as data at risk only after a candidate opened state * fix(update): keep a shipped updater's hold unless the reread confirms the baseline * test(update): assert the recovered verdict carries no data-at-risk mark * fix(update): keep recorded risk and the in-place Git runner on the conservative inspection route * fix(update): fall back only to a release of the serving build before a recovered restart * test(update): finalize an unmatched in-place checkout hold unchanged * test(update): share the release build fixture and record the test-line allocation * refactor(update): narrow to the installed updater's Git release inspection (cherry picked from commit 2183caf) Release adaptation: Keep only the package update warning when neither Doctor nor the no-restart check could open state. Unknown evidence, recorded risk and changed-schema paths retain conservative behavior. Do not import the Git release switch. Companion audit: PR #201463 is the source. #201668 handles revalidation of recorded risk, not needed for this warning; #201600 and later Git release activation follow-ups are out of scope. Deferred Doctor selector retention is independently ordered at row 17. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
openclaw updateon a Git checkout install can fail right after it switches the release link and before the new release ever runs. The Gateway is still serving the old version on untouched state, but the update reports a failure anyway, in one of two ways:openclaw doctor): this happens on every update to a target that bumps a database schema.Either way the link is left half-switched.
User Impact
User impact: a Git checkout update now gets through a schema change and a busy database. The Gateway restarts into the new release, which migrates state when it starts, and the release trial settles as designed.
This needs an installed updater that contains the fix. Installs whose installed updater is
8f80fe08, or any main build between #199706 and this fix, still fail in that updater's own process on every Git update that changes a schema. Their checkout must be rebuilt once (git pullandpnpm buildin the checkout) to get a fixed updater. The candidate cannot repair this, because the installed updater runs first. The failed update's own output already offersopenclaw triage, which hands this step to a repair agent on that machine.Package installs (stable, beta) get the same evidence rule: they are reported as data at risk only after the new version's Doctor or boot check may have written state.
Why This Change Was Made
Root cause: after the switch,
inspectActivatedUpdateState(src/cli/update-cli/update-command-migrated.ts) applied package-install assumptions to Git releases.preserveSourceArtifacts: true). That flag protects the database generation a package update's final Doctor captured, and a Git release captures none. Itscatchalso marked any read failure as data at risk (rollback-state-unverified), even though no new-version process had opened state.Changes:
state-migrated-no-rollback).executeMutableUpdatereportscandidateOpenedState. It is false only for a Git release before its restart, and for a package install before its candidate Doctor ran (and not under--no-restart). The in-place Git runner stays conservative. A result that already records data at risk keeps its route. Otherwise, a store the updater cannot read becomes a one-linestate-schema-verificationwarning that says what is true: no data was changed, and whether the update continues.#201327 (merged on main today) changed the copy path itself. When every copy attempt loses to a writer on a complete WAL family, it now takes one online-backup read transaction instead of failing with
wal-copy-unstable, so artifact-preserving reads no longer fail under load. This PR does not conflict with it: package installs keep that copy path. Git releases still need the direct read, for time and disk: on a 555 MiB agent database with a writer committing about 8 MiB/s, current main's copy read took 568–667 ms and used 555–566 MiB of extra disk per read. The direct read took 6–7 ms and used no extra disk (3 runs each). Both costs grow with the database, so a 20 GiB store means a 20 GiB copy on every update. #201327 also explains why the candidate-side recovery that an earlier revision of this PR carried is gone. With current candidates the shipped updater's copy succeeds, so the failure that recovery recognized no longer occurs; the shipped updater fails earlier, on "migration did not finish", which only an installed-updater fix can address.Evidence
Real
openclaw updateon an isolated macOS launchd Git checkout install (its own profile, state and port; no channels, providers or credentials), pinned to the PR headdb9a13ceas the dev target. The installed updater is6691acae, the last main commit before the agent schema 42 → 43 bump; it already has the Git release layout. The agent database is 512 MiB at schema 42.6691acae⚠️ OpenClaw update failed: openclaw doctorwith "Agent database migration did not finish … expected 43, found 42", after 425 s. Left half-switched: link on the new release,.trialarmed, service still on the checkout, schema 42, Gateway serving the old build.6691acae+ this fixpost-update-failed: "SQLite database pathname changed while its worker owner is active". See Not covered. 403 s wall.6691acae+ this fixpost-update-failedexit after verification. 383 s wall.Gateway downtime in the GREEN cells is the restart window of about 4 s; the run's verifying phase then took about 30 s. Extra disk in the GREEN busy cell: about 2.8 GiB for the release build and the state upgrade's
.pre-<build>copies; the inspection itself adds none.Focused tests:
node scripts/run-vitest.mjs src/cli/update-cli/update-command-migrated-schema.test.ts src/cli/update-cli.preactivation-inspection.test.ts src/infra/update-migrated-finalize.worker.test.ts: 64 tests pass. The new cases fail on base for the stated reasons:rollback-state-unverifiedinstead of a warning.error,openclaw doctor.The controls pass on both base and the fix:
update-cli.preactivation-inspection.test.ts).The rendered next-action text is asserted for each outcome.
Checks
pnpm tsgo:core, the CLI-update test type lane and oxlint on the touched files: pass.pnpm check:baseline-ratchets --base <main>: all ok.pnpm check:docs;git diff --check: clean.Independent review by an Opus reviewer and a ClawSweeper rating (round 1: D/D/D) were done on the earlier, wider revision. Their findings on the remaining code are fixed: POSIX-only fixtures, truthful warning text, and the in-place and recorded-risk routes.
autoreviewdoes not run on this machine.Not covered
A second defect after verification, newly reachable (blocks a clean exit): once the update gets past the false failure, the new release's boot state upgrade replaces
state/openclaw.sqlite, and keeps the old file as.pre-<build>. The installed updater still holds a SQLite worker on the old file. Its post-update work then refuses with "SQLite database pathname changed while its worker owner is active; close the existing store first". It also logs "Update progress history unavailable: SQLite database file identity changed". The Gateway is already serving the new version and the result text says so, but the run exits 1 aspost-update-failed. This PR does not change that store-lifecycle path; it needs its own fix (close or reopen the updater's state store across a Git release restart). A follow-up PR fixes it next.Installed updaters without this fix (
8f80fe08and main builds from feat(update): run Git checkout installs from releases behind the release link #199706 up to this fix): they fail every Git update that changes a schema in their own process, before the new release runs. They need their checkout rebuilt once."Update finalization left the update run nonterminal": seen in an in-place control run. This PR no longer touches that path; it is a separate known defect.
Original-state capture: it still copies the live databases; this is a separate follow-up. fix: let updates proceed while a busy agent database keeps writing #201327's fallback applies there too.
Platforms: macOS launchd only. The busy writer is a stand-in process, not the real Gateway's load.