Skip to content

fix(sqlite): backport bundled WAL-reset fix for Crab - #78

Merged
forhappy merged 1 commit into
codex/node-log-expiry-rotationfrom
codex/sqlite-wal-safety
Oct 15, 2026
Merged

forhappy merged 1 commit into
codex/node-log-expiry-rotationfrom
codex/sqlite-wal-safety

Conversation

@forhappy

@forhappy forhappy commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Cellule currently bundles SQLite 3.49.1, which is affected by the upstream WAL-reset corruption race. Upgrade the ordinary published dependency to rusqlite 0.39 / SQLite 3.51.3 and preserve range-checked unsigned SQL bindings with fallible_uint.

This is the minimal backport for Crab's exact pinned Cellule revision 6ac8a03. It targets the preserved codex/node-log-expiry-rotation branch because current main has moved to the 0.2 Node Bundle representation. Crab must not import that unrelated storage/API migration as part of a SQLite safety fix. The same upgrade is forward-ported to current main in #79. No merge requested.

Contract adaptation

  • Replace removed DatabaseName::Main with upstream's MAIN_DB at incremental blob I/O and read-only-root validation.
  • Propagate fallible hook installation before any application SQL. rusqlite 0.39 rejects hooks on borrowed handles; ignoring that result would execute SQL without the authorizer. Preserve standard typed error sources and scoped cleanup on every exit.
  • Add a borrowed-handle regression at the public SQL-query boundary. Existing protected-table, trigger/view and post-error cleanup coverage remains.
  • Keep managed capture, checkpoint and verified recovery policies unchanged. No patch override, vendored source or configuration surface.
  • Lockfile changes are limited to rusqlite/libsqlite3-sys, its hashlink/hashbrown/foldhash closure, and wasm-target dependencies introduced by upstream. Native builds still link the bundled fixed SQLite.

Evidence and limits

  • Read the upstream release, Cargo features and downloaded SQLite source. The linked amalgamation identifies SQLite 3.51.3 with source ID 737ae4a34738ffa0c3ff7f9bb18df914dd1cad163f28fd6b6e114a344fe6d618.
  • The borrowed-authorizer regression fails before the adapter correction and passes afterward.
  • All seven SQL integration tests pass, including real mutation, publication and exact restore. The complete 44-test primitive integration target also passes.
  • LTX replica qualification passes 240 executable tests and one doctest, with six opt-in RustFS/provider/filesystem cases ignored. The local-only feature separately passes 35 library tests, ten integration tests and its doctest. Strict LTX/runtime all-target/all-feature Clippy passes. Full workspace, cross-platform and provider qualification remain CI/live gates; this PR stays draft.
  • Four separate real RustFS tests pass: native/bundled root range compaction and exact reconstruction; fragmented demand reads; origin-admission release before optional cache sync; and concurrent sparse activation. Each uses a fresh scoped test prefix. Receipts: cellule-sqlite-rustfs-compaction1.json and cellule-sqlite-rustfs-extra-receipt.json. The six opt-in cases above were skipped by the default suite; these runs explicitly qualify four. Two manual provider-cost/filesystem diagnostics remain unrun.
  • Architecture boundaries, module ownership, 104 Rust documentation snippets and 1,082 local documentation links pass. A missing local PATH entry was corrected before rerunning these checks.

Review evidence map

Boundary Evidence
Dependency owner Workspace rusqlite shared by cellule-ltx and cellule-runtime
Callers Managed DB capture/recovery; public sql_batch/sql_query_batch via execute_batch; incremental blob write
Callees rusqlite MAIN_DB, checked hook registration and SQLite WAL/checkpoint implementation
Siblings SQL read/write batches share AuthorizerGuard; existing primitive tests cover protected access and cleanup
Pinned baseline Exact revision used by Crab; only the dependency closure and required API adaptations change
Current main Separate 0.2 Node Bundle lineage; same dependency fix prepared independently

Is this the best fix? Use the maintained upstream SQLite fix and adapt its explicit API contracts. Global cache serialization or private SQLite patches would add ownership complexity and constrain throughput without delivering the same dependency correction.

Primary contracts: SQLite WAL-reset fix, rusqlite 0.39 release, feature authority.

Use SQLite 3.51.3 to fix WAL-reset corruption. Preserve checked unsigned bindings and reject hook installation failures before SQL. Backport to the exact Cellule revision pinned by Crab.
@forhappy
forhappy marked this pull request as ready for review October 15, 2026 07:20
@forhappy
forhappy merged commit 619b5bd into codex/node-log-expiry-rotation Oct 15, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant