Repository navigation
fix(sqlite): prevent plugin metadata reads from mutating state - #106103
Conversation
68c4d94 to
04a2a82
Compare
04a2a82 to
77338bc
Compare
|
Land-ready proof for
Known gap: the production corruption interleave from #101290 remains nondeterministic. This PR removes the writable lifecycle from the two installed-plugin metadata read paths; doctor, migration, plugin-state diagnostics, and external maintenance ownership remain follow-up work, so #101290 should stay open. |
|
Merged via squash.
|
|
Post-merge CI regression: The helper appears to be a narrowly justified read-only SQLite bootstrap. Please either add it to the raw SQLite allowlist under a named read-only shared-state reason, or route it through an already allowed Kysely boundary. This inherited |
Related: #101290
What Problem This Solves
Fixes an issue where CLI/config/plugin metadata reads could join the shared state's writable lifecycle while a live Gateway owned the database. A nominal read could repair canonical indexes, configure WAL maintenance, checkpoint, or mutate file permissions.
Why This Change Was Made
Plugin index reads now use a short-lived
DatabaseSynchandle opened withreadOnly: true. The helper preserves state-path resolution, busy timeout, newer-schema rejection, and deterministic close behavior while leaving schema repair and WAL lifecycle work to writable owners.Both persisted plugin-index read paths moved to the read-only helper. Writable refreshes still use the existing state transaction path.
User Impact
CLI and configuration flows that inspect installed plugin metadata no longer mutate or repair the shared state database. This reduces cross-process SQLite ownership overlap while a Gateway is running without changing plugin-index results.
Evidence
29227894730.tbx_01kxd2m9558776fyy9p4btxt3s: 77 tests passed across shared-state and plugin-index suites.pnpm check:changedlane passed on the same Testbox, including typechecks, lint, import-cycle checks, database-first guards, and formatting. Currentmainindependently regenerates a different Plugin SDK API hash; that hash was reconciled only inside the disposable Testbox worktree so the unrelated remaining gates could run, and no generated file is part of this PR.DatabaseSync(path, { readOnly: true })opens SQLite withSQLITE_OPEN_READONLY; the default constructor uses writable/create flags.