feat(store): backups in plain folders, written once (P15 section 9, D-91, D-92)

A backup is a folder holding one folder per set of books, made only of
files that are written once: the journal and the access log as immutable
segments, an index of stored files and the stored files under their hash,
the vault and keys by content hash, and a manifest, written last, that
makes a backup complete. It is built beside the git form for now.

Accounting reasoning: the journal is append-only and a stored file never
changes, so what the store's lock must fix is one look (its length, that
its last line is the head, the vault and keys); the rest is read after it.
A destination is written only when its newest whole manifest is a point on
the live journal (byte-identical prefix); otherwise nothing is written.
Two writers cannot corrupt it: pieces are named by what is in them, the
manifest number is taken by exclusive create, the loser looks again.

A passphrase (D-92) seals every piece with XChaCha20-Poly1305 in 1 MiB
chunks, the key derived by Argon2id at the owner passphrase's own cost
(64 MiB, 3 passes, 1 lane); names are made from the key and say nothing;
the derived key is kept in the book's local/ folder, owner-only.
"Save a backup..." is a zip of the same form (.wbbackup).

New dependencies: none new to the tree. chacha20poly1305, zeroize and zip
(deflate only) were already used by ledger-vault, the viewer and the
packages; ledger-store now names them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 17:19:12 -07:00
1 parent 836543694c
commit 9f4529b078
12 files changed
+3827

No files matched your search

Generated
+3
View File
@@ -4262,6 +4262,7 @@ name = "ledger-store"
version = "0.1.0"
dependencies = [
"argon2",
"chacha20poly1305",
"chrono",
"criterion",
"getrandom 0.2.17",
@@ -4279,6 +4280,8 @@ dependencies = [
"tempfile",
"thiserror 2.0.21",
"windows-sys 0.61.2",
"zeroize",
"zip",
]
[[package]]