Skip to content

fix(storage): connection profile unification — 14 sites bypass WRITE_CONNECTION_PRAGMA_STATEMENTS #780

Closed

Description

@Sinity

Problem

14 sqlite3.connect() sites open database connections without applying the canonical WRITE_CONNECTION_PRAGMA_STATEMENTS (WAL mode, busy_timeout=30s, foreign_keys=ON, cache_size=128MiB, mmap=1GiB, synchronous=NORMAL).

Severe sites (read-write on main archive, all pragmas missing):

  • write_gateway.py:120 — dead code (never instantiated) but would be severe if wired
  • reset.py:44,62,145 — 3 sites in the reset command
  • blob_gc.py:141 — GC operations
  • sampling_db.py:163,274 — schema sampling
  • corpus.py:229 — validation with conditional writes
  • sqlite_vec_runtime.py:24 — vector ops, missing 7 of 9 pragmas
  • daemon/cli.py:39 — FTS startup check

Impact: SQLITE_BUSY on lock conflict (no busy_timeout), no FK enforcement, no WAL crash recovery, severely degraded I/O performance.

Acceptance criteria

  • All production connection sites route through connection_profile.py factories
  • write_gateway.py connection site is either wired or deleted
  • reset.py uses connection_context() or open_connection()
  • CI linter rejects bare sqlite3.connect() in production code (allow in tests)
  • 3 sites using WRITE profile for read-only ops use read profile instead

Ref: deep audit 4b, C4. Ref #771, #772.

Activity

  1. Sinity commented on May 4, 2026

    @Sinity
    OwnerAuthor

    Resolved by PR #788. All 14 connection sites routed through connection_profile.py factories, verify_connection_sites.py linter created.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions