swaitsandClaude Opus 5.5 aec55b8d12 Store: say "newer wanderbooks", not "corrupt", for books from a newer version
An unknown event type on a whole, chained line, or a journal.format_set
declaring a newer journal format, now raises StoreError::NewerJournal
(update wanderbooks) instead of JournalCorrupt. Corruption (bad hash,
seq, or JSON) is still corruption. The gate runs in the store, the
Snapshot and the GUI, after each line's parse, seq and hash checks, and
never skips a line it can't read. Adds the journal.format_set event
(format 1 today; nothing writes it yet) and a registry of every event
type this version reads, tested against the replay and projection arms.

Review fixes (P0 review, 2026-10-16):
- A line's own hash is checked only by the next line's prev, and the
  gate used to refuse a line before reading the next: a flipped bit in a
  middle line's type (or a format_set edited from 1 to 2) was reported
  as "newer, the books are not damaged". Now the reader settles every
  refusal against the next line (format::settle): a next line that
  doesn't chain makes it corrupt; one that chains makes it newer and
  verified; with no next line the message says "newer or damaged; update,
  then run verify", never "not damaged" (NewerJournal.verified).
- A newer format number is judged newer before its features are parsed:
  a newer format may shape them differently.
- Snapshot treats a blank complete line as corrupt, as the writer does.
- docs/spec/rules.md B-27, which the code cites, now exists.

Round-2 review fixes (2026-10-16):
- The envelope {seq, ts, type, payload, prev} and its hash (SHA-256 of
  the canonical JSON) are frozen across formats (rules.md B-27); new
  fields go in payload. settle reads only the next line's prev, leniently,
  so a newer format's next line (a float, a string seq, keys of its own)
  is never called corrupt: no readable prev means unverified newer.
- A key beside the envelope's was silently dropped (and the chain then
  broke as "corrupt"): it is now NewerJournal, hashed over the raw
  canonical JSON so the next line still checks it; JournalLine::parse
  refuses such a line.
- "the books are not damaged" overclaimed: a verified refusal says line N
  is intact and this version can't check the lines after it.
- The writer read the journal with BufRead::lines (invalid UTF-8 was an
  I/O error); it now splits bytes on newlines as the Snapshot does, so a
  non-UTF-8 line is JournalCorrupt in both.
- Store::open truncated a torn tail before the gate ran, altering newer
  books (perhaps mid-append) before refusing them. The gate now runs over
  the complete lines first; the tail is set aside (and journaled) only
  when they pass.
- Mutation testing (docs/testing.md, P0): the viewer and the writer say
  the same words about the same damaged line (the newline is no part of
  it); read_journal_and_format returns every line and the format in
  force; the journal page tells a format declaration.
Plan: plan/served.md P0 and 5.1.

Review round 3 (S6, S7). Store::open replays every complete line in
memory (the first line's currency, then the ledger) before a cut-off
last line is set aside, so a complete line the books can't apply
refuses the open with the journal byte for byte as it was and nothing
set aside (B-27 SCENARIO 3; test
a_bad_complete_line_before_a_torn_tail_leaves_the_journal_as_it_was);
catch_up now only projects. The viewer
applies the writer's first-line rule (created_currency, shared) instead
of guessing USD: any other first line, or a store.created without a
sound base_currency, is corrupt to both (test
the_first_line_is_store_created_for_the_viewer_and_the_writer). fuzz_store_replay varies the
first line (14,696 runs clean).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj
2026-10-17 00:32:42 -06:00

wanderbooks

Canonical double-entry bookkeeping, rebuilt from scratch. The engine is verified against oracles, parity is tracked automatically, and the primary interface is AI-first: you talk to an agent, the agent drives the books through MCP. Self-hosted, no rent.

What it is

  • ledger-core — the semantics engine. Exact decimal money, five account types, balanced journal entries, immutable posted log with reversing entries, trial balance, P&L, balance sheet, indirect-method cash flow, fixed-asset register with straight-line depreciation.
  • ledger-store — durable storage. The source of truth is an append-only, hash-chained JSONL journal; SQLite is a disposable projection rebuilt from it; receipts live in a content-addressed blob store. Drafts are durable, corrupt projections self-heal.
  • ledger-mcp — the AI-first interface. 64 MCP tools over stdio or Streamable HTTP: draft → preview → post workflow, server-side receipt policy (>$25), anti-splitting detection, asset management, digest for human review, plus read-only resources for dashboards.
  • ledger-import — QuickBooks interop. Import bank/credit-card CSVs and chart-of-accounts CSVs; export IIF journal entries (for QuickBooks Desktop) and XLSX reports.
  • ledger-config — the company settings in a books dir's wanderbooks.toml.
  • ledger-gui — the viewer: a read-only, live window on the books for owners and their accountant (egui). Answers first (cash, runway, profit, what needs attention), then every number drills down to its lines, its entry, the rendered receipt, and the journal history. Follows the journal live: a change the agent makes appears in milliseconds. --demo opens a realistic demo company.

Verification

This is the storytold way applied to accounting: agents verify against oracles, never ship what they haven't demonstrated.

  • 190+ workspace tests: invariant tests encoding accounting law, golden-file report snapshots, property tests (proptest), end-to-end MCP stdio tests.
  • Formal proofs of the accounting laws (just prove, docs/verification.md). Kani model-checks the engine's arithmetic kernel exhaustively within bounds. Lean 4 proves that, after any sequence of commands, the trial balance balances, the accounting equation holds, posted entries are forever, closed periods stay frozen, and a close moves exactly the net income to equity. The first pass found three engine bugs that every test, fuzzer, and mutant had missed: negative amounts accepted, and two crashes on oversized amounts. It also caught a soundness bug in the model checker itself.
  • Mutation testing via cargo-mutants; fuzzing via cargo-fuzz (11.5M+ executions, zero crashes).
  • GnuCash is a behavioral cross-check, never the authority and never a code source (clean room, MIT OR Apache-2.0). Accounting principles, proved, are the spec. Where any other program disagrees, we work out from principles who is right.

Status

Parity is 12 of 12 against the spreadsheet workflow it replaces (docs/capability-parity.md). The parallel-run plan (docs/parallel-run.md) is written; the Google Sheet stays the system of record until a clean month and explicit cutover approval.

See plan/STATUS.md for where things stand and plan/roadmap.md for where it's going.

Quickstart

cargo test          # whole suite
cargo run -p ledger-mcp -- --data-dir /tmp/books   # MCP server over stdio
cargo run -p ledger-gui -- --demo                   # the viewer, on a demo company

New books, one command (installs Rust and wanderbooks if needed, makes the books dir with the MCP server registered for it, and starts the agent):

curl -fsSL https://wanderbooks.ai/install.sh | sh -s -- ~/Books/Acme

Already installed: wanderbooks new ~/Books/Acme (add --codex to keep the books with Codex instead of Claude Code). In a books dir, just lists the shortcuts (just gui, just agent, just backup).

Developing

Every tool the recipes use (Rust, just, Kani, Lean, cargo-mutants, cargo-fuzz, Node for deploys) is pinned in mise.toml:

mise install
just          # lists the recipes: check, build, prove, demo, ...

Layout

crates/ledger-core/    # engine: money, accounts, journal, ledger, reports
crates/ledger-store/   # journal + SQLite projection + blob store
crates/ledger-mcp/     # MCP server: 64 tools, resources, receipt policy
crates/ledger-import/  # QBO CSV import, IIF/XLSX export
crates/ledger-config/  # wanderbooks.toml company settings
crates/ledger-cli/     # `wanderbooks new`: one-command books dir + agent
crates/ledger-gui/     # the viewer: read-only, live (egui)
docs/                  # requirements, architecture, oracle, parity, glossary
plan/                  # STATUS.md, roadmap.md
AGENTS.md              # operating manual for agents working here

License

MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE.

S
Description
Canonical double-entry bookkeeping, rebuilt from scratch. AI-first via MCP, self-hosted, no rent.
Readme
4.9 MiB
0 Stars 1 Watchers 0 Forks
Languages
Rust 97.8%
Lean 1.1%
HTML 0.5%
Typst 0.3%
Just 0.2%