Skip to content

fix(sqlite): reject incomplete maintenance schemas - #105583

Merged
vincentkoc merged 1 commit into
mainfrom
fix/sqlite-schema-completeness
Jul 12, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/sqlite-schema-completeness

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Related: #94805
Related: #94967

What Problem This Solves

Fixes an issue where SQLite maintenance operations could trust a current-version global or agent database even when required tables, column clauses, constraints, indexes, triggers, virtual-table definitions, or table options had drifted. That made compaction and future snapshot/restore work capable of preserving a structurally incomplete database.

Why This Change Was Made

Maintenance now validates the full canonical schema contract before touching a database. Column declaration order and table-constraint order remain migration-safe, while temporary defaults are accepted only for the exact additive migrations OpenClaw has shipped.

User Impact

Operators get a hard failure with a concrete schema mismatch instead of compacting, snapshotting, or restoring a database whose current-version metadata hides structural drift. Existing databases produced by supported additive migrations remain accepted.

Evidence

  • Blacksmith Testbox through Crabbox: tbx_01kxbqm8vw76mgsmeymqsbrkn9 (violet-hermit), Actions run https://github.com/openclaw/openclaw/actions/runs/29202964021
  • Focused SQLite bundle: 174 passed, 2 platform-specific skips
  • Path-scoped pnpm check:changed: passed on the seven touched files; the known current-main Plugin SDK hash drift was regenerated only inside the disposable Testbox command and restored on exit
  • Structured branch autoreview: clean, no accepted/actionable findings
  • Regression coverage includes missing tables, drifted columns/checks/defaults/collations/generated expressions/conflict clauses/AUTOINCREMENT/foreign-key deferral, unsafe canonical index replacement, trigger drift, migration column order, and supported temporary migration defaults

@vincentkoc vincentkoc self-assigned this Jul 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XL maintainer Maintainer-authored PR labels Jul 12, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Land-ready proof:

  • Implemented full canonical SQLite schema validation for global and agent maintenance paths, including columns, constraints, indexes, triggers, virtual tables, table options, and exact supported additive-migration defaults.
  • Blacksmith Testbox through Crabbox: tbx_01kxbqm8vw76mgsmeymqsbrkn9 (violet-hermit), Actions run https://github.com/openclaw/openclaw/actions/runs/29202964021.
  • corepack pnpm test:serial src/infra/sqlite-schema-contract.test.ts src/state/openclaw-database-maintenance.test.ts src/state/openclaw-state-db.test.ts src/state/openclaw-agent-db.test.ts src/commands/doctor-state-sqlite-compact.test.ts src/commands/doctor-session-sqlite.test.ts: 174 passed, 2 platform-specific skips.
  • Path-scoped corepack pnpm check:changed -- CHANGELOG.md src/commands/doctor-state-sqlite-compact.test.ts src/infra/sqlite-schema-contract.test.ts src/infra/sqlite-schema-contract.ts src/state/openclaw-agent-db.ts src/state/openclaw-database-maintenance.test.ts src/state/openclaw-state-db.ts: passed. The unrelated current-main Plugin SDK baseline drift was regenerated only inside the disposable Testbox command and restored on exit.
  • Structured branch autoreview: clean, no accepted/actionable findings.
  • OPENCLAW_TESTBOX=1 OPENCLAW_ALLOW_ROOT_CHANGELOG_PR=1 scripts/pr prepare-run 105583: passed; PR head stayed 90d9edf93bfb21ebfb663b8673f55cdc110740d1.

Known gap: destructive cross-platform snapshot/vacuum/restore stress is the next follow-up after the CLI lands; it is tracked by #94967 and is not substituted by this schema-verifier proof.

@vincentkoc
vincentkoc marked this pull request as ready for review July 12, 2026 18:06
@vincentkoc
vincentkoc merged commit f11b17d into main Jul 12, 2026
113 of 116 checks passed
@vincentkoc
vincentkoc deleted the fix/sqlite-schema-completeness branch July 12, 2026 18:06
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant