Commit Graph
832 Commits
Author SHA1 Message Date
swaitsandClaude Opus 5.5 81bc16c386 merge: the adapter runs settlements, recoveries, invoice numbers and vendor references; a fee above the cash is its own refusal (X-H1b's wanderbooks half; reviewed, re-checked)
Wanderbooks passes every bookspec example for the options it picked: 80
run, 80 passed, 11 for options it did not pick. The settlement refusal
that read a fee above the cash out of one half of an error message's 'or'
is now a typed refusal (LedgerError::FeeAboveCash), checked before the
kernel's settle at the same point, so no refusal's order changes; the
remaining message names only what is left (an amount too large, a
negative fee). BS-arap-10's pick is ignore-case-spaces-and-hyphens, as
plan P4b S4 decided and the engine always did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 01:56:38 -07:00
swaitsandClaude Sonnet 5.5 0ffb0935fe fix(core): a fee above the cash is its own refusal
A processor cannot keep more than it was paid. The engine already refused
a settlement whose fee is above its cash, but as InvalidSettlement, one
message for two causes ("the cash and discounts don't cover the
applications exactly, or the fee is above the cash"), so the bookspec
adapter had to read the refusal out of the message's prose. Settlement
now checks fee > Σ cash itself, in the same place as before (after the
per-application checks, before kernel::settle), and returns the typed
LedgerError::FeeAboveCash { fee, cash }. InvalidSettlement keeps what
remains (a sum too large, a negative fee, a fee that leaves no deposit),
and its message no longer claims the fee case. The adapter matches the
variant like every sibling.

The refusal's precedence is unchanged, and nothing was journaled by a
refused settlement before or now (the store journals only a settlement
that succeeded); no stored data changes. The only output change is the
error text of a fee above the cash and of the leftover InvalidSettlement
cases; no golden or test asserted either text, and no caller matched the
variant (ledger-mcp, ledger-store, ledger-cli pass them on as text).
a_fee_above_the_cash_is_refused_and_changes_nothing encodes the rule
(150.00 of cash, a fee of 150.01 refused, books untouched; a fee equal to
the cash is the other refusal; a fee of 3.00 posts, deposit 147.00).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 01:53:36 -07:00
swaitsandClaude Opus 5.5 3d026b6473 merge: the last rule citations in program output name bookspec ids (S-E2; re-checked)
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 kept thirteen old B-n citations in program output and one golden,
since output is a contract and a golden changes only when verified by
hand. They now cite bookspec: the eight evidence sources BS-entry-5, the
CPA package's aging tie-out BS-ledger-8, the bills-due tool BS-arap-2,
and the projects note BS-statement-5 items 2 and 4 (the figures and that
no cost is allocated). None is stored: each is computed when shown, so
old books replay and show the new text. The golden moved in exactly
those two strings. No retired number now remains anywhere outside the
plan and the index. Found on the way: the sub-references S-E carried
over keep the old numbering (S-E3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 01:44:13 -07:00
swaitsandClaude Opus 5.5 3b0ae5b440 docs(plan): S-E3 moves the carried-over sub-references to bookspec's numbering
S-E2 found that S-E's rewrite kept the old item numbers after the new
ids: BS-statement-5 item 7 now means finished or abandoned projects, not
what B-37 item 7 meant. 261 sub-references outside plan/ carry the old
numbering; S-E3 maps them from the last rules.md that held the text and
adds a test that each names an item the pinned record has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 01:38:19 -07:00
swaitsandDeepSeek V4.1 Flash 885cbe403e test(core): no retired rule number remains anywhere
The retired B-1..B-45 allow-list is empty: every citation outside
`plan/`, `docs/spec/rules.md` and `docs/spec/claims/` now names a
bookspec id, program output included. The check still scans whole
tracked file text for any word-boundary B-<1..45>, so a regression fails
with the file and count. The allow-list mechanism stays for a future
deliberate keep, which must edit the list and its count in the same
commit.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 01:36:47 -07:00
swaitsandDeepSeek V4.1 Flash 797c418184 fix: the last rule citations in program output name bookspec ids
The engine's last program-output citations were the retired wanderbooks
numbers. Each moves to the bookspec id that states the rule:

- B-43 -> BS-entry-5, in the eight evidence-source strings of
  `Ledger::origin_exemption` and the two golden lines that record them.
- B-23 -> BS-ledger-8, in the CPA package README's aging tie-out.
- B-38 -> BS-arap-2, in `books.bills_due`'s description.
- B-37 -> BS-statement-5, in the project page's contribution note. The
  old "item 7" was the snapshot presentation in the retired numbering;
  in BS-statement-5 the figures are item 2 (a project's figures are
  exactly its tagged lines, net revenue less expenses) and item 4 (no
  cost is allocated), so the note cites those.

None of the strings is stored. The evidence source is computed on every
call by `evidence::requirement` from the ledger (`origin_exemption`);
the journal records only a draft state's note and a discard's reason
(`entry.draft_state_set`, `entry.draft_discarded`), never the gate's
source. The CPA README is built on request into the package's bytes and
exported for a token; it is never read back. Tool descriptions are
compiled into the router. The GUI note is a `const`. So an old book
replays unchanged and reports the new text; no compatibility layer is
needed.

Golden verification: `draft_states_and_evidence_gate.json` changes in
exactly two strings, the reversal's and the closing entry's evidence
sources. Both are recomputed from the same ledger by the test and
compared whole; after the change the test passes against the file, and
`git diff` shows no other line moved. The figures, decisions, journal
lines and trial balances are untouched, as the hand worksheet
`plan/golden-worksheets/draft-states-and-evidence-gate.md` derives.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 01:36:40 -07:00
swaitsandClaude Opus 5.5 1ea3f9a226 merge: proportional shares in the kernel, one copy for six sites (K-U3; reviewed, fixes applied)
Six places computed a share as whole x weight / total, rounded it and
handed out the leftover, each with its own copy: the K-1 property split,
the tax-capital running split, a convention's split, a party's shares,
the 1099 bucket split, the cash-flow split. They now call one kernel
function, each keeping its own rounding, step and leftover recipient, so
no figure moves: every golden and every test passes unchanged, and a
review fuzzed 700,000 cases a site, old against new, as strings.

Proved: eight Kani harnesses, bridge properties against an independent
integer reference, and law 42 in bookspec's Lean (exact shares sum to the
whole; a part is within one step of its share). Found and pinned: an
exact tie between remainders goes where Decimal's 28th digit sends it,
as it always did (K-U10 puts exact ranking to the owner, with the cents
it moves); a product of two ten-place amounts can round (K-U10). Fixed
in review: the first part of a first-absorbs split had lost its scale,
and an inherited correction loop could run without end on absurd input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 01:32:29 -07:00
swaitsandDeepSeek V4.1 Flash fb45b290d3 test(core): the kernel shares pass the traceability gate
split_by_weights_with allocates its Vec buffers and has no harness of its
own, so it joins the gate's EXCEPTIONS (15 now) and SKIPPED, with its law
18 carried by split_by_weights_into, whose fixed-array call the bridge
makes directly; the harnesses call share_of and share_floor_with by name,
their SOURCE lines cite the rules laws 18 and 42 serve (share_floor_with
cites BS-partner-1 and BS-1099-1 so it intersects law 42), and the K-U3
note's rows give each harness its law number.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 01:31:45 -07:00
swaitsandDeepSeek V4.1 Flash d6bc8d6cfe docs(core): what the shares round, where ties go, and the API
The K-U3 note listed share_floor and split_by_weights, which are gone;
it now names the two public functions. The Kani table carries the law
number in its own column (the traceability gate reads only a bare integer
there), law 18 for the split's shape and law 42 for the exact share and
the floor. The note records the bridge's ranking, ties, scale and cap
properties, and its findings say both checked_mul and checked_div can
round at Decimal's edge (the product's rounding is reachable below the
line cap, the pinned quotient case is not), that the correction is
bounded, that the first part keeps the old scale, and that ties follow
the rounded quotient.

The proof-harness comments no longer claim a step of 7 or a strict i64
bound, and Lean is described as proving the exact-share model at any
size, not the engine's rounded ranking.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 01:31:45 -07:00
swaitsandDeepSeek V4.1 Flash 8edc2e85dd fix(core): the shares keep the old scale, and the floor's correction is bounded
The review's kernel findings, with the bridge properties that hold them.

FirstAbsorbs computed the first part as whole minus the rest, which is
algebraically the old split_first's parts[0] + (whole minus the sum of
parts) but not the same scale: 4860 by 6/0.7/0.5 gave 4050.00 where the
old code gave 4050, and 902 by 1/0.000001/0.000001 gave 902 where the old
code gave 902.00. That scale reaches Part.amount, so a printed share
moved. The kernel computes the old expression now, with checked ops;
LastAbsorbs was already the old plug_last and the no-places conventions
split. The bridge compares the strings.

share_floor_with's correction loop could walk without end on a rounded
product far from the exact floor: 0.1113 x 5909471247797156928749568911.8
/ 0.11134381908633486049673 hangs. Both directions now stop at
MAX_CORRECTION_STEPS and refuse, so an input past the cap is None, never
a hang; no figure produced within the cap changes. The bridge pins the
input.

Ranking needed a property of its own: on i64 every remainder is zero, so
the harnesses never rank. A random-weight bridge checks the split against
the independent exact reference over non-terminating totals, excluding
exact ties because the kernel ranks the rounded quotients' remainders;
finding_ties_follow_the_rounded_quotient pins those ties (20.00 by 4/1/1
over 6 is 13.33/3.34/3.33, 20 whole is 13/4/3), today's behaviour and the
pre-U3 sites' alike, for K-U10 to decide.

share_floor and split_by_weights had no engine caller (only the bridge),
so they are gone; split_by_weights_with and share_floor_with are the
public API, and the docs say both checked_mul and checked_div can round
at Decimal's edge.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 01:31:45 -07:00
swaitsandDeepSeek V4.1 Flash d4440b6a4e build: pin bookspec at 6e1b99d, the shares law
Law 42 (the split's exact shares sum, and each part is near its exact
share) is merged in bookspec, so the Lean package and the Rust checker
move to the same rev. The two must name one spec version: the checker
runs the bookspec the Lean proves.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 01:06:36 -07:00
swaits 73879044b2 Merge branch 'main' into t3/k-u3-kernel-shares 2026-11-09 01:05:05 -07:00
swaitsandClaude Opus 5.5 f5ad691b80 docs(plan): K-U10 carries the exact tie-break, an owner decision
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
K-U3's review found the split ranks remainders by a rounded quotient, so
a tie goes where the 28th digit sends it. Making it exact moves a cent
between parties in recomputed past reports, so it is put to the owner
with the cents it moves; K-U3 keeps today's behaviour and pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 01:03:52 -07:00
swaitsandClaude Sonnet 5.5 d35775922b docs(claims): BS-arap-10's pick is ignore-case-spaces-and-hyphens, as the plan decided
The engine has always dropped hyphens too (plan P4b S4, the owner:
"(vendor, normalized vendor_ref) (lower-case, spaces and hyphens
removed)", pinned by duplicate_vendor_ref_refused_unless_a_reason_is_given);
bookspec's record lost the hyphens in transcription and is corrected, so
there is no divergence to note. PICKS and the claims file name the option
ignore-case-spaces-and-hyphens, "spaces" being any whitespace, and the
example ids follow the record's rename.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 00:58:02 -07:00
swaitsandClaude Sonnet 5.5 b78b5e9f39 docs(claims): the arap Checked lines name the X-H1b examples
B-38, B-40, B-41 and B-42 list the new bookspec examples the adapter runs
for the options wanderbooks picked, and those it skips for the options it
did not (BS-arap-2, -10, -11, -12, -13, -14). B-40 records that wanderbooks'
vendor-reference comparison also drops hyphens, which BS-arap-10's option
(case and spaces) does not say; no example distinguishes them yet. B-41
notes the allowance method of BS-arap-5 still has no example (it needs a
provision event).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 00:16:28 -07:00
swaitsandClaude Sonnet 5.5 ea4d8bc86e test(core): the adapter runs settlements, recoveries, numbers and vendor references
bookspec's X-H1b examples state BS-arap-4, -6 and -10 to -14 through new
events and queries; the adapter runs each through the real API, none
reimplemented.

- settlement: `Store::settle` with the applications, the fee and the
  deposit account; the party is the first document's customer or vendor, so
  the engine itself finds an invoice mixed with a bill, two customers, a
  document twice, more than a document owes, a discount that needs a reason,
  a discount on an asset bill and a fee above the cash. Each engine error is
  read as the examples' word (the fee case from the one InvalidSettlement
  error that can arise from exact inputs).
- recovery (BS-arap-11, reverse-then-plain-entry): in the write-off's fiscal
  year `Store::reverse_entry` of the write-off then `Store::receive_payment`;
  in a later year a plain entry, deposit debited and the recoveries account
  credited, naming the invoice. The engine has no recovery command; the two
  calls are the pick's own procedure.
- a bill's vendor reference and duplicate reason go to `BillFields`, so
  `Ledger::check_vendor_ref` is what refuses a second bill; each invoice is
  numbered with `Ledger::next_invoice_number`; a line's own account goes to
  `DocumentLine`.
- queries `document` (`Ledger::invoice_state`/`bill_state`) and
  `invoice_numbers` (the number the engine stored, read as its place in the
  order of issue).

Wanderbooks passes all 80 examples it runs. The runner skips eleven for the
options it did not pick (six new: documents-kept-apart, compare-exactly,
recovery-movement, net-of-expected-discount, net-against-the-deposit,
apportion-across-the-lines), so the pinned count is 11. No engine disagreed
with an example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 00:16:28 -07:00
swaitsandDeepSeek V4.1 Flash f6069cbcff test(core): Kani and bridge for the kernel shares
Prove the split's laws on the integer model and carry them to Decimal:
the parts sum to the whole, each is within one step of its share, no
part exceeds the whole, a zero total and all-zero weights are the
callers' answer, and overflow is None rather than a panic. The bridge
checks the i64 and Decimal instantiations against each other and the
Decimal split against an independent i128 exact reference, with weights
summing to one and to arbitrary totals, every leftover policy, one and
many members, and Decimal::MAX and scale 28 edges.

The one finding is K-U10's: at Decimal's 96-bit mantissa edge the
quotient's rounding can move a share across a step, and the comparison
product's rounding can hide it from the floor correction; the split
refuses rather than emit a part above the whole, and the bridge pins the
case. The i64 division truncates, so the proof's within-one-step bound
is inclusive there; the bridge checks the strict Decimal bound.

The note records the harnesses, bounds and times, including the
unwind(4) the floor harness needed and the just-prove batch cap that the
shared machine's load hit.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 00:14:37 -07:00
swaitsandDeepSeek V4.1 Flash 24b59e7b85 refactor(core): proportional shares in the kernel, one copy
The K-1/1065 worksheet, the 1099 worksheet, the parties' shares, the
conventions' template split and the cash-flow government split each
computed "whole x weight / total, round, hand out the leftover" for
themselves. Six copies meant six places for a rounding or sign change to
reach a filed figure.

Put the shape in kernel::allocate: share_of (the engine's division,
rounded at Decimal's 28 significant digits, truncating on a machine
integer), share_floor_with (the exact floor to a step by multiplication,
the 1099 correction loop's arithmetic), and split_by_weights_with (the
split, with the leftover policy named: largest remainder, first absorbs,
last absorbs; the running policy stays apportion_cumulative). Each site
keeps its own mode, step, sign and leftover policy, so every figure is
the same to the digit; the frozen periods rules only gain a doc line
naming the kernel policy they equal.

Amount gains checked_div, the engine's division as distinct from
checked_div_exact.

All goldens and existing tests pass unchanged.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 00:14:26 -07:00
swaitsandClaude Opus 5.5 b304fc9a9a docs(plan): X-H1e makes BS-prepaid-2's examples depend on its pick
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
Found in X-H1a's re-check: every schedule event names its convention,
so no schedule example depends on the engine's BS-prepaid-2 pick, and
for whole months from the 1st the daily and equal-months methods agree.
The fix is a schedule that takes the engine's method, with a mid-month
start, where the two differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 23:24:40 -07:00
swaitsandClaude Opus 5.5 946777628f docs(claims): name what the aging examples rest on in words
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 traceability gate refused `under` in B-18's checked line: it is the
key bookspec's examples use to name the option they rest on, not a name
in wanderbooks, so it resolves to nothing here. The sentence now says it
in words. Found when X-J's gate first read X-H1a's claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 23:22:49 -07:00
swaitsandClaude Opus 5.5 90e62e20b3 merge: the traceability gate (X-J; reviewed, re-checked twice, fixes applied)
Every claim in docs/spec/claims/ now has to be backed. A yes or partly
claim names where the engine enforces it and what checks it, and every
name resolves strictly: a Rust item by its whole path (a method on its
own type), a test by its #[test], a Kani harness by its #[kani::proof],
a Lean theorem in the list bookspec audits, a path that exists. Every
kernel function has a harness and a bridge property that call it, and a
law whose rules its own SOURCE cites; the fourteen that cannot are listed
with why, and the seven it cannot check for a law are pinned.

The gate found what the claims got wrong: B-22 claimed partial
enforcement of a rule the engine does not enforce (now no); WB-prepaid-2
claimed K-U5's rounding before it landed (now partly); two rules cited
retired ids as live; nineteen names had moved or never existed. The
reviews found three ways a wrong name could still pass, then two more;
all closed, with probes that a made-up name of each kind fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 23:14:01 -07:00
swaitsandClaude Opus 5.5 47502999d0 build: pin bookspec at 00b7c54, payments and the aging, and audit_lean
bookspec main now carries X-H1a (a payment event, terms, the aging and
due-date queries, their examples; an example names the option it rests
on, and a claimed CHOICE declares its pick) and X-J's half (audit_lean,
the audited theorem list an engine checks its claims against). The
checker and the Lean move together (tests/bookspec/pin.rs): Lean 177
theorems, standard axioms only; 71 of 76 examples run and pass, the five
others are for options wanderbooks did not pick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 23:14:01 -07:00
swaitsandDeepSeek V4.1 Flash cc8526ae07 perf(core): the gate builds its index once
The four tests each rebuilt the full index (every source file, every
claim, the rule records): a fresh scan apiece spent seconds re-reading the
same tree. One OnceLock now holds it for the file. build_definitions also
re-reads each file once per type it defines and makes a second full pass;
it now reads each file once into a map and reuses that text for the module
scan, the variants and fields, and the test names.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 22:35:42 -07:00
swaitsandDeepSeek V4.1 Flash 5a029f3cab test(core): the reversal bridge reaches the refusal
reverse_target_agrees claimed to compare refusal agreement, but arb_cents
is bounded to +/-2^40, so the i64::MIN arm of reverse_target's match never
ran: the bridge compared two answers, never a refusal. The edge strategy
now includes i64::MIN and i64::MAX, and the None arm is checked: at least
one amount is i64::MIN, and Decimal (which can hold the negation) answers
the exact opposite. The docs say that plainly instead of claiming the two
types refuse the same values.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 22:35:23 -07:00
swaitsandDeepSeek V4.1 Flash 176b59cc4f fix(proofs): part_weight is a lemma for laws 26-28
Law 26 is that the parts of a proration sum to its total, which
prorate_parts_sum_to_total proves. part_weight_is_days_of_the_month proves
the weight formula (days x monthly rate), which is law 27's statement. Its
row is numbered 27 now, in both tables, with a note that it is a lemma for
laws 26-28 rather than a restatement of law 26.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 22:35:10 -07:00
swaitsandDeepSeek V4.1 Flash c784bfe1d4 test(core): the gate's call and field probes
The stricter call matcher and the field check were fixed in code but had
no self-test, so a regression could hide behind the gate's own pass. These
probe them directly: x.take(5), a bare mention and other::take( are not
calls, kernel::take( is; Iif::form_4797 and TaxSummary::changes are the
other type's items and must not resolve, while each type's own fields and
methods do.

The made-up-name probe also gains NaiveDate::NoSuchThing and the two bogus
prefixes, and the `tests` probe now says plainly that bare `tests` resolves
as a Rust item (`mod tests`), not as a crate.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 22:35:01 -07:00
swaitsandDeepSeek V4.1 Flash 4d3444c0af fix(core): the gate walks a whole path and pins its skips
Three holes in the traceability gate let a name pass that should not:

- an imported uppercase type excused any associated item, so
  NaiveDate::NoSuchThing resolved. External types' items are now an
  explicit list of what the claims cite (NaiveDate::MAX only);
- only the last two segments of a qualified path were checked, so
  bogus::Ledger::post_entry and bogus::form1099::untagged_payments
  resolved. The whole path is walked: an optional crate name, then every
  module segment against the real module tree (file modules, inline mods,
  glob re-exports), then the item the module or type defines;
- a bare-name call counted in any module, so other::take( looked like
  take. Only kernel::name( or an imported name( counts now.

The right-law check was skippable by omission: a function with no rule or
no harness law was silently counted as skipped. Every ordinary function
must now be applied, and the skipped set is pinned to the excepted
wrappers that lack a law or a rule (SKIPPED), compared exactly.

source_ids reads only the spec block's source clause and is keyed by the
function's signature, so the free flip and Direction::flip no longer share
one id set and fx_booked stops picking BS-ledger-14 from prose.

The index also read root.rs badly: strip_code treated the backslash in a
raw Windows path (r"\\?\UNC\") as an escape and blanked the rest of
the file, so Root (and its adopt) were invisible. Raw strings are parsed
as raw strings now; Root::adopt resolves through its own impl, not through
the imported-type excuse that used to hide the bug.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 22:34:28 -07:00
swaitsandDeepSeek V4.1 Flash e98b9a63de docs(core): every kernel function cites its rule
Twenty-six kernel entry points had a harness, a bridge or a law, but no
SOURCE line of their own: their doc comments stopped at a sentence, so the
traceability gate could not check that the harness's law serves the rule
the function claims. Each now carries the house spec block, its source
clause naming the rule of the law its harness proves (take is law 10, so
BS-statement-3; flip is law 5, so BS-ledger-5).

Where a wrapper's law is its inner function's (round_places, round_minor,
fx_booked_minor), the source clause says so; part_weight and catch_up had
their rule id on a continuation line, so the SOURCE line now names it.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 22:33:25 -07:00
swaitsandClaude Opus 5.5 e435df0e81 merge: custom terms are due on the date they give; the adapter runs payments, the aging and due dates (X-H1a's wanderbooks half; reviewed twice)
The bookspec examples for A/R and A/P reading run through the real
Ledger: payments, the aging as of a day, a document's due and discount
dates. Writing them exposed an engine bug: custom terms ("Due
2026-11-15") came back due on the document's own date through the MCP
tools, so an invoice read past due two weeks early. Terms now keep the
agreed date and due_date returns it (BS-arap-3). The journal records each
document's due date and replay reads it, so books already written keep
what they recorded; the live books hold no invoices or bills. Five
examples are for options wanderbooks did not pick and are skipped,
pinned at five.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 22:10:01 -07:00
swaitsandClaude Sonnet 5.5 08733c6fa2 test(core): five examples are for options wanderbooks did not pick
The bookspec adapter's test pinned the examples for an unpicked option at
three (the other option of BS-arap-7, -8 and -9). The bookspec fixes give
BS-prepaid-2's equal-months and BS-ledger-20's refuse each an example of
their own, so no option-example allow-list grows; wanderbooks picks daily and
warn-by-default, so it skips both, and the count is five. The runner and the
loader tests still agree on exactly which.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 21:56:37 -07:00
swaitsandDeepSeek V4.1 Flash 36d1954e59 docs(proofs): the harness-to-law table format
The gate reads every proof note for a machine-readable table pairing a
harness with its bookspec law, but the format was undocumented. State it:
the first cell is the harness name in backticks, the second a bare integer,
extra columns allowed; name the three failures it drives (a kernel
function with no row, one harness with two different laws, a law sharing
no `BS-` id with the function's `SOURCE:` line).

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:54:24 -07:00
swaitsandDeepSeek V4.1 Flash 10fdab668d fix(core): the gate resolves names strictly
Three resolver weaknesses let a wrong name pass as backed, which is
exactly what the gate exists to catch:

- Kani harnesses resolved as Rust items: every `fn` under
  `src/proofs/` was in the item set, so 79 of ~82 harness citations
  never reached the harness class. Proof functions are excluded from
  items and harnesses are checked before items, so deleting a
  `#[kani::proof]` attribute now leaves the claim unbacked.
- A kernel function was "called" by a word mention or any `.name(`.
  A call is now a bare `name(` that is not a method call, or
  `Type::name(` for a kernel type's method. The two proof and bridge
  call sites that only used method syntax are written as the qualified
  call they mean.
- A `Type::item` token matched if its last segment existed anywhere,
  and every `fn` under `tests/` counted as a test. `Type::item` must
  now be an impl function, a variant, a field or an associated const of
  that type; `module::item` must be defined in that module's file; and
  only `#[test]`/`#[tokio::test]`/`proptest!` functions are tests.
- Product surfaces are the exact tool registrations (or exact declared
  names); the dotted-string fallback is gone; crate names come from
  `[package] name`, not directory names.
- `Audit.lean` is parsed once and matched exactly, with or without the
  `Bookspec.` prefix.

The law-table check is stricter too: duplicate rows with different law
numbers fail, and where a kernel function's `SOURCE:` line and its
harness's law row both cite rule ids, they must intersect. Of the 55
kernel functions, 29 have both and are checked; 26 are skipped (no
`SOURCE:` ids or a law with no rules).

Self-tests cover a harness name, a proof helper that is not a harness, a
made-up method, a real item under the wrong type, a test helper, an
unregistered `books.` name, a directory as a crate, and an unaudited
Lean name.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:54:19 -07:00
swaitsandDeepSeek V4.1 Flash 080a3ffbf5 test(core): Kani for Direction::of and part_weight
Both were exceptions for lacking all three backing kinds; neither is a
wrapper or an enum map. `Direction::of` is the sign classification the
party direction law is stated over (law 23), and `part_weight` is the
weight the proration charges are computed from (laws 26-28).

- `direction_of_is_the_sign` explores any `i64` and covers paid,
  received and neither (`kani::cover!`).
- `part_weight_is_days_of_the_month` explores `days` and `month_days`
  up to 40 and covers a partial month, a whole month and an invalid
  part.
- each spec block now carries its `SOURCE:` line, so the gate's
  right-law check applies to them.
- `docs/proofs/entries.md` records each harness's law in the
  machine-readable table; the exception list drops from 16 to 14
  (`Direction::key` and `MonthPart::is_valid` stay, with their reasons).

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:54:10 -07:00
swaitsandDeepSeek V4.1 Flash 6f2e2cf1eb test(core): bridge the party direction, part weight and reverse_target
Three properties the traceability gate can see as calls, not mentions:

- `reverse_target_agrees`: the earlier party bridge only passed
  `reverse_target` to `and_then`, which proves nothing about the `i64`
  and `Decimal` instantiations agreeing; the property now calls both.
- `direction_of_agrees`: `Direction::of` classifies the same sign at
  both types, each case keeping its meaning.
- `part_weight_agrees`: `part_weight` is the same weight at `i32`,
  `i64` and `i128`, and `None` exactly for a part no month has.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:54:01 -07:00
swaitsandDeepSeek V4.1 Flash 087ddaf094 docs(claims): one Enforced/Checked pair for WB-prepaid-2
The rule carried two pairs, the first naming only `amortization_plan`
and the replay entry point and the second naming `schedule_month_hold`
too. One pair says both: the schedule's plan, replay, and the month
hold, with the three tests that check them.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:53:56 -07:00
swaitsandDeepSeek V4.1 Flash 6b20946ae7 docs(claims): name the real items the stricter gate caught
The traceability gate now resolves a name exactly, so five citations that
were only approximately right are corrected to the code they mean:

- `form1099::Vendor1099Report::untagged_payments` is the free
  `form1099::untagged_payments`, not a method.
- `JournalFormat::declared` is the free `format::declared`, not an
  associated function.
- the Deductible and Apportion Lean theorems were cited bare; they live in
  those namespaces (`Deductible.tie_away_pos`, `Apportion.allocW_sum`, ...).
- `control_agrees` is `Documents.control_agrees`.
- `Step.discard` is a Step constructor, not an audited theorem; the claim
  keeps the two audited theorems that prove it.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:53:53 -07:00
swaitsandClaude Sonnet 5.5 e6c0d0d51b test(core): the adapter reads due dates from the engine
The bookspec adapter took a custom terms' due date by parsing the example's
terms text, which sidestepped the engine bug that custom terms were due on
the document's own date, so no example could catch it. It now takes every
due date, custom included, from Terms::due_date; an example on "Due
2026-11-15" passes only if the engine computes 2026-11-15 (BS-arap-3).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 21:25:16 -07:00
swaitsandClaude Sonnet 5.5 71a4e7e59d fix(core): custom terms are due on the date they give
BS-arap-3 statement 1: custom terms ("Due 2026-11-15") are due on the date
they give. Terms::due_date returned the document's own date for them, so
the MCP path (create_invoice / create_bill, from the terms given or a
party's default) stored an invoice dated 2026-11-01 on "Due 2026-11-15" as
due 2026-11-01: a document that read past due two weeks early in the aging.

Terms now keeps the agreed date (a new `agreed` field, Some exactly for
custom terms, with Terms::agreed_date), and due_date returns it, refusing
an agreed date before the document's like any due date before its document.
TermsKind keeps its shape, so stored kinds read as before. Terms read back
from storage fill `agreed` from their canonical text when it is missing, and
a custom terms with no readable date is refused rather than invented.

Stored books: the journal records each document's due_date itself
(invoice.created / bill.created payloads) and replay reads it, never
recomputing it from the terms, so a document already written keeps the due
date it recorded (posted is forever). New journal entries with custom terms
carry the extra "agreed" key; older ones read as before. No golden under
crates/*/tests/golden holds custom terms, so none changes; the live books
have no invoices or bills.

Through the tool, an invoice dated 2026-11-01 on "Due 2026-11-15": due
2026-11-01 before, 2026-11-15 after. Tests: ledger-core
custom_terms_are_due_on_the_date_they_give (Terms, the stored document, the
storage round trip incl. the older form, and the refusals) and the same
through books.create_invoice / create_bill / a party's default terms and the
refusal of a document dated after the agreed day (ledger-cli documents.rs).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 21:25:16 -07:00
swaitsandDeepSeek V4.1 Flash 0a90290160 test(core): the traceability gate
A claim is worth what backs it. The new bookspec test module reads every
claimed rule's Enforced and Checked paragraphs and follows each backticked
name to a real Rust item, test, Kani harness, Lean theorem (checked
against bookspec's embedded Audit.lean), path, rule id, or an explicitly
classified value; it requires a live record behind every bookspec id and
a unique WB id. It then walks every pub fn in the kernel and requires a
harness that calls it, a bridge property that calls it, and a harness
whose numbered law is a row of spec/laws.md; the wrappers and enum maps
with no independent proof are named in a pinned exceptions list with why.
Finally it checks every law row that cites a claimed rule names audited
theorems or says why not. Floors on sections, tokens and kernel functions,
and a made-up name that must fail, keep the gate from passing vacuously.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:20:45 -07:00
swaitsandDeepSeek V4.1 Flash 5703657957 docs(proofs): number each kernel-sweep harness's law
The kernel sweep's proof notes described each harness's law in prose. The
traceability gate needs the number to check it against a row of
bookspec's spec/laws.md, so each note now carries a machine-readable
Harness | Law table: fx_booked's harnesses law 41, round_step's law 40,
and total's law 4 (the engine-bound law whose Lean row says why it has no
theorem). The prose tables and times stay as they were.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:20:45 -07:00
swaitsandDeepSeek V4.1 Flash 2ef945ae3f docs(claims): name only live records and real items
The traceability gate follows every backticked name a claimed rule's
Enforced and Checked paragraphs carry, so the claims now name what exists:

- B-22 claimed `partly` while stating the engine enforces nothing; it is
  `no` now, with the reason (the policy is the books' own AGENTS.md).
- WB-prepaid-2 is `partly`: replay of old schedules is implemented and
  tested, while moving new monthly-even schedules to the currency's minor
  unit is K-U5 and not landed.
- The stale names: Vendor1099Report::untagged is untagged_payments,
  Asset::set_entry is Ledger::set_asset_acquisition, shares::share_target
  is shares::target, tag_in_use is check_asset_tag's refusal,
  Step.extends and Step.record are the audited Steps.extends and
  Step.record_changes_no_figure, and two asset tests are named as they
  exist (a_journaled_tag_taken_by_another_asset_is_refused_on_open,
  legacy_tax_basis_set_lines_replay_to_todays_figures).
- BS-format-1, BS-ledger-12 and BS-ledger-13 are retired; they are marked
  `retired bookspec:` so a live `bookspec:` id means a live record.
- B-44 and B-45 are wholly product rules: their enforcement and checks are
  the WB rules they point at.
- WB-ledger-3, -4 and -6 had one `Enforced and checked` marker; each now
  carries `Enforced` and `Checked` separately.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:20:45 -07:00
swaitsandDeepSeek V4.1 Flash 67bf2280a8 test(core): bridge the small cash-flow and bounds helpers
The traceability gate asks every public kernel function for a bridge
property. Three amount-generic helpers had none: take, entry_movements
and flows_of (the statement of cash flows' split) and running_bounds and
bounds_kept (a document's position against its total). The properties
compare the i64 instantiation Kani proves with the Decimal one the engine
runs, on random inputs, so law 10 and law 34 hold at both types.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 21:20:45 -07:00
swaitsandClaude Sonnet 5.5 23e52de969 test(core): the adapter runs payments, aging and due dates
The bookspec adapter learns the three things X-H1a's examples ask: a
`payment` event (Store::receive_payment for an invoice, pay_bill for a bill,
a payment dated before its document refused as `payment_before_document`
from LedgerError::PaymentBeforeDocument, BS-arap-9); `terms` on a bill or
invoice (the document is created with the engine's own Terms, its due date
from Terms::due_date, and the engine must print the example's spelling back
as written, BS-arap-3); and the `aging` and `document_dates` queries, read
from Ledger::{ar_aging, ap_aging} and the stored document's due date and
Terms::discount_by. Nothing of aging or terms is recomputed in the test.

An example for an option wanderbooks did not pick (`under`, checked against
PICKS) is read and not run, in the loader tests as in the runner, which
reports it skipped; the 71 others pass: wanderbooks agrees with every example
for the options it picks (BS-arap-7 due-today-is-current, BS-arap-8
as-of-the-day, BS-arap-9 refuse-a-payment-before-its-document). Run against
bookspec branch x-h1a by patching the dependency; the pin does not move
here. Claims for B-18 and B-39 name the new examples.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 20:47:46 -07:00
swaitsandClaude Opus 5.5 71df823080 docs(plan): X-H1 in five slices, one after another
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
Every slice adds to the same four files (the schema, its derivation, the
Lean runner and the adapter), so they cannot run in parallel; split by
what the schema must learn, A/R and A/P reading first (the most rules
for one new event and two queries).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:15:30 -07:00
swaitsandClaude Opus 5.5 8dec2900eb fix(prove): audit bookspec's own theorem list, not a copy
just prove audited verify/lean/Audit.lean, a copy of bookspec's list
made when the laws moved there (L-F2). The laws then grew in bookspec
(the FX law, the rounding primitive, the executable model's soundness
and completeness, the empty close) and the copy did not: it audited 151
theorems of the 177 bookspec states, so 26 were proved but never
checked for axioms on this side. Bookspec's CI audits them, so no
theorem is known to rest on more than Lean's three; but the laws live
once (D-69), and so must their list. just prove now runs bookspec's
lean/Audit.lean from the pinned package, and the copy is gone: 177
theorems, standard axioms only. A unit's #print axioms line now goes in
its bookspec branch with its theorem.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:13:40 -07:00
swaitsandClaude Opus 5.5 127d33fb0b build: pin bookspec at 51375ec, the spec floors and L-G2
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 L-G2 (documents run as a Lean step; the
example runner posts them) and X-I (per-rule coverage, and the floors
against the base commit: an issued id is never lost, an allow-list never
grows, no rule or option loses its example). The checker and the Lean
move together (tests/bookspec/pin.rs). Option names are now plain words
in bookspec; every pick named in docs/spec/claims/ already is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:09:12 -07:00
swaitsandClaude Opus 5.5 ec10ef3b77 merge: rule references cite bookspec ids (S-E; reviewed, fixes applied)
Every citation of the retired B-1..B-45 numbering in code, docs and
tests now names the rule's bookspec id, the one stable name for it
(D-68). docs/spec/rules.md is the index from the old numbers, and
docs/spec/claims/ holds what wanderbooks claims for each rule. Thirteen
citations in program output and one golden stay as they were: output is
a contract and a golden changes only when recomputed by hand, so S-E2
moves them together.

A test now holds it: no retired number anywhere outside the index and
an exact-count list of the kept ones, and every SOURCE clause in the
sources, tests and fuzz targets names a bookspec rule the pinned checker
has, a product rule the claims hold, a file that exists, or a declared
outside source (pinned in number, so the free-text set cannot grow
unseen). The review found unrewritten citations, a mangled range or
two, and a user-visible note changed by accident; all fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:03:59 -07:00
swaitsandClaude Opus 5.5 b131bdded8 docs: rules.md is an index; the rules are in bookspec
Pointers that said the rule text lives in docs/spec/rules.md now point at bookspec's rules and/or wanderbooks' claims in docs/spec/claims/: the dated-rule catalog doc, the kernel module header, a payout doc, the spec-derived and model and GnuCash tests (including its panic message), the MCP interface crate table and the spec README. Same treatment for the other stale mentions the grep found in attention, the P3 seams test and the store schema. AGENTS.md gains a Docs index row for docs/spec/claims/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:02:13 -07:00
swaitsandClaude Opus 5.5 b63fbf8847 chore: remove the one-time rewrite script
The script was one-time, is not idempotent, and treats --help as a live run. Method, for the record: the map was parsed from docs/spec/rules.md's index table, a word-boundary retired number (1 to 45) was replaced outside plan/, docs/spec/rules.md and docs/spec/claims/, and the kept strings were restored by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:02:13 -07:00
swaitsandClaude Opus 5.5 8d3cc5056f test(core): no retired rule number anywhere, SOURCE clauses checked whole
The retired-reference test now scans the whole text of every tracked file (git ls-files, skipping plan/, docs/spec/rules.md and docs/spec/claims/) for any word-boundary retired number from 1 to 45, wrapped references included, with an exact-count allow-list for the deliberately kept user-visible and golden strings; a count rising or falling fails. The SOURCE test now reads each whole clause with its continuations (crates/*/src, crates/*/tests and fuzz/), checks every bookspec and product-rule id in it, requires every path-like token to exist and every crate code reference to name a real item, counts clauses passing only through the free-text branch against a constant (56; 353 clauses checked), and keeps a floor on the total. The repo_root doc comment became the module header.

Lines the tightened check made fail, fixed in the lines not the test: relative sources/ and claims/ paths in form1099, instruments, kernel entries, money, kernel round and the 1099 tests now give full docs/spec paths; wrapped docs/spec/sources/ and docs/parties-and-attachments.md paths in ledger, store, reconciliation, tins and the GUI books module are joined; settings.rs names the real parser path instead of a runtime filename; the bounds tests name the real kernel and calendar files, and spec_bounds no longer cites rules.md for the line bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:02:08 -07:00