Repository navigation
ledger: store each catalog record once, and a command that converts a ledger - #127
Merged
Merged
Conversation
The ledger stores the whole catalog again on every daily sync: 95% of a 552 MB file is 30 copies of the same 2,296 records. The spec keeps every synced ref and stores each record body once by content hash, converting an existing ledger at open. Measured on a copy: 57 MB, 0.54 MB per sync. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A start converts nothing: buffer-api refuses a ledger in the old shape and names the command, the buffers check gains a ledger line so a release stops before it flips, and mia-buffers ledger migrate does the conversion and the vacuum between mia down and mia up. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…erts a ledger records names each body by the hash of its text and record_bodies holds a body once however many synced refs contain it. A ledger whose records still holds a body in every row is read and written as it is: opening one never changes its shape. mia-buffers ledger migrate converts the file in one transaction and vacuums it, and refuses while buffer-api answers. On a copy of a 552 MB ledger with 31 refs: 57 MB after 2.5 s, every ref reads back equal. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…(v0.3) The runbook is down, copy, ledger migrate, up. The spec no longer has buffer-api refuse an unconverted ledger: a release always runs the buffers check, which needs buffer-api up, so the code has to run on either shape. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
mia down left a -wal file beside dev's ledger; a copy of the main file alone could miss writes. mia down also stops a managed Temporal, so the step no longer says it keeps running. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
buffer-api's ledger kept a full copy of every catalog record for every synced catalog commit. On a ledger of 552 MB, 95% was the
recordstable: 31 commits, 68,153 rows, 2,296 distinct record bodies. It grew about 18 MB a day, and every timed backup carried the same weight.What changes
recordsholds a commit's ids and paths and names each body by the SHA-256 of its stored text. A newrecord_bodiestable holds each body once, however many commits have it. Every synced commit is kept, so a plan over an older commit reads what it read before.mia exec mia-buffers ledger migrateconverts an existing ledger in one transaction and gives the freed space back. It refuses while buffer-api answers and finds nothing to do when run again.mia downandmia up.Measured
A sync adds about 0.5 MB afterwards. On both, every commit read back identical (paths, ids and stored body text) and SQLite's integrity check passed. The second is a running installation that was converted by the runbook and came back with the same running workflows.
Rollout
Runbook in
docs/deployment.md("converting the ledger's catalog records"): release,mia down, copy the ledger with its-waland-shmfiles,ledger migrate,mia up. Code from before this change cannot read a converted ledger; the runbook says how to go back.Notes for review
docs/specs/2026-11-26-ledger-record-bodies.md._whole_recordsinLedger) can be removed once every installation is converted.🤖 Generated with Claude Code