Skip to content

fix(update): keep updates working after read-only database reads - #204095

Merged
obviyus merged 4 commits into
mainfrom
fix/update-readonly-reader-guard
Nov 23, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/update-readonly-reader-guard

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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 remains bound to that exact commit. Node/Bun CI write controls and the serial focused consumer run are still pending.
  • Final-head local ClawSweeper review (4ff5ebdd239a..57dc1a001943) completed: patch correct, zero findings, security cleared. The offline review did not load execution receipts.
  • Windows reader-success and checkpointed-write-refusal first hops remain unproven. This PR is ready for hosted CI/review, but is not merge-ready until those explicit proof gaps are closed.

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.
@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 23, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
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.
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Doctor rejects migration with “SQLite migration source changed after update capture.”
  • After: Doctor accepts the reader transition when database identity and committed content still match.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source change is focused and has no identified introduced defect, but required runtime proof is absent and final-head validation remains incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A read-only database inspection can fail an update even though no committed data changed.
Reason: The maintainer-authored direction restores the existing reader-tolerance contract through the candidate-side bridge used by published updaters.

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
Reviewed head: 57dc1a001943020610c6721d3ca0d3ccc92016a6

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The author should supply redacted terminal output or logs for exact-head Windows first hops from v2026.11.7 showing checkpointed-reader success with settings and data intact, plus checkpointed-write refusal.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Rebuilt WAL-index fingerprint equivalence keeps the original intent (0a39956: Accept read-only index rebuilds over retained frames while binding database identity, committed content, and write evidence.)
  • Same-observation reader and writer controls keeps the original intent (50cfa7d: Permit non-writing index presence transitions during a generation read while refusing committed writes.)
  • Doctor migration admission regression keeps the original intent (237fdc6: Allow candidate-side migration after harmless SQLite probes without changing shipped fingerprints or accepting changed sources.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit 50cfa7d adds src/infra/update-database-generations.ts:117 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 50cfa7d2eb84; files: src/infra/update-database-generations.ts)
  • Ayaan Zaidi: Raw commit 2e8c1ad adds docs/install/updating.md:127 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2e8c1ad0aa97; files: docs/install/updating.md)

PR surface

Source +5, Tests +51, Docs +7. Total +63 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 4 +5
Tests 2 70 19 +51
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 86 23 +63

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: A limited SQLite reader transition can fail an update and require recovery; the report concerns an advanced concurrent-reader workflow.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A limited SQLite reader transition can fail an update and require recovery; the report concerns an advanced concurrent-reader workflow.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 23, 2026, 10:17 AM ET / 15:17 UTC.

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Native Windows read-only reader proof: PASS on 57dc1a001943020610c6721d3ca0d3ccc92016a6.

  • Fresh published 2026.11.7 → candidate 2026.11.8-first-hop.0, through external openclaw --profile PROFILE update --yes --json; no package override, --tag, or --no-restart.
  • Run 39c3fcbb-281c-4cda-8a86-38dcccb09ad4: terminal succeeded / finished; CLI exit 0; 885.903 s wall.
  • Exactly one controlled readOnly: true SQLite connection at the actual post-swap Doctor maintenance window, after capture. It read PRAGMA user_version and sqlite_master, then closed successfully. No collector/status polling or other harness database connection ran during the hop.
  • Before/after database SHA-256 stayed a70db0580d5d3ffa223784cd6b0d71f9a58ae7319bbf1ac697cfb0cd39b83c1d; file identity stayed equal. The reader rebuilt absent WAL/SHM into WAL length 0, SHM iChange 00000000, checksum 0000000000000000.
  • Serving build: 2026.11.7-57dc1a001943-2026-11-23T14-56-09.127Z; shared schema 41 and agent schema 43, with migration-table evidence. Final /readyz reports ready/coreReady. The actual Updates page shows all seven phases complete. Nine warnings are retained, not hidden.
  • Candidate archive SHA-256 verified on the lease: 9e4fb9cc0fcef5f0e3bcfff94e87c75ebde704e73d41ecc2a1f4ee0ab5856714.

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 cli trigger and has no Gateway update.run line for it. The complete CLI result and separate durable SQLite run row retain the same successful run ID; that correlation gap is not presented as a collector pass.

Windows controlled-reader update succeeded on candidate 57dc1a001943

@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Native Windows checkpointed-write control: PASS — the real write was refused on 57dc1a001943020610c6721d3ca0d3ccc92016a6.

  • Fresh published 2026.11.7 → candidate 2026.11.8-first-hop.0, through external openclaw --profile PROFILE update --yes --json. No update override, --tag, --no-restart, or shortened product timeout. Candidate archive SHA-256 verified on Windows: 9e4fb9cc0fcef5f0e3bcfff94e87c75ebde704e73d41ecc2a1f4ee0ab5856714.
  • Run 2c8af5ee-189c-4b6c-a39c-5f5ac745d6e5: terminal failed / finished, reason post-update-failed, cause state-migration-failed; CLI exit 1. Candidate checks passed. The actual post-swap Doctor rejected with SQLite migration source changed after update capture.
  • Exactly one controlled writer ran during that Doctor, after its unprefixed schema-admission heading and maintenance-begin line. It changed the existing schema_meta.updated_at from 1795443019796 to 1795443019797, then ran wal_checkpoint(TRUNCATE). No schema change: agent schema remained 38 during the write. File identity stayed equal; committed database SHA-256 changed from e7ccbcab123fd050db338d9fb7696e2a006ad380223e858021436aeebac373b9 to 02aabe9ea2deb3e075facf622657e4e35a8e4c081b2b497cb4be70cd402dc92b.
  • Preserved the refusal and write receipts before recovery. Followed update status → its named service-owner stop → update repair; repair run 7a6aff24-8779-4594-833d-8d389de371a0 succeeded with warnings. Then followed repair's named gateway start and gateway status --deep: exit 0, HTTP /readyz 200, candidate build serving. The original recovery capture remained retained/unresolved for inspection. No update retry or manual state restore.

Actual Updates UI: refusal first, then completed repair below.

Windows real-write guard refusal

Windows status-guided repair completed

…eader-guard

# Conflicts:
#	docs/install/updating.md
@obviyus
obviyus merged commit ab24e71 into main Nov 23, 2026
118 checks passed
@obviyus
obviyus deleted the fix/update-readonly-reader-guard branch November 23, 2026 17:08
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as ab24e71.

  • Problem: on Windows, one harmless read-only reader of the agent database during an update (for example openclaw status in another terminal, or a backup tool) failed the update with "SQLite migration source changed after update capture", and the user needed update repair.
  • Fix: the reader clears the WAL index's change counter and checksum after a checkpoint without changing the database. The guard now accepts that reset while the committed content and file identity are unchanged; any real write is still refused.
  • Proof: on Windows, a first hop with a read-only reader succeeded (run 39c3fcbb), and a real write during Doctor was still refused (run 2c8af5ee) with a working update status → update repair recovery. A narrower existing gap is tracked in SQLite generation verification can miss a rapid checkpointed write from a closed source #204101.

tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 24, 2026
## 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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 25, 2026
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 25, 2026
## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
## 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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 26, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows update fails when a read-only SQLite reader opens during Doctor

1 participant