Files
wanderbooks/plan/2026-11-09_TRIAGE.md
T
swaitsandClaude c09f492c46 docs(verification): every Ledger command, and the step of the Lean model it is
bookspec proves its laws (the trial balance, the accounting equation,
posted is forever) for every state its steps reach. The engine has 119
public commands and the model 14 steps, and nothing said which command is
which step, so "every reachable state" read wider than it was.

docs/command-steps.md is that map, command by command: 71 are the
`record` step (they change how the books are kept and no figure), 11 are
one step, 19 are several steps run as one, 17 are the doors a journal is
replayed through, and one, `renumber_account`, is no step at all.

What the map shows that was not written down before:

- A renumber changes the chart's codes and the model has no step for it.
- Four doors apply a journaled change without a check the model's step
  requires (a draft dated in a closed period, a period overlapping
  another, a reversal dated before its original). Books replayed from an
  old journal can therefore be outside the model's reachable states. The
  laws resting on distinct codes, acceptable entries and known accounts
  still hold by reading their proofs; no theorem says so yet.
- The registers (assets, schedules, recurring entries, payroll runs) have
  proved arithmetic and no model of how they change over time.
- No proof ties a Rust command to its step: bookspec's examples and the
  differential test do, and the page lists what that test does not reach.

Each closes with Lean in bookspec; the triage (P2.5) lists them.

tests/command_steps.rs keeps the map whole: a command with no row, a row
with no command, a step the model does not have, or a new command marked
as no step without being added to the pinned list fails the build.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 21:00:11 -07:00

9.5 KiB

Triage, 2026-11-09

What a full evaluation of the project found, in the order it should be worked. Each item says what is wrong, how it is known, what closes it and who does it. "Mine" is the orchestrating session; "worker" is a delegated model (docs/routing.md); "owner" is Steve.

The engine itself is in good shape: 36 parity items done, more than 188 Lean theorems, 97 Kani harnesses, every rule cited by its bookspec id, 95.5% of ledger-core's lines covered. Nothing below is a wrong number in the live books. The gaps are in what the gates do not see.

P0: broken now

  1. portable-windows was red for four pushes and nobody looked. Only check was being read. Cause: a test named a Unix path for backup.folder. Fixed in 5cad55023, pushed with 0ef1ef2c2, and that commit's Windows gate read green on 2026-11-09 (all four gates green). Closed. The rule since: read all four gates after every batch push.

P1: a promise of the manual that is not kept, or a correctness risk

  1. The kernel rule is not met and nothing enforced it. Bar item 1 says money arithmetic lives in kernel/ and nowhere else. scripts/raw-decimal-arith.sh (95ae7717d) asks the compiler, and at 8ad55e82a it lists 210 places in ledger-core that add, subtract, multiply, negate or sum a Decimal outside the kernel: raw operators that panic on overflow, and checked_* calls that reach rust_decimal's methods (which round silently past 28 digits) instead of the kernel's. The outer crates, after K-U9: ledger-gui 123 (the viewer computes averages, shares and totals of its own in books.rs and the pages; 137 before K-U9), ledger-import 18 (was 22), ledger-mcp 19, ledger-package 13, ledger-store 8, ledger-config 2, and none in ledger-cli, ledger-host, ledger-reader and ledger-vault. Closes with:
    • K-U11a, ledger-core: every site routed through the kernel (branch k-u11a; a script driven by the compiler's own spans, so no site is hand-copied). 199 of the 210 are done and committed there; the last 11 wait for K-U10a's exact operations. Mine.
    • K-U12, the outer crates. Worker or script, decided on the counts.
    • The script in just check at zero, so the count cannot rise again.
  2. Decimal sums and products round silently (K-U10a, in flight). Decimal::checked_add and checked_mul return a rounded answer when the exact one needs more than 28 digits. The kernel's Amount for Decimal should refuse instead. Independent review before it merges.
  3. An exact tie between shares goes where Decimal's 28th digit sends it (K-U10b, written and measured). The docs and bookspec's Lean say a tie goes to the earlier part; the engine ranked rounded remainders, so 20.00 by 4/1/1 came out 13.33 / 3.34 / 3.33. The owner decided on 2026-11-09 (D-76): exact ranking from now on (13.34 / 3.33 / 3.33). No golden moves, two-member books cannot differ, at most one cent per part. Merges after K-U10a (the same file).
  4. The audit's close check (V-D3, merged abafa94a5, 09a8707e2): it checked a JPY close at a cent, and its pre-true-up bound ignored the member count. Left open: the bound covers one legacy close, not several in one set of books.
  5. Rounding for display was done outside the kernel in ledger-gui, ledger-import and ledger-package, each with its own copy, and the viewer's percentages were f64. Done (K-U9, merged 0e9990f11): one round_display through the kernel, percentages by the kernel's percent_of. A change against a zero or negative base now shows no percentage.
  6. Recorded regression seeds that no test read. Fixed (129a90dcf): the failures are replayed again, and a seed file no test reads fails the build.
  7. overflow-checks was off in the release profile. An integer overflow in the shipped program wrapped silently where the test build would panic. Fixed (724edc61f), checked with a release build.
  8. The live books are not on documents_v2 or schedule_minor_unit. Two format upgrades the code supports and the live file has not taken. Owner (exact commands when he is ready).
  9. P12 step 2 has never run on today's code: the overnight mutation and fuzz run (just p12-night). Owner, overnight.

P2: the gates themselves

  1. CI's check took 72 minutes, one test binary at a time. Done (5544a3e66): five parts on five runners from one definition in the justfile, and the lint part fails if CI's list is not the justfile's. Not yet seen on CI: the first push shows it.
  2. just prove had one 1800 s cap for all 97 Kani harnesses. On a loaded machine it was cut off with no failure named. Done (fe3b10e2d): a cap per harness, and a run that does not verify everything lists what failed, what ran past its cap and what never finished.
  3. There was no supply-chain gate. Done: just deny (cargo-deny, deny.toml) in the lint part of just check and in the weekly run. Its first run found 23 known vulnerabilities in the lock file, one unsound crate, two yanked and nine unmaintained. Closed by upgrades (quick-xml 0.42, rusqlite 0.41, rust_xlsxwriter 0.102, rmcp 3.9, rustls, tokio, zstd, pulldown-cmark); two quick-xml advisories remain for the copy typst brings, which parses nothing from outside, and are written down in deny.toml. The upgrade also found a wrong answer: the XLSX reader dropped every &amp; and &#...; in a cell (AT&amp;T read as ATT), since the parser reports a reference as its own event and the reader took only the text. Fixed with a test. The licence list allows two that are not plain permissive: MPL-2.0 (one crate, unchanged) and CDLA-Permissive-2.0 (Mozilla's root certificates). It allows no font licence: egui's default font set carried Ubuntu Light under the Ubuntu Font Licence, which Debian and Fedora class as non-free, so that set is switched off and the viewer names its own fonts (Inter, Hack, Noto, two symbol fonts; OFL 1.1, MIT and Bitstream Vera), each beside its licence (crates/ledger-gui/assets/fonts/README.md).
  4. The packages carry no third-party licence notices. The .deb, the .rpm, the AUR tarball and the installers hold the program and little else. The fonts (OFL, MIT, Bitstream Vera) and the MIT, Apache and BSD crates all ask that their notice travel with a binary. Nothing has been released yet, so nothing is out of terms, but this closes before the first release run: one generated notices text (cargo-about for the crates, the font licences beside it), compiled into the program (wanderbooks licenses; the viewer has no About page yet), with a check in the lint part that it is current. Worker, well specified.
  5. The Lean model of the books covers 14 steps; the Rust Ledger has 119 commands, and no list mapped one to the other, so "every reachable state" covered less than it read. The inventory is done (docs/command-steps.md, kept whole by tests/command_steps.rs): 71 commands are the record step, 11 are one step, 19 are several steps run as one, 17 are replay doors and one is no step. What it found, each closing with Lean in bookspec (hard implementation, then the pin moves):
    • renumber_account is no step of the model. A renumber step: codes stay distinct, and every balance is the old one under the new code.
    • Four doors apply a change without a check the model's step requires (create_entry, replay_generate_recurring, replay_create_period, replay_reverse_entry), so books replayed from an old journal can be outside Reachable. The laws that rest on distinct codes, acceptable entries and known accounts still hold, by reading the proofs; a ReplayStep relation and its theorem would make that proved.
    • The registers (fixed assets, schedules, recurring entries, payroll runs) have proved arithmetic and no step model of how they change.
    • Nothing proves a Rust command is its Lean step. Two tests check it: bookspec's examples and the differential test (lean_model.rs), which does not reach a standalone period, a close with explicit targets, a draft left unposted or an account added late. Extend it.
  6. Coverage is measured only for ledger-core and ledger-store.
  7. Three allocation preludes are still outside the kernel (try_allocate, allocate_cumulative, tax_capital::split): they prepare the remainders the kernel then apportions. Each needs a Kani harness, a Lean theorem and a bridge property. Hard implementation.

P3: drift and debt

  • plan/roadmap.md Phase 3 and a few other pages describe an older state.
  • bookspec: 39 CHOICE options and 2 rules (BS-asset-9, BS-partner-16) without examples; the second implementation (X-O, hledger), X-K2 and L-G4 are not started.
  • ledger.rs is past 9,000 lines; reports.rs, parties.rs and cashflow.rs are large too. Not a correctness problem.

The owner's alone

Mac, Windows and clean-Linux trials; the first release run; the icon; signing (D-64); the re-audit (P10); Q-6 before P9b.

Order of work

  1. Land what is in flight: V-D3 (done), K-U9 (done), K-U10a (reviewed), K-U10b (the owner answered: exact; after K-U10a).
  2. K-U11a on top of them, then K-U12, then the detector in just check.
  3. overflow-checks, the CI split, just prove's cap, cargo-deny (all four done).
  4. One gate at the end (just check, just prove), one push, four gates read.
  5. The steps the inventory found missing (bookspec), the allocation preludes, then bookspec's examples and second implementation.