Skip to content

Add SQLite database page attribution - #4993

Merged
Widthdom merged 1 commit into
mainfrom
fix-issue4888
Jul 30, 2026
Merged

Add SQLite database page attribution#4993
Widthdom merged 1 commit into
mainfrom
fix-issue4888

Conversation

@Widthdom

Copy link
Copy Markdown
Owner

Summary

  • Add an additive database_size_attribution block to full CLI and MCP status JSON, including physical main/WAL/SHM sizes, logical page bytes, table/index/object totals, page-type totals, payload/unused/structural overhead, freelist bytes, residual bytes, and bounded top objects.
  • Prefer SQLite dbstat and fall back to a bounded read-only b-tree/WAL parser with explicit unavailable reasons instead of reporting missing measurements as zero.
  • Keep the attribution synchronized with the rest of status: live WAL fallback pins the connection's active read snapshot in a cancellation-aware private backup, while stable detached query snapshots avoid that extra copy.
  • Skip the expensive page scan for human/compact output, projections that do not request the block, and unrelated internal status consumers.

Root cause

Status exposed only coarse database and WAL file sizes, so support automation could not reconcile logical SQLite allocation by object, page type, freelist, payload, or overhead. The file-parser fallback also needed to be bound to the active SQLite read snapshot so a concurrent WAL commit could not mix generations within one status response.

Validation

  • dotnet build CodeIndex.sln -c Release --no-restore -p:UseSharedCompilation=false — passed with 0 warnings and 0 errors.
  • Issue-focused tests — 9/9 passed on both net8.0 and net9.0, including corruption, limits, cancellation, WAL truncation, and concurrent WAL snapshot consistency.
  • Full Release suite — net8.0: 10,896 passed, 7 skipped, 0 failed; net9.0: 10,422 passed, 420 skipped, 0 failed.
  • make lint — passed.
  • Documentation status contract — 3/3 passed on both target frameworks.
  • dotnet run --project tools/CodeIndex.Changelog -- check — 64 fragments valid.
  • Local index refresh completed for 1,294 files with 0 warnings/errors; status --check --json reported index_matches_workspace=true and no failed checks.
  • Two Codex adversarial-review rounds completed; actionable cancellation, WAL-truncation, and active-snapshot findings were addressed and covered by regression tests.

Documentation and changelog

  • Updated README.md, DEVELOPER_GUIDE.md, TESTING_GUIDE.md, and AGENT_GUIDE.md.
  • Added bilingual fragment changelog.d/unreleased/4888.added.md.

Follow-ups

  • None.

Fixes #4888

@Widthdom
Widthdom marked this pull request as ready for review July 30, 2026 07:53
@Widthdom
Widthdom merged commit 63694af into main Jul 30, 2026
12 checks passed
@Widthdom
Widthdom deleted the fix-issue4888 branch July 30, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attribute SQLite database size by object and page usage

1 participant