Commit Graph
891 Commits
Author SHA1 Message Date
swaitsandDeepSeek V4.1 Flash 4f6cbefeb2 test(core): the split harness proves divisibility at step 3
The harness split with step 1, where every integer is a multiple, so its
"the rounded side is a whole multiple of the step" claim was vacuous and
the assertion absent. Step 3 makes it mean something, and the harness
asserts `part % step == 0`; the sum and the two covers are unchanged.
Record the re-run (3.1 s wall, 0.66 s verification), note that the Lean
model is total where the kernel is partial (a + b = 0), and refresh the
traceability counts from the merged bookspec branch.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 09:38:13 -07:00
swaitsandDeepSeek V4.1 Flash 803dfc5de0 fix(core): a ratio split's zero rest is +0, never -0
`split_ratio(0.00, 1, 2, 0.01, half-to-even)` handed the rest back as -0:
the generic `checked_sub` negates the subtrahend, and a zero negated
keeps its sign bit. Decimal equality hides it, but a printed "-0.00" is
not money and a sign test saw it. Map a zero rest to T::ZERO, which is
generic and always +0.

The bridge's edge test now asserts the sign (`!is_sign_negative()`) for
a zero rest and a zero percent, including a negative-zero amount, instead
of trusting equality. Its refusal test also covers a negative step for
both functions, which the kernel already refuses.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 09:38:09 -07:00
swaits c9d6c8f59a Merge branch 'main' into t3/kernel-percentages-ratios 2026-11-09 09:25:35 -07:00
swaitsandDeepSeek V4.1 Flash a5c62a2412 test(core): Kani and bridge for the kernel ratios
Kani proves the kernel's percentages and ratio splits on i64: a percent is
within half a step of the exact ratio (the model's whole fixed so its
truncating division is exact: an i64 quotient loses the fraction before
the multiply, which Decimal keeps), a percent of a zero or negative whole
is None, and a 1 : 2 split's rounded part plus its exact rest is the
amount.

The bridge carries the same laws to Decimal: the i64 model and the engine
agree where the quotient is exact; percent_of and split_ratio agree with
an independent exact i128 reference (no Decimal division at the reference)
for parts, wholes, ratios and steps of every sign and scale; a split's
parts sum and its rounded side is a whole multiple on every input; and the
edges (Decimal::MAX, scale 28, a zero whole and a zero ratio) are None or
exact, never a panic.

docs/proofs/k-u6.md records the harness-to-law table, the measured times,
the bridge properties and what rounds at Decimal's edge (K-U10). The law
is bookspec law 44; the traceability gate passes against the k-u6 bookspec
branch (the pin moves when that branch is merged).

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 09:14:41 -07:00
swaitsandDeepSeek V4.1 Flash a70099daae refactor(core): percentages and ratios in the kernel
A project's contribution margin is its net as a percent of revenue: the
exact ratio times 100, rounded once to the place the page prints (one
place, half to even), and none when there is no revenue to divide by. The
same computation was hand-written in reports; it is now
kernel::percent_of, division first as the call site always did, so the
figures, the scale and the None on a non-positive revenue do not move.

The government's part of an operating payment is an amount split a : b:
the government side rounded once to the currency's places, half to even,
the rest exact, the two summing to the payment (BS-statement-3 statement
8). U3 had already routed the share through kernel::share_of; U6 names the
whole split as kernel::split_ratio, which builds on share_of and
round_step, and cashflow::split_part calls it. The old party-shares
refusal on the shares' own sum is kept.

The percentage's rules come from BS-statement-5 statement 2 (a project's
net is revenue less expenses) and wanderbooks' WB-statement-7 (the margin
as a percent of revenue), and BS-entry-3 (round only where a rule says
to); the split's from BS-statement-3 statement 8, BS-partner-1 and
BS-entry-3.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 09:14:19 -07:00
swaitsandClaude Opus 5.5 f5826d45a4 merge: the adapter runs refused dates, amounts, periods, roles, exports, 1099 years and returns (X-H1d's wanderbooks half; reviewed, re-checked)
Wanderbooks passes every bookspec example for its picks on refused
input: 95 run, 95 passed, 16 for options it did not pick. The IIF export
now keeps its typed refusal (an entry on two receivable or payable
accounts is BS-format-10's), where it had stringified it; the package and
the MCP tool still show the same text. A test walks every role the
schema lists through the engine's control_account, so the two lists
cannot drift apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:09:03 -07:00
swaitsandClaude Opus 5.5 009049d968 merge: SOURCE lines cite what states the rule now, not a retired record (S-E4; re-checked)
Thirty-seven SOURCE clauses across four crates cited a retired bookspec
record: BS-format-1 (25), BS-ledger-13 (8), BS-ledger-12 (4). Each now
cites the product rule that states its fact: the journal format gate,
its features, the owner's upgrade and the projection schemas
(WB-format-1 to 4), the audit (WB-ledger-16), evidence read from the
bytes (WB-ledger-15). source_refs now refuses a retired id unless the
clause names a live successor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:01:34 -07:00
swaitsandDeepSeek V4.1 Flash a63e02b810 test(core): a retired bookspec id is no source
source_refs checked existence only, so a SOURCE clause could rest on a
record that bookspec retired (D-71) as long as the record still existed.
It now refuses a retired BS id unless the same clause names a live
successor, so a historical mention can still read "formerly
BS-ledger-13, now WB-ledger-16" while a bare retired id fails. The
self-tests pin both sides. The tree after S-E4 has zero problems, and
the free-text count stays 56 because every rewritten clause cites a
product rule rather than falling through to free text.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 09:00:52 -07:00
swaitsandDeepSeek V4.1 Flash b72ba2514a docs: SOURCE lines cite what states the rule now, not a retired record
Unit S-E4: 37 SOURCE clauses across ledger-core, ledger-gui, ledger-mcp
and ledger-store still cited records bookspec retired on 2026-11-08
(D-71). A retired id names what a rule was, not what governs now, so
each clause cites its successor: BS-ledger-13 is WB-ledger-16 (the
audit), BS-ledger-12 is WB-ledger-15 (evidence read from the bytes),
and BS-format-1, whose retirement names no successor, becomes the
WB-format rule that states each clause's fact: WB-format-1 (the format
gate), WB-format-2 (a journal feature declared before its first line),
WB-format-3 (the owner's format upgrade) or WB-format-4 (each projection
schema in a file of its own). No clause's fact was left without a live
rule, so no claim was added.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 09:00:48 -07:00
swaitsandDeepSeek V4.1 Flash 9c2e586733 docs(claims): BS-ledger-19's example shows both refusals
The example is renamed to what it now shows, and it refuses two
assignments: the receivables role on a header account (not postable) and
the payables role on a postable revenue account (wrong type). The claims
entry names both and the new example id.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 08:58:25 -07:00
swaitsandDeepSeek V4.1 Flash 75533aeb45 test(core): every role the schema lists is a role the engine assigns
The schema's `ACCOUNT_ROLES` is now the list BS-ledger-8 names, not a list
read off any engine. The adapter passes `assign_role`'s key straight to
`Store::assign_role`, so a listed key this engine spelled differently
would turn an example into a refused assignment it did not ask for. The
new test walks the schema's list and requires `control_account` to resolve
every key, which is also the check that `other_deductions_payable` is now
listed and the internal-only roles are not.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 08:58:25 -07:00
swaitsandDeepSeek V4.1 Flash eb073b53c6 style(core): rustfmt the refused-input adapter additions
The X-H1d adapter commits left two expressions the workspace's rustfmt
reflows: the `matches!` in `check.rs` and the `assert_eq!` arguments in
`queries/parties.rs`. No behavior changes; `cargo fmt --all -- --check`
now passes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 08:58:16 -07:00
swaitsandClaude Opus 5.5 b3ee97a94f docs(plan): S-E5, the old Rule n labels in wanderbooks move to statement positions
S-C8 dropped BS-statement-3's and BS-partner-3's Rule n labels, which
had drifted from their positions; wanderbooks' cash-flow code and tests
still cite them by label (Rule 11 is statement 16).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:49:18 -07:00
swaitsandClaude Opus 5.5 7a5cb6873a docs(status): 2026-11-09, P14 most of the 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
What landed since yesterday's status, unit by unit, what the reviews and
the units found and fixed, and what is next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:34:49 -07:00
swaitsandDeepSeek V4.1 Flash ad55ede8e4 docs(claims): refused dates, amounts, periods, roles, exports, 1099 years and returns
Each rule's Checked line names the bookspec example that now shows it, the
enforcement site it goes through, and the test that runs it:

- B-28 (BS-entry-4, BS-entry-7): the date past 9999 and the line past the
  cap, through `try_create_entry` and `add_line`;
- B-12 (BS-period-4): the partly overlapping quarter, through
  `create_period`'s PeriodsOverlap;
- B-23 (BS-ledger-19): the role on a header, through `Store::assign_role`
  and `check_assign_role`;
- BS-format-10: the export refused through `IifError`;
- B-19 (BS-1099-2): the 2027 worksheet refused through `RuleNotKnown`;
- B-26 (BS-partner-8): the return taking 123-45-6789 from the vault.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 07:40:31 -07:00
swaitsandDeepSeek V4.1 Flash 7ac1e644b2 test(core): the adapter runs refused dates, amounts, periods, roles, exports, 1099 years and returns
The bookspec examples now spell the input an engine has to refuse, and the
adapter takes each through the real books:

- a date past 9999 is refused by `Store::create_entry`'s own
  `try_create_entry` (DateOutOfRange), and a line past one quadrillion by
  `add_line` (AmountOutOfRange), each on a rehearsal so a refused entry
  leaves no draft;
- a close whose period partly overlaps another creates it through
  `Store::create_period` and reads PeriodsOverlap;
- `assign_role` is `Store::assign_role`, the journaled command, so a role
  on a header is refused by `check_assign_role` (ControlAccountMismatch)
  and the chart stays as it was;
- an IIF export with an entry on a receivable and a payable account is
  refused with BS-format-10's word, which is why `export_iif` keeps its
  typed error;
- a 2027 worksheet is refused through `RuleNotKnown` as
  `unknown_1099_year`, never guessed;
- `return_tin` reads the full number from the real `ledger_vault::Vault`
  the example's `setup.vault_tins` fills, and the books' own record keeps
  only the last four.

The adapter skips sixteen examples now (three more, each for an option
wanderbooks did not pick): allow-partial-overlap, carry-the-last-amount
and nowhere. Every one of the 95 it runs passes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 07:40:26 -07:00
swaitsandDeepSeek V4.1 Flash 9c299eb768 fix(package): the IIF export keeps its typed refusal
`export_iif` turned `journal_to_iif`'s refusal into a string, so a caller
could not tell why the file was refused without reading the message. An
entry on more than one receivable or payable account is BS-format-10's
own refusal (the receiving program will not take the transaction), while
every other IIF refusal is BS-format-2's; the bookspec adapter must name
the one rule an example expects. Returning `IifError` keeps the two apart
by type. The package and the MCP tool still hand the human a string.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 07:40:21 -07:00
swaitsandClaude Opus 5.5 045e70bb0d merge: tests where coverage was thinnest, the audit's strict close bound, WB-ledger-17 (V-D2; reviewed, fixes applied)
Ninety-six tests, each encoding the rule it covers, reach what the core
and store suites left untouched: the evidence requirement (34% to 100% of
its lines), the store's reconcilable accounts (0% to 100%), the command
steps' refusals, conventions, settings and the audit's branches. ledger-
core's line coverage rises from 89.79% to 95.49%, and the floor with it.

Found: the digest listed cash accounts found by name in hash order, so
the same books could list them differently; they come in ascending
account id now. The audit now holds a close's member split to under one
unit (BS-partner-1 statement 5) once the count has been trued up, a
close records its rule, and only drift beyond one unit before; the
reconciliations rule is written down as WB-ledger-17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 07:33:54 -07:00
swaitsandClaude Opus 5.5 50e966e8fb docs(coverage): the store's floor stays at 92.58%; a run inside the tolerance is recorded, not written over it
The merged, reviewed tree measured the store at 92.45%, twenty lines
fewer on the same lines (main's store changes were comments, the fixes
added no store code): run-to-run movement in the property and process
tests, which the 0.5 pp tolerance exists to absorb. The floor recorded
the run as measured, which lowered it, against the rule the same
paragraph states, that a floor only rises. The store's floor is back to
92.58% and the 92.45% run is in the table; the core's floor rises to
95.49%. scripts/coverage-floor.sh passes on both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 07:33:46 -07:00
swaitsandClaude Sonnet 5.5 cefb9bc83f docs(coverage): the floors are what the merged, reviewed tree measures
`just coverage` on the tree after the review fixes and the merge of main:
ledger-core 95.49% lines (18,422 of 19,292), 93.09% regions, 88.98% branches;
ledger-store 92.45% lines (14,359 of 15,531), 85.86%, 81.72%. The store is 20
covered lines under the earlier run's 92.58% on the same 15,531 lines: main's
store changes are comments only and the fixes add no store code, so it is
run-to-run movement in the property and process tests, inside the 0.5 pp
tolerance. `just coverage-check` passes at both floors.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 07:32:49 -07:00
swaitsandClaude Sonnet 5.5 ae32a83407 docs(spec): WB-ledger-17, the reconciliations rule, and the order the tests pin
Which accounts the monthly close reconciles, and when each is due, was a
module's own spec block with no id. It is now WB-ledger-17 (product-only, a
CONVENTION sourced to docs/parties-and-attachments.md "Reconciliations"),
checked against the code: the cash accounts (configured ones in the order
given, else by name in ascending account id), the card accounts (ascending
id), then the other liabilities with a statement in the order the statements
are given (period end, then file; not ascending id), each once; and an account
is due through last month's end when it has a posted line on or before it and
no reconciliation not voided is dated on or after it. The module and the test
file cite it.

The order within the cash group is the account id's, as `card_accounts` sorts,
not the chart code's (`ChartOfAccounts::all` is unordered). The test is renamed
to say so and its codes are out of creation order, so a sort by code fails it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 06:15:39 -07:00
swaitsandClaude Sonnet 5.5 2ce48090fd test(core): a replayed line past the line limit is refused when it posts
Opening old books is a real input: a draft line an earlier version accepted
past MAX_LINE_AMOUNT replays as journaled, and its post refuses it
(AmountOutOfRange, BS-entry-4), leaving the draft and the books as they were.
Covered for a plain line and a foreign line (bounded by its booked base
amount), at Decimal::MAX and one cent past the limit, and a draft at the limit
itself posts. A foreign original of any size beside an in-range base amount is
not refused by replay or by the post, and no journal writes one, so it is
left documented, not pinned.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 06:15:38 -07:00
swaitsandClaude Sonnet 5.5 344e09933d test(core): cite the rule that states the fact, and assert the fact, not the wording
Review of V-D2's tests:
- S-E3's vocabulary: `item k` and `INVARIANT k` become `invariant k` of
  WB-ledger-15, WB-ledger-9 (no numbered parts: cited whole), and the statements
  and invariants of BS-arap-5 and BS-arap-6 that the tests actually pin.
- The split-group tests cite WB-entry-6, the only rule that says "as part of a
  split group", not BS-entry-5.
- A refusal is pinned by its variant plus the fragment that states the fact (a
  figure, "positive", "strictly greater"), not its whole sentence; the
  `ConventionKind::ALL.len() == 7` pin is dropped.
- `a_send...moves_no_figure` compared receivables with itself; it now asserts
  the bank unchanged and receivables at 500.00.
- The disposal test says a day before the asset was acquired is refused and
  now asserts DisposalBeforeAcquisition.
- Main's FeeAboveCash variant replaces the InvalidSettlement text the fee test
  matched; it now asserts the variant and both figures.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 06:15:38 -07:00
swaitsandClaude Sonnet 5.5 7ac1ef8c5a fix(core): the audit holds a close's split to under one unit once the count is trued up
BS-partner-1 statement 5 says that after a close that posts, each member's
running total MUST be under one smallest unit from its exact share. The audit
flagged drift only when it was greater than a unit, so exactly one unit passed.
The looser bound is right only until the first true-up (statement 6,
WB-partner-1): a count that still holds closes made under the older rules may
carry their rounding until a cumulative close posts.

A close records both facts replay needs: its rule (`MembersClosed.rule`) and
whether it posted (`closing_entry`). `Ledger::member_close_trued_up` says a
count has had a cumulative close that posted, at or before a given close, and
`audit::check_split` flags drift of a unit or more once it has, drift beyond a
unit before. Closes under the older rules are not read by the audit at all.

Tests: both regimes at the edge in either direction, and a count walked through
a per-close January, a non-posting February (not trued up), a posting March
(trued up) and a non-posting April (still trued up). WB-ledger-16 gains
invariant 8 for it. The same test file now cites WB-ledger-16 for the audit
(BS-ledger-13 is retired), and audit.rs's own invariant and scenario where
WB-ledger-16's numbering does not match.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 06:15:38 -07:00
swaitsandClaude Opus 5.5 2ee01e7e65 fix(prove): the fast set is the harnesses not on the slow list
The _kani recipe takes the fast set as comm -23 of the bare harness names
and kani_slow. comm needs sorted input, and the bare names came from a
list sorted by qualified name: once the proofs became modules (K-U0,
proofs::allocate::x sorts apart from proofs::x), they were no longer in
order. comm then put seven of the ten slow harnesses in the fast set
(94, not 87), which ran past the fast set's 30-minute cap (just prove
exit 124; K-U3's worker hit the same cap), and the two checks beside it
saw nothing: comm refused the unsorted input, so the check that every
slow name is a harness never fired, and uniq -d found only adjacent
duplicate names. The bare names are sorted now: the fast set is 87,
verified in 599 s, with the Lean audit at 188 theorems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 06:06:50 -07:00
swaitsandClaude Opus 5.5 a983f5f238 merge: the kernel sweep's proof notes folded into verification.md (re-checked)
docs/verification.md is the one place the proofs are described; the
sweep units wrote notes instead so parallel branches would not collide.
They are now folded in: laws 40 to 43 with their harnesses, bridges and
Lean theorems, the totals under law 4, the party direction and the part
weight, the sweep's bounds, and what it found (the FX double rounding,
Decimal's edges for K-U10, the tie ranking K-U3 pinned). 34 harness
rows, each with its note's law; just prove counts 87 harnesses, the Lean
audit 188 theorems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 05:42:58 -07:00
swaitsandDeepSeek V4.1 Flash 0e049d9188 docs(proofs): the kernel sweep's notes folded into verification.md
Fold the six proof notes of plan P14's kernel sweep into the one place the
proofs are described. verification.md gains:

- the harness table's thirty-four new rows, each with its note's law
  number and measured time (all run in `prove`; none is in `kani_slow`);
- four new law sections in the existing house style: law 40 rounding to a
  step (K-U2), law 41 FX booking at the transaction-date rate (K-U1), law
  42 shares by weights (K-U3), and law 43 equal monthly parts (K-U5);
- law 4's collection-total harnesses (K-U4), law 23's Direction::of and
  law 27's part_weight harnesses (the entries note), with their bridges
  and the Lean theorems each cites;
- the sweep's Kani bounds (fixed steps, rates, month counts, weights
  totals, the `unwind(4)` and MAX_CORRECTION_STEPS bounds) and the
  symbolic-divisor note that carries them to Lean and the bridge;
- "What the proofs found" and "What is and isn't proved": K-U1's double
  rounding and D-75 precondition with its open 96-bit edge, K-U4's
  checked_add dust at Decimal::MAX, K-U3's quotient-crossing-a-step and
  non-terminating correction loop, the pinned tie ranking, the preserved
  printed scale, and K-U10's MAX and scale-28 edges, each with the test
  that pins it;
- the overview table's scope, the sweep's bridge reference, and the
  harness/audit counts (97 harnesses, 87 in `prove`; 188 Lean theorems).

Each unit note now opens with the section it was folded into; the notes
stay as the units' records. No code changed.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 05:42:07 -07:00
swaitsandClaude Opus 5.5 d59eca0c1a merge: new schedules round to the currency's minor unit (D-72), even monthly parts in the kernel (K-U5; reviewed, fixes applied)
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
A monthly-even schedule spread its total to two places in every
currency: 100,000 yen over three months booked 33333.33 a month, a
fraction of a yen no bank moves, and 1.000 dinar booked 0.33 where the
dinar has three places. The owner decided (D-72) that new schedules round
to their currency's minor unit and that schedules written before the
format feature replay the cent rule, so nothing journaled moves. A
schedule now records the rule it was written under (rounding on
schedule.registered, absent for the cent rule), so snapshots, adoption
copies and mid-journal replays read it right; the format feature
schedule_minor_unit waits for the owner's upgrade, and an older binary
refuses the newer journal rather than misreading it. Yen now books 33333,
33333, 33334; dinar 0.333, 0.333, 0.334; dollars as before.

The arithmetic is one kernel function, even_parts, with Kani harnesses,
bridge properties against an exact integer reference, and law 43 in
bookspec's Lean. A review compared 1.5 million plans as printed text
against the old function: no schedule moves; it found a zero total's last
month printed -0, now 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 05:24:41 -07:00
swaitsandClaude Opus 5.5 ee3c2b99c3 build: pin bookspec at 2b3b6c9, the even-parts law
bookspec main now carries law 43 (K-U5): a monthly-even schedule's parts
sum to its total, all but the last the same rounded share, at any size.
Lean 188 theorems, standard axioms only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 05:24:41 -07:00
swaits 5fd382450b Merge branch 'main' into t3/coverage-gap-tests-v-d2 2026-11-09 05:07:33 -07:00
swaits 5e4950697e Merge main into the K-U5 branch: X-H1b, K-U3, S-E2, S-E3, X-H1c 2026-11-09 04:35:21 -07:00
swaitsandClaude Opus 5.5 f74eccddfc build: pin bookspec at c597c8f, drafts and evidence
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 main now carries X-H1c: drafts, receipts, discards and the
evidence decision as examples, BS-entry-1 without the choice it never
owned, payroll its own exemption source. Lean 179 theorems, standard
axioms only; 88 of 101 examples run and pass, the other 13 are for
options wanderbooks did not pick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:34:41 -07:00
swaitsandClaude Opus 5.5 ef9995ebed test(core): the sub-reference self-tests read their bounds from the record
They hard-coded BS-entry-1's four statements and one scenario; X-H1c
moved a choice's statement out of BS-entry-1, an authority rule, into
BS-entry-6, which owns it, and the self-tests broke on the merge. They now
take a record's counts from the pinned bookspec and test one past each,
so a record that gains or loses a part moves them with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:34:41 -07:00
swaitsandClaude Opus 5.5 d47bc47508 fix(core): a zero plan prints 0 every month, as the cent rule always has
The K-U5 review's probe compared 1.5 million plans as printed text,
legacy against new, and found one difference: a zero total's last month
printed -0 (the kernel's 0 - 0), where the old plan printed 0. A zero
total is never registered, so no journaled schedule is touched, but the
promise is that the same plan prints the same, so the zero plan now
prints a bare 0 every month; a test pins it (and fails without the fix).

Also from the review: the kernel's GOAL said no month is more than a
rounding from the rest, which the last month need not be (INVARIANT 4
bounds it); and WB-prepaid-2's Checked list lacked the fifth harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:30:35 -07:00
swaitsandClaude Opus 5.5 b8e9b3ea8e merge: the adapter runs drafts and evidence (X-H1c's wanderbooks half; reviewed, re-checked)
Wanderbooks passes every bookspec example for its picks on drafts and
their evidence: a draft waiting on its receipt, a discard that leaves the
books as they were, a draft holding its period open, the one evidence
decision answering for every entry. A refused hand entry is posted on a
rehearsal of the real store, so the refusal is the engine's own; payroll
postings are their own exemption source. No engine change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:25:01 -07:00
swaitsandClaude Sonnet 5.5 56461c1bb6 test(core): the adapter's refused hand entries go through a real Store, and payroll is its own source
A hand entry the example says is refused when posted at once was made on a
clone of the Ledger and the receipt-gate error hand-built from
`evidence::requirement`, as `Store::post_entry_checked` builds it: the
adapter, not the engine, produced the refusal. A store journals a draft the
moment it is made, so the entry is now made, lined and posted on a rehearsal:
the books replayed from their journal into a Store of their own (the journal
and blobs copied, opened as any store is), and posted through
`post_entry_checked` under a policy, `post_entry` otherwise. The refusal is the
engine's own (ReceiptRequired included) and the example's books keep nothing.

A payroll run or tax remittance is exempt by its own source, so the engine's
"a payroll ..." sentence now reads as bookspec's new `payroll_posting`, not
`document_entry`. A draft reversal, which wanderbooks has no path for, is
returned as an unsupported-operation error (reported as "another refusal"), not
a panic that takes the harness down with it.

The claims for B-43 name the new example, entry-only-a-draft-can-be-posted-or-
discarded (a posted entry or a discarded draft is no draft), and the rehearsal.
Needs bookspec's x-h1c commits (payroll_posting, the new example, the
25.00 threshold example); the pin moves when they land.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 04:23:10 -07:00
swaitsandClaude Sonnet 5.5 1a25e66f23 docs(coverage): the floor rises to 95.45% core and 92.58% store
V-D2's tests (94 of them: 85 in ledger-core, 9 in ledger-store) take the
core from 89.79% to 95.45% of lines (17,299 -> 18,391 of 19,267) and the
store from 92.09% to 92.58% (14,301 -> 14,379 of 15,531), from the full
`just coverage` run before and after on the same code and tools. The
recorded floors, 90.01% and 91.71%, rise to the new totals; coverage-check
reads them from the floor line of docs/coverage-floor.md and passes at
exactly the new numbers.

Per file: evidence.rs 33.85% -> 100%, conventions.rs 77.76% -> 97.24%,
audit.rs 80.33% -> 94.14%, settings.rs 91.05% -> 98.16%, ledger.rs 86.00%
-> 96.87%, reconcilable.rs 0% -> 100%. What is left is mostly arms no
posted book reaches (a sum past Decimal's range; a line is capped at 1e15)
and replay-only refusals. docs/testing.md gets V-D2's record: the tests by
area and rule, the finding, what was not reached and the P12 mutation
targets.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 04:05:17 -07:00
swaitsandClaude Opus 5.5 b62625ea71 merge: sub-references name bookspec's statements, invariants and scenarios (S-E3; reviewed, fixes applied)
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
S-E rewrote B-37 item 7 as BS-statement-5 item 7, but the old number
counted the rules.md text's items, and bookspec's records number their
statements their own way. S-E3 mapped every sub-reference by content
(the last rules.md that held the text against the pinned records) and
wrote it in bookspec's words: statement, invariant, scenario. Where
bookspec states no counterpart, the product rule that does is cited.

The mapping caught citations that were wrong before the renumbering (a
discount rule cited as the payment bound, three times), and the review
caught nine more. A test now checks all 361: each names a part its
record has, product rules' parts included, no old word survives, and
none can vanish unseen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 04:01:42 -07:00
swaitsandClaude Sonnet 5.5 dfdb066245 test(core): the sub-reference test sees every old form, and checks product rules
- An id closed by a backtick before the part word (`BS-asset-1` rules
  23), the filler "states (rules 25-26", and a bare spec-block word on
  the id's line (BS-arap-3 SCENARIOS:) now fail as old vocabulary; each
  has a self-test.
- Product rules (WB-<area>-<n>) are checked: the numbered INVARIANTS: and
  SCENARIOS: lists in docs/spec/claims/*.md are parsed (a list that does
  not count 1, 2, 3 fails the parse), and WB-ledger-15 invariant 3 is
  checked like a bookspec part. A product rule with no list takes no
  sub-number, and has no statements.
- Counting: every member of a range and every number of a list is one
  reference ("27-30" is 4); a backwards range fails. The floor is
  exactly the number found, 361.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 04:01:09 -07:00
swaitsandClaude Sonnet 5.5 74fc553272 docs: the sub-references the review found land on the part that states the claim
A review of S-E3 against the pinned bc92cf3 records found citations one
part off, and old vocabulary the test could not see. Each is checked
against the record's own text:

- BS-statement-5: the partition of the P&L is statement 3 (not 2, and
  not BS-statement-3, the cash-flow statement); the ASC 340-40-25-7/-8
  trail (a cost traceable to one job is that job's, several only by a
  stated allocation) is statement 4, not 6.
- BS-asset-1: "one figure everywhere" is statement 31 (28 is the two
  figures, schedule and books); "disposed only for a disposal dated by
  then" is statement 30 (and 7 where the schedule stops).
- BS-arap-6: one receivable line per invoice, each tagged, is statements
  1-2 and invariant 4 (one application per document).
- BS-asset-1 statements 8 and 9 for the true-up and the credit back.
- BS-arap-2: "nothing unattached, no command adds a hand line" is
  invariants 2 and 3, beside 1, 6 and 9.
- BS-format-2: a class name written differently and reported adds 32.
- BS-arap-5: the cash-basis refusal is statement 6, everywhere.
- BS-partner-3: statement 3's cases are lettered (a)-(e), not numbered.
- BS-asset-1 "rules 23-24 / 25-26" in the claims, "BS-arap-3 SCENARIOS:"
  and "WB-ledger-15 INVARIANT 3" are in the new vocabulary.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 04:01:09 -07:00
swaitsandClaude Sonnet 5.5 d889f2e7fb docs(claims): the draft and evidence examples are checked lines
B-1 (BS-entry-1, BS-entry-6), B-43 (BS-entry-5) and B-20 (BS-ledger-7,
BS-ledger-17) name the bookspec examples that now show their rules, the real
engine functions each runs through, and the examples for the options
wanderbooks did not pick, which are skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:44:13 -07:00
swaitsandClaude Sonnet 5.5 8c57046c53 test(core): the adapter runs drafts and evidence
bookspec's examples for BS-entry-5, BS-entry-6 and BS-ledger-17 are run through
the real Store, none reimplemented: a draft is made by `Store::create_entry` and
`add_line` (tried on a clone first, so a line the engine refuses on a header
account leaves no half-made draft in the journal), posted by `post_entry_checked`
when the example states an evidence policy (the server's gate; the primitive
otherwise), given its state by `set_draft_state`, its document by
`attach_receipt` and thrown away by `discard_draft`. A close a draft holds back
is tried on a clone too. The two queries are read off the engine: a draft's
state from the entry itself, and the evidence decision from
`evidence::requirement`, its sentence of exemption read into the examples'
closed words. The refusals are read off the engine's errors: a placeholder
account is `header_account`, the receipt gate `evidence_required`, a draft's
command on an entry that is no draft `not_drafted`, a close with a draft in its
period `drafts_in_period`.

Wanderbooks passes every example for its picks (check-when-line-added,
reversal-evidence-is-originals); the two examples for the other options are
skipped, so the pinned skip count goes from 11 to 13.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:44:13 -07:00
swaitsandClaude Sonnet 5.5 317c53fa00 test(core): Kani and bridge for even_parts
Five Kani harnesses on i64 (fixed arrays, fixed months and steps, covers
reached): the parts sum to the total, all but the last are the half-even
rounded quotient and a whole multiple of the step, the last takes what the
others leave, the first part is within half a step of the quotient (a unit
a month wider against the true one, because i64 truncates), and no months
or a bad step is None. Law 43, bookspec's even-parts law.

The bridge checks i64 against Decimal where the quotient is exact, and
Decimal against an independent exact i128 reference at the USD, JPY, KWD
and CLF steps for any month count, with an edge table: Decimal::MAX and
scale 28 never panic and still sum exactly, though the 28-digit division
leaves MAX / 2 half a unit off its exact quotient (the K-U10 item, pinned).

docs/proofs/k-u5.md records the API, how a schedule knows its rule, the
times and the bounds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:33:15 -07:00
swaitsandClaude Sonnet 5.5 09308d5528 feat(core): new schedules round to the currency's minor unit (D-72)
The owner's decision D-72: a new monthly-even schedule rounds each month
to its currency's minor unit (yen whole, dinar to the thousandth), where
the cent rule gave two places to every currency; a schedule written
earlier replays under the cent rule, so nothing journaled moves
(BS-prepaid-4, BS-entry-8).

The rule is the schedule's own flag, journaled on its schedule.registered
line ("rounding": "minor_unit", absent for the cent rule), not the
sequence position of the journal feature: a flag survives a snapshot, a
copy and a replay that starts mid-journal. The new feature
schedule_minor_unit gates it (KNOWN_FEATURES, ensure_feature in
Store::register_schedule): books that haven't declared it keep the cent
rule and write nothing new, and an older reader stops at the declaration
as newer books (BS-format-1); an unknown rounding is newer, never
corrupt. A dollar schedule plans the same under both rules.

Tests: a dinar schedule written before the feature replays to the same
plan and the same posted line after the owner's upgrade, while one written
after plans 0.333, 0.333, 0.334. WB-prepaid-2 becomes yes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:33:15 -07:00
swaitsandClaude Sonnet 5.5 768ed7d92b refactor(core): even monthly parts in the kernel
An equal-months schedule books exactly its total: every month but the last
is the quotient rounded to the currency's step, the last takes what the
others leave (BS-prepaid-1, BS-prepaid-2). That arithmetic moves from
amortization_plan into kernel::even_parts, built on round_step and
plug_last, with its spec block (what rounds: Decimal's division, a K-U10
item, is stated, not hidden).

amortization_plan keeps the cent rule exactly. The exhaustive test
(300,000+ plans, and a proptest to 10^25) compares it with a verbatim copy
of the old function, values and printed text: a posted month's replay
compares journaled lines as text, and round_step prints 0.250 and a zero
differently from round_places, so present_as_rounded restores the old
scale (it found 1 over 360 printing 1.00 against 1).

The rule a schedule was written under is now its own flag
(ScheduleRounding, AmortizationSchedule.rounding, unsaid for the cent
rule), with Ledger::register_schedule_under and the replay twin; the plain
register_schedule stays the cent rule, so every existing test and golden
is unchanged. amortization_plan_under rounds to the currency's minor unit:
100,000 yen over 3 months is 33,333, 33,333, 33,334 and 1.000 dinar is
0.333, 0.333, 0.334 (hand-checked in the tests).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:33:15 -07:00
swaitsandClaude Opus 5.5 7b40d243a6 docs(plan): S-C8, bookspec's records cite their own parts by position
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
S-E3 found two records still using the old words inside bookspec:
BS-format-2's statements cite each other as items, and BS-statement-3's
and BS-partner-3's statements carry Rule n labels that no longer equal
their positions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:31:29 -07:00
swaitsandClaude Sonnet 5.5 d26a75b2ae test(core): every sub-reference names a part its record has
`sub_refs` scans every tracked file outside plan/ and checks each
`BS-<area>-<n> statement k`, `invariant k` and `scenario k` (a list, a
range, a parenthesised or comment-wrapped form, or a continuation on the
same id such as "invariant 2 and statement 11") against the pinned
record: k must lie within the length of that list. It also fails the old
vocabulary after a bookspec id (item, rule, INVARIANT, SCENARIO, r, or a
miscased word) when a number follows, so S-E's leftover forms cannot
creep back. The number of references checked is printed (328) and
floored (320); the self-tests refuse `BS-entry-1 statement 99`, a list or
range with one bad number, a wrapped reference, a bad continuation and
every old form, and accept the forms the records do have.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:30:06 -07:00
swaitsandClaude Sonnet 5.5 e41cc3a161 docs: sub-references name bookspec's statements, invariants and scenarios
Unit S-E rewrote each `B-n` citation to its bookspec id but kept the
sub-reference after it ("item 7", "rule 11", "INVARIANT 2"). Those
numbers counted parts of the retired rules.md text, so `BS-statement-5
item 7` pointed at finished and abandoned projects, not at the snapshot
it meant. Bookspec numbers a record's parts from 1 as `statement`,
`invariant` and `scenario`; every sub-reference now says so.

The map was built by content, not by position: each old item,
INVARIANT or SCENARIO was read in `git show ca8d676d5^:docs/spec/rules.md`
(the last full rule text), found in the pinned records
(bookspec bc92cf3) and in docs/spec/claims/, and each reference was
read in its context before it was mapped. Where the old numbering still
survives as the "Rule n" labels inside bookspec's statements (the cash
flow, party totals) the new number is that statement's position; where
a record carries the whole rule differently (the asset depreciation, the
IIF file, the arap invariants) the reference follows the content. Where
bookspec keeps no counterpart, the product rule that states it is cited
instead: WB-statement-5 (a project's facts and names), -7 (the snapshot),
WB-arap-4 (the document_standing feature), -8 (the issued PDF), -15 (a
payment event names its line), WB-ledger-15 (BS-ledger-12 is retired).
A reference that had pointed at the wrong part is corrected, for example
the discount-reason references that said BS-arap-6 INVARIANT 2 (a
bound) now say invariant 6 (the discount cap and date).

Only the reference tokens and their sentence change; no paragraph is
reflowed. A reference wrapped across a comment prefix keeps its wrap.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:30:06 -07:00
swaitsandClaude Opus 5.5 609e4e6b26 build: pin bookspec at bc92cf3, settlements and the shares law
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 main now carries X-H1b (settlements, recoveries, invoice
numbers, vendor references and their examples; BS-arap-10 ignores
hyphens as plan P4b S4 decided) and K-U3's law 42. The checker and the
Lean move together (tests/bookspec/pin.rs): Lean 179 theorems, standard
axioms only; 80 of 91 examples run and pass, the other 11 are for
options wanderbooks did not pick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 03:09:18 -07:00
swaitsandClaude Sonnet 5.5 11314db1f7 fix(store): cash accounts found by name come in chart order
FINDING from V-D2's reconcilable tests: cash_accounts returned the asset
accounts whose names say cash in the order ChartOfAccounts::all yields
them (a HashMap: "order unspecified"), so books.digest's
unreconciled_accounts could list the same books' accounts in a different
order from one run to the next. card_accounts, the rule beside it,
already sorts by account id. The name-matched path now sorts the same
way; configured codes keep the order they were configured in. No figure,
membership or due date changes, only the order of the list.

The earlier ignored test (cash_accounts_come_in_chart_order) now runs.
This is a small fix kept in its own commit so it can be dropped without
touching the tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:08:03 -07:00