Skip to content

mcpx(logstore): read-only log-sql guard still executes bare mutating PRAGMAs (optimize, wal_checkpoint) #6638

Closed

Description

@dezren39

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 writes sqlite_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

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

  • CheckReadOnly admits bare PRAGMAs only from an explicit allowlist of known reads (e.g. journal_mode, user_version, schema_version, database_list, compile_options, integrity_check as 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 and RunSQL-level, following TestRunSQLRefusesPragmaAssignments): PRAGMA optimize and PRAGMA wal_checkpoint are refused; the established bare reads (PRAGMA journal_mode, PRAGMA user_version;) still pass.
  • incremental_vacuum gets 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

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    on Nov 6, 2026
  2. developing-today commented on Nov 6, 2026

    @developing-today
    Contributor
  3. added
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 6, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    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 while repo-worker-code-a posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  5. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  6. 11 remaining items

  7. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · verified / branch_created

    • Agent: repo-queue-worker Lane W (code-w), fallback mode
    • Task: mcpx(logstore): read-only log-sql guard still executes bare mutating PRAGMAs (optimize, wal_checkpoint) #6638 (task/small-fix)
    • Stage: verified — defect re-confirmed on fresh origin/main (checkReadOnlyPragma bare fall-through returns nil, read from both the laptop working tree and git show origin/main:); existing guard tests located (TestReadOnlyGuardRejectsAnythingThatWrites, TestRunSQLRefusesPragmaAssignments in logstore_test.go)
    • Propagation check: dezren39/darwin-nix carries no logstore Go source (mcpx there is config/planning only) — no nix-side copy of the guard to patch; this repo is the whole set
    • Branch: queue/fallback-6638-bare-pragma, laptop worktree ~/git/fleet/fb-6638 from origin/main 6ba1efd
    • Next: implement bare-PRAGMA read allowlist + regression tests
  8. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · pr_opened

  9. added 2 commits that reference this issue on Nov 7, 2026
  10. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Released by repo-worker-code-w (Lane W, fallback mode) — outcome: done. Fix landed: PR #6700 merged (merge commit b7d16d1; verified on origin/main — bareReadPragmas present in pkgs/mcpx/internal/logstore/sql.go). This issue auto-closed via the PR's Fixes link.

    🤖 Agent note · done

    • Agent: repo-queue-worker Lane W (code-w), fallback mode
    • Task: mcpx(logstore): read-only log-sql guard still executes bare mutating PRAGMAs (optimize, wal_checkpoint) #6638 (task/small-fix) — outcome: fixed_merged
    • What landed: bare PRAGMAs pass only from the bareReadPragmas allowlist of known reads (schema qualifier stripped, matching the function-form branch); optimize / wal_checkpoint / incremental_vacuum / shrink_memory refused — incremental_vacuum disposition is refusal, recorded in the registry comment and tests
    • Codex gate: round 1 P1 (registry-driven class guard) + P2 (read_uncommitted read) both fixed in c44c1a6 and replied on their threads; round 2 on that head completed with no unresolved findings
    • Tests: laptop go test ./internal/logstore -count=1 pass; guard tests pass -race -shuffle=on -count=5; vet/gofmt clean. PR CI basic: scripts-test was still pending at merge (slow infra, unrelated to this Go change); merged under the standing merge authority with the change verified independently
    • Propagation: darwin-nix carries no logstore source — nothing owed there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/pr-diff-reviewFiled by the pr-diff-review jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions