The K-U1 review: foreign 0.99999999999999999999999999 (26 places) x rate
0.005 into USD booked 0.01, though the exact product
0.00499999999999999999999999995 is under half a cent. Decimal::checked_mul
rounds a product finer than 28 places to 28 before fx_booked rounds it to
the cent: two roundings, one cent off. A ledger in one money books the
exact product rounded once (BS-ledger-1, BS-ledger-14).
Owner decision D-75 (2026-11-08): a new line's foreign amount and its rate
take at most MAX_LINE_SCALE (10) decimal places each, as a base amount does
(B-28), so their product has at most 20 places, under Decimal's 28.
Ledger::add_line_fx refuses past it with ValueOutOfRange ("foreign amount
..." / "FX rate ..."; the variant for an amount that is not a journal
line's), trailing zeros not counted, before computing, and never on replay
(is_replaying; replay_add_line_fx books a journal's older line verbatim).
Tests: 11-place foreign amount and rate refused; ten and ten accepted with
hand-checked books; the review's input refused, not mis-booked; trailing
zeros are not places; replay keeps a 26-place foreign line in core, and a
store journal holding one opens with its figures.
fx_booked's spec block states the precondition (scales within 10 each, and
the mantissas' product within Decimal's 96 bits) and that the result is
exact under it, and documents Decimal::checked_mul's behaviours outside it
(rounding past scale 28 and past 96 bits; 1e-28 x 1e-28 underflowing to
zero); invariant 1 now says None when T's checked_mul cannot hold the
product. The bridge covers every D-75 scale (0..=10 each, products to 20
places) against an independent exact reference, shows 26 places is where the
reference and Decimal part (and the engine refuses), and pins an open edge
this bridge found: ten places each still allow a 20-place product past
~7.9e8 that outgrows 96 bits (1050000010.0000000001 x 9.9999999999 books
10500000099.90, exact 10500000099.89). B-28 and B-3 claims record the
enforcement and checks.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The engine now refuses a reversal dated before its original (D-73), so
the gap the Lean-model test counted (the engine accepting a backdated
plain reversal the model refuses) is zero: the recipe sets
WANDERBOOKS_D73_LANDED, making any return of it a failure, and the
test's error mapping follows the variant's new name
(ReversalBeforeOriginal). 256 sequences, 2,204 commands: 0 mismatched,
0 gaps. Also formats the adapter's PICKS list, left unformatted by the
S-C7 renumbering.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claims/ledger.md conflicted with the reduced B-9 section: the D-73 pick,
Enforced and Checked lines sit above its product rules; the check's
place corrected (after the schedule double-post check, not ahead of it)
and the citation completed (BS-ledger-16, the Lean model since L-G1).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cargo.toml: both the dev-dependencies for decimal_exact and the bookspec
comment's new path kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: the file's checked_add property stays at the books' sums, so it
couldn't see K-U4's finding that MAX + 0.4 gives Some(MAX); the header
now says where the checks are exact and a test pins the edge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
periods.rs conflicted with K-U2: the frozen replay rules delegate to
K-U4's checked twins, whose rounding now goes through K-U2's
round_places (so every rounding stays in the kernel); no figure changes.
The K-U4 note gains the review's list of bounded raw sums left, and the
caveat that the twin test checks delegation (the review's independent
20,000-case comparison found the twins identical).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookspec splits every CHOICE embedded in another rule into its own
record (S-C7), so an engine declares its pick for each by id; wanderbooks
declares its 65 picks (one list in the adapter, checked against each
record's options and the claims files). Lean builds and audits; adapter
and package tests pass on the new rev.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A correction comes after what it corrects (Pacioli ch. 31; B-9). Until now
only document reversals and depreciation/schedule runs were held to it; a
plain posted entry could be reversed with an earlier date, leaving the
books carrying the opposite of an entry that doesn't exist yet at the
reversal's date. The owner's decision D-73 (2026-11-08) makes it one rule
for every kind of entry; bookspec BS-ledger-5 states it.
- Ledger::check_reversal refuses date < original.date() with one error,
ReversalBeforeOriginal (it replaces DocumentReversalBeforeOriginal,
which was the document-only wording). Same-day reversals are allowed.
- Not on replay (B-28): the check sits behind is_replaying(), so a journal
an earlier version wrote, holding a reversal dated before its original,
reopens with the same figures.
- The store's own date check for depreciation runs and schedule months
(InvalidSchedule / AssetEntryIrreversible wording) was the same rule
for a narrower case; it is removed so there is one variant for all.
Store::check_reverse_entry, books.reverse_entry (preview and post), and
the document voids all reach the refusal through check_reversal; the
only construction path for a reversal is reverse_entry_steps, which
calls it first.
Tests: store reversal_dates.rs (plain entry refused before it, nothing
journaled, same day and later taken; a journal with an earlier-dated
reversal written the old way opens with the same figures); ledger-cli
spec_mcp (preview, unconfirmed and confirmed post all refuse alike).
Existing tests changed: store assets.rs (three expectations move to the
new variant); core spec_asset_basis.rs (it backdated a reversal on
purpose to check the trial balance carries -100.00 between the dates; it
now replays one, as an old journal would); model.rs (the model oracle's
`reverse` requires the date, as the Lean/bookspec rule does); bookspec
common.rs (the pinned depreciation example words this refusal
"entry_irreversible"); spec_documents.rs (variant rename).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add the seven older CHOICE records (with a B number) that carried no declared pick in the adapter, taking each option from its record's options and the claims file's existing Pick line for its B section:
- BS-arap-2 lines-that-stand, BS-arap-5 direct-write-off, BS-asset-3 tag-and-never-reuse, BS-ledger-6 reversible-once, BS-ledger-9 facts-in-the-books, BS-ledger-10 label-only, BS-statement-5 project-is-a-class
- PICKS in crates/ledger-core/tests/bookspec/engine.rs gains all seven; each claims file gains a '**Pick (BS-...):**' line beside its B section's Pick
- Widen rules_md.rs's pick check from b == 0 records to every non-retired CHOICE record wanderbooks claims, so no CHOICE can go undeclared again
Co-Authored-By: Muse Wonder 1.0
docs/proofs/k-u4.md: the six harnesses with bounds and times, the Lean
counterparts (Basic.net_append is total_append for the signed sum; no new
law), the bridge, the sites replaced with file:line, the sites left raw
because their signatures are infallible, the regression tests, and two
findings: Decimal's checked_add rounds dust within a unit of Decimal::MAX,
and the audit's reachability claims for section 2.1 were overstated.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Four Kani harnesses on i64 with fixed steps (a symbolic step is
intractable for CBMC's division, as K-U2 found; written down in
docs/proofs/k-u1.md): whole unit, within half a unit with tie covers,
positive for positive, and overflow/non-positive rate refused. The
bridge checks i64 against Decimal and Decimal against an independent
i128 exact-product reference at 0, 2 and 3 minor units (JPY, USD,
KWD), with Decimal::MAX, scale 28, and both-sign tie edges. The law
itself is proved in bookspec's Lean (Fx.booked_whole/near/pos, law
41) on the k-u1 branch there.
Co-Authored-By: Muse Wonder 1.0
The one FX conversion that books money (add_line_fx: foreign x rate,
rounded once to the base currency's minor unit, half away from zero,
B-3 / BS-ledger-1 and its CHOICE BS-ledger-14) was inline in ledger.rs.
It now lives in kernel/fx.rs as fx_booked<T: Amount> (exact checked
product, one round_step; None on a non-positive rate or overflow) with
fx_booked_minor as its Decimal/currency spelling, which also keeps the
pre-kernel scale and books the exact product for a currency with no
minor unit. add_line_fx keeps its own error variants and refusals, so
behaviour is identical for every input; every test and golden passes
unchanged. Grep found no other FX conversion site: set/get_fx_rate
only record a rate, the store delegates to the core, and replay books
a recorded amount verbatim.
Co-Authored-By: Muse Wonder 1.0
docs/verification.md proves the accounting laws of a model of the
ledger (bookspec's Bookspec.Step, run by Bookspec.Exec.step); that the
model is the engine was checked by review. This makes it a machine check.
tests/bookspec/lean_model.rs generates random command sequences (entries
balanced or not, with zero, negative, finer-than-a-cent and unknown-account
lines; invoices; reversals of anything posted, twice, of a closing entry,
backdated; closes to retained earnings over nested, disjoint, partly
overlapping, inverted, empty and out-of-order periods), runs each through
the Rust Ledger, writes it as a bookspec example whose expected values are
the engine's own answers, and has `lake exe bookspec-check` (the pinned
bookspec, built in a copy under target/) check every refusal, the trial
balance after each event, and at the end the trial balance, balances, P&L
and each posted entry's lines. All cases of a run go to one directory and
one lake call; a failure is shrunk (rounds of single-event removal, one
lake call each) and printed with both answers. `just lean-model [cases]`
runs it with WANDERBOOKS_REQUIRE_LEAN=1; without lake it skips unless that
is set.
Refusal words the checker does not list are compared through a probe (the
model's own word is read from its mismatch), so every refusal is checked,
not skipped; the one word the model does not have (the control guard) is
an explicit allow-listed skip. The D-73 gap (a backdated plain reversal the
engine still accepts and the model refuses) is rolled back and counted.
Findings, all of word only (both sides refuse, the books agree): the order
of checks when a command fails two. Allow-listed in KNOWN_WORD_DIFFERENCES,
pinned by a test that fails when one side changes, and by #[ignore]d d_*
tests that assert agreement: reversing a closing entry or an already
reversed entry on a closed day, an unknown account beside another fault, a
zero line beside a negative one, a close inside a closed period (the
model's own word closed_period_contains_end), a finer amount on a closed
day (the example reader's order). Nothing in the engine or the model is
changed. docs/verification.md's "Be precise about the claims" says what is
now checked and what stays by review.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bookspec's Lean now proves round_step's law (law 40) for every mode at
any step: multiple, near, ties, the directed modes' bounds, sign,
idempotent, odd, scale (K-U2). With the K-U2 kernel merge above: 1,155
ledger-core and package tests pass, and just prove (Kani 59+ fast
harnesses, Lean 151 audited) is green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BS-format-2 item 7: QuickBooks Desktop records at most one A/R or A/P
account in a transaction (Intuit's own warning, sources/intuit-iif.md
and rules/format/BS-format-2.toml), so an entry with lines on two
receivable accounts, two payable accounts, or one of each cannot be
written as one IIF transaction. journal_to_iif used to write it and
merely list it in Iif::receivable_payable.
Now the export collects every entry whose lines touch more than one
distinct A/R/A/P account and returns
IifError::SeveralReceivablePayableAccounts, naming the entries and
saying why and what to do (reverse and post as two entries through a
clearing account; splitting one would change what it says). It never
splits an entry itself. ledger_package::export_iif and build_package
pass the refusal through, so books.export and books.export_cpa_package
return it before a file is handed over.
The README test's entry on both controls moved to its own refusal test;
the valid books it covers (one A/R entry, one A/P entry) are unchanged,
as are every IIF golden and every test of the file's bytes.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
Review found two holes in K-U2's evidence.
1. The spec block's invariants 3, 4 and 6 (toward zero: |r| <= |x| and
|r - x| < step; toward negative infinity: r <= x < r + step; no mode
flips the sign) had no proof: Kani checked those modes only at exact
ties. Three harnesses now assert them for every amount over the fixed
steps (round_step_toward_zero_bounds, round_step_toward_neg_inf_is_floor,
round_step_sign_preserved), each with covers for a non-tie and a negative
non-multiple; bookspec's Lean carries the same laws for any step. With
TowardZero mutated to round 7 at step 10 up to 10, the first harness
fails ("magnitude never grows"); reverted.
2. The bridge never ran checked_round_to_step's finer-step branch (step
with more places than the amount and a mantissa above one). Three
properties compare the kernel with a second, independent i128 reference
that takes any step (mantissa 1..1000 at scales 0..10, amounts at scales
0..28, small amounts, and constructed exact ties). Replacing
.checked_add(remainder / b) with .checked_add(0) in the digit loop fails
all three; reverted.
docs/proofs/k-u2.md also states the one exception to "no result changes":
a negative-zero input (round_dp keeps -0.00; round_places gives 0.00; no
call site can produce one).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Bookspect S-C7 split the CHOICEs embedded in these areas' AUTHORITY and CONVENTION rules into their own records, so an engine declares its pick by rule id. Each parent B-n section in docs/spec/claims/<area>.md now carries a **Pick (BS-<area>-<n>):** line naming wanderbooks' option with who decided it and when (the parents' **bookspec:** lines stand), and the bookspec adapter's claims() declares the same twenty picks with Claims::with_choice. The rules_md test now reads a born-after-B-n rule (b = 0 in the catalogue) by its **Pick (BS-...):** line instead of a B-n index row it cannot have.
No engine behaviour changes: every pick is the decision the claims already recorded in prose (for example check-when-line-added, D-73's on-or-after-the-original, D-67's round-once-on-the-total, D-72's minor-unit-for-new-schedules). Verified against the s-c7a bookspec branch with the documented patch override (not committed): cargo test -p ledger-core --test bookspec, 53 passed.
Co-Authored-By: Muse Wonder 1.0
bookspec split the CHOICEs embedded in BS-partner-1..4, BS-asset-1, BS-asset-4,
BS-1099-1 and BS-format-2 into records of their own (S-C7b). Wanderbooks'
decisions are unchanged; each is now recorded against the id an engine
declares it by:
- partner: BS-partner-5 largest-remainder-first-listed (owner, 2026-10-13),
-6 cumulative-from-first-close (D-10, 2026-10-16), -7 running-split (D-38,
2026-10-20), -8 outside-the-books and -9 tin-facts-then-w9 (2026-10-15),
-10..-13 money, entry flow, books' carrying amount, labelled basis
(2026-10-15, 2026-10-20), -14 tax-basis-beside-book (D-41), -15
running-cumulative (D-38's rule, 2026-10-22)
- asset: BS-asset-5 straight-line-by-days, -6 lesser-of-value-and-basis, -7
books-recorded-amounts, -8 register-carries-tax-figures
- 1099: BS-1099-2 refuse-an-unknown-year, -3 presumed-a-check-ach-or-transfer,
-4 dated-by-the-payments-date
- format: BS-format-3..7 (D-36, 2026-10-20)
Each is a `**Pick (BS-..):**` line in docs/spec/claims/<area>.md and a
`with_choice` in the adapter's claims(). The rules_md test no longer expects a
B-n row for a rule born without one (a split-out CHOICE has none): it requires
the pick line, that the pick is one of the record's options, and that the
adapter declares the same option.
The pin is not moved here: this needs bookspec's s-c7b to be merged and the
pin moved to it. Verified with ledger-core's bookspec test patched to the
s-c7b checker and runner (53 passed).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Kani checks the primitive on i64 over fixed steps: a whole multiple, the
half modes nearest, each mode's tie, idempotence, no negative zero, and a
non-positive step refused. A symbolic divisor did not finish in 30 minutes
(CBMC's bit-blasted division), so the steps are fixed constants; the
bridge's exact-reference property carries the laws to every Decimal step.
The bridge agrees i64 with Decimal, checks Decimal against an independent
i128 reference over amounts of up to ten places and steps down to 1e-4,
checks round_places against round_dp_with_strategy to the character, and
has the edge table (.5, -.5, 0.004, 1.005, -1.005, scale 28, Decimal::MAX).
docs/proofs/k-u2.md records the harnesses, bounds, times, bridge properties
and the bookspec Lean theorem names.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
Every money round_dp*/rescale in ledger-core now goes through
kernel::round_step: amount to a whole multiple of a step, in a named mode
(half away, half even, toward zero, toward negative infinity), exact
integer arithmetic on Decimal mantissas and scales, None instead of a
panic, no negative zero. The call sites use round_places, which reproduces
Decimal::round_dp_with_strategy exactly (value, scale and its early
return), and add_line_fx uses round_minor for the base currency's smallest
unit. This is a refactor: every site produces exactly what it produced
before, so no golden changes.
The schedules' monthly-even plan keeps its two-place cent rule: moving it
to the currency's minor unit is K-U5's decision (D-72), not this
behaviour-preserving unit. The remaining rescales (money.rs's display
padding, the contribution margin's one place) are formatting, not
rounding, and stay.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
bookspec now states the format rules too (S-C6), so every accounting
rule is complete as a record, and the Lean model runs its examples
(L-G3: 8 whole, agreeing with the Rust derivation on all 25 figures both
answer). Lean builds and audits 151; adapter and package tests pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookspec now states the A/R and A/P rules and the draft rule completely
(S-C5) and is self-contained (S-K1): the GnuCash oracle's container
lives there and just oracle builds it from this pin. Lean builds and
audits 151; adapter 53, package 29 and the GnuCash oracle pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookspec now owns the oracle (gnucash/oracle/, image
bookspec-gnucash-oracle; unit S-K1). just oracle resolves the pinned
bookspec rev from ledger-core's Cargo.toml, fetches it, and builds
bookspec's image from that checkout: one source of truth, no copy here.
Until the batch pin bump lands a rev that contains gnucash/oracle, the
recipe fails loudly saying so. oracle_gnucash.rs uses the new image name.
Co-Authored-By: Muse Wonder 1.0
bookspec now states the entry, ledger, statement, period, prepaid,
revenue, partner, asset and 1099 rules completely as records (P14 units
S-C1 to S-C4, each reviewed by a second model and fixed), with the
executable Lean model (L-G1) and the owner's D-73 reversal-date rule;
the matching wanderbooks claims files are reduced to wanderbooks' picks,
enforcement sites and WB product rules (merged above). All four pins
move together; Lean builds and audits 151, the adapter (53) and the
package (29) pass on the new rev.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The engine trusts Decimal for every money path, and docs/verification.md
said so without checking it: Kani cannot explore Decimal arithmetic, and
the bridge tests only tie the Decimal kernel to the i64 one. This adds a
property test that compares the operations the books use against
num-rational/num-bigint, an independent exact reference: checked_add and
checked_sub over signed line amounts (1e15 at up to ten places),
1,000-line sums, checked_mul while the true product fits 28 digits
(including the top of the line range and FX-style rates),
round_dp_with_strategy for every strategy the workspace uses at every
scale 0..=28, rescale's half-away rounding, normalize, comparison and
equality across scales (1.0 = 1.00), and from_str/to_string round trips
at every scale.
It also pins the one inexact edge: when a product's scale does not fit,
checked_mul rounds to 28 decimal places, ties to even, rather than
failing; None comes only when the integer part cannot fit. That case is
reachable through Ledger::add_line_fx, whose foreign amount and rate are
unbounded positive Decimals (the base amount is then rounded to the
currency's minor unit). No property failed: 256 cases by default,
PROPTEST_CASES=5000 passed, plus hand cases at 28-digit mantissas, scale
28 and negative ties.
The two dev-dependencies are test-only and already in the lockfile
(through proptest and the PDF stack); they are the exact reference the
whole check rests on.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
ledger-core/tests/exact_totals.rs: the engine's sum/add/sub helpers, arap's
document_total, audit::check_articulation (current_earnings + closed was a
raw + that panicked for a public caller's MAX figures) and the frozen
close splits' try_ twins refuse at Decimal::MAX with TooLargeToCompute,
and give the infallible rules' exact result for ordinary input.
ledger-store/tests/exact_totals.rs: an invoice or a bill of enormous
lines is refused and journals nothing. (A posted entry's lines are capped
when it posts, restored or new, so report sums over posted lines cannot
reach the edge; documents are the figures that can.)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The burn-and-runway card subtracted each month's out from in with a raw
- inside a map and summed raw; it totals with kernel::total_try and shows
a note when the figures are too large to compute. Display unchanged
otherwise.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
preview_lines_for (balance before + line), the disposal preview's debits,
the depreciation run's catch-up difference, the digest's account movement
and the payroll remittance total used raw + / - / .sum() on stored or
replayed figures; they now go through ledger_core::money's checked
helpers and return the tool's string error (TooLargeToCompute). Unchanged
for ordinary input.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The K-1 members' total row, the receipts index amount and the 1099
worksheet's payments text summed with a raw .sum(); they use
kernel::total_of and print 'too large to compute' if a sum is past exact
arithmetic (text::total_text), so an export of restored books never
crashes. Unchanged text for every ordinary input.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Store::create_invoice / create_bill summed their lines with a raw .sum()
before arap::document_total (which is checked) ran; a document restored
from its journal is bounded only by what the version that wrote it
checked (rules.md B-28), so two lines near Decimal::MAX panicked the sum.
They now call document_total (itself now kernel::total_of). The
remittance and disposal-run sums go through money::sum_exact_of and
refuse with TooLargeToCompute. No figure changes for any ordinary input.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A raw Decimal + / += / .sum() panics at Decimal::MAX, and a replayed
journal line is accepted of any size (rules.md B-28), so a total of
restored figures must be exact or refused (B-21), never a crash. The
reports (P&L, balance sheet, general ledger, members' equity, asset
register), K-1 lines, tax-basis wholes, payouts, the 1099 split, the
audit's articulation check, the members close split and arap's
document_total now sum with kernel::total / total_of / total_try and
add or subtract with checked arithmetic, refusing with TooLargeToCompute.
money::sum_exact* and add_exact/sub_exact are the engine's thin wrappers
over the kernel (no second copy of the sum). form1099::sum3 was a copy of
the kernel's sum and is now kernel::total.
periods::allocate and allocate_last_absorbs (frozen replay rules) keep
their signatures and results to the cent; each gains a try_ twin that
returns TooLargeToCompute where the raw amount * share used to panic, and
the ledger's close split calls the twins.
Behaviour for every ordinary input is unchanged: no figure moves, no test
or golden edited. Infallible public signatures (trial_balance,
ProfitAndLossStatement::net_income, tax book_net, project_entries,
cash-flow kinds, the Regime) keep their raw sums; making them fallible
would change ~100 callers and is a decision, not a refactor.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A raw Decimal + / += / .sum() panics at Decimal::MAX; a replayed journal
line is accepted 'of any size' (rules.md B-28) so a restored figure is the
realistic path to that edge, and amounts are exact (B-21): a total is the
exact sum or it is refused. kernel::total sums any figures, total_of a
mapped field, total_try a fallible mapping (a difference), each None on
overflow. The signed sum of (Side, amount) lines stays kernel::net/totals.
Kani (proofs/total.rs, fixed arrays): total_empty_is_zero, total_append,
total_is_sound (any i64), total_of_is_map_sum (= net), total_try_is_map_sum,
total_overflow_is_none, each with covers. Bridge (kernel_bridge/total.rs):
i64 vs Decimal on random runs, a Decimal edge table, and a canary for the
finding that rust_decimal rounds dust when a sum lands on Decimal::MAX.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The ten Lean files were code-identical to bookspec's (checked per file);
wanderbooks keeps a thin Wanderbooks.lean importing Bookspec and audits
the same 151 theorems. The Lean pin moves to 62c0bf26 at the merge,
the rev the Rust checker was pinned to after S-B (the new pin test
caught the difference), and lake-manifest.json is regenerated. Conflicts
with K-U0 and S-D0 resolved: the proofs/ path and the bookspec Lean path
both kept, L-F2's Deductible path fix applied to the claims file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The laws are proved once in bookspec (D-69), so the documents that said
"put the new theorem in `verify/lean`" or cited
`verify/lean/Wanderbooks/<File>.lean` now say otherwise:
- AGENTS.md's formal-methods bar: a new law is written in bookspec's
`lean/Bookspec/`; wanderbooks requires it and moves its pin (the lakefile,
the manifest, and the crates' Cargo.toml together; the pin test fails if
they drift). `Audit.lean` lists every theorem.
- docs/verification.md: the model and every cited Lean file are
`bookspec/lean/Bookspec/<File>.lean`; "Running it" says the dependency is
fetched and that all 151 theorems are audited.
- docs/testing.md and docs/spec/rules.md: the same paths, and the apportion
row records where its law moved.
- README's repo map and the two test comments that named the Lean peer.
No accounting behavior changes; only where the proofs and their names live.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
D-69 puts the accounting laws in one place: bookspec's Lean, namespace
`Bookspec`. L-F1 landed there every file of `verify/lean/Wanderbooks/`.
Before deleting the copies, each was checked: comments stripped, namespace
normalised, blank lines dropped, and diffed against its bookspec peer --
all ten are identical (Basic, Entry, Statements, Closing, Ledger,
Apportion, Parties, Prorate, Deductible, Documents). There is nothing
wanderbooks-only left to keep.
So `verify/lean/lakefile.toml` now `[[require]]`s bookspec as a git
dependency at 77e046334eea29e082b53bbe907017d9ffef5a0a -- the same rev
`crates/ledger-core/Cargo.toml` pins the Rust checker to -- with
`subDir = "lean"`. The generated `lake-manifest.json` is committed, because
Lake builds from it and it must not float.
`Wanderbooks.lean` is now a thin local target that imports `Bookspec`:
`lake build` builds and checks the whole law set, and the file says where
a law is edited and how wanderbooks picks it up (move the pin). The
duplicated modules and the `Wanderbooks/` directory are gone.
`Audit.lean` imports `Bookspec` and audits all 151 theorems (the 118
headline laws plus the 33 named laws in `Laws.lean` that cite them) --
the whole set bookspec itself audits. `just prove` still checks standard
axioms only; its summary now says "theorems", since the set is more than
headline ones.
The new `tests/bookspec/pin.rs` reads the rev out of the lakefile, the
manifest, and both crates' Cargo.toml, and fails unless all four name the
same repository at the same commit, and bookspec's `lean/` package. Without
it the Lean laws and the Rust checker could silently be different spec
versions.
Verified: `lake build` from a clean `.lake` (fetches and builds in 7 s);
`just prove` 871 s (Kani 53 harnesses, then 151 theorems, standard axioms
only); `cargo test -p ledger-core --test bookspec pin`; `cargo fmt --check`;
`cargo clippy -p ledger-core --tests -D warnings`.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
Conflicts with X-H0 and S-D0 resolved: both new paths kept
(tests/bookspec/, tests/kernel_bridge/, src/proofs/); K-U0's two path
fixes in rules.md applied to the claims file the rule moved to.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bookspec now carries the 21 authorities its rules cite (IRS texts,
Pacioli, ISO 4217 facts, FASB and Intuit notes, each with an accurate
licence line) and checks every one of its 40 citations verbatim itself
(P14 unit S-B, reviewed, licence fixes applied). Adapter 52 and package
29 tests pass on the new rev.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kernel.rs is now kernel/: mod.rs keeps the laws and re-exports entries
(the old file, unchanged) plus one file per kernel-sweep unit (U1 fx, U2
round, U3 allocate, U4 total, U5 schedule, U6 ratio, U7 payroll, U8
control). proofs.rs is proofs/: mod.rs holds the original 63 harnesses and
each unit gets a file of its own. tests/kernel_bridge.rs is now
tests/kernel_bridge/main.rs plus one file per unit; Cargo still builds the
single test target named kernel_bridge.
`_kani` now scans proofs/mod.rs and proofs/*.rs and passes the fully
qualified name each file gives its harness (Kani's --exact matches only a
fully qualified name), so a harness resolves wherever it lives. It fails
when kani_slow names no harness, or when two harnesses share a name and
would make the slow list ambiguous; `just prove-list` prints every harness
with its module path and set, showing the slow list resolved without
running it.
Nothing moves in the books: the same 53 fast Kani harnesses and 118 Lean
theorems verify, and the same 1096 tests pass (27 in the bridge).
Docs: verification.md gains the kernel-sweep policy (each unit writes
docs/proofs/<unit>.md; the integrator folds the notes into
verification.md and Audit.lean in one edit per batch), and the file
references in AGENTS.md, testing.md, architecture.md, oracle.md and
spec/rules.md follow the new paths.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>