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

Co-Authored-By: Muse Wonder 1.0
2026-11-08 19:40:22 -07:00
swaitsandClaude Opus 5.5 3da9d97929 merge: foreign-currency conversion in the kernel, fx_booked, and D-75's ten-place bound (K-U1; branch t3/kernel-fx-booked-conversion; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:51:53 -07:00
swaitsandClaude Sonnet 5.5 c5a4894985 fix(core): foreign amounts and rates take at most 10 places (D-75)
The K-U1 review: foreign 0.99999999999999999999999999 (26 places) x rate
0.005 into USD booked 0.01, though the exact product
0.00499999999999999999999999995 is under half a cent. Decimal::checked_mul
rounds a product finer than 28 places to 28 before fx_booked rounds it to
the cent: two roundings, one cent off. A ledger in one money books the
exact product rounded once (BS-ledger-1, BS-ledger-14).

Owner decision D-75 (2026-11-08): a new line's foreign amount and its rate
take at most MAX_LINE_SCALE (10) decimal places each, as a base amount does
(B-28), so their product has at most 20 places, under Decimal's 28.
Ledger::add_line_fx refuses past it with ValueOutOfRange ("foreign amount
..." / "FX rate ..."; the variant for an amount that is not a journal
line's), trailing zeros not counted, before computing, and never on replay
(is_replaying; replay_add_line_fx books a journal's older line verbatim).

Tests: 11-place foreign amount and rate refused; ten and ten accepted with
hand-checked books; the review's input refused, not mis-booked; trailing
zeros are not places; replay keeps a 26-place foreign line in core, and a
store journal holding one opens with its figures.

fx_booked's spec block states the precondition (scales within 10 each, and
the mantissas' product within Decimal's 96 bits) and that the result is
exact under it, and documents Decimal::checked_mul's behaviours outside it
(rounding past scale 28 and past 96 bits; 1e-28 x 1e-28 underflowing to
zero); invariant 1 now says None when T's checked_mul cannot hold the
product. The bridge covers every D-75 scale (0..=10 each, products to 20
places) against an independent exact reference, shows 26 places is where the
reference and Decimal part (and the engine refuses), and pins an open edge
this bridge found: ten places each still allow a 20-place product past
~7.9e8 that outgrows 96 bits (1050000010.0000000001 x 9.9999999999 books
10500000099.90, exact 10500000099.89). B-28 and B-3 claims record the
enforcement and checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:08:12 -07:00
swaitsandClaude Opus 5.5 e080f761a0 merge: every reversal is dated on or after its original (D-73; branch t3/reversal-dating-d73, bb5008ed; reviewed)
claims/ledger.md conflicted with the reduced B-9 section: the D-73 pick,
Enforced and Checked lines sit above its product rules; the check's
place corrected (after the schedule double-post check, not ahead of it)
and the citation completed (BS-ledger-16, the Lean model since L-G1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:14:13 -07:00
swaitsandClaude Opus 5.5 ee3ac6e6fc merge: wanderbooks declares its pick for every CHOICE it claims (S-C7; branch t3/s-c7-split-embedded-choices, de57598d; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:00:45 -07:00
swaitsandClaude Sonnet 5.5 bb5008edb5 fix(core): every reversal is dated on or after its original (D-73)
A correction comes after what it corrects (Pacioli ch. 31; B-9). Until now
only document reversals and depreciation/schedule runs were held to it; a
plain posted entry could be reversed with an earlier date, leaving the
books carrying the opposite of an entry that doesn't exist yet at the
reversal's date. The owner's decision D-73 (2026-11-08) makes it one rule
for every kind of entry; bookspec BS-ledger-5 states it.

- Ledger::check_reversal refuses date < original.date() with one error,
  ReversalBeforeOriginal (it replaces DocumentReversalBeforeOriginal,
  which was the document-only wording). Same-day reversals are allowed.
- Not on replay (B-28): the check sits behind is_replaying(), so a journal
  an earlier version wrote, holding a reversal dated before its original,
  reopens with the same figures.
- The store's own date check for depreciation runs and schedule months
  (InvalidSchedule / AssetEntryIrreversible wording) was the same rule
  for a narrower case; it is removed so there is one variant for all.
  Store::check_reverse_entry, books.reverse_entry (preview and post), and
  the document voids all reach the refusal through check_reversal; the
  only construction path for a reversal is reverse_entry_steps, which
  calls it first.

Tests: store reversal_dates.rs (plain entry refused before it, nothing
journaled, same day and later taken; a journal with an earlier-dated
reversal written the old way opens with the same figures); ledger-cli
spec_mcp (preview, unconfirmed and confirmed post all refuse alike).
Existing tests changed: store assets.rs (three expectations move to the
new variant); core spec_asset_basis.rs (it backdated a reversal on
purpose to check the trial balance carries -100.00 between the dates; it
now replays one, as an old journal would); model.rs (the model oracle's
`reverse` requires the date, as the Lean/bookspec rule does); bookspec
common.rs (the pinned depreciation example words this refusal
"entry_irreversible"); spec_documents.rs (variant rename).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 16:00:23 -07:00
swaitsandMuse Wonder 1.0 de57598df8 docs(spec): every CHOICE wanderbooks claims has a declared pick
Add the seven older CHOICE records (with a B number) that carried no declared pick in the adapter, taking each option from its record's options and the claims file's existing Pick line for its B section:

- BS-arap-2 lines-that-stand, BS-arap-5 direct-write-off, BS-asset-3 tag-and-never-reuse, BS-ledger-6 reversible-once, BS-ledger-9 facts-in-the-books, BS-ledger-10 label-only, BS-statement-5 project-is-a-class
- PICKS in crates/ledger-core/tests/bookspec/engine.rs gains all seven; each claims file gains a '**Pick (BS-...):**' line beside its B section's Pick
- Widen rules_md.rs's pick check from b == 0 records to every non-retired CHOICE record wanderbooks claims, so no CHOICE can go undeclared again

Co-Authored-By: Muse Wonder 1.0
2026-11-08 15:59:44 -07:00
swaitsandMuse Wonder 1.0 03f667585d docs(spec): partner picks follow the renumbering
Co-Authored-By: Muse Wonder 1.0
2026-11-08 14:53:25 -07:00
swaitsandMuse Wonder 1.0 3877a49a81 docs(spec): one picks list; picks for every CHOICE record
The two S-C7 halves declared their picks two ways; there is now one
shared PICKS list in the bookspec adapter's engine.rs, declared via
Claims::with_choice, and rules_md.rs keeps S-C7b's check (the
backticked option in the claims file must be one of the record's
options and the adapter must declare the same), skipping retired
rules. S-C7a's Pick lines are rewritten with backticks.

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

Co-Authored-By: Muse Wonder 1.0
2026-11-08 14:40:14 -07:00
swaits 75758b250c Merge branch 't3/split-embedded-choices-s-c7b' into t3/s-c7-split-embedded-choices 2026-11-08 14:39:55 -07:00
swaitsandDeepSeek V4.1 Flash 45ea103283 fix(import): the IIF export refuses an entry on two A/R or A/P accounts
BS-format-2 item 7: QuickBooks Desktop records at most one A/R or A/P
account in a transaction (Intuit's own warning, sources/intuit-iif.md
and rules/format/BS-format-2.toml), so an entry with lines on two
receivable accounts, two payable accounts, or one of each cannot be
written as one IIF transaction. journal_to_iif used to write it and
merely list it in Iif::receivable_payable.

Now the export collects every entry whose lines touch more than one
distinct A/R/A/P account and returns
IifError::SeveralReceivablePayableAccounts, naming the entries and
saying why and what to do (reverse and post as two entries through a
clearing account; splitting one would change what it says). It never
splits an entry itself. ledger_package::export_iif and build_package
pass the refusal through, so books.export and books.export_cpa_package
return it before a file is handed over.

The README test's entry on both controls moved to its own refusal test;
the valid books it covers (one A/R entry, one A/P entry) are unchanged,
as are every IIF golden and every test of the file's bytes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 14:32:23 -07:00
swaitsandMuse Wonder 1.0 cb55787852 docs(spec): wanderbooks declares its picks for the new CHOICE records (entry, ledger, period, statement, prepaid)
Bookspect S-C7 split the CHOICEs embedded in these areas' AUTHORITY and CONVENTION rules into their own records, so an engine declares its pick by rule id. Each parent B-n section in docs/spec/claims/<area>.md now carries a **Pick (BS-<area>-<n>):** line naming wanderbooks' option with who decided it and when (the parents' **bookspec:** lines stand), and the bookspec adapter's claims() declares the same twenty picks with Claims::with_choice. The rules_md test now reads a born-after-B-n rule (b = 0 in the catalogue) by its **Pick (BS-...):** line instead of a B-n index row it cannot have.

No engine behaviour changes: every pick is the decision the claims already recorded in prose (for example check-when-line-added, D-73's on-or-after-the-original, D-67's round-once-on-the-total, D-72's minor-unit-for-new-schedules). Verified against the s-c7a bookspec branch with the documented patch override (not committed): cargo test -p ledger-core --test bookspec, 53 passed.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 13:49:15 -07:00
swaitsandClaude Sonnet 5.5 422a956ffc docs(spec): wanderbooks declares its picks for the new CHOICE records (partner, asset, 1099, format)
bookspec split the CHOICEs embedded in BS-partner-1..4, BS-asset-1, BS-asset-4,
BS-1099-1 and BS-format-2 into records of their own (S-C7b). Wanderbooks'
decisions are unchanged; each is now recorded against the id an engine
declares it by:

- partner: BS-partner-5 largest-remainder-first-listed (owner, 2026-10-13),
  -6 cumulative-from-first-close (D-10, 2026-10-16), -7 running-split (D-38,
  2026-10-20), -8 outside-the-books and -9 tin-facts-then-w9 (2026-10-15),
  -10..-13 money, entry flow, books' carrying amount, labelled basis
  (2026-10-15, 2026-10-20), -14 tax-basis-beside-book (D-41), -15
  running-cumulative (D-38's rule, 2026-10-22)
- asset: BS-asset-5 straight-line-by-days, -6 lesser-of-value-and-basis, -7
  books-recorded-amounts, -8 register-carries-tax-figures
- 1099: BS-1099-2 refuse-an-unknown-year, -3 presumed-a-check-ach-or-transfer,
  -4 dated-by-the-payments-date
- format: BS-format-3..7 (D-36, 2026-10-20)

Each is a `**Pick (BS-..):**` line in docs/spec/claims/<area>.md and a
`with_choice` in the adapter's claims(). The rules_md test no longer expects a
B-n row for a rule born without one (a split-out CHOICE has none): it requires
the pick line, that the pick is one of the record's options, and that the
adapter declares the same option.

The pin is not moved here: this needs bookspec's s-c7b to be merged and the
pin moved to it. Verified with ledger-core's bookspec test patched to the
s-c7b checker and runner (53 passed).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 13:46:41 -07:00
swaitsandClaude Opus 5.5 8ecf177cb2 merge: format claims reduced; the journal format gate's product rules (S-C6; branch t3/format-iif-export-rules, 5e69743d; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:25:35 -07:00
swaitsandClaude Sonnet 5.5 5e69743d89 fix(spec): the IIF record states the header rows, cites what Intuit says, review fixes
B-34 claims: the pick not to write a customer or vendor NAME is a CHOICE with
its open risk named; the ACCNTTYPE mapping is stated; the engine's gap on
a transaction with two A/R or A/P accounts is recorded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 13:19:48 -07:00
swaitsandDeepSeek V4.1 Flash 280d3a1b6d docs(spec): format claims reduced to wanderbooks' picks and product rules
B-27's journal format gate is wholly the product's: its full text is now
WB-format-1 to WB-format-4 (the gate and the frozen envelope; the journal
features and when a command asks for one; the format upgrade with the
owner's passphrase and a proven backup; one SQLite projection file per
schema), with the enforcement and tests split among them. Its id
BS-format-1 stays retired, and the one engine-independent sentence it
carried — a reader that does not know a record's format version refuses
it, never misreads it and never calls it corrupt — is now bookspec's
BS-ledger-4, statement 4.

B-34 keeps its pick (plain ASCII transliterated and reported, CR LF,
DOCNUM the entry's id, closes left out, every entry through the as-of
day, D-36), its enforcement and its tests; what is wanderbooks' only is
WB-format-5 to WB-format-7: the export tool's as_of and warnings, the
package README's words and the names of entries on A/R and A/P, the rest
of the package's text and fonts, and the pinned deunicode 1.6.0 table.
The accounting text itself (encoding, line structure, signs, accounts by
name, classes) lives in bookspec's BS-format-2.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 12:49:50 -07:00
swaitsandClaude Sonnet 5.5 b4d0c07a59 docs(spec): entry claims, B-43 reduced to wanderbooks' picks and product rules
B-43 keeps its heading, BS-entry-5 id, Pick (D-47, cross-referenced to
BS-ledger-7 and B-20's claims rather than restated), Enforced and Checked. The
draft/evidence/discard principle moved to bookspec's BS-entry-5 (branch s-c5).
WB-entry-5..9 keep what is wanderbooks' only: evidence::requirement as the one
function and its callers, the exempt-by-origin list with the policy.evidence.*
settings (threshold, required accounts, split groups), the building and
awaiting_evidence states and their journal event, what a discard drops and
journals, and the receipt_required refusal with confirm-against-preview.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 12:45:38 -07:00
swaitsandClaude Sonnet 5.5 c81a21faf5 docs(spec): arap claims reduced to wanderbooks' picks and product rules
B-18 and B-38..B-42 keep their heading, their bookspec id, Claims, Pick,
Enforced and Checked; the accounting text moved to bookspec's records
BS-arap-1..6 (branch s-c5). What stays here as WB-arap-1..17 is only
wanderbooks': the replay derivation of document tags and the projection
that keeps no figure, the default account codes 1200/2000/6990/6995, the void
description, journal feature document_standing and documents_v2 and the
invoice.written_off event, the net-days range and settings fallback, the INV-
number format, the issued PDF filed as receipt.attached with its sha256, the
vendor reference's duplicate_reason, the write-off evidence filed in the same
call and its Needs-attention flag, the settlement's row order and event
fields, and the aging CSV exports. The picks stay: due today is Current and
the as-of reading (owner, 2026-10-13), lines-that-stand (D-45, 2026-10-23),
the direct write-off (A-5) with D-49's recovery, the gross discount (A-8) and
fee (A-4).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 12:45:38 -07:00
swaitsandClaude Opus 5.5 0aeb913756 merge: asset and 1099 claims reduced (S-C4; branch t3/s-c4-asset-1099-spec, d5b589c3; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:31:07 -07:00
swaitsandClaude Sonnet 5.5 d5b589c324 docs(spec): asset and 1099 claims, review fixes
- B-25: the lesser-of pick for personal-use property is named as the MAY of
  BS-asset-4, taken by analogy to Treas. Reg. 1.168(i)-4(b)(1) (a taxpayer's
  own conversion); the choice stays wanderbooks', the CPA to confirm.
- WB-asset-1 points at BS-asset-1 rules 25-26, which now hold the engine-neutral
  refusals (link after the in-service date or disposal, in-service date before
  the linked entry, disposal before the acquired date); the replay carve-out
  stays here.
- WB-1099-4: the worksheet's card accounts are the recorded business-card
  methods only; the liabilities named "card" are the party-totals fallback,
  and a charge to one counts for no one either way on the worksheet.
- WB-1099-5 (new): attorney gross proceeds ($600) and royalties ($10) are not
  modelled, and the worksheet says so, as the original B-19 stated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 12:30:05 -07:00
swaitsandClaude Opus 5.5 8bae4e41a0 merge: partner claims reduced (S-C3; branch t3/partner-area-s-c3, cba264d7; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:21:21 -07:00
swaitsandClaude Opus 5.5 7a6cc9cbd6 merge: statement, period, prepaid and revenue claims reduced (S-C2; branch t3/s-c2-statement-period-revenue, 1349bb47; reviewed, fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:21:21 -07:00
swaitsandDeepSeek V4.1 Flash ce02a44bb0 docs(spec): 1099 claims reduced to wanderbooks' picks and product rules
B-19's accounting text (thresholds, payor, card and network exclusion, the
bucket table, decisions and dates, the status function, shares) now lives
in bookspec's `rules/1099/`; this file keeps the four embedded choices'
picks, the enforced and checked evidence, and the product rules.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 11:53:41 -07:00
swaitsandMuse Wonder 1.0 73010c4acb docs(spec): revenue claims reduced to wanderbooks' picks and product rules
B-17's accounting text moved to bookspec (BS-revenue-1). What stays:
the Enforced/Checked evidence and WB-revenue-1, the
books.record_payout tool surface.

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

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

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

Co-Authored-By: Muse Wonder 1.0
2026-11-08 11:45:32 -07:00
swaitsandClaude Opus 5.5 05702b5a34 merge: verify/lean requires bookspec's Lean; the laws live once (L-F2; branch t3/lean-laws-bookspec-dependency, 4d9c73de)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
The ten Lean files were code-identical to bookspec's (checked per file);
wanderbooks keeps a thin Wanderbooks.lean importing Bookspec and audits
the same 151 theorems. The Lean pin moves to 62c0bf26 at the merge,
the rev the Rust checker was pinned to after S-B (the new pin test
caught the difference), and lake-manifest.json is regenerated. Conflicts
with K-U0 and S-D0 resolved: the proofs/ path and the bookspec Lean path
both kept, L-F2's Deductible path fix applied to the claims file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:37:48 -07:00
swaitsandDeepSeek V4.1 Flash 4d9c73deef docs: the Lean laws, and their paths, are bookspec's
The laws are proved once in bookspec (D-69), so the documents that said
"put the new theorem in `verify/lean`" or cited
`verify/lean/Wanderbooks/<File>.lean` now say otherwise:

- AGENTS.md's formal-methods bar: a new law is written in bookspec's
  `lean/Bookspec/`; wanderbooks requires it and moves its pin (the lakefile,
  the manifest, and the crates' Cargo.toml together; the pin test fails if
  they drift). `Audit.lean` lists every theorem.
- docs/verification.md: the model and every cited Lean file are
  `bookspec/lean/Bookspec/<File>.lean`; "Running it" says the dependency is
  fetched and that all 151 theorems are audited.
- docs/testing.md and docs/spec/rules.md: the same paths, and the apportion
  row records where its law moved.
- README's repo map and the two test comments that named the Lean peer.

No accounting behavior changes; only where the proofs and their names live.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:36:00 -07:00
swaitsandClaude Opus 5.5 75c666a7ce merge: the kernel and its proofs become modules, one file per sweep unit (K-U0; branch t3/kernel-modules-scaffold, 0cf013b5; same 1,096 tests, 27 bridge properties, 53 harnesses, 118 theorems)
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
Conflicts with X-H0 and S-D0 resolved: both new paths kept
(tests/bookspec/, tests/kernel_bridge/, src/proofs/); K-U0's two path
fixes in rules.md applied to the claims file the rule moved to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:32:32 -07:00
swaitsandDeepSeek V4.1 Flash 0cf013b578 refactor(core): the kernel and its proofs become modules, one file per sweep unit
kernel.rs is now kernel/: mod.rs keeps the laws and re-exports entries
(the old file, unchanged) plus one file per kernel-sweep unit (U1 fx, U2
round, U3 allocate, U4 total, U5 schedule, U6 ratio, U7 payroll, U8
control). proofs.rs is proofs/: mod.rs holds the original 63 harnesses and
each unit gets a file of its own. tests/kernel_bridge.rs is now
tests/kernel_bridge/main.rs plus one file per unit; Cargo still builds the
single test target named kernel_bridge.

`_kani` now scans proofs/mod.rs and proofs/*.rs and passes the fully
qualified name each file gives its harness (Kani's --exact matches only a
fully qualified name), so a harness resolves wherever it lives. It fails
when kani_slow names no harness, or when two harnesses share a name and
would make the slow list ambiguous; `just prove-list` prints every harness
with its module path and set, showing the slow list resolved without
running it.

Nothing moves in the books: the same 53 fast Kani harnesses and 118 Lean
theorems verify, and the same 1096 tests pass (27 in the bridge).

Docs: verification.md gains the kernel-sweep policy (each unit writes
docs/proofs/<unit>.md; the integrator folds the notes into
verification.md and Audit.lean in one edit per batch), and the file
references in AGENTS.md, testing.md, architecture.md, oracle.md and
spec/rules.md follow the new paths.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:30:47 -07:00
swaitsandDeepSeek V4.1 Flash ca8d676d53 docs(spec): rules.md splits into one claims file per bookspec area
P14 unit S-D0 (plan/bookspec-audit.md D0) is a mechanical split, no
content change. bookspec is becoming the definitive spec, and later
units move each rule's accounting text there and reduce wanderbooks'
copy to the engine's claim (the pick, where it is enforced, which
tests check it) plus product rules. Several workers reduce different
areas in parallel; one 3,696-line file blocks them, so the file is
split first by bookspec area (the B -> area map is bookspec's
spec/rules-index.md).

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

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

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:10:16 -07:00
swaitsandDeepSeek V4.1 Flash f9cdf4d718 refactor(core): the bookspec adapter becomes modules by area
The bookspec adapter was one 4,647-line test file, and every later unit
that adds a query or an event touches it. Split it by its own sections,
with no behaviour change: `main` keeps the crate doc, the shared imports
and the module list; `common` holds the shared vocabulary (dates,
refusals, exact decimals, figure formatting); `books` the example's
books and setup; `events` the application of each event; `queries/` the
answers and checks per query family (statements, parties, tax, assets,
formats, commands, dates); `engine` the `Engine` impl; `check` and `run`
the drivers; and `examples`, `loader_tests`, `sources` and `rules_md`
the tests by area. Every `#[test]` keeps its function name (52 tests,
same names), and Cargo still builds one test target named `bookspec`.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 10:49:03 -07:00
swaitsandClaude Sonnet 5.5 aa1331c8bd docs: law 39 names its Lean theorems
Law 39 said no Lean theorem was needed because the Books model has no
tax categories. That reasoning was wrong: the law is pure kernel
arithmetic, like Prorate's roundUnit laws, and needs no Books model.
verify/lean/Wanderbooks/Deductible.lean now proves it at any size.

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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 08:14:49 -07:00
swaitsandDeepSeek V4.1 Flash be98b99abb docs: B-32 and verification name the kernel's deductible rounding
B-32's CHOICE now says the category rounding is
`kernel::deductible_amount`, and its Enforced/Checked lines name the two
Kani harnesses and the bridge property. docs/verification.md adds law 39
(the exact sum, rounded once to the cent, never share by share), its
harnesses, the bridge, and the harness table row and the new prove /
prove-slow counts. It records why this law has no Lean model: it is a
report figure's arithmetic, like `discount_max` and `unrecovered_cost`,
not a `Ledger` command or a law about posted entries; the model's Books
has no tax categories, and the arithmetic it would restate is the kernel
function's own definition.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 05:44:59 -07:00
swaitsandClaude Opus 5.5 30bbf9a1ba docs: B-32 names D-67 and its tests; the tax worksheet notes the rounding is decided
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
Review notes on the round-once change: B-32's Status line now lists the
owner's 2026-11-07 CHOICE and its Checked line the two tests that pin
it; the Form 1065 worksheet's two remarks that no rule stated the
rounding now say D-67 settled it (the golden, one account per
category, is unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 12:10:52 -07:00
swaitsandMuse Wonder 1.0 5b1f9d0232 docs: D-67, the tax summary rounds once per category
Record the owner's 2026-11-07 decision in rules.md B-32 and as D-67 in plan/served.md 10.1: a category's deductible amount is the exact sum of its accounts' shares, rounded once to the cent, following B-21's 'round off only the total'.

Co-Authored-By: Muse Wonder 1.0
2026-11-07 12:03:43 -07:00
swaitsandClaude Fable 5.1 b77a25fd7b refactor(bookspec): the specification lives in its own repository (P13 step 6)
bookspec/ (spec, examples, checker, runner, Lean, GnuCash adapter) moves to
https://git.swaits.com/swaits/bookspec, history kept by git subtree split
(public home; CC BY 4.0 for spec/ and examples/, MIT OR Apache-2.0 for the
code). ledger-core and ledger-package depend on bookspec-checker and
bookspec-runner as git dev-dependencies pinned to
74f2853d5f0db0066147c17fed8033cfe3d83a24, and read the examples through
bookspec_checker::examples(). just check still runs every example via
cargo test --workspace. The pin check against docs/spec/sources and the
rules.md id check move into tests/bookspec.rs (they need this repository's
files). The accounting is unchanged: no example or rule moved.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
2026-10-29 16:51:18 -06:00
swaitsandClaude Fable 5.1 4774bd9abd feat(audit): fit the audit tools into the agent surface (P8)
After P5 merged first: a close leads to the audit and the period's
attestation, an audit run to its workpaper and the claims behind it, the
attest tools to the attestations and the CPA package; a refusal for want of
a standing audit is the guard audit_required with books.audit as its
remedy; the audit prompt runs the audit tools. policy.cpa_package_requires_audit,
unset, refuses once the books hold an audit run and warns before, so a
book that has not begun the programme is not stopped from its first handoff
by a rule it has not met; set to refuse, it holds from the start.
bookspec states B-45 (convention) in its checker.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
2026-10-29 16:03:53 -06:00