Skip to content

fix: prevent SQLite lock stalls and schema drift - #108663

Merged
steipete merged 3 commits into
mainfrom
codex/sqlite-safety-hardening
Jul 16, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/sqlite-safety-hardening

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where OpenClaw's SQLite-backed state stores applied inconsistent safety guarantees: some schemas accepted invalid value types, WAL activation could fail silently, and a memory cache copy held SQLite work across an asynchronous yield. Those gaps could turn ordinary contention or upgrades into lock stalls, schema drift, or partially enforced invariants.

Why This Change Was Made

This applies the relevant safeguards from the SQLite Editions audit across the shared state DB, agent DB, and touched plugin-owned databases. It adds versioned atomic STRICT migrations that preserve rows, indexes, triggers, views, implicit rowids, foreign keys, and AUTOINCREMENT high-water marks; verifies WAL activation and network-storage policy; bounds managed-handoff lock waits; and keeps all write transactions synchronous.

Logbook writes now use relational constraints and checked row counts, Memory Core copies cache rows in committed materialized pages, and filesystem mtimes retain sub-millisecond precision. No new config or compatibility fallback is introduced.

User Impact

Operators get deterministic SQLite upgrades, stronger on-disk invariants, and shorter lock ownership during concurrent work. Existing valid state is migrated in place. Invalid or unsafe schema transitions fail clearly instead of silently weakening storage guarantees.

Evidence

  • 421 focused Vitest cases passed across shared/agent state, WAL, strict migrations, managed handoff, Logbook, Memory Core, Workboard, Workspaces, proxy capture, and schema-shape coverage; 3 platform/feature-gated cases skipped.
  • Real Memory Core in-place reindex and the new 1,001-row cache paging regression passed.
  • Plugin SDK API baseline, SDK surface budget, SQLite session schema baseline, generated Kysely types, targeted lint/format, and git diff --check passed.
  • Blacksmith Testbox full pnpm build passed, including tsdown, public Plugin SDK declaration verification, CLI bootstrap guards, bundled assets, and Control UI performance budgets.
  • pnpm check:changed reached the repository's pre-existing current-main max-lines ratchet failure for src/agents/live-cache-regression-runner.ts; this PR does not touch that file or its baseline.
  • Fresh structured autoreview: clean, no accepted/actionable findings (0.90 confidence).
  • Non-visual storage change; screenshots are not applicable.

AI-assisted. I reviewed the complete change and validation evidence.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core scripts Repository scripts commands Command implementations plugin: workboard plugin: logbook Logbook automatic work journal plugin plugin: workspaces Agent-composable Workspaces plugin size: XL maintainer Maintainer-authored PR labels Jul 16, 2026
@steipete
steipete force-pushed the codex/sqlite-safety-hardening branch from 180e5d8 to 8b9ae93 Compare July 16, 2026 06:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 180e5d8ee8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md Resolved
@steipete
steipete force-pushed the codex/sqlite-safety-hardening branch from 9905168 to 31e7d2b Compare July 16, 2026 07:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31e7d2bb7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete
steipete force-pushed the codex/sqlite-safety-hardening branch from 31e7d2b to e03cca9 Compare July 16, 2026 08:05
@steipete
steipete merged commit 30ae21f into main Jul 16, 2026
184 of 186 checks passed
@steipete
steipete deleted the codex/sqlite-safety-hardening branch July 16, 2026 08:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
* fix: harden SQLite state storage

* build: allow strict SQLite migration SQL

* test: align SQLite and model-default assertions
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* fix: harden SQLite state storage

* build: allow strict SQLite migration SQL

* test: align SQLite and model-default assertions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR plugin: logbook Logbook automatic work journal plugin plugin: workboard plugin: workspaces Agent-composable Workspaces plugin scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant