Repository navigation
fix(sqlite): reject orphaned database state before mutation - #105222
Merged
Merged
Conversation
vincentkoc
marked this pull request as ready for review
July 12, 2026 09:14
Member
Author
|
Land-ready verification for Behavior proof:
Validation:
Known proof gap: this narrow pragma hardening was not rerun on native Windows or ARM. The broader cross-platform snapshot/restore/high-I/O matrix remains follow-up work; no platform-specific SQLite API or filesystem behavior is introduced here. |
Member
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 13, 2026
…#105222) * fix(sqlite): detect foreign key corruption * docs(sqlite): document foreign key compaction checks * fix(sqlite): prevent pragma shadow bypass
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #101290
What Problem This Solves
Fixes an issue where users opening, backing up, verifying, or vacuuming an OpenClaw SQLite database could have orphaned foreign-key rows accepted as healthy because SQLite's
quick_checkandintegrity_checkdo not validate foreign keys.Why This Change Was Made
The shared fail-closed integrity gate now also runs
foreign_key_checkbefore any writable initialization, checkpoint,VACUUM,VACUUM INTO, or canonical backup verification. Diagnostics are deterministic and bounded, preserve 64-bit rowids, and identify the child table, row, parent table, and foreign-key id without changing the existing doctor report contract.This intentionally detects and rejects inconsistent state; it does not guess at an automatic repair for orphaned user data.
User Impact
Corrupt databases with orphaned references are rejected before OpenClaw mutates or snapshots them. Valid databases behave as before. Operators receive a specific error that identifies the violated relationship instead of a misleading healthy result.
AI-assisted: yes. The implementation and tests were reviewed with the repository autoreview workflow.
Evidence
tbx_01kxasf4b71wbmwahctjrbrxn6, Actions run https://github.com/openclaw/openclaw/actions/runs/29187032505: 166 focused tests passed across the shared integrity helper, pragma-shadow bypass, shared-state open/repair/startup, per-agent open/schema setup, backup creation, backup verification, and doctor compaction.tbx_01kxarrf09rdv1qczgbq92be9d:tsgo:core,tsgo:core:test, and targeted oxlint passed.pnpm check:changedreaches formatting and repository guards, then is blocked by the existingdocs/.generated/plugin-sdk-api-baseline.sha256drift. The same baseline check was reproduced on a pristineorigin/mainworktree; this PR does not touch plugin SDK surfaces.