Commit Graph
62 Commits
Author SHA1 Message Date
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
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 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
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 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 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
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 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 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 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 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 Sonnet 5.5 7a1d4a51a8 docs(spec): claims cite the V-D2 tests
WB-entry-5 and WB-entry-6 (the evidence requirement and its exemptions),
WB-ledger-15 (annotations and entry.settles), WB-ledger-10 (approval
rules and renumbering) and WB-ledger-16 (the audit) now name the tests
that check them; the traceability gate resolves each.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 03:08:03 -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 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 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
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
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 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