Skip to content

fix(snapshot): make SQLite publication crash recoverable - #113367

Merged
vincentkoc merged 15 commits into
mainfrom
fix/sqlite-snapshot-publication-durability-20260724
Jul 24, 2026
Merged

vincentkoc merged 15 commits into
mainfrom
fix/sqlite-snapshot-publication-durability-20260724

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Related: #113306

What Problem This Solves

Fixes an issue where SQLite snapshot creation and fresh restore could report success after newly created parent links or final publication metadata had not been durably synchronized. A crash at those boundaries could leave missing, partial, or ambiguously committed state.

Why This Change Was Made

The change adds an identity-pinned directory durability primitive that is strict on POSIX filesystems and explicitly classifies unsupported Windows directory flushing. POSIX directory opens reject symlinks and FIFOs without blocking. Existing private repositories are repaired only after owner, ancestor, and ACL validation, then the durability pin is bound to the exact repaired directory identity.

Snapshot repositories now durably link newly created parent chains, fsync the .pending marker before publishing payloads, persist the repository entry before payload publication, and use pending removal plus a directory sync as the commit point. Shared SQLite publication pins the destination directory before staging or linking and uses that receipt for every strict sync. Fresh restore verifies the exact durably created parent identity and reports final staging-cleanup sync failures.

User Impact

Operators get stronger crash consistency for snapshot creation and fresh restore. On supported filesystems, success now means the relevant parent and publication metadata syncs completed. Empty or .pending directories remain recoverable interrupted state; markerless artifact-only, manifest-only, or unknown contents fail closed instead of being silently hidden.

Evidence

  • Exact head 8adfdb2c2a02ee669ebb49e95ee68706f1062158 on Blacksmith Testbox tbx_01kyadf1xhgz410c460skrffdf (run https://github.com/openclaw/openclaw/actions/runs/30107403342): 94 focused assertions passed and 5 platform assertions skipped across repository create/list/verify/restore, strict directory durability, and shared SQLite publication.
  • Exact-head pnpm check:changed passed on the same Testbox.
  • Native macOS: the two focused infra suites passed 38 assertions with 2 Windows-only assertions skipped, including FIFO rejection and transient publication-directory replacement.
  • Native Windows x64: https://github.com/openclaw/openclaw/actions/runs/30113968403 checked out the exact head and passed all 10 pnpm test:windows:ci shards, including deep-path snapshot, unsafe-index, and SQLite publication coverage. WSL2 was unavailable and is not claimed by this PR.
  • Fault coverage includes recursive parent-sync failure, transient parent and publication-directory replacement, FIFO substitution, private-mode repair from 000, 200, 300, and 777, POSIX unsupported-code propagation, Windows unsupported classification, pending-file sync failure, exact publication ordering, markerless partial state, post-commit mutation, and final restore cleanup sync failure.
  • Fresh full-branch autoreview completed with no accepted/actionable findings for the documented Linux, macOS, and Windows host contract.
  • git diff --check passed.

@vincentkoc vincentkoc self-assigned this Jul 24, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Jul 24, 2026
@vincentkoc
vincentkoc force-pushed the fix/sqlite-snapshot-publication-durability-20260724 branch from f23cfcd to d1ac5bc Compare July 24, 2026 16:22
@vincentkoc
vincentkoc marked this pull request as ready for review July 24, 2026 17:30
@vincentkoc

Copy link
Copy Markdown
Member Author

Land-ready proof for exact head 8adfdb2c2a02ee669ebb49e95ee68706f1062158:

Known remaining matrix work is tracked in #113306: WSL2, ARM64, broader filesystems/containers, high-I/O contention, and real power-loss replay.

@vincentkoc
vincentkoc merged commit 0920946 into main Jul 24, 2026
125 checks passed
@vincentkoc
vincentkoc deleted the fix/sqlite-snapshot-publication-durability-20260724 branch July 24, 2026 17:56
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 25, 2026
…3367)

* fix(sqlite): pin directory durability checks

* fix(snapshot): make publication crash recoverable

* fix(snapshot): revalidate committed publication

* fix(sqlite): pin durable directory ancestry

* test(sqlite): target directory sync fault

* fix(sqlite): pin every durability edge

* test(sqlite): target pinned sync failures

* fix(snapshot): reject markerless partial state

* fix(sqlite): harden durable directory opens

* test(snapshot): accept hardened redirect rejection

* test(sqlite): accept optional open flags

* fix(sqlite): repair pinned directory permissions

* fix(sqlite): bind publication and trusted repair

* fix(snapshot): preserve safe repository mode repair

* fix(sqlite): keep sync outcome internal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant