Files
wanderbooks/crates/ledger-store/Cargo.toml
T
swaitsandClaude Fable 5.2 9f4529b078 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>
2026-11-21 17:19:12 -07:00

71 lines
2.2 KiB
TOML

[package]
name = "ledger-store"
version = "0.1.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
publish.workspace = true
description = "Durable persistence for wanderbooks: a hash-chained JSONL journal as the source of truth, content-addressed blob store, and a disposable SQLite projection."
[dependencies]
ledger-core = { path = "../ledger-core" }
# The one reader (plan P6 step 1, D-53, D-61: its own crate): the writer journals a file's
# text at attach time and on `wanderbooks books extract`, so the extractor
# must be callable here rather than only from the server. It is pure and
# deterministic (no I/O, no network, no time source).
ledger-reader = { path = "../ledger-reader" }
rusqlite = { version = "0.41", features = ["bundled", "fallible_uint"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = "0.4"
rust_decimal = "1"
thiserror = "2"
sha2 = "0.10"
hex = "0.4"
getrandom = { version = "0.2", features = ["std"] }
subtle = "2"
argon2 = "0.6"
# A backup protected by a passphrase is sealed as the TIN vault is
# (XChaCha20-Poly1305, already in the tree); its key is kept off the
# page when this program is done with it (D-92).
chacha20poly1305 = "0.11"
zeroize = "1"
# "Save a backup..." is one file: a zip of the backup's folder form (the
# crate the viewer and the packages already use, deflate only).
zip = { version = "9.0.1", default-features = false, features = ["deflate"] }
[target.'cfg(unix)'.dependencies]
libc = "0.2"
# Owner-only DACLs, the account's SID, the known-folder API and
# MoveFileExW (P11c, D-62). The raw bindings, no runtime: the smallest
# Microsoft crate that covers them, already in the lockfile.
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = [
"Win32_Foundation",
"Win32_Security",
"Win32_Security_Authorization",
"Win32_Storage_FileSystem",
"Win32_System_Com",
"Win32_System_Pipes",
"Win32_System_SystemServices",
"Win32_System_Threading",
"Win32_UI_Shell",
] }
[dev-dependencies]
tempfile = "3"
proptest = "1"
rust_decimal = "1"
criterion = "0.8.2"
[target.'cfg(unix)'.dev-dependencies]
libc = "0.2"
[[bench]]
name = "store"
harness = false
[lints]
workspace = true