# Receipt & document store + persistence spec Three pieces: the **journal** (the source of truth), the **blob store** (the bytes), and **SQLite** (the queryable projection). All immutable-first, matching the ledger's philosophy: the books never forget, and neither does the filing cabinet. ## The journal: the source of truth SQLite is the query engine, not the source of truth. The source of truth is an **append-only journal of domain events**: one JSON object per line (JSONL), hash-chained. This is the deliberate answer to "insanely durable, easily backupable, journable": - **Durable.** Every state change is an immutable fact appended to `journal.jsonl`, fsync'd per append. Each line carries the SHA-256 of the previous line's canonical bytes (`prev`), forming a tamper-evident chain: bit rot, torn writes, and casual editing are detected on read/verify, not discovered at tax time. Honest scope: this detects corruption and casual tampering. It does not stop a determined attacker with full write access from rewriting the chain — nothing local does. - **Backupable.** The backup is `cp -r $WANDERBOOKS_DATA /backup`: the journal file plus the blob directory. Plain files, no WAL-file timing windows, no special backup API. A copy taken mid-write, like a crash or power loss mid-append, can end in a cut-off line (bytes after the last newline). It was never acknowledged, so opening the books saves those bytes to `journal.jsonl.torn.