Repository navigation
Description
mcpx(logstore): the read-only log-sql guard still executes bare mutating PRAGMAs (PRAGMA optimize, PRAGMA wal_checkpoint)
Finding
PR #3516 closed the value-carrying half of #1664: CheckReadOnly now refuses PRAGMAs in name = value and name(value) form (except an allowlist of function-form reads). But checkReadOnlyPragma passes any bare PRAGMA — a name with no = and no parentheses — and SQLite has bare, no-value PRAGMAs that perform actions instead of answering questions:
PRAGMA optimize— runs ANALYZE over the database and writessqlite_stat1.PRAGMA wal_checkpoint— checkpoints the live WAL into the main database file (this store's DSN is WAL mode, see evidence).PRAGMA incremental_vacuum— performs vacuum work in its bare form (verified mutating in rollback-journal mode; in WAL mode its effect was nil in the probe until a checkpoint, so it needs a disposition either way).
These run on the same writable store connection #1664 was about, through mcpx log sql, on a surface whose own contract is: "CheckReadOnly rejects a statement that would change anything."
Evidence
- Source PR: fix(mcpx/logstore): refuse value-carrying PRAGMAs in read-only log sql guard (#1664) #3516 (fix(mcpx/logstore): refuse value-carrying PRAGMAs in read-only log sql guard (#1664) #3516), head commit
afcce321e62f258ca290b73b1d1795adde603f38, merge8f0c004f738f181615aa0652759f9ffee8366610. It addedcheckReadOnlyPragmarefusing only=-carrying and parenthesised non-allowlist forms. - Current main
4ecb3510c9a46e5392a1c3218743251b1c4ae921(verified ×2, file byte-identical across both reads):pkgs/mcpx/internal/logstore/sql.go:24— "CheckReadOnly rejects a statement that would change anything."pkgs/mcpx/internal/logstore/sql.go:74—checkReadOnlyPragma: returns nil for anyrestwith no=and no(; there is no bare-name allowlist.pkgs/mcpx/internal/logstore/sql.go:151—RunSQLexecutes the checked statement vias.db.Query(query)on the store DB.pkgs/mcpx/internal/logstore/store.go:134— the store DSN sets_pragma=journal_mode(WAL), sowal_checkpointhas a live WAL to act on.
- Laptop probe (python sqlite3, WAL-mode database matching the store's mode): after
PRAGMA optimize(bare),sqlite_stat1contained 1 row (a persistent write); barePRAGMA wal_checkpointreturned(0, 414, 414)— 414 WAL frames checkpointed into the database file. In a rollback-journal database, barePRAGMA incremental_vacuumshrank the freelist 200 → 199 and the file by one page. - Dedupe: issue searches for
incremental_vacuum,PRAGMA optimize,wal_checkpoint,bare pragma, andCheckReadOnlyreturn only mcpx(logstore): the 'read-only' log sql guard admits mutating PRAGMAs — journal_mode=DELETE persistently un-WALs index.db, user_version/application_id rewrite its header #1664 (CLOSED — the value-carrying issue this PR fixed) and unrelated mcpx(openapi): Build is nondeterministic — duplicate operationIds swap tool names between runs, and the body schema is whichever JSON media type the map yields first #1668. No open or closed issue covers the bare forms.
Why it matters
The guard is the only thing standing between the documented read-only mcpx log sql surface and writes to the live log index. #1664's lesson was that this surface executes what it admits, persistently (its assignments survived reopen). The bare forms are the same class with the value removed: optimize rewrites planner statistics, wal_checkpoint forces WAL frames into the main file on a database the daemon is concurrently writing. Severity is modest — these are maintenance actions, not data destruction — but they break the stated read-only contract and can race/surprise the live writer.
Acceptance criteria
CheckReadOnlyadmits bare PRAGMAs only from an explicit allowlist of known reads (e.g.journal_mode,user_version,schema_version,database_list,compile_options,integrity_checkas applicable), or equivalently refuses the known action PRAGMAs (optimize,wal_checkpoint,incremental_vacuum,shrink_memory, and any other bare form triage finds that changes state).- Regression tests in
pkgs/mcpx/internal/logstore(guard-level andRunSQL-level, followingTestRunSQLRefusesPragmaAssignments):PRAGMA optimizeandPRAGMA wal_checkpointare refused; the established bare reads (PRAGMA journal_mode,PRAGMA user_version;) still pass. incremental_vacuumgets an explicit disposition: refused, or a comment/test records why its bare form cannot change this WAL-mode store.- Existing logstore tests still pass.
Activity
developing-today commentedon Nov 6, 2026
CODE-2044
dezren39 commentedon Nov 7, 2026
Picked up by
repo-worker-code-a— working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live whilerepo-worker-code-aposts progress markers; after 30 minutes of silence any other worker may pick this up.)11 remaining items
dezren39 commentedon Nov 7, 2026
🤖 Agent note · verified / branch_created
origin/main(checkReadOnlyPragmabare fall-through returns nil, read from both the laptop working tree andgit show origin/main:); existing guard tests located (TestReadOnlyGuardRejectsAnythingThatWrites,TestRunSQLRefusesPragmaAssignmentsinlogstore_test.go)dezren39/darwin-nixcarries no logstore Go source (mcpx there is config/planning only) — no nix-side copy of the guard to patch; this repo is the whole setqueue/fallback-6638-bare-pragma, laptop worktree~/git/fleet/fb-6638fromorigin/main6ba1efddezren39 commentedon Nov 7, 2026
🤖 Agent note · pr_opened
checkReadOnlyPragma; commit 39e4841 onqueue/fallback-6638-bare-pragmago test ./internal/logstore/pass (guard + RunSQL refusal tests verbosely green); vet/gofmt clean; two pre-existinginternal/apifailures in the full mcpx suite, one reproduced on clean main (noted on the PR)fix(mcpx): disposition Codex findings on PR #6700 — read_uncommitted …
Merge pull request #6700 from developing-today/queue/fallback-6638-ba…
dezren39 commentedon Nov 7, 2026
Released by repo-worker-code-w (Lane W, fallback mode) — outcome: done. Fix landed: PR #6700 merged (merge commit b7d16d1; verified on origin/main —
bareReadPragmaspresent inpkgs/mcpx/internal/logstore/sql.go). This issue auto-closed via the PR's Fixes link.🤖 Agent note · done
bareReadPragmasallowlist of known reads (schema qualifier stripped, matching the function-form branch);optimize/wal_checkpoint/incremental_vacuum/shrink_memoryrefused —incremental_vacuumdisposition is refusal, recorded in the registry comment and testsread_uncommittedread) both fixed in c44c1a6 and replied on their threads; round 2 on that head completed with no unresolved findingsgo test ./internal/logstore -count=1pass; guard tests pass-race -shuffle=on -count=5; vet/gofmt clean. PR CIbasic: scripts-testwas still pending at merge (slow infra, unrelated to this Go change); merged under the standing merge authority with the change verified independently