Repository navigation
fix(update): keep updates working after read-only database reads - #204095
Conversation
Extend the existing rebuilt-index equivalent to the zero-frame WAL case without changing the generation format or captured fields. Keep file identity and committed-content binding, with reader and checkpointed-write regression cases. Fixes #204078
Remove the pre-header absence restriction from the existing zero-commit publication equivalence. Extend mid-read native reader and checkpointed-write controls; committed content and physical identity remain required.
|
🦞👀 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. |
Restore the existing observation predicate; limit reader equivalence to the captured fingerprint alternate. Keep real-write controls anchored to the retained checkpointed index, while preserving the original closed-source writer control. Track the unchanged SHM-absent rapid-write window separately in #204101.
|
Codex review: needs maintainer review before merge. What this changesThis PR lets candidate Doctor recognize an unchanged SQLite database after a reader rebuilds its checkpointed WAL index. Example: During an update from v2026.11.7, a read-only SQLite reader rebuilds an empty WAL index, resetting its counter from 03000000 to 00000000.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a source-backed update failure with a focused change; no introduced correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe database-generation owner supplies fingerprints and equivalent reader states to update Doctor, which uses them to admit migrations and attribute writes for recovery. flowchart TD
A[Captured SQLite database] --> B[Generation observation]
C[Read-only reader rebuild] --> B
B --> D[Identity and content fingerprint]
D --> E[Doctor migration admission]
E --> F[Migration and recovery receipt]
Technical reviewBest possible solution: Extend the existing rebuilt-index alternate for checkpointed readers while preserving identity, committed-content binding, and the current observation guard. Do we have a high-confidence way to reproduce the issue? The controlled Windows report and current-main empty-WAL exclusion establish a concrete reproduction path; this read-only review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair for the stated between-observation transition: it reuses the existing alternate and admission consumers, with distinct migration and real-write controls. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1601f86def0c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +51, Docs +7. Total +63 across 4 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. 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 23, 2026, 10:17 AM ET / 15:17 UTC. |
|
Native Windows read-only reader proof: PASS on
The screenshot is the real rendered Updates result; it contains no credentials or private infrastructure paths. This is the controlled-reader cell, not a claim about the independent write-control cell. Collection boundary: the kit's UI/API-only log-correlation check rejects the requested |
|
Native Windows checkpointed-write control: PASS — the real write was refused on
Actual Updates UI: refusal first, then completed repair below. |
…eader-guard # Conflicts: # docs/install/updating.md
|
Landed as ab24e71.
|
…4095) Closes #204078 ## What Problem This Solves On Windows, opening a read-only SQLite connection during an update's Doctor step can fail the update with “SQLite migration source changed after update capture.” A status reader, backup tool, or database browser can trigger this without writing anything. Users then need `openclaw update status` and `openclaw update repair`. ## User Impact Read-only readers no longer count as database writes after a WAL checkpoint. A real change to committed content or file identity still refuses migration. This fix is in the candidate's Doctor, so it applies to first hops from published v2026.11.7; the installed updater needs no backport. No schema, stored-field, fingerprint-format, option, or lock changes. ## Why This Change Was Made A checkpoint can leave an empty WAL with a nonzero shared-memory index counter and commit checksum. A read-only reopen rebuilds that disposable index and clears both values while preserving database bytes and identity. The existing rebuilt-index equivalent covered only nonempty WALs. Extend that existing equivalent to a reader rebuild completed between capture and source verification. The equivalent still includes the original file identity and committed-content hash. The same-observation guard is unchanged. No new state, hook, retry, or reader lock. Existing native-generation and migration tests keep real-write refusal, including a checkpointed retained index followed by a reader rebuild. Accepted edge: a reader inside the guard's own observation window can still cause a rare, visible refusal; recover with `openclaw update status`, then `openclaw update repair`. The separate SHM-absent/coarse-metadata rapid-write window in #204101 exists on main and is unchanged here; its fixture and evidence limits are recorded in that issue. ## Evidence - Controlled original Windows failure: `8c73a489-9f22-4a56-936a-81b2f33182ce`; one read-only connection during Doctor. Clean no-reader control succeeded. - Native Windows probe: counter `03000000` → `00000000`, checksum `0443775e300eeaf7` → `0000000000000000`, WAL length 0, with identical database SHA-256/device/inode/birthtime. Linux and macOS show the same transition; real-write controls change database hashes. - Owning migration regression fails on unchanged main at the exact source-changed guard. - Formatting/lint passed on the narrowed head. An earlier local test attempt failed collection because concurrent packaging rewrote `package.json`; that was setup contamination, not a product verdict. - Narrowed head `57dc1a001943` built and passed canonical tarball validation on isolated AWS. First-hop archive SHA-256: `9e4fb9cc0fcef5f0e3bcfff94e87c75ebde704e73d41ecc2a1f4ee0ab5856714`. Its build ID is bound to that exact commit. Hosted CI is green on this head, including the Node and Bun write-refusal controls; the serial focused run on AWS passed. - Final-head local ClawSweeper review (`4ff5ebdd239a..57dc1a0`) completed: patch correct, zero findings, security cleared. - Windows, reader case: a first hop from published v2026.11.7 to this head with one read-only reader after the capture succeeded (run `39c3fcbb-281c-4cda-8a86-38dcccb09ad4`; the candidate serves). [Proof](#204095 (comment)). - Windows, write control: the same first hop with one committed write during Doctor was refused at the source-changed guard (run `2c8af5ee-189c-4b6c-a39c-5f5ac745d6e5`), the user recovers by following `openclaw update status` (stop the service, then `openclaw update repair`; repair run `7a6aff24-8779-4594-833d-8d389de371a0` succeeded with warnings). - Accepted edge case: a reader that opens inside the guard's own short observation window, while the WAL index is absent, behaves as on main (#204101). (cherry picked from commit ab24e71) Release adaptation: Add only the checkpointed-index explanation next to stable retained-frame documentation. Inline the checkpointed setup in the existing generation writer control because stable has the retained-frame reader coverage in update-doctor-migration-wal-rebuild.test.ts rather than the upstream retainedWalFixture. Preserve the stable malformed-anchor fixture and include the upstream attribution scenarios unchanged. Companion audit: #201330 is present-equivalent via stable 0446f25, including retained-frame custody and repeated admission tests. 2c47390 is already selected earlier in this lane. Later same-path overlaps affect only updating.md for separate changes and are not-applicable; 1f4e88f cites this SHA as a green baseline for unrelated operator-authority tests. Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…tate database (#203578) * fix(update): refuse migrating updates while a node service keeps the state open Refs #203457 * docs(update): explain the node-service migration refusal Refs #203457 * fix(update): match the node service's own state directory by filesystem identity A default node service omits the state selector and must not inherit the updater's; path aliases name one directory. Refs #203457 * fix(update): refuse every activation while a node service keeps the state open Update Doctor takes native exclusion of openclaw.sqlite on every activation, including patch updates without a schema change (#203457 reported 2026.11.5 -> 2026.11.6, both schema 36). Refuse whenever a running, kind-marked node service resolves to the same state directory, not only for pending migrations. Refs #203457 Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 19fcba1) Release adaptation: retain stable captureUpdateActivationSchemas destructuring and check node ownership only before first mutation, so Git revalidation after mutation does not report a pre-mutation refusal. Keep stable preparatory staging and check before any Gateway stop or installed activation. Release adaptation: keep only the node-service docs and regression in the conflict regions; the separate Gateway migration admission (#203170) is not a prerequisite and remains outside the lane. Companion audit: no later PR or SHA mentions through 665c286. #203497 (future package preparation) is not needed; the existing stable package/Git activation hooks already share the pre-stop boundary. #203981 is selected elsewhere and already present at lane base (f6ad5b5). Later #204275, #204253, #204224, #204127, #204094, #204095, #204151, #204054, #203994, #203990, #203917, #203959, #203926, #203925, #203915, #203914, #202934 and #203735 are not applicable as companions: independent Git, rollback, Doctor/recovery, plugin, output, docs and host changes do not supply or consume node-service admission. Validation: two same-state activation cases red on f6ad5b5 (wrongly reached mutation), three controls passed; all 73 tests in update-command-execution.test.ts passed with the fix. Co-authored-by: RomneyDa <[email protected]>
…nclaw#204095) Closes openclaw#204078 ## What Problem This Solves On Windows, opening a read-only SQLite connection during an update's Doctor step can fail the update with “SQLite migration source changed after update capture.” A status reader, backup tool, or database browser can trigger this without writing anything. Users then need `openclaw update status` and `openclaw update repair`. ## User Impact Read-only readers no longer count as database writes after a WAL checkpoint. A real change to committed content or file identity still refuses migration. This fix is in the candidate's Doctor, so it applies to first hops from published v2026.11.7; the installed updater needs no backport. No schema, stored-field, fingerprint-format, option, or lock changes. ## Why This Change Was Made A checkpoint can leave an empty WAL with a nonzero shared-memory index counter and commit checksum. A read-only reopen rebuilds that disposable index and clears both values while preserving database bytes and identity. The existing rebuilt-index equivalent covered only nonempty WALs. Extend that existing equivalent to a reader rebuild completed between capture and source verification. The equivalent still includes the original file identity and committed-content hash. The same-observation guard is unchanged. No new state, hook, retry, or reader lock. Existing native-generation and migration tests keep real-write refusal, including a checkpointed retained index followed by a reader rebuild. Accepted edge: a reader inside the guard's own observation window can still cause a rare, visible refusal; recover with `openclaw update status`, then `openclaw update repair`. The separate SHM-absent/coarse-metadata rapid-write window in openclaw#204101 exists on main and is unchanged here; its fixture and evidence limits are recorded in that issue. ## Evidence - Controlled original Windows failure: `8c73a489-9f22-4a56-936a-81b2f33182ce`; one read-only connection during Doctor. Clean no-reader control succeeded. - Native Windows probe: counter `03000000` → `00000000`, checksum `0443775e300eeaf7` → `0000000000000000`, WAL length 0, with identical database SHA-256/device/inode/birthtime. Linux and macOS show the same transition; real-write controls change database hashes. - Owning migration regression fails on unchanged main at the exact source-changed guard. - Formatting/lint passed on the narrowed head. An earlier local test attempt failed collection because concurrent packaging rewrote `package.json`; that was setup contamination, not a product verdict. - Narrowed head `57dc1a001943` built and passed canonical tarball validation on isolated AWS. First-hop archive SHA-256: `9e4fb9cc0fcef5f0e3bcfff94e87c75ebde704e73d41ecc2a1f4ee0ab5856714`. Its build ID is bound to that exact commit. Hosted CI is green on this head, including the Node and Bun write-refusal controls; the serial focused run on AWS passed. - Final-head local ClawSweeper review (`81bdd39b0a0c..57dc1a0`) completed: patch correct, zero findings, security cleared. - Windows, reader case: a first hop from published v2026.11.7 to this head with one read-only reader after the capture succeeded (run `39c3fcbb-281c-4cda-8a86-38dcccb09ad4`; the candidate serves). [Proof](openclaw#204095 (comment)). - Windows, write control: the same first hop with one committed write during Doctor was refused at the source-changed guard (run `2c8af5ee-189c-4b6c-a39c-5f5ac745d6e5`), the user recovers by following `openclaw update status` (stop the service, then `openclaw update repair`; repair run `7a6aff24-8779-4594-833d-8d389de371a0` succeeded with warnings). - Accepted edge case: a reader that opens inside the guard's own short observation window, while the WAL index is absent, behaves as on main (openclaw#204101). Co-authored-by: Ayaan Zaidi <[email protected]>
## What Problem This Solves Release validation and state migration walked different database inventories. Registered external stores could escape rollback coverage, while a healthy closed WAL database without SHM could fail `check-release`. Closes #204394. Closes #204227. Related: #204775, #204502, #204095, #204127. ## User Impact User impact: release preparation checks the databases the migration owner actually knows about, before stopping the serving Gateway. Unsupported recovery paths are refused with the affected database and a next step. Healthy closed WAL databases use the existing artifact-preserving inspection fallback. **No update is refused by database size.** The SQLite/PostgreSQL budget refusal, its rate constant and its size-admission tests/docs have been removed per the approved state-model decision. Ordinary non-trial starts remain unrestricted by size. Newly refused users are those with a pending schema migration and a registered/configured database outside the state directory, deeper than the frozen launcher's four-directory limit, symlinked/separately mounted, or below its skipped git-install/npm/node_modules/tmp/logs directories. Their old Gateway stays serving. The reason names the database and says to move it to a real covered directory (for agents: agents/<agent-id>/agent/openclaw-agent.sqlite), update its registration/configuration, and retry. This recovery-layout refusal remains until the separately sequenced restore-manifest cutover; it does not apply when no schema migration is pending. Missing unconfigured retained registrations do not block an unrelated update. ## Why This Change Was Made `discoverDatabases` owns the inventory, metadata projection and copy eligibility. `check-release` no longer has a second scanner or direct `readonly_shm` opener. The copier consumes the authoritative target paths and retains its copy-coverage assertion. The obsolete success-notice recorder and the in-place PostgreSQL trial notice path are removed. This PR intentionally does not add a manifest writer, CoW/in-place migration model, reader-floor logic or Doctor-chain rewrite. The manifest writer follows as its own small PR; the larger state-model cutover is separate. ## Evidence - Pinned base `d4c6c46e32ae`: initial owner/release-check regressions produced12 intended failures and4 passes. [AWS base proof](https://crabbox.openclaw.ai/portal/runs/run_9a0a8afeaa9a1af9caa2385e34602eac). ## Real-route proof on merged head5f8ce752 Both legs were rerun after the `run.ts` conflict resolution, on separate AWS leases using product-installed native services and the qualification kit's TLS/registry fixture preserving the exact public latest URL. No package-spec override or app-state injection. - **Genuine published stable2026.11.7 → merged head:** [run](https://crabbox.openclaw.ai/portal/runs/run_846f96823734c8f716089e1b2ce03148), exit0, product `520d08a2-52a0-4999-a9ae-d3fda7d098f6`, `api/succeeded`. Exact-head serving build verified (fixture package2026.11.9-first-hop.0). State36→41 and dormant agent38→43; the cleanly closed WAL-mode agent had no SHM before candidate inspection and was accepted. Wall227.986s, sampled outage94.229s. - **Merged head → same-head schema42 successor:** [run](https://crabbox.openclaw.ai/portal/runs/run_47605dc74641c05448ec970d6e8fdf12), exit0. External agent store refused before stop: product `80cdfd2d-1350-44ed-a0f2-245ca1ac490d`, `release-check-failed`. PID25851/schema41 unchanged; all278 readiness samples healthy (250ms interval). Validation took1.620s after staging. The actual Settings→Updates page and `update status --json` showed the affected path, move/update-registration/retry instructions, and “The current version is still running.” Private receipts: `StateBoundary-proof/{mergedwal-result.json,mergedwal-receipt.tgz,merged-proof.tgz,merged-complete.tgz,merged-settings.txt,merged-settings.webp}`. These boundary legs are not a one-minute-outage or crash-rollback qualification. Production `tokei` on the PR's six production TypeScript files after merging main336e9314: **2,540 → 2,557 (+17)**, excluding tests/support/harness. ## Review repair: ordinary PostgreSQL startup Review-repair head: `cbe972b00e5e32cd0585713b032c53d773be7acb`. A local-review finding caught protected-copy CREATE admission accidentally applying outside a release trial. PostgreSQL protected-copy targets and prerequisites now apply only to pending/trial starts; manual package upgrades retain the existing in-place migration owner, original namespace and ordinary startup availability. The existing owner table covers restricted-role ordinary startup versus protected-trial preflight refusal before mutation. [Merged-head AWS owner/build check](https://crabbox.openclaw.ai/portal/runs/run_93771e93ed0d283deb95854a692042ea) passed **118 tests** including large-postgres, gateway-trial and prepare-failure; three live-PG cases were skipped without a conformance connection. Full build and pack passed. The restricted-role case models the copy prerequisite at the upgrade boundary; it is not new live-PG serving proof. Existing protected-copy live-PG fixtures explicitly declare a pending trial. ## Main integration Current head: `5f8ce7521eec58f2c98bf39f250922ecef3f967f`, merging main336e9314. Conflicts were only `docs/install/updating.md` and `src/update/run.ts`. The update owner retained main's under-lock trial admission and single failure settlement, and C's obsolete success-reason recorder stays deleted. Documentation retains both main's early-recovery contract and C's shared inventory/no-size policy. AWS PostgreSQL schema regeneration completed with a zero-byte diff. Its first wrapper failed only downloading an obsolete artifact path; the generator completed successfully and the correct empty patch/log were collected with the passing owner/build run. Both affected real-route legs passed on this merged head, as recorded above. Co-authored-by: Ayaan Zaidi <[email protected]>
Release validation and state migration walked different database inventories. Registered external stores could escape rollback coverage, while a healthy closed WAL database without SHM could fail `check-release`. Closes #204394. Closes #204227. Related: #204775, #204502, #204095, #204127. User impact: release preparation checks the databases the migration owner actually knows about, before stopping the serving Gateway. Unsupported recovery paths are refused with the affected database and a next step. Healthy closed WAL databases use the existing artifact-preserving inspection fallback. **No update is refused by database size.** The SQLite/PostgreSQL budget refusal, its rate constant and its size-admission tests/docs have been removed per the approved state-model decision. Ordinary non-trial starts remain unrestricted by size. Newly refused users are those with a pending schema migration and a registered/configured database outside the state directory, deeper than the frozen launcher's four-directory limit, symlinked/separately mounted, or below its skipped git-install/npm/node_modules/tmp/logs directories. Their old Gateway stays serving. The reason names the database and says to move it to a real covered directory (for agents: agents/<agent-id>/agent/openclaw-agent.sqlite), update its registration/configuration, and retry. This recovery-layout refusal remains until the separately sequenced restore-manifest cutover; it does not apply when no schema migration is pending. Missing unconfigured retained registrations do not block an unrelated update. `discoverDatabases` owns the inventory, metadata projection and copy eligibility. `check-release` no longer has a second scanner or direct `readonly_shm` opener. The copier consumes the authoritative target paths and retains its copy-coverage assertion. The obsolete success-notice recorder and the in-place PostgreSQL trial notice path are removed. This PR intentionally does not add a manifest writer, CoW/in-place migration model, reader-floor logic or Doctor-chain rewrite. The manifest writer follows as its own small PR; the larger state-model cutover is separate. - Pinned base `d4c6c46e32ae`: initial owner/release-check regressions produced12 intended failures and4 passes. [AWS base proof](https://crabbox.openclaw.ai/portal/runs/run_9a0a8afeaa9a1af9caa2385e34602eac). Both legs were rerun after the `run.ts` conflict resolution, on separate AWS leases using product-installed native services and the qualification kit's TLS/registry fixture preserving the exact public latest URL. No package-spec override or app-state injection. - **Genuine published stable2026.11.7 → merged head:** [run](https://crabbox.openclaw.ai/portal/runs/run_846f96823734c8f716089e1b2ce03148), exit0, product `520d08a2-52a0-4999-a9ae-d3fda7d098f6`, `api/succeeded`. Exact-head serving build verified (fixture package2026.11.9-first-hop.0). State36→41 and dormant agent38→43; the cleanly closed WAL-mode agent had no SHM before candidate inspection and was accepted. Wall227.986s, sampled outage94.229s. - **Merged head → same-head schema42 successor:** [run](https://crabbox.openclaw.ai/portal/runs/run_47605dc74641c05448ec970d6e8fdf12), exit0. External agent store refused before stop: product `80cdfd2d-1350-44ed-a0f2-245ca1ac490d`, `release-check-failed`. PID25851/schema41 unchanged; all278 readiness samples healthy (250ms interval). Validation took1.620s after staging. The actual Settings→Updates page and `update status --json` showed the affected path, move/update-registration/retry instructions, and “The current version is still running.” Private receipts: `StateBoundary-proof/{mergedwal-result.json,mergedwal-receipt.tgz,merged-proof.tgz,merged-complete.tgz,merged-settings.txt,merged-settings.webp}`. These boundary legs are not a one-minute-outage or crash-rollback qualification. Production `tokei` on the PR's six production TypeScript files after merging main336e9314: **2,540 → 2,557 (+17)**, excluding tests/support/harness. Review-repair head: `cbe972b00e5e32cd0585713b032c53d773be7acb`. A local-review finding caught protected-copy CREATE admission accidentally applying outside a release trial. PostgreSQL protected-copy targets and prerequisites now apply only to pending/trial starts; manual package upgrades retain the existing in-place migration owner, original namespace and ordinary startup availability. The existing owner table covers restricted-role ordinary startup versus protected-trial preflight refusal before mutation. [Merged-head AWS owner/build check](https://crabbox.openclaw.ai/portal/runs/run_93771e93ed0d283deb95854a692042ea) passed **118 tests** including large-postgres, gateway-trial and prepare-failure; three live-PG cases were skipped without a conformance connection. Full build and pack passed. The restricted-role case models the copy prerequisite at the upgrade boundary; it is not new live-PG serving proof. Existing protected-copy live-PG fixtures explicitly declare a pending trial. Current head: `5f8ce7521eec58f2c98bf39f250922ecef3f967f`, merging main336e9314. Conflicts were only `docs/install/updating.md` and `src/update/run.ts`. The update owner retained main's under-lock trial admission and single failure settlement, and C's obsolete success-reason recorder stays deleted. Documentation retains both main's early-recovery contract and C's shared inventory/no-size policy. AWS PostgreSQL schema regeneration completed with a zero-byte diff. Its first wrapper failed only downloading an obsolete artifact path; the generator completed successfully and the correct empty patch/log were collected with the passing owner/build run. Both affected real-route legs passed on this merged head, as recorded above. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 270aae3) Co-authored-by: RomneyDa <[email protected]>
…aw#204752) ## What Problem This Solves Release validation and state migration walked different database inventories. Registered external stores could escape rollback coverage, while a healthy closed WAL database without SHM could fail `check-release`. Closes openclaw#204394. Closes openclaw#204227. Related: openclaw#204775, openclaw#204502, openclaw#204095, openclaw#204127. ## User Impact User impact: release preparation checks the databases the migration owner actually knows about, before stopping the serving Gateway. Unsupported recovery paths are refused with the affected database and a next step. Healthy closed WAL databases use the existing artifact-preserving inspection fallback. **No update is refused by database size.** The SQLite/PostgreSQL budget refusal, its rate constant and its size-admission tests/docs have been removed per the approved state-model decision. Ordinary non-trial starts remain unrestricted by size. Newly refused users are those with a pending schema migration and a registered/configured database outside the state directory, deeper than the frozen launcher's four-directory limit, symlinked/separately mounted, or below its skipped git-install/npm/node_modules/tmp/logs directories. Their old Gateway stays serving. The reason names the database and says to move it to a real covered directory (for agents: agents/<agent-id>/agent/openclaw-agent.sqlite), update its registration/configuration, and retry. This recovery-layout refusal remains until the separately sequenced restore-manifest cutover; it does not apply when no schema migration is pending. Missing unconfigured retained registrations do not block an unrelated update. ## Why This Change Was Made `discoverDatabases` owns the inventory, metadata projection and copy eligibility. `check-release` no longer has a second scanner or direct `readonly_shm` opener. The copier consumes the authoritative target paths and retains its copy-coverage assertion. The obsolete success-notice recorder and the in-place PostgreSQL trial notice path are removed. This PR intentionally does not add a manifest writer, CoW/in-place migration model, reader-floor logic or Doctor-chain rewrite. The manifest writer follows as its own small PR; the larger state-model cutover is separate. ## Evidence - Pinned base `ad98b9e7f734`: initial owner/release-check regressions produced12 intended failures and4 passes. [AWS base proof](https://crabbox.openclaw.ai/portal/runs/run_9a0a8afeaa9a1af9caa2385e34602eac). ## Real-route proof on merged head5f8ce752 Both legs were rerun after the `run.ts` conflict resolution, on separate AWS leases using product-installed native services and the qualification kit's TLS/registry fixture preserving the exact public latest URL. No package-spec override or app-state injection. - **Genuine published stable2026.11.7 → merged head:** [run](https://crabbox.openclaw.ai/portal/runs/run_846f96823734c8f716089e1b2ce03148), exit0, product `520d08a2-52a0-4999-a9ae-d3fda7d098f6`, `api/succeeded`. Exact-head serving build verified (fixture package2026.11.9-first-hop.0). State36→41 and dormant agent38→43; the cleanly closed WAL-mode agent had no SHM before candidate inspection and was accepted. Wall227.986s, sampled outage94.229s. - **Merged head → same-head schema42 successor:** [run](https://crabbox.openclaw.ai/portal/runs/run_47605dc74641c05448ec970d6e8fdf12), exit0. External agent store refused before stop: product `80cdfd2d-1350-44ed-a0f2-245ca1ac490d`, `release-check-failed`. PID25851/schema41 unchanged; all278 readiness samples healthy (250ms interval). Validation took1.620s after staging. The actual Settings→Updates page and `update status --json` showed the affected path, move/update-registration/retry instructions, and “The current version is still running.” Private receipts: `StateBoundary-proof/{mergedwal-result.json,mergedwal-receipt.tgz,merged-proof.tgz,merged-complete.tgz,merged-settings.txt,merged-settings.webp}`. These boundary legs are not a one-minute-outage or crash-rollback qualification. Production `tokei` on the PR's six production TypeScript files after merging main336e9314: **2,540 → 2,557 (+17)**, excluding tests/support/harness. ## Review repair: ordinary PostgreSQL startup Review-repair head: `cbe972b00e5e32cd0585713b032c53d773be7acb`. A local-review finding caught protected-copy CREATE admission accidentally applying outside a release trial. PostgreSQL protected-copy targets and prerequisites now apply only to pending/trial starts; manual package upgrades retain the existing in-place migration owner, original namespace and ordinary startup availability. The existing owner table covers restricted-role ordinary startup versus protected-trial preflight refusal before mutation. [Merged-head AWS owner/build check](https://crabbox.openclaw.ai/portal/runs/run_93771e93ed0d283deb95854a692042ea) passed **118 tests** including large-postgres, gateway-trial and prepare-failure; three live-PG cases were skipped without a conformance connection. Full build and pack passed. The restricted-role case models the copy prerequisite at the upgrade boundary; it is not new live-PG serving proof. Existing protected-copy live-PG fixtures explicitly declare a pending trial. ## Main integration Current head: `5f8ce7521eec58f2c98bf39f250922ecef3f967f`, merging main336e9314. Conflicts were only `docs/install/updating.md` and `src/update/run.ts`. The update owner retained main's under-lock trial admission and single failure settlement, and C's obsolete success-reason recorder stays deleted. Documentation retains both main's early-recovery contract and C's shared inventory/no-size policy. AWS PostgreSQL schema regeneration completed with a zero-byte diff. Its first wrapper failed only downloading an obsolete artifact path; the generator completed successfully and the correct empty patch/log were collected with the passing owner/build run. Both affected real-route legs passed on this merged head, as recorded above. Co-authored-by: Ayaan Zaidi <[email protected]>
## What Problem This Solves The launcher currently guesses restore coverage by scanning `.pre-<generation>` files. That freezes directory depth, excluded names and ctime policy into the installed launcher. This is the candidate-writer stage of replacing that knowledge with explicit restore intent (related #204394, #204752, #204775, #198389 and #204095). ## User Impact The active candidate writes `<prefix>/releases/<target-release-id>/.restore` as `{v:1,runId,files:[{live,preimage}]}` before publishing its replayable swap plan or canonical schema/config changes. The trial's existing target release owns the receipt by construction; run IDs are recorded, not compared. Paths are absolute; null pre-images explicitly remove new files and SQLite WAL/SHM/journal/seal companions. Under exclusive custody, SQLite originals are checkpointed and closed, then their complete main files are hard-linked as adjacent run-bound images. Publication renames a different prepared inode over the live path; it does not modify the image. Normal adjacent images add no database byte copy. The fallback copies bytes only if the filesystem rejects hard linking, recording its cause. No new size admission or disk-copy reservation is added. Retries within that prepared release reuse immutable images; another release cannot reuse its receipt, including a retry prepared by old2026.11.15 code. A changed or missing restore plan refuses instead of re-imaging mutated state. Known no-upgrade trials record an empty plan under the same exclusive owner. Ordinary non-trial starts are unchanged. Cleanup consumes only the manifest captured by its own candidate process after confirmed committed IPC, never rereading a slot or matching IDs. ## Scope and Compatibility Legacy `.pre-<generation>` files and `Trial.config` remain in use: today's launcher continues to work and ignores the new manifest. This PR does not enable external stores yet, change the launcher reader, add reader floors, or start in-place migrations. A hard-linked image is valid for this rename-based swap only; the later in-place cutover must use its approved clone/copy pre-image primitive. The state owner is the only manifest/image writer. UpdateOwner supplied both revisions of the committed-IPC cleanup caller; no `src/update/` file was edited directly here. Receipts stay with their prepared releases. Old retained-image cleanup errors cannot block a different release's no-upgrade preparation; the A-delayed/B-safe regression remains and also deletes A's receipt before invoking its captured cleanup. ## Evidence On `8b410b54`, isolated AWS checks passed **88 owner tests**; baseline5e5ecba4 failed exactly the two selected missing-manifest/order regressions. The JSON gate positively verified those causes, not an arbitrary exit. A recovered OOM-interrupted broad run was not claimed green. On `cb5abca7`, **35 changed-owner tests**, assertion safety, SQLite worker/dialect guards, core types and targeted production lint passed on32GiB. Targeted test lint found a shadowing fixture variable, now renamed through LSP. CI's Bun lane exposed an orderly `process.exit(0)` WAL fixture; it now uses a real forced crash and retains the physical WAL/data assertions. This review repair also removes stale-run comparisons by per-release scope and captured cleanup. No manual proof on the new scope has run while the required predecessor PRs are pending. One-worker AWS wall times at8b410b54: writer63.535s, startup63.798s, swap-owner73.935s. The first writer suite included51.888s compiled-worker preparation; the native filesystem/WAL assertions themselves are small. Current-head CI owns its fresh check results. The real filesystem WAL/config fixtures asserted hard links with zero byte copies; the forced `EXDEV` fixture exercised one actual copy fallback. No genuine cross-device failure was observed. Adjacent images normally share their source's filesystem; individually mounted files or unsupported hard linking can require the fallback. This is not a population-frequency estimate. **Must not land before #204868 (custody), then #204866 (install owner).** Per the lead's sequence, merge main once after both land, then run the native crash/full-package qualification on that integrated head. No further manual writer proof will run before that point. The hard-link immutability assumption requires custody; checkpointing alone is not claimed to fix the previously observed malformed rollback. The in-place/floor stage separately waits for ReaderFloor. ## Size `tokei` on all four touched production files, including the update caller, against integrated main25efa334: **1,058 → 1,388 (+330)**. Tests: **+479 net lines**, with a 79-line excess allocation for distinct WAL, durable-ordering, retry, frozen rollback, symlink, captured cleanup and startup contracts. No competing legacy reader is deleted in this explicitly sequenced writer-first stage; its removal belongs to the following reader PR. ## Conflict Integration Merged main25efa334 once to clear the named conflict. Resolutions retained main's config/include inventory and external/workspace/missing-include fixtures together with the managed-trial manifest case. No `src/update/` conflict or direct edit was involved. No manual proof was run. The later main merge and native crash qualification still wait for the predecessor landing order above. Co-authored-by: Ayaan Zaidi <[email protected]>
## What Problem This Solves The launcher currently guesses restore coverage by scanning `.pre-<generation>` files. That freezes directory depth, excluded names and ctime policy into the installed launcher. This is the candidate-writer stage of replacing that knowledge with explicit restore intent (related openclaw#204394, openclaw#204752, openclaw#204775, openclaw#198389 and openclaw#204095). ## User Impact The active candidate writes `<prefix>/releases/<target-release-id>/.restore` as `{v:1,runId,files:[{live,preimage}]}` before publishing its replayable swap plan or canonical schema/config changes. The trial's existing target release owns the receipt by construction; run IDs are recorded, not compared. Paths are absolute; null pre-images explicitly remove new files and SQLite WAL/SHM/journal/seal companions. Under exclusive custody, SQLite originals are checkpointed and closed, then their complete main files are hard-linked as adjacent run-bound images. Publication renames a different prepared inode over the live path; it does not modify the image. Normal adjacent images add no database byte copy. The fallback copies bytes only if the filesystem rejects hard linking, recording its cause. No new size admission or disk-copy reservation is added. Retries within that prepared release reuse immutable images; another release cannot reuse its receipt, including a retry prepared by old2026.11.15 code. A changed or missing restore plan refuses instead of re-imaging mutated state. Known no-upgrade trials record an empty plan under the same exclusive owner. Ordinary non-trial starts are unchanged. Cleanup consumes only the manifest captured by its own candidate process after confirmed committed IPC, never rereading a slot or matching IDs. ## Scope and Compatibility Legacy `.pre-<generation>` files and `Trial.config` remain in use: today's launcher continues to work and ignores the new manifest. This PR does not enable external stores yet, change the launcher reader, add reader floors, or start in-place migrations. A hard-linked image is valid for this rename-based swap only; the later in-place cutover must use its approved clone/copy pre-image primitive. The state owner is the only manifest/image writer. UpdateOwner supplied both revisions of the committed-IPC cleanup caller; no `src/update/` file was edited directly here. Receipts stay with their prepared releases. Old retained-image cleanup errors cannot block a different release's no-upgrade preparation; the A-delayed/B-safe regression remains and also deletes A's receipt before invoking its captured cleanup. ## Evidence On `8b410b54`, isolated AWS checks passed **88 owner tests**; baseline5e5ecba4 failed exactly the two selected missing-manifest/order regressions. The JSON gate positively verified those causes, not an arbitrary exit. A recovered OOM-interrupted broad run was not claimed green. On `cb5abca7`, **35 changed-owner tests**, assertion safety, SQLite worker/dialect guards, core types and targeted production lint passed on32GiB. Targeted test lint found a shadowing fixture variable, now renamed through LSP. CI's Bun lane exposed an orderly `process.exit(0)` WAL fixture; it now uses a real forced crash and retains the physical WAL/data assertions. This review repair also removes stale-run comparisons by per-release scope and captured cleanup. No manual proof on the new scope has run while the required predecessor PRs are pending. One-worker AWS wall times at8b410b54: writer63.535s, startup63.798s, swap-owner73.935s. The first writer suite included51.888s compiled-worker preparation; the native filesystem/WAL assertions themselves are small. Current-head CI owns its fresh check results. The real filesystem WAL/config fixtures asserted hard links with zero byte copies; the forced `EXDEV` fixture exercised one actual copy fallback. No genuine cross-device failure was observed. Adjacent images normally share their source's filesystem; individually mounted files or unsupported hard linking can require the fallback. This is not a population-frequency estimate. **Must not land before openclaw#204868 (custody), then openclaw#204866 (install owner).** Per the lead's sequence, merge main once after both land, then run the native crash/full-package qualification on that integrated head. No further manual writer proof will run before that point. The hard-link immutability assumption requires custody; checkpointing alone is not claimed to fix the previously observed malformed rollback. The in-place/floor stage separately waits for ReaderFloor. ## Size `tokei` on all four touched production files, including the update caller, against integrated main25efa334: **1,058 → 1,388 (+330)**. Tests: **+479 net lines**, with a 79-line excess allocation for distinct WAL, durable-ordering, retry, frozen rollback, symlink, captured cleanup and startup contracts. No competing legacy reader is deleted in this explicitly sequenced writer-first stage; its removal belongs to the following reader PR. ## Conflict Integration Merged main25efa334 once to clear the named conflict. Resolutions retained main's config/include inventory and external/workspace/missing-include fixtures together with the managed-trial manifest case. No `src/update/` conflict or direct edit was involved. No manual proof was run. The later main merge and native crash qualification still wait for the predecessor landing order above. Co-authored-by: Ayaan Zaidi <[email protected]>
## What Problem This Solves The launcher currently guesses restore coverage by scanning `.pre-<generation>` files. That freezes directory depth, excluded names and ctime policy into the installed launcher. This is the candidate-writer stage of replacing that knowledge with explicit restore intent (related #204394, #204752, #204775, #198389 and #204095). ## User Impact The active candidate writes `<prefix>/releases/<target-release-id>/.restore` as `{v:1,runId,files:[{live,preimage}]}` before publishing its replayable swap plan or canonical schema/config changes. The trial's existing target release owns the receipt by construction; run IDs are recorded, not compared. Paths are absolute; null pre-images explicitly remove new files and SQLite WAL/SHM/journal/seal companions. Under exclusive custody, SQLite originals are checkpointed and closed, then their complete main files are hard-linked as adjacent run-bound images. Publication renames a different prepared inode over the live path; it does not modify the image. Normal adjacent images add no database byte copy. The fallback copies bytes only if the filesystem rejects hard linking, recording its cause. No new size admission or disk-copy reservation is added. Retries within that prepared release reuse immutable images; another release cannot reuse its receipt, including a retry prepared by old2026.11.15 code. A changed or missing restore plan refuses instead of re-imaging mutated state. Known no-upgrade trials record an empty plan under the same exclusive owner. Ordinary non-trial starts are unchanged. Cleanup consumes only the manifest captured by its own candidate process after confirmed committed IPC, never rereading a slot or matching IDs. ## Scope and Compatibility Legacy `.pre-<generation>` files and `Trial.config` remain in use: today's launcher continues to work and ignores the new manifest. This PR does not enable external stores yet, change the launcher reader, add reader floors, or start in-place migrations. A hard-linked image is valid for this rename-based swap only; the later in-place cutover must use its approved clone/copy pre-image primitive. The state owner is the only manifest/image writer. UpdateOwner supplied both revisions of the committed-IPC cleanup caller; no `src/update/` file was edited directly here. Receipts stay with their prepared releases. Old retained-image cleanup errors cannot block a different release's no-upgrade preparation; the A-delayed/B-safe regression remains and also deletes A's receipt before invoking its captured cleanup. ## Evidence On `8b410b54`, isolated AWS checks passed **88 owner tests**; baseline5e5ecba4 failed exactly the two selected missing-manifest/order regressions. The JSON gate positively verified those causes, not an arbitrary exit. A recovered OOM-interrupted broad run was not claimed green. On `cb5abca7`, **35 changed-owner tests**, assertion safety, SQLite worker/dialect guards, core types and targeted production lint passed on32GiB. Targeted test lint found a shadowing fixture variable, now renamed through LSP. CI's Bun lane exposed an orderly `process.exit(0)` WAL fixture; it now uses a real forced crash and retains the physical WAL/data assertions. This review repair also removes stale-run comparisons by per-release scope and captured cleanup. No manual proof on the new scope has run while the required predecessor PRs are pending. One-worker AWS wall times at8b410b54: writer63.535s, startup63.798s, swap-owner73.935s. The first writer suite included51.888s compiled-worker preparation; the native filesystem/WAL assertions themselves are small. Current-head CI owns its fresh check results. The real filesystem WAL/config fixtures asserted hard links with zero byte copies; the forced `EXDEV` fixture exercised one actual copy fallback. No genuine cross-device failure was observed. Adjacent images normally share their source's filesystem; individually mounted files or unsupported hard linking can require the fallback. This is not a population-frequency estimate. **Must not land before #204868 (custody), then #204866 (install owner).** Per the lead's sequence, merge main once after both land, then run the native crash/full-package qualification on that integrated head. No further manual writer proof will run before that point. The hard-link immutability assumption requires custody; checkpointing alone is not claimed to fix the previously observed malformed rollback. The in-place/floor stage separately waits for ReaderFloor. ## Size `tokei` on all four touched production files, including the update caller, against integrated main25efa334: **1,058 → 1,388 (+330)**. Tests: **+479 net lines**, with a 79-line excess allocation for distinct WAL, durable-ordering, retry, frozen rollback, symlink, captured cleanup and startup contracts. No competing legacy reader is deleted in this explicitly sequenced writer-first stage; its removal belongs to the following reader PR. ## Conflict Integration Merged main25efa334 once to clear the named conflict. Resolutions retained main's config/include inventory and external/workspace/missing-include fixtures together with the managed-trial manifest case. No `src/update/` conflict or direct edit was involved. No manual proof was run. The later main merge and native crash qualification still wait for the predecessor landing order above. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 31c4e6b) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>



Closes #204078
What Problem This Solves
On Windows, opening a read-only SQLite connection during an update's Doctor step can fail the update with “SQLite migration source changed after update capture.” A status reader, backup tool, or database browser can trigger this without writing anything. Users then need
openclaw update statusandopenclaw update repair.User Impact
Read-only readers no longer count as database writes after a WAL checkpoint. A real change to committed content or file identity still refuses migration. This fix is in the candidate's Doctor, so it applies to first hops from published v2026.11.7; the installed updater needs no backport. No schema, stored-field, fingerprint-format, option, or lock changes.
Why This Change Was Made
A checkpoint can leave an empty WAL with a nonzero shared-memory index counter and commit checksum. A read-only reopen rebuilds that disposable index and clears both values while preserving database bytes and identity. The existing rebuilt-index equivalent covered only nonempty WALs.
Extend that existing equivalent to a reader rebuild completed between capture and source verification. The equivalent still includes the original file identity and committed-content hash. The same-observation guard is unchanged. No new state, hook, retry, or reader lock. Existing native-generation and migration tests keep real-write refusal, including a checkpointed retained index followed by a reader rebuild.
Accepted edge: a reader inside the guard's own observation window can still cause a rare, visible refusal; recover with
openclaw update status, thenopenclaw update repair. The separate SHM-absent/coarse-metadata rapid-write window in #204101 exists on main and is unchanged here; its fixture and evidence limits are recorded in that issue.Evidence
8c73a489-9f22-4a56-936a-81b2f33182ce; one read-only connection during Doctor. Clean no-reader control succeeded.03000000→00000000, checksum0443775e300eeaf7→0000000000000000, WAL length 0, with identical database SHA-256/device/inode/birthtime. Linux and macOS show the same transition; real-write controls change database hashes.package.json; that was setup contamination, not a product verdict.57dc1a001943built and passed canonical tarball validation on isolated AWS. First-hop archive SHA-256:9e4fb9cc0fcef5f0e3bcfff94e87c75ebde704e73d41ecc2a1f4ee0ab5856714. Its build ID remains bound to that exact commit. Node/Bun CI write controls and the serial focused consumer run are still pending.4ff5ebdd239a..57dc1a001943) completed: patch correct, zero findings, security cleared. The offline review did not load execution receipts.