Skip to content

fix(update): verify migrations across read-only WAL index rebuilds - #201307

Closed
roboclaw-bot wants to merge 1 commit into
mainfrom
roboclaw/ur-197083
Closed

roboclaw-bot wants to merge 1 commit into
mainfrom
roboclaw/ur-197083

Conversation

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Related: #197083

Thanks to @warm-cloth for the read-only monitoring trace and @Staruy for the original report.

Work sessions

Linked for team reference; these sessions aren’t public.

What Problem This Solves

During an update, an outside process can read an agent database while the post-install Doctor verifies a migration. A read-only SQLite open over a non-empty WAL can rebuild the WAL index: it resets the index change counter (iChange) and recomputes the header checksum, while the database and WAL bytes stay identical. sameWalCommitPublication treated any index change with WAL frames present as an unverifiable commit, so Doctor failed with "SQLite WAL commit publication could not be verified", rollback was then refused because the writer was unknown, recovery snapshots stayed on disk and plugin convergence was deferred.

User Impact

Doctor can verify the migration when a read-only connection rebuilt the WAL index over the same committed frames. It still refuses verification when another process appends a commit, so the outside write is preserved and the updater's data-at-risk refusal is unchanged.

Why This Change Was Made

The generation reader accepts the index transition only when the existing database and WAL file checks pass and the new index header still names the same commit: identical version, isInit, page size, mxFrame, nPage, frame checksums and salts, with iChange reset to zero. Anything else, including any new frame, still fails closed.

Evidence

  • On base, a real read-only SQLite process reproduced the WAL publication error after a synthetic migration commit (new update-database-generations.retained-wal.test.ts). With the fix, verification completes with identical database and WAL bytes.
  • A real outside SQLite commit during the same observation is refused on base and with the fix, and the newly committed row survives.
  • Both new cases and 51 existing database-generation tests pass; focused formatting, lint and git diff --check pass; local autoreview scoped-clean at P2.
  • Gap: the reporter's exact Doctor observation and a full published-package upgrade through plugin convergence are not yet verified.

@clawsweeper

clawsweeper Bot commented Nov 18, 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 18, 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. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR accepts a read-only WAL-index rebuild when the database, WAL bytes, and committed-frame identity remain unchanged.

Example: On Linux, a read-only SQLite process queries agent.sqlite while its retained WAL is being observed after a migration.

  • Before: Resetting the WAL index change counter to zero causes “SQLite WAL commit publication could not be verified,” interrupting update finalization.
  • After: The generation observation succeeds when the committed frames match; an outside INSERT still causes refusal and its row survives.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation and distinct SQLite regressions support patch confidence, but the evidence does not yet satisfy the required product-boundary proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An outside read-only SQLite monitor can interrupt Doctor verification and leave an otherwise activated update with plugin convergence unfinished.
Reason: The maintainer-authored direction repairs a demonstrated false refusal with a small change at the existing owner; retaining Related rather than closing the broader issue is appropriate.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored draft contains a useful, focused repair for behavior current main still rejects; no concrete patch defect was found.

Priority: P2
Reviewed head: 4dadd354ccd88d0737403d1cd4156b5f5437e7dd

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Show an isolated upgrade from the latest stable through Doctor and plugin convergence while a read-only process rebuilds a retained WAL index, with settings and data intact.
Agent review details

How this fits together

The updater’s database-generation reader observes SQLite database families and supplies verified fingerprints to Doctor migration attribution, backup, and restoration checks.

flowchart TD
  A[Update coordinator] --> B[Doctor migration attribution]
  B --> C[Database generation reader]
  D[Database and WAL files] --> C
  E[Outside SQLite reader] --> F[WAL index rebuild]
  F --> C
  C --> G[Verified generation or refusal]
Loading

Technical review

Best possible solution:

Extend the existing publication predicate only for the demonstrated same-commit index rebuild while retaining database-family verification and outside-write refusal.

Do we have a high-confidence way to reproduce the issue?

The narrow failure is source-reproducible: main rejects the header transition produced by the supplied Linux real-SQLite fixture, although no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch fixes the owning predicate directly and preserves the invariant that a benign index rebuild may pass only when durable bytes and committed-frame identity remain unchanged.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0aafe6691b81.

Provenance checked

  • WAL commit-publication equivalence changes intended behavior with a stated reason (50cfa7d: The earlier repair accepted empty-WAL reader opens and closes while deliberately retaining strict checks for headers carrying commit evidence.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0ac1c24 adds src/infra/update-database-generations.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0ac1c241fba8; files: src/infra/update-database-generations.ts)
  • 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)

PR surface

Source +14, Tests +86, Docs +4. Total +104 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 16 2 +14
Tests 1 86 0 +86
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 106 2 +104

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 concrete SQLite observation failure can interrupt update finalization and defer plugin convergence, with bounded scope and an existing operator recovery path.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A concrete SQLite observation failure can interrupt update finalization and defer plugin convergence, with bounded scope and an existing operator recovery path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • 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 18, 2026, 10:47 AM ET / 15:47 UTC.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 18, 2026 16:04
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #201330, which fixes the same read-only WAL-index rebuild at the same owner (update-database-generations.ts) and also covers the across-read case: the migration pre-read, companion checks and settlement. This PR only handled the in-read case. Its regression still lives on the branch roboclaw/ur-197083 if it helps #201330.

Thanks again to @warm-cloth for the read-only monitoring trace that pinned this down.

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.

1 participant