Skip to content

Audit SQLite maintenance, migration, WAL, and prune boundaries #4338

Description

@Widthdom

Context

Dogfooding found a large SQLite maintenance and migration surface. Read-only checks worked in the current workspace, but apply/write maintenance modes remain only partially exercised.

Representative search inventory:

dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search PRAGMA --format count --limit 100
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search transaction --format count --limit 100
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search migration --format count --limit 100
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search WAL --format count --limit 100
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search integrity_check --format count --limit 100
dotnet ./src/CodeIndex/bin/Debug/net8.0/cdidx.dll search --recipe sqlite-query-policy-surfaces --format count --summary-only --json --limit 5

Observed baseline:

  • PRAGMA: 218 hits across 57 files.
  • transaction: 112 hits across 28 files.
  • migration: 121 hits across 36 files.
  • WAL: 144 hits across 45 files.
  • integrity_check: 50 hits across 14 files.
  • sqlite-query-policy-surfaces: 658 hits across 55 files.
  • db --integrity-check --json succeeded with integrity_ok.
  • db prune --dry-run --json succeeded with zero orphan rows.
  • db schema --summary-only --json --limit 20 returned zero entries by design while object counts reported tables/indexes/triggers.

Audit questions

  • Are WAL/read-only/immutable fallback paths, checkpoints, busy timeouts, and stale snapshot diagnostics tested across normal and failure cases?
  • Do migrations and user_version compatibility checks fail safely on newer/older databases and partial migration attempts?
  • Does db prune --apply protect active rows and report deleted counts/transactions accurately under interruption?
  • Are maintenance commands (optimize, vacuum, prune, integrity-check, schema) consistent about JSON shape, truncation metadata, and support-safe diagnostics?

Acceptance criteria

  • SQLite maintenance commands have representative tests for read-only, dry-run, apply, failure, and cancellation cases.
  • Migration and compatibility diagnostics are stable and actionable without raw SQL/path leakage.
  • WAL and vacuum/optimize/prune guidance is consistent with status.maintenance_guidance.
  • Summary-only DB schema output clearly distinguishes intentional row omission from truncation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions