Commit Graph
862 Commits
Author SHA1 Message Date
swaitsandClaude Sonnet 5.5 7aa0cc68f3 refactor(store): invoice, bill, payroll-remit and disposal totals use the kernel's checked sum
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>
2026-11-08 12:23:11 -07:00
swaitsandClaude Opus 5.5 8bae4e41a0 merge: partner claims reduced (S-C3; branch t3/partner-area-s-c3, cba264d7; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:21:21 -07:00
swaitsandClaude Opus 5.5 7a6cc9cbd6 merge: statement, period, prepaid and revenue claims reduced (S-C2; branch t3/s-c2-statement-period-revenue, 1349bb47; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:21:21 -07:00
swaitsandClaude Sonnet 5.5 3376c3d549 refactor(core): every report and book total goes through the kernel's checked sum
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>
2026-11-08 12:17:58 -07:00
swaitsandDeepSeek V4.1 Flash ce02a44bb0 docs(spec): 1099 claims reduced to wanderbooks' picks and product rules
B-19's accounting text (thresholds, payor, card and network exclusion, the
bucket table, decisions and dates, the status function, shares) now lives
in bookspec's `rules/1099/`; this file keeps the four embedded choices'
picks, the enforced and checked evidence, and the product rules.

The picks: an unknown year is refused, never guessed (the owner,
2026-10-13); a cash-account payment with no recorded method is presumed a
check, ACH or transfer (D-40, 2026-10-20); a shared entry counts only the
payee's share (2026-10-15); decisions are dated and a payment takes the
one in force on its reversal chain's first date (D-40).

Product rules: WB-1099-1 (the untagged-entry note), WB-1099-2 (the dated
registry of known threshold years and its staleness alarm), WB-1099-3 (the
recording of payment methods, entry tags, decisions and their sources),
WB-1099-4 (the card-account fallback and the card charge listed, not
dropped).

The Enforced and Checked lists carry over the engine's sites and the
buckets' 16-case check, unchanged.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 12:17:48 -07:00
swaitsandDeepSeek V4.1 Flash 6f19d4018c docs(spec): asset claims reduced to wanderbooks' picks and product rules
The accounting text of B-15, B-22, B-24 and B-25 now lives in bookspec's
records (`rules/asset/`); this file keeps what is wanderbooks': the option
each CHOICE picks, the Enforced and Checked evidence, and the product
rules.

Picks: B-15's straight-line-by-days (the owner, 2026-10-13, the arithmetic
settled from ASC 360-10-35-4 on 2026-10-20); B-24's tag-and-never-reuse
(the owner, 2026-10-15); B-25's register-carries-tax-figures and the D-41
options (lesser-of for personal use, the traditional section 704(c)
method, the books' recorded contribution values).

Product rules: WB-asset-1 (a run's and a disposal's bounds are the
commands', replay accepts what earlier versions wrote), WB-asset-2 (the
store and the viewer read every run the books recorded), WB-asset-3 (the
tag and serial-number events and the label sheet), WB-asset-4 (a legacy
basis record reads its book cost; Needs attention asks for the value),
WB-asset-5 (the tools never assume a contributed property's value).

B-22 is procedural: the bookkeeper is bound, the engine is not, so it
claims no engine behaviour and has no product rule.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 12:17:48 -07:00
swaitsandClaude Sonnet 5.5 cba264d717 docs(spec): partner claims, review fixes
WB-partner-1 now carries what is engine history rather than law: the
true-up bound for closes made under the earlier journaled rules (under
one unit per break in a "cumulative" run and per "largest_remainder"
close; a last-absorbs close's half unit each, a unit with three members)
and the two-unit bound when replaying books written before whole minor
units were required (B-3, BS-ledger-1).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 12:17:44 -07:00
swaitsandDeepSeek V4.1 Flash 1349bb478b docs(spec): claims restore enforcement sites and product rules (review)
B-14 (statement):
- The Pick records the kind order the record now restores: within a
  section, the rest of its kinds, then interest received, then interest
  paid (CONVENTION, as the engine splits it).
- Enforced restores `Ledger::reversal_chain`, rule 6's chains.
- WB-statement-8 is new: the statement's label strings and the
  reconciliation's grouping are wanderbooks product, not accounting
  ("Reversal of #N — …", "Reinstatement of #A (reverses #B)", "Proceeds
  from borrowing — …", "Contributions from members — …", "(Gain) loss and
  other noncash changes in investing assets", "Depreciation", "Noncash:
  through <account>", "Other noncash items", "Increase in"/"Decrease in").

B-37 (statement):
- WB-statement-6 says "a decision" again, not "a choice": a decision is a
  record kind the books have.
- WB-statement-9 is new: a document's entry posts one line per project in
  the order each is first named, the untagged sum as one line, a document
  naming none posting exactly the one line documents always posted; its
  journal events (`entry.line_class_set`, feature
  `document_line_projects`) are recorded.

B-11 (period):
- Enforced says INVARIANT 5 (a close with nothing to close posts no entry
  and still closes, D-73); Checked adds Lean `closingEntry_net` and
  `a_close_with_nothing_to_close_posts_no_entry`, the rule the record now
  states.

B-12 (period): Enforced restores `Ledger::create_period`
(`PeriodsOverlap`); Checked restores
`periods_nest_but_never_partially_overlap` and `periods_nest`.

B-30 (period): Enforced restores `InvalidDateRange` and
`StartAfterToday`, with what each refuses.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 12:17:01 -07:00
swaitsandClaude Opus 5.5 7e855f16cc merge: entry and ledger claims reduced to wanderbooks' picks and product rules (S-C1; branch t3/s-c1-entry-ledger-rules, 738995a0; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:10:06 -07:00
swaitsandClaude Opus 5.5 c5fc16cad6 docs(plan): D-73, every reversal is dated on or after its original
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:07:04 -07:00
swaitsandMuse Wonder 1.0 738995a0bc fix(spec): entry and ledger records, review fixes
- B-20 (BS-ledger-7): claims Pick now names CHOICE D-47, a reversal's evidence is its original's (2026-10-26), matching the bookspec status_note

Co-Authored-By: Muse Wonder 1.0
2026-11-08 12:06:55 -07:00
swaitsandMuse Wonder 1.0 40e433104c docs(spec): partner claims reduced to wanderbooks' picks and product rules
Each B-13/B-26/B-35/B-36 section keeps its heading, bookspec id, Claims, Pick, Enforced and Checked; the accounting text moved to bookspec BS-partner-1..4. What stayed is numbered WB-partner-1..14: the members_cumulative journal feature and legacy-close replay, the close tool and members pages, the TIN vault, TIN masking and text scanning, project-text TIN rules, TIN-bearing downloads, the TIN-file registry and its two-candidate probe bound, money/creditor/member settings and journaled derived splits, labelled party/1099 tool presentation, and the CPA package's K-1 tax-basis file.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 12:06:52 -07:00
swaitsandClaude Sonnet 5.5 b3d504067f feat(kernel): total, total_of and total_try, the exact checked sum with Kani proofs and a bridge
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>
2026-11-08 11:59:32 -07:00
swaitsandClaude Sonnet 5.5 1a61472f7b docs(spec): ledger claims reduced to wanderbooks' picks and product rules
B-3, B-4, B-5, B-8, B-9, B-10, B-20, B-23, B-29, B-31, B-32, B-44 and
B-45 keep their heading, the bookspec id, Claims, Pick, Enforced and
Checked; the accounting text lives in bookspec's BS-ledger-1..13 (branch
s-c1, 461a440). The owner's picks are recorded per rule (minor-unit
booking, a child's type, reversible once, role assignment journaled,
facts in the books, label-only rename, warn by default and D-67's one
rounding). Product rules WB-ledger-1..16: the hash-chained journal; the
role list, default codes and refusal wording; the journal events, TIN
guard, settings adoption, newer keys, posting-template slots and approval
rules of B-29; the account.renamed event and the by-name picks of B-31;
the tax-category policy, Needs attention and control-role categories of
B-32; and the full text of B-44 and B-45, whose bookspec ids are retired
(D-71). B-20 is claimed partly: the receipt policy lives in the tool
layer, not the engine.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 11:53:41 -07:00
swaitsandClaude Sonnet 5.5 edb1d6baf3 docs(spec): entry claims reduced to wanderbooks' picks and product rules
B-1, B-2, B-21 and B-28 keep their heading, the bookspec id, Claims,
Pick, Enforced and Checked; their accounting text now lives in bookspec's
BS-entry-1..4 (branch s-c1, a00e968). B-1's pick is the owner's
2026-10-13 choice to check a line's account when the line is added;
B-28's pick carries the 1,000-draft recurring bound and the P0 review
provenance. The wanderbooks-only parts of B-28 become WB-entry-1 (replay
accepts what an earlier version accepted, with the command/replay
function pairs), WB-entry-2 (the full-TIN detector's replay), WB-entry-3
(the earlier version's projection files stay untouched) and WB-entry-4
(derived figures refuse, the server stays up). B-43 is unit S-C5's and
is untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 11:53:41 -07:00
swaitsandClaude Opus 5.5 3cd251255d docs(plan): S-C7, embedded CHOICEs become their own records
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:47:03 -07:00
swaitsandMuse Wonder 1.0 73010c4acb docs(spec): revenue claims reduced to wanderbooks' picks and product rules
B-17's accounting text moved to bookspec (BS-revenue-1). What stays:
the Enforced/Checked evidence and WB-revenue-1, the
books.record_payout tool surface.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 11:45:32 -07:00
swaitsandMuse Wonder 1.0 fd1c4ae018 docs(spec): prepaid claims reduced to wanderbooks' picks and product rules
B-16's accounting text moved to bookspec (BS-prepaid-1). What stays:
the daily pick (D-11/D-37), the equal-months-from-the-first pick
(D-37), the minor-unit rounding pick for new monthly-even schedules
(D-72), Enforced/Checked evidence, and WB-prepaid-1..2: the
books.schedule_convention setting and D-72's versioning (schedules
written before the change replay the cent rule; the engine change is
unit K-U5's).

Co-Authored-By: Muse Wonder 1.0
2026-11-08 11:45:32 -07:00
swaitsandMuse Wonder 1.0 3344c9cf60 docs(spec): period claims reduced to wanderbooks' picks and product rules
B-11, B-12 and B-30's accounting text moved to bookspec
(BS-period-1..3). What stays: the nesting pick (2026-10-13), the
fiscal-year-to-date default pick (2026-10-20), Enforced/Checked
evidence, and WB-period-1..4: refused commands never reach the journal,
the surfaces the one default binds, the package and viewer presets
that do not follow the default, and the surfaces with no default.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 11:45:32 -07:00
swaitsandMuse Wonder 1.0 79291c6927 docs(spec): statement claims reduced to wanderbooks' picks and product rules
The accounting text of B-6, B-7, B-14, B-33 and B-37 moved to bookspec
(BS-statement-1..5). What stays: B-14's picks (direct method, the
operating/investing/financing allocation order, constructive on-behalf
cash per D-42, the government split rounding, payroll's class), B-33's
pick (the 1099 worksheet stops at as_of, D-36) and B-37's picks
(project-is-a-class; document lines name one project or none, D-43),
each rule's Enforced/Checked evidence, and WB-statement-1..7: the
account designation settings and role refusal, the statement warnings
and printed layout, rule 11's bookkeeping limits, the CPA package, the
project facts, the link and notice behaviour, and the snapshot
presentation.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 11:45:32 -07:00
swaitsandClaude Opus 5.5 05702b5a34 merge: verify/lean requires bookspec's Lean; the laws live once (L-F2; branch t3/lean-laws-bookspec-dependency, 4d9c73de)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
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>
2026-11-08 11:37:48 -07:00
swaitsandDeepSeek V4.1 Flash 4d9c73deef docs: the Lean laws, and their paths, are bookspec's
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>
2026-11-08 11:36:00 -07:00
swaitsandClaude Opus 5.5 959464ec53 docs(plan): product rules are WB-<area>-<n>; each content unit reduces its own claims file
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:35:26 -07:00
swaitsandDeepSeek V4.1 Flash e431791bbc build(lean): verify/lean requires bookspec's Lean; the laws live once
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>
2026-11-08 11:35:07 -07:00
swaitsandClaude Opus 5.5 75c666a7ce merge: the kernel and its proofs become modules, one file per sweep unit (K-U0; branch t3/kernel-modules-scaffold, 0cf013b5; same 1,096 tests, 27 bridge properties, 53 harnesses, 118 theorems)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
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>
2026-11-08 11:32:32 -07:00
swaitsandClaude Opus 5.5 e0e8b9c5fe build: pin bookspec at 62c0bf2, the sources vendored there with checked pins
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>
2026-11-08 11:32:07 -07:00
swaitsandDeepSeek V4.1 Flash 0cf013b578 refactor(core): the kernel and its proofs become modules, one file per sweep unit
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>
2026-11-08 11:30:47 -07:00
swaitsandClaude Opus 5.5 b4479036a5 merge: rules.md splits into one claims file per bookspec area (S-D0; branch t3/split-rules-md-claims-by-area, ca8d676d; lossless, rebuilt byte for byte)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:11:03 -07:00
swaitsandDeepSeek V4.1 Flash ca8d676d53 docs(spec): rules.md splits into one claims file per bookspec area
P14 unit S-D0 (plan/bookspec-audit.md D0) is a mechanical split, no
content change. bookspec is becoming the definitive spec, and later
units move each rule's accounting text there and reduce wanderbooks'
copy to the engine's claim (the pick, where it is enforced, which
tests check it) plus product rules. Several workers reduce different
areas in parallel; one 3,696-line file blocks them, so the file is
split first by bookspec area (the B -> area map is bookspec's
spec/rules-index.md).

Every `## B-n` section moves verbatim, in B order, into
docs/spec/claims/<area>.md: entry 5, ledger 13, statement 5, period 3,
partner 4, asset 4, prepaid 1, arap 6, revenue 1, 1099 1, format 2.
docs/spec/rules.md keeps its preamble and becomes the index (B,
bookspec id, area, link to the claims heading), so the existing
"rules.md B-n" references still resolve until S-E rewrites them. The
bookspec test now reads every claims file and the index, so every
stated rule's id is still verified where it is carried.

The split is proved lossless: the preamble plus the 45 claims sections
concatenated in B order is byte-identical to the old rules.md. No WB-n
product rules exist in rules.md, so no docs/spec/product.md is created
(D0's other half) until product rules are written.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:10:16 -07:00
swaitsandClaude Opus 5.5 7a3860de73 build: pin bookspec at 77e04633, rule records and every law in its Lean
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
bookspec now keeps one structured record per rule (rules/, each with a
plain-English description, generated index and per-area pages, link
checks, ids never reused) and proves all 118 headline theorems plus 33
named laws in its own Lean (P14 units S-A and L-F1, reviewed, with the
review fixes). The checker's public API is unchanged: the adapter (52
tests) and the package tests (29) pass on the new rev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:05:28 -07:00
swaitsandClaude Opus 5.5 539ef8a345 merge: the bookspec adapter becomes modules by area (X-H0; branch t3/split-bookspec-adapter-modules, f9cdf4d7; same 52 tests, same functions)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:49:40 -07:00
swaitsandDeepSeek V4.1 Flash f9cdf4d718 refactor(core): the bookspec adapter becomes modules by area
The bookspec adapter was one 4,647-line test file, and every later unit
that adds a query or an event touches it. Split it by its own sections,
with no behaviour change: `main` keeps the crate doc, the shared imports
and the module list; `common` holds the shared vocabulary (dates,
refusals, exact decimals, figure formatting); `books` the example's
books and setup; `events` the application of each event; `queries/` the
answers and checks per query family (statements, parties, tax, assets,
formats, commands, dates); `engine` the `Engine` impl; `check` and `run`
the drivers; and `examples`, `loader_tests`, `sources` and `rules_md`
the tests by area. Every `#[test]` keeps its function name (52 tests,
same names), and Cargo still builds one test target named `bookspec`.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 10:49:03 -07:00
swaitsandClaude Opus 5.5 69cfc81bb4 merge: Money::checked_add and checked_sub return an error on overflow (branch t3/fix-money-checked-overflow, bac0ea22; reviewed)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:14:00 -07:00
swaitsandClaude Opus 5.5 66d9b7ac54 docs(plan): P13 step 6 names bookspec's pin after the history rewrite
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:11:47 -07:00
swaitsandClaude Opus 5.5 54c710bc43 build: pin bookspec at 4eb99123, its history purged of build output
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
bookspec's first push committed 1,979 files of cargo build output
(target/). At the owner's request its history was rewritten to drop
them (git filter-branch, every commit) and force-pushed: the repository
went from 105 MB to under 400 KB. Every commit got a new hash, so the old
pin 74f2853d no longer exists upstream. Its rewritten twin is 6b309306,
with an identical tree apart from target/ (checked against a mirror
backup); the pin moves to the new tip 4eb99123, which only adds a
.gitignore. The bookspec adapter (52 tests) and the package tests (29)
pass on it. Older wanderbooks commits still name 74f2853d and will not
fetch bookspec from scratch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:11:32 -07:00
swaitsandClaude Sonnet 5.5 bac0ea22af fix(core): Money::checked_add and checked_sub return an error on overflow, never panic
Both were named checked but only checked the currency; the amounts went
through raw Decimal + and -, which panic past Decimal's range. A sum or
difference too large for exact arithmetic is now refused with
TooLargeToCompute, as everywhere else in the engine: never rounded,
wrapped or crashed. Currency mismatch still reports as a mismatch.

Test: checked_arithmetic_refuses_overflow_instead_of_panicking (MAX+MAX,
MIN+MIN, MIN-MAX, MAX-MIN refused; MAX+MIN and MAX-MAX exact).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 10:09:35 -07:00
swaitsandClaude Opus 5.5 c99a24893c docs(plan): P14, bookspec the definitive spec, the kernel sweep, D-68 to D-72
The owner's decisions of 2026-11-08 and the plan built from the two
audits: bookspec becomes the specification (one structured record per
rule with a plain-English description, the laws proved once in its
Lean, wanderbooks keeping claims and WB-n product rules), every money
computation moves into the proved kernel, the Lean model is run against
the code, and hledger joins GnuCash as an oracle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:03:07 -07:00
swaitsandClaude Opus 5.5 c433bc5062 merge: the kernel sweep and hledger audit (commit 9369c1f4; plan input)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:02:11 -07:00
swaitsandClaude Opus 5.5 9ea8254161 merge: the bookspec and kernel-sweep audits (branches t3/bookspec-audit 671d2fd6, t3/5250266e 9369c1f4; plan input)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:02:07 -07:00
swaitsandClaude Sonnet 5.5 671d2fd6cc docs(plan): bookspec audit
Read-only audit of what it takes to make bookspec the definitive
accounting specification: the 45 rules classed (accounting law,
convention/choice, format, product) with bookspec's completeness for
each, the 27 vendored sources and their licences, the Lean drift and a
verified lake require, the golden files as candidate examples, the
executable reference model (decidability, soundness, TOML in Lean), and
a unit breakdown with dependencies and file ownership.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 09:58:18 -07:00
swaitsandDeepSeek V4.1 Flash 9369c1f45a docs(plan): kernel sweep and hledger audit
Read-only audit of money arithmetic outside kernel.rs: 211 sites
(169 must move, 35 display-only, 7 not money), 76 raw/panic-capable
operators, grouped into nine sweep units with kernel signatures, Kani
harnesses, bridge properties, Lean laws, and a module layout that keeps
parallel units from conflicting. Also assesses hledger as a second
semantic oracle: what it can compare, how to map the journal, the
display-precision trap, a pinned static 1.52.4 image, and an hledger
engine adapter for bookspec.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 09:56:28 -07:00
swaitsandClaude Opus 5.5 a2ad2ed35e merge: Lean proves the deductible share rounds once, at any size (branch t3/deductible-share-lean-proof, aa1331c8)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 08:19:17 -07:00
swaitsandClaude Sonnet 5.5 aa1331c8bd docs: law 39 names its Lean theorems
Law 39 said no Lean theorem was needed because the Books model has no
tax categories. That reasoning was wrong: the law is pure kernel
arithmetic, like Prorate's roundUnit laws, and needs no Books model.
verify/lean/Wanderbooks/Deductible.lean now proves it at any size.

verification.md law 39 lists the Lean theorems in the usual format and
states the split plainly: Lean proves the law on integers over a common
denominator (one rounding, Prorate.roundUnit on the magnitude, signed
after); Kani proves the code on i64; the bridge and exact-reference
properties carry it to Decimal; overflow stays outside the model.
rules.md B-32's Checked line and plan/STATUS.md name the Lean file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 08:14:49 -07:00
swaitsandClaude Sonnet 5.5 2d345d02bc feat(lean): the deductible share rounds once, at any size
Law 39 (kernel::deductible_amount, B-32, D-67) was proved by Kani only
for up to three accounts and books to 2^20 cents. Like the proration
kernel, its arithmetic needs no Books model: Deductible.lean states it
on integers, for any number of accounts and any sizes.

Model: a share is a pair of integer numerators over one positive common
denominator D (10^(p+s) for books at p places and percents at s). The
category in cents is N / D, N = sum of book x percent; the /100 of the
percent and the x100 of dollars-to-cents cancel, so there is one
rounding: roundHA N D, the magnitude rounded by Prorate.roundUnit (unit
one, reused, not a second rounding function) and signed after, which is
what checked_div_round_cent does with a_mag, b_mag and `negative`.

Theorems (all on the exact sum, none by cases on the list):
- near: |2(D c - N)| <= D, any size
- tie_away_pos / tie_away_neg: at exactly k + 1/2 cents the result is
  k + 1 (resp. -(k + 1)), the cent farther from zero
- sign: never the opposite sign; zero when the sum is zero
- neg: negating every book negates the result (odd symmetry)
- of_sum, of_perm, append, split_percent: the result depends on the
  shares only through their exact sum
- per_account_differs (+ _mixed, tie_example): the kernel's three
  scenarios by decide: 1.01+1.01 at 50% is 1.01 once, 1.02 by account;
  1.05 at 50% and 30% is 0.84 vs 0.85; 333.33 at 50% is 166.67
- scale_books / scale_percents: a finer common denominator (books or
  percents carrying more decimal places) changes nothing

The Lean proves the law, not the Rust: Kani proves the code on i64, the
bridge and exact-reference properties carry it to Decimal. Overflow
(None) is outside the model. 20 headline theorems added to Audit.lean,
standard axioms only; no sorry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 08:12:24 -07:00
swaitsandClaude Opus 5.5 5353b5ae58 docs(status): the deductible share is kernel arithmetic, proved (2026-11-08)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 07:01:23 -07:00
swaitsandClaude Opus 5.5 f2c84d6779 test(core): the deductible rounding step at Decimal's edges
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Pins the re-check's adversarial rows (each matched exact fractions):
Decimal::MAX over 1 and 10 (two and one trailing-zero reductions), over
2 and 4 (no scale holds .50 or .75, so None), 1 over 1e-28 (the widest
exponent), and a half-cent tie written at scale 28, both signs, with the
value just under it. The 2,000-case property stays in the ordinary band;
these hold the edges it doesn't reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 07:01:10 -07:00
swaitsandClaude Opus 5.5 5630b9aff8 merge: the tax summary's deductible share is kernel arithmetic with Kani and bridge proofs (branch t3/move-deductible-share-kernel, 9f5ff9d0; reviewed twice, just prove and the slow harness green)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 07:00:35 -07:00
swaitsandMuse Wonder 1.0 9f5ff9d0bf docs: law 39 names the Decimal coverage and the no-x100 rounding
Say which part of the Decimal path the new exact-reference property covers (decimal percents, sub-cent books, multi-share categories) beside deductible_amount_agrees, note the negative-tie cover, and record that Decimal checked_div_round_cent now rounds from mantissa and scale by exact i128 arithmetic with None left for a product or sum overflow or a quotient Decimal cannot hold. That is the spec change the overflow fix makes in law 39's text.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 06:41:05 -07:00
swaitsandMuse Wonder 1.0 d3837a3a0a test(core): the deductible share's Decimal path against an exact reference
No committed test exercised decimal percents or sub-cent books: Kani proves the integer shape, the bridge used 2-decimal books and integer percents, and the tax tests use integer percents. Add deductible_amount_matches_exact_reference_on_decimal_shares, over books at 0-6 decimal places and percents in hundredths 0.00-100.00 (half at 4 places), several shares per category, against an independent reference computed as an exact i128 scaled numerator over a power of ten, rounded half away from zero by integer arithmetic. Pin the review's unit table (ties, sub-cent and FX-precision books, a 6-decimal percent, the Finding 1 regression, and a genuinely unrepresentable quotient) in kernel_bridge, and cover the negative half-cent tie (exact % 100 == -50) in the slow deductible_amount_rounds_once harness, whose Rust % only fired the existing cover for a positive tie.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 06:41:01 -07:00
swaitsandMuse Wonder 1.0 17b37d3e76 fix(core): the kernel's deductible share never overflows on a representable result
The Decimal checked_div_round_cent formed self * 100 before dividing, so a book of 10^25 - 1 at 100% -- whose exact deductible 9999999999999999999999999.00 is representable, and which the code before the kernel move returned -- overflowed that intermediate and came back None, making tax_summary report TooLargeToCompute. That breaks the function's own spec: None only for a product or sum that overflows, or a quotient Decimal cannot hold.

Round from the two mantissas and scales by exact i128 arithmetic instead: cents are round(a / b * 10^(sb - sa + 2)), half away from zero, with no x100 intermediate ever formed. Scale 28 is settled by the integer remainder, so digits a Decimal division by 100 would have to round away to fit still decide the half-cent tie. A trailing zero may let a past-mantissa quotient fit at scale 1 or 0; anything else past the mantissa is genuinely unrepresentable and stays None, and a zero result is never a negative zero.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 06:40:58 -07:00