Commit Graph
929 Commits
Author SHA1 Message Date
swaitsandMuse Wonder 1.0 ec366e7e14 test(core): every SOURCE line names a rule or source that exists
source_refs in the bookspec suite: every SOURCE: line in crates/*/src cites a BS id the pinned bookspec has (bookspec_checker::rules()), a WB id in docs/spec/claims/, an existing repo path, or an external/declared source; unknown BS/WB ids fail. A second test fails if a retired rules.md B-n reference remains outside plan/ and the map files.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 19:40:28 -07:00
swaitsandMuse Wonder 1.0 7928531c47 docs: AGENTS.md points at bookspec for the rules
Specs come from authorities now states that the rules live in bookspec (its rules/ records, spec/rules/ pages, rules-index), that docs/spec/claims/ holds wanderbooks' picks, enforcement and WB- product rules, that docs/spec/rules.md is only the retired B-n index, and that SOURCE lines cite BS-/WB- ids. The docs index says the same.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 19:40:28 -07:00
swaitsandMuse Wonder 1.0 489360f598 refactor: rule references cite bookspec ids
Every B-n citation in crates/, docs/, deploy/, scripts/ and .github/ now names its bookspec id BS-<area>-<n> (D-68), via scripts/rewrite-rule-refs.py: the map is parsed from docs/spec/rules.md's index, rules.md-prefixed and bare forms are rewritten, sub-references (rule 11, item 7, INVARIANT 2) survive, and plan/, docs/spec/rules.md and docs/spec/claims/ are untouched. Program-output string literals that cited a rule were reverted by hand so user-visible output and its goldens are unchanged; DatedRule.catalog, metadata no output prints, now holds BS-1099-1. One SOURCE line that cited only 'R-?' now also cites BS-statement-5.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 19:40:22 -07:00
swaitsandClaude Opus 5.5 7a177a3cfc docs(status): 2026-11-08, P14 under way
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 19:14:44 -07:00
swaitsandClaude Opus 5.5 a27bdafde1 build: pin bookspec at aaa02ca, the FX law and D-75's bound
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 proves the FX law (law 41: whole unit, within half a unit,
positive from half a unit, the tie included), links BS-ledger-14's FX
invariants, and states D-75's ten-place bound in BS-entry-4. With the
K-U1 merge above: 1,198 core and package tests pass, just prove is
green (Lean 151 audited here, 174 in bookspec), the Lean-model test
agrees on 64 sequences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 19:14:24 -07:00
swaitsandClaude Opus 5.5 3da9d97929 merge: foreign-currency conversion in the kernel, fx_booked, and D-75's ten-place bound (K-U1; branch t3/kernel-fx-booked-conversion; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:51:53 -07:00
swaitsandClaude Opus 5.5 61a381b921 docs(plan): K-U10 makes Decimal's multiply exact-or-None too (found by K-U1's fix)
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 18:51:50 -07:00
swaitsandClaude Sonnet 5.5 c400624310 docs(proofs): K-U1 notes after review and D-75
The overflow harness proves two concrete cases (and non-positive rate for
every symbolic rate), not every overflow; step <= 0 -> None rests on K-U2's
round_step_refuses_nonpositive_step and the bridge; the D-75 precondition,
the open 96-bit edge, the bridge's new properties, Fx.booked_pos now proved
at the tie, and the BS-ledger-14 link landed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:08:12 -07:00
swaitsandClaude Sonnet 5.5 c5a4894985 fix(core): foreign amounts and rates take at most 10 places (D-75)
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>
2026-11-08 18:08:12 -07:00
swaitsandClaude Sonnet 5.5 bf2fe200c2 style: rustfmt engine.rs (main's S-C7 merge left it unformatted)
No accounting change; `cargo fmt --check` was red on main.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:08:12 -07:00
swaitsandClaude Opus 5.5 3b59f7fec9 test(core): the Lean-model test requires D-73 to have landed; cargo fmt
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>
2026-11-08 17:16:20 -07:00
swaitsandClaude Opus 5.5 5de13d480b merge: the Rust ledger and the Lean model agree on random command sequences, refusals checked under D-74 (L-G5; branch t3/lean-model-differential-test; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:14:33 -07:00
swaitsandClaude Opus 5.5 e080f761a0 merge: every reversal is dated on or after its original (D-73; branch t3/reversal-dating-d73, bb5008ed; reviewed)
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>
2026-11-08 17:14:13 -07:00
swaitsandClaude Opus 5.5 4de03c1eaa merge: a coverage report and floor; rust_decimal checked against exact rationals (V-D; branch t3/decimal-exact-coverage-floor, e6fe6e29; reviewed, fix applied)
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>
2026-11-08 17:11:27 -07:00
swaitsandClaude Opus 5.5 e6fe6e2949 test(core): decimal_exact pins the add's rounding next to Decimal::MAX
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>
2026-11-08 17:10:16 -07:00
swaitsandClaude Opus 5.5 57d86b1920 merge: every report and book total goes through the kernel's checked sum (K-U4; branch t3/kernel-checked-totals, bc81b849; reviewed)
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>
2026-11-08 17:09:27 -07:00
swaitsandClaude Opus 5.5 7ed3f431de docs(plan): V-D2, tests where coverage is thinnest
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 17:07:05 -07:00
swaits 38b843cfe9 Merge branch 'main' into t3/kernel-fx-booked-conversion 2026-11-08 17:06:45 -07:00
swaitsandClaude Opus 5.5 ed9adaeec5 docs(plan): D-75, foreign amounts and rates take at most 10 places
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 17:06:14 -07:00
swaitsandClaude Opus 5.5 72de6efec0 build: pin bookspec at 218b5c8, every CHOICE its own record
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>
2026-11-08 17:06:14 -07:00
swaitsandDeepSeek V4.1 Flash 986c75b31e feat(just): coverage report and floor
Coverage is a tripwire, not a correctness oracle: the proofs, the
property tests, the GnuCash cross-check and mutation testing answer
whether the books are right; a line/branch report answers whether a test
still reaches the code it used to. This adds that measurement, pinned in
mise.toml like every other tool: cargo-llvm-cov 0.9.1, and the
llvm-tools component on the pinned nightly because branch coverage is
nightly-only (-Zcoverage-options=branch).

`just coverage` runs each crate's own suite instrumented (core and
store separately, so one crate's dev-dependency code does not enter the
other's totals), writes HTML, the JSON and the plain per-file table under
target/coverage/<crate>/, and excludes src/proofs.rs (Kani-only,
cfg(kani)) plus test and bench files: it measures the library.
`just coverage-check` reads docs/coverage-floor.md and fails when a
crate's total line coverage is more than 0.5 pp below its floor; regions
and branches are recorded for context but not gated, since branch
coverage is the noisier number across compiler versions.

First measurement from the full run: ledger-core 90.01% lines (88.86%
regions, 82.65% branches), ledger-store 91.71% lines (85.27%, 80.73%).
The store measured 91.98% on an earlier run the same day; properties pick
random cases, so a few tenths move between runs and the 0.5 pp tolerance
absorbs it (the floor records the lower run). The largest holes are
findings, not fixes here: ledger-store/reconcilable.rs is 0% (the server
and viewer are its readers; the store suite never calls it), and
ledger.rs is mostly the document/payroll replay steps the store's replay
tests exercise rather than the core's own.

It is not a push gate (the instrumented suites are slow: the store alone
runs about a hundred minutes of tests once built); the weekly scheduled
workflow runs it beside the proofs. The store's tests start and kill
helper processes that inherit LLVM_PROFILE_FILE, so a killed child can
leave a truncated profraw; the run passes --failure-mode all, which
merges the test binaries' profiles and ignores such a file (it holds no
test coverage).

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 16:05:43 -07:00
swaitsandMuse Wonder 1.0 720a93f0e0 ci: the Lean-model test runs weekly
Co-Authored-By: Muse Wonder 1.0
2026-11-08 16:01:28 -07:00
swaitsandMuse Wonder 1.0 22a9cc79a3 test(core): the Lean-model test checks D-74: each refusal names a rule the command breaks
Co-Authored-By: Muse Wonder 1.0
2026-11-08 16:01:13 -07:00
swaitsandClaude Opus 5.5 ee3ac6e6fc merge: wanderbooks declares its pick for every CHOICE it claims (S-C7; branch t3/s-c7-split-embedded-choices, de57598d; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:00:45 -07:00
swaitsandClaude Sonnet 5.5 bb5008edb5 fix(core): every reversal is dated on or after its original (D-73)
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>
2026-11-08 16:00:23 -07:00
swaitsandMuse Wonder 1.0 de57598df8 docs(spec): every CHOICE wanderbooks claims has a declared pick
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
2026-11-08 15:59:44 -07:00
swaitsandClaude Opus 5.5 b24062e8fa docs(plan): K-U10, the Decimal sum exact at the edge (found by K-U4)
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 15:50:14 -07:00
swaitsandClaude Opus 5.5 27e47a2b51 docs(plan): D-74, any rule a command breaks is a conformant refusal
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 15:48:58 -07:00
swaitsandClaude Sonnet 5.5 bc81b84932 docs(proofs): K-U4 note, and a clippy fix in the bridge
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>
2026-11-08 15:30:41 -07:00
swaitsandMuse Wonder 1.0 abad8d892b test(core): Kani and bridge for fx_booked
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
2026-11-08 15:12:51 -07:00
swaitsandMuse Wonder 1.0 f9affd0e1f refactor(core): foreign currency conversion, fx_booked, in the kernel
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
2026-11-08 15:11:36 -07:00
swaitsandClaude Sonnet 5.5 8775d38d0d test(core): the Rust ledger and the Lean model agree on random command sequences
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>
2026-11-08 15:10:22 -07:00
swaitsandMuse Wonder 1.0 03f667585d docs(spec): partner picks follow the renumbering
Co-Authored-By: Muse Wonder 1.0
2026-11-08 14:53:25 -07:00
swaitsandClaude Opus 5.5 9d58502a09 docs(plan): X-I checks ids-issued only grows against the base commit
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 14:45:02 -07:00
swaitsandMuse Wonder 1.0 3877a49a81 docs(spec): one picks list; picks for every CHOICE record
The two S-C7 halves declared their picks two ways; there is now one
shared PICKS list in the bookspec adapter's engine.rs, declared via
Claims::with_choice, and rules_md.rs keeps S-C7b's check (the
backticked option in the claims file must be one of the record's
options and the adapter must declare the same), skipping retired
rules. S-C7a's Pick lines are rewritten with backticks.

Picks are added, in the claims files and the adapter, for the 16
records of s-c7b-noexample (BS-partner-16..18, BS-asset-9,
BS-1099-5, BS-arap-7..14, BS-format-8..10), taken from each parent's
old status_note and the claims' existing Pick lines. BS-partner-9's
pick is gone with its record (folded into BS-partner-2), and
BS-ledger-17's pick now appears once, under B-20.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 14:40:14 -07:00
swaits 75758b250c Merge branch 't3/split-embedded-choices-s-c7b' into t3/s-c7-split-embedded-choices 2026-11-08 14:39:55 -07:00
swaitsandClaude Opus 5.5 8874b603b4 merge: the IIF export refuses an entry on two A/R or A/P accounts (branch t3/iif-refuse-multiple-ar-ap, 45ea1032; 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 14:34:12 -07:00
swaitsandClaude Opus 5.5 c7c7ffd248 build: pin bookspec at c467093, the rounding law for every mode
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 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>
2026-11-08 14:34:09 -07:00
swaitsandDeepSeek V4.1 Flash 45ea103283 fix(import): the IIF export refuses an entry on two A/R or A/P accounts
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>
2026-11-08 14:32:23 -07:00
swaits df9f3164ab Merge branch 't3/s-c7a-resolve-embedded-choices' into t3/s-c7-split-embedded-choices 2026-11-08 14:21:14 -07:00
swaitsandClaude Opus 5.5 f77eaa515a merge: one rounding primitive, round_step, in the kernel, proved for every mode (K-U2; branch t3/kernel-round-step-primitive, f0a5d107; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:04:40 -07:00
swaitsandClaude Sonnet 5.5 f0a5d10708 test(core): round_step's directed modes and finer steps are proved and tested
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>
2026-11-08 14:03:50 -07:00
swaitsandClaude Opus 5.5 512352ecec docs(plan): every CHOICE is a record now; the ones no example shows go on the allow-list
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 13:50:32 -07:00
swaitsandMuse Wonder 1.0 cb55787852 docs(spec): wanderbooks declares its picks for the new CHOICE records (entry, ledger, period, statement, prepaid)
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
2026-11-08 13:49:15 -07:00
swaitsandClaude Opus 5.5 cbcb7f07a6 docs(plan): X-H1 carries the 16 CHOICEs no example can show yet
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 13:48:46 -07:00
swaitsandClaude Sonnet 5.5 422a956ffc docs(spec): wanderbooks declares its picks for the new CHOICE records (partner, asset, 1099, format)
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>
2026-11-08 13:46:41 -07:00
swaitsandDeepSeek V4.1 Flash f16525fd35 test(core): Kani and bridge for round_step
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>
2026-11-08 13:46:24 -07:00
swaitsandDeepSeek V4.1 Flash 74943fb699 refactor(core): one rounding primitive, round_step, in the kernel
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>
2026-11-08 13:37:48 -07:00
swaitsandClaude Opus 5.5 4b295ee224 build: pin bookspec at d877bcf, every area's rules complete there
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 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>
2026-11-08 13:34:55 -07:00
swaitsandClaude Opus 5.5 8ecf177cb2 merge: format claims reduced; the journal format gate's product rules (S-C6; branch t3/format-iif-export-rules, 5e69743d; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:25:35 -07:00