diff --git a/Cargo.lock b/Cargo.lock index 0480f8df..355d6be1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -788,7 +788,7 @@ dependencies = [ [[package]] name = "bookspec-checker" version = "0.1.0" -source = "git+https://git.swaits.com/swaits/bookspec?rev=c46709379781593139f5a23e8198f027bffaa44b#c46709379781593139f5a23e8198f027bffaa44b" +source = "git+https://git.swaits.com/swaits/bookspec?rev=218b5c89799f6b9df80607e711c29bb559a485ac#218b5c89799f6b9df80607e711c29bb559a485ac" dependencies = [ "chrono", "include_dir", @@ -801,7 +801,7 @@ dependencies = [ [[package]] name = "bookspec-runner" version = "0.1.0" -source = "git+https://git.swaits.com/swaits/bookspec?rev=c46709379781593139f5a23e8198f027bffaa44b#c46709379781593139f5a23e8198f027bffaa44b" +source = "git+https://git.swaits.com/swaits/bookspec?rev=218b5c89799f6b9df80607e711c29bb559a485ac#218b5c89799f6b9df80607e711c29bb559a485ac" dependencies = [ "bookspec-checker", "serde_json", diff --git a/crates/ledger-core/Cargo.toml b/crates/ledger-core/Cargo.toml index c83b1811..a339cbcf 100644 --- a/crates/ledger-core/Cargo.toml +++ b/crates/ledger-core/Cargo.toml @@ -28,8 +28,8 @@ proptest = "1" toml = "1" # The specification lives in its own repository (P13 step 6, D-34, D-65), # pinned to a commit. -bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "c46709379781593139f5a23e8198f027bffaa44b" } -bookspec-runner = { git = "https://git.swaits.com/swaits/bookspec", rev = "c46709379781593139f5a23e8198f027bffaa44b" } +bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "218b5c89799f6b9df80607e711c29bb559a485ac" } +bookspec-runner = { git = "https://git.swaits.com/swaits/bookspec", rev = "218b5c89799f6b9df80607e711c29bb559a485ac" } ledger-package = { path = "../ledger-package" } ledger-import = { path = "../ledger-import" } ledger-store = { path = "../ledger-store" } diff --git a/crates/ledger-core/tests/bookspec/engine.rs b/crates/ledger-core/tests/bookspec/engine.rs index d83d769f..03e22ff3 100644 --- a/crates/ledger-core/tests/bookspec/engine.rs +++ b/crates/ledger-core/tests/bookspec/engine.rs @@ -29,10 +29,85 @@ impl Engine for Books<'_> { } fn claims(&self) -> Claims { - Claims::new( + let mut claims = Claims::new( bookspec_checker::covered_rules() .into_iter() .map(|r| r.id.clone()), - ) + ); + for &(area, n, option) in PICKS { + claims = claims.with_choice(RuleId::new(area, n), option); + } + claims } } + +/// The option wanderbooks picks for each CHOICE record split out of an +/// embedded choice (P14 unit S-C7); each is recorded in +/// `docs/spec/claims/.md` as `**Pick (BS--):**`. +pub(crate) const PICKS: &[(Area, u32, &str)] = &[ + (Area::Entry, 6, "check-when-line-added"), + (Area::Entry, 7, "refuse-rather-than-crash"), + (Area::Entry, 8, "bounds-bind-commands-never-replay"), + (Area::Ledger, 6, "reversible-once"), + (Area::Ledger, 9, "facts-in-the-books"), + (Area::Ledger, 10, "label-only"), + (Area::Ledger, 14, "book-in-the-smallest-unit"), + (Area::Ledger, 15, "child-has-its-parents-type"), + (Area::Ledger, 16, "on-or-after-the-original"), + (Area::Ledger, 17, "reversal-evidence-is-originals"), + (Area::Ledger, 18, "assignment-is-a-fact-in-the-books"), + (Area::Ledger, 19, "refuse-rather-than-renumber"), + (Area::Ledger, 20, "warn-by-default"), + (Area::Ledger, 21, "round-once-on-the-total"), + (Area::Period, 4, "nest-never-partially-overlap"), + (Area::Period, 5, "fiscal-year-to-date-by-default"), + (Area::Statement, 5, "project-is-a-class"), + (Area::Statement, 6, "direct"), + (Area::Statement, 7, "constructive"), + (Area::Statement, 8, "year-through-as-of"), + (Area::Statement, 9, "one-project-per-line"), + (Area::Prepaid, 2, "daily"), + (Area::Prepaid, 3, "start-on-the-first"), + (Area::Prepaid, 4, "minor-unit-for-new-schedules"), + (Area::Partner, 5, "largest-remainder-first-listed"), + (Area::Partner, 6, "cumulative-from-first-close"), + (Area::Partner, 7, "running-split"), + (Area::Partner, 8, "outside-the-books"), + (Area::Partner, 9, "cash-cards-and-financing"), + (Area::Partner, 10, "capital-movement-counted-once"), + (Area::Partner, 11, "books-carrying-amount"), + (Area::Partner, 12, "labelled-cash-default-or-all"), + (Area::Partner, 13, "tax-basis-beside-book"), + (Area::Partner, 14, "running-cumulative"), + (Area::Partner, 15, "contract-is-property-vendor-paid-is-cash"), + (Area::Partner, 16, "close-at-the-change"), + (Area::Partner, 17, "book-amount-with-note"), + (Area::Asset, 3, "tag-and-never-reuse"), + (Area::Asset, 5, "straight-line-by-days"), + (Area::Asset, 6, "lesser-of-value-and-basis"), + (Area::Asset, 7, "books-recorded-amounts"), + (Area::Asset, 8, "register-carries-tax-figures"), + (Area::Asset, 9, "traditional"), + (Area::Tax1099, 2, "refuse-an-unknown-year"), + (Area::Tax1099, 3, "presumed-a-check-ach-or-transfer"), + (Area::Tax1099, 4, "dated-by-the-payments-date"), + (Area::Tax1099, 5, "payees-share-only"), + (Area::Arap, 2, "lines-that-stand"), + (Area::Arap, 5, "direct-write-off"), + (Area::Arap, 7, "due-today-is-current"), + (Area::Arap, 8, "as-of-the-day"), + (Area::Arap, 9, "refuse-a-payment-before-its-document"), + (Area::Arap, 10, "ignore-case-and-spaces"), + (Area::Arap, 11, "reverse-then-plain-entry"), + (Area::Arap, 12, "gross-when-taken"), + (Area::Arap, 13, "gross"), + (Area::Arap, 14, "refuse-with-the-remedy"), + (Area::Format, 3, "plain-ascii-transliterated-and-listed"), + (Area::Format, 4, "cr-lf"), + (Area::Format, 5, "docnum-is-the-entry-id"), + (Area::Format, 6, "everything-through-as-of"), + (Area::Format, 7, "journal-sample-columns"), + (Area::Format, 8, "closes-left-out"), + (Area::Format, 9, "no-customer-or-vendor-name"), + (Area::Format, 10, "refuse-the-entry"), +]; diff --git a/crates/ledger-core/tests/bookspec/rules_md.rs b/crates/ledger-core/tests/bookspec/rules_md.rs index 91daa5e3..5487609c 100644 --- a/crates/ledger-core/tests/bookspec/rules_md.rs +++ b/crates/ledger-core/tests/bookspec/rules_md.rs @@ -25,6 +25,37 @@ pub(crate) fn rules_md_carries_every_id() { } for rule in bookspec_checker::rules().iter() { + if rule.is_retired() { + continue; + } + // Every non-retired CHOICE record wanderbooks claims -- whether + // it carries a B number or was split out of another rule (P14 + // unit S-C7) -- has its pick recorded in its claims file, and + // the engine's adapter declares the same option, which the + // record names, so no CHOICE can go undeclared. + if rule.status == Some(bookspec_checker::Status::Choice) { + let marker = format!("**Pick ({}):** `", rule.id); + let at = all + .find(&marker) + .unwrap_or_else(|| panic!("{} carries its pick in its claims file", rule.id)); + let option = all[at + marker.len()..].split('`').next().unwrap(); + assert!( + rule.record().options.iter().any(|o| o.name == option), + "{}'s pick {option:?} is one of its options", + rule.id + ); + assert!( + engine::PICKS + .iter() + .any(|&(area, n, o)| RuleId::new(area, n) == rule.id && o == option), + "{}'s pick {option:?} is declared in the adapter's claims()", + rule.id + ); + } + if rule.b == 0 { + // A rule born after the B numbering has no row in the index. + continue; + } assert!( index.contains(&format!("| B-{} | `{}` |", rule.b, rule.id)), "rules.md indexes B-{} to {}", diff --git a/crates/ledger-package/Cargo.toml b/crates/ledger-package/Cargo.toml index 4bfcb695..3e31c659 100644 --- a/crates/ledger-package/Cargo.toml +++ b/crates/ledger-package/Cargo.toml @@ -21,7 +21,7 @@ zip = "9.0.1" workspace = true [dev-dependencies] -bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "c46709379781593139f5a23e8198f027bffaa44b" } +bookspec-checker = { git = "https://git.swaits.com/swaits/bookspec", rev = "218b5c89799f6b9df80607e711c29bb559a485ac" } proptest = "1" tempfile = "3" toml = "1" diff --git a/docs/spec/claims/1099.md b/docs/spec/claims/1099.md index 2442d792..e7ea2c5a 100644 --- a/docs/spec/claims/1099.md +++ b/docs/spec/claims/1099.md @@ -14,6 +14,13 @@ Rules: B-19. **Pick:** `refuse-an-unknown-year` and the D-40 options: a threshold the engine does not know is refused, never guessed (CHOICE, the owner, 2026-10-13); a payment from a cash account with no recorded method is presumed a check, ACH or transfer and counts (CHOICE D-40, the owner, 2026-10-20); a shared entry counts only the payee's share (CHOICE, the owner, 2026-10-15); decisions are dated, and each payment takes the decision in force on its reversal chain's first entry's date (CHOICE D-40, the owner, 2026-10-20: "legally this has to be 2 dated statuses"). +**Pick (BS-1099-2):** `refuse-an-unknown-year`, the owner, 2026-10-13. + +**Pick (BS-1099-3):** `presumed-a-check-ach-or-transfer`, the owner, D-40, 2026-10-20. + +**Pick (BS-1099-4):** `dated-by-the-payments-date`, the owner, D-40, 2026-10-20. +**Pick (BS-1099-5):** `payees-share-only`, the owner, 2026-10-15. + **Enforced:** the bucket table is `kernel::payment_bucket` and `kernel::net_buckets`; `kernel::apportion` splits a payee's part across the buckets; `form1099::vendor_1099_report` applies the threshold and the diff --git a/docs/spec/claims/arap.md b/docs/spec/claims/arap.md index 0b7656ff..11ec2997 100644 --- a/docs/spec/claims/arap.md +++ b/docs/spec/claims/arap.md @@ -13,6 +13,11 @@ Rules: B-18, B-38, B-39, B-40, B-41, B-42. **Claims:** yes **Pick:** a document due today is Current, not 1 day past due: CHOICE (the owner, 2026-10-13); an aging as of a day shows only the documents issued by then, less only the payments made by then: CHOICE (the owner, 2026-10-13); a payment never predates its invoice or bill, a real prepayment being a deposit: CHOICE (the owner, 2026-10-13). The bucket edges are the record's. +**Pick (BS-arap-7):** `due-today-is-current`, the owner, 2026-10-13. + +**Pick (BS-arap-8):** `as-of-the-day`, the owner, 2026-10-13. + +**Pick (BS-arap-9):** `refuse-a-payment-before-its-document`, the owner, 2026-10-13. **Enforced:** `arap::aging_bucket`, `Ledger::ar_aging`/`ap_aging` (through `Ledger::doc_state`), `receive_payment`/`pay_bill` @@ -28,6 +33,8 @@ Rules: B-18, B-38, B-39, B-40, B-41, B-42. **Claims:** yes +**Pick (BS-arap-2):** `lines-that-stand`, the owner, 2026-10-23. + **Pick:** `lines-that-stand`: CHOICE (the owner, 2026-10-23, plan D-45: "we kinda need stronger invoice support. Like make it a first class citizen"; hand entries to receivables and payables refused, the owner's answer 5). A control account agreeing with its subledger is the CONVENTION beside it (as B-23, `BS-ledger-8`). The sources are cited and not yet vendored (the Open list in `README.md`). **Enforced:** `ledger_core::arap::{DocRef, DocTag, Movement, DocState, @@ -159,6 +166,7 @@ behind the feature `documents_v2`. **Checked:** **Claims:** yes **Pick:** a vendor's invoice reference is compared after the normalization that drops case and spaces (`Ledger::check_vendor_ref`); the old text names no separate decision for it. +**Pick (BS-arap-10):** `ignore-case-and-spaces`; a vendor's invoice reference is compared after the normalization that drops case and spaces. **Enforced:** `Ledger::next_invoice_number`, `Ledger::check_vendor_ref`, `PartySnapshot::from_party` (the snapshots at issue, D-55); @@ -218,6 +226,9 @@ the viewer `a_numbered_invoice_shows_its_number_terms_bill_to_and_po`. **Claims:** yes **Pick:** `direct-write-off`: CHOICE (the owner, 2026-10-23, plan 8.3.1 A-5: bad debts by the direct write-off method; and 8.3.2: for a small company's receivables a CPA accepts the direct method and notes it, where GAAP prefers an allowance under ASC 326-20). A recovery is not a new movement (plan D-49): the same year, the write-off is reversed; a later year, a plain entry to a bad-debt-recoveries revenue account. +**Pick (BS-arap-5):** `direct-write-off`, the owner, 2026-10-23. + +**Pick (BS-arap-11):** `reverse-then-plain-entry`, plan D-49. **Enforced:** `ledger_core::Ledger::write_off` (and its replay `replay_invoice_write_off`), `LedgerError::{WriteOffOnCashBasis, @@ -280,6 +291,11 @@ leaves the books and the journal unchanged and never panics. **Claims:** yes **Pick:** the gross method for an early-payment discount (the owner, A-8); the processor's fee posted gross (the owner, A-4); D-49's refusal to apportion a discount across a bill's asset lines. ASC 606-10-32-5 to 32-9 are the strict treatment of an expected discount; this company's size makes the gross method immaterial (A-8). The sources are cited and not yet vendored (the Open list in `README.md`). +**Pick (BS-arap-12):** `gross-when-taken`, the owner, A-8. + +**Pick (BS-arap-13):** `gross`, the owner, A-4. + +**Pick (BS-arap-14):** `refuse-with-the-remedy`, plan D-49. **Enforced:** `kernel::settle`, `Ledger::{settle, settlement_lines, check_discount}`, `arap::{Application, Fee, SettleParams, SettlementRow}`, diff --git a/docs/spec/claims/asset.md b/docs/spec/claims/asset.md index e7f242c8..73f6ee4c 100644 --- a/docs/spec/claims/asset.md +++ b/docs/spec/claims/asset.md @@ -14,6 +14,8 @@ Rules: B-15, B-22, B-24, B-25. **Pick:** `straight-line-by-days`: CHOICE (the owner, 2026-10-13; the engineer settled the arithmetic from ASC 360-10-35-4, 2026-10-20): straight line, partial months prorated by days, including a schedule through a mid-month date, with each cumulative figure rounded half away from zero to the currency's minor unit. The tax conventions (half-year, mid-month, mid-quarter) are not applied: they are the CPA's, per IRS Publication 946. +**Pick (BS-asset-5):** `straight-line-by-days`, the owner, 2026-10-13; the engineer settled the arithmetic from ASC 360-10-35-4, 2026-10-20. + **Enforced:** `assets::depreciation_schedule`, `assets::run_amount`, `assets::catch_up_room`, `assets::depreciation_effects`, `kernel::prorated_through`, `kernel::catch_up`, `kernel::true_up`, @@ -117,6 +119,8 @@ None. **Claims:** yes +**Pick (BS-asset-3):** `tag-and-never-reuse`, the owner, 2026-10-15. + **Pick:** `tag-and-never-reuse`: CHOICE (the owner, 2026-10-15): each asset may carry one tag, generated `PREFIX-0001` or the human's own, unique ignoring case and never reused, and the register reconciles to the cost and accumulated depreciation accounts. **Enforced:** `Ledger::set_asset_tag` / `check_asset_tag_for` / @@ -147,6 +151,13 @@ printer makes an Avery 5160 label sheet from the register's tags. **Pick:** `register-carries-tax-figures` and the D-41 options: the register carries the tax figures beside book value (CHOICE, the owner, 2026-10-15); for property a member contributed from personal use, the depreciable basis is the lesser of its fair market value and the member's adjusted basis (the MAY of `BS-asset-4`, taken by analogy to Treas. Reg. §1.168(i)-4(b)(1), which governs a taxpayer converting its own property; the choice is wanderbooks', the CPA to confirm at year end); the §704(c) method is `traditional`, recorded as a choice the CPA confirms; the contributed property's values on the contribution date are the books' recorded amounts (CHOICE D-41, the owner, 2026-10-20). +**Pick (BS-asset-6):** `lesser-of-value-and-basis`, the owner, D-41, 2026-10-20. + +**Pick (BS-asset-7):** `books-recorded-amounts`, the owner, D-41, 2026-10-20. + +**Pick (BS-asset-8):** `register-carries-tax-figures`, the owner, 2026-10-15; D-41, 2026-10-20. +**Pick (BS-asset-9):** `traditional`, the owner, D-41, 2026-10-20; recorded as a choice the CPA confirms. + **Enforced:** `kernel::basis_figures` (Kani `basis_figures_laws`), `AssetBasis::check` (a purchase takes no contribution facts; a contribution needs the adjusted basis and the fair market value, each diff --git a/docs/spec/claims/entry.md b/docs/spec/claims/entry.md index fde6a60f..c5aa77df 100644 --- a/docs/spec/claims/entry.md +++ b/docs/spec/claims/entry.md @@ -10,6 +10,8 @@ Rules: B-1, B-2, B-21, B-28, B-43. **bookspec:** `BS-entry-1` +**Pick (BS-entry-6):** `check-when-line-added`, the owner, 2026-10-13 + **Claims:** yes **Pick:** a line's account must exist and take postings when the line is added to a draft, not only when the entry posts: CHOICE (the owner, 2026-10-13). @@ -60,6 +62,10 @@ None. **bookspec:** `BS-entry-4` +**Pick (BS-entry-7):** `refuse-rather-than-crash`, the owner, 2026-10-16 + +**Pick (BS-entry-8):** `bounds-bind-commands-never-replay`, the owner, 2026-10-17 + **Claims:** yes **Pick:** the bounds are bookspec's (dates 0001-01-01 through 9999-12-31, an amount at most `kernel::MAX_LINE_AMOUNT` = 1,000,000,000,000,000, scale at most `MAX_LINE_SCALE` = 10), and one run of the recurring entries creates at most 1,000 drafts (`MAX_RECURRING_RUN`). Provenance: CHOICE (P0 review round 3, 2026-10-16, finding S1: the @@ -178,6 +184,7 @@ pinned; every tool over every old book). **bookspec:** `BS-entry-5` + **Claims:** partly (bookspec's record states the evidence gate's principle, the draft state as a note and the discard; the gate's function, the policy settings, the states' names and the surfaces are wanderbooks product, below) **Pick:** reversals stay posted and need no evidence of their own, their evidence being their original's: CHOICE D-47 (owner-adopted recommendation, 2026-10-26; stated in `BS-ledger-7`'s status note, and in B-20's claims). A draft's state as a note that moves no figure, and discarding a draft rather than posting and reversing it, are the CONVENTIONs of the record. diff --git a/docs/spec/claims/format.md b/docs/spec/claims/format.md index 00606017..89956646 100644 --- a/docs/spec/claims/format.md +++ b/docs/spec/claims/format.md @@ -239,6 +239,21 @@ unless another class's own name is the same ignoring case (the P4 follow-ups' review, finding 4, 2026-10-22: before, all the classes whose names matched were renamed). +**Pick (BS-format-3):** `plain-ascii-transliterated-and-listed`, the owner, 2026-10-20, D-36. + +**Pick (BS-format-4):** `cr-lf`, the owner, 2026-10-20, D-36. + +**Pick (BS-format-5):** `docnum-is-the-entry-id`, the owner, 2026-10-20, D-36. + +**Pick (BS-format-6):** `everything-through-as-of`, the owner, 2026-10-20, D-36. + +**Pick (BS-format-7):** `journal-sample-columns`, the owner, 2026-10-20, D-36 (CHOICE). +**Pick (BS-format-8):** `closes-left-out`, the owner, 2026-10-20, D-36. + +**Pick (BS-format-9):** `no-customer-or-vendor-name`, the owner, 2026-10-20, D-36. + +**Pick (BS-format-10):** `refuse-the-entry`, the owner, 2026-10-20, D-36. + **Pick:** `no-customer-or-vendor-name`: CHOICE (open risk). The IIF writes no NAME on a line to accounts receivable or payable, though Intuit's staff say such a line requires one: no Intuit source says what an IIF journal import diff --git a/docs/spec/claims/ledger.md b/docs/spec/claims/ledger.md index b1d30aed..e5dc5053 100644 --- a/docs/spec/claims/ledger.md +++ b/docs/spec/claims/ledger.md @@ -10,6 +10,8 @@ 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, B-45. **bookspec:** `BS-ledger-1` +**Pick (BS-ledger-14):** `book-in-the-smallest-unit`, the owner, 2026-10-13 + **Claims:** yes **Pick:** a foreign line is booked in the base currency's smallest unit (ISO 4217 minor units, `sources/iso-4217.md`), half away from zero: CHOICE (the owner, 2026-10-13), after the GnuCash cross-check found wanderbooks kept $108.34567 where GnuCash booked $108.35. Lines booked before then replay as booked (WB-entry-1). @@ -38,6 +40,8 @@ None. **bookspec:** `BS-ledger-2` +**Pick (BS-ledger-15):** `child-has-its-parents-type`, the owner, 2026-10-13 + **Claims:** yes **Pick:** a child account has its parent's type: CHOICE (the owner, 2026-10-13). @@ -92,6 +96,8 @@ and never called corrupt (statement 4). **Checked:** Lean `Step.extends`, **bookspec:** `BS-ledger-5` +**Pick (BS-ledger-16):** `on-or-after-the-original`, the owner, 2026-11-08, wanderbooks D-73 + **Claims:** yes **Pick:** none (AUTHORITY). @@ -110,6 +116,8 @@ None. **Claims:** yes +**Pick (BS-ledger-6):** `reversible-once`, the owner, 2026-10-13. + **Pick:** `reversible-once`: CHOICE (the owner, 2026-10-13). **Enforced:** `Ledger::check_reversal`. **Checked:** @@ -123,6 +131,8 @@ None. **bookspec:** `BS-ledger-7` +**Pick (BS-ledger-17):** `reversal-evidence-is-originals`, D-47, the owner, 2026-10-26 + **Claims:** partly (the engine does not enforce it; the receipt policy of the tool layer does) **Pick:** a reversal's evidence is its original's (a reversal needs no evidence of its own): CHOICE D-47 (the owner, 2026-10-26; options: a reversal's evidence is its original's / a reversal needs its own). The rest is AUTHORITY; a procedural rule. @@ -137,6 +147,10 @@ None. **bookspec:** `BS-ledger-8` +**Pick (BS-ledger-18):** `assignment-is-a-fact-in-the-books`, the owner, 2026-10-15 + +**Pick (BS-ledger-19):** `refuse-rather-than-renumber`, the owner, 2026-10-13 + **Claims:** yes **Pick:** the assignment of a role to an account is journaled, so replay never depends on a setting outside the journal: CHOICE (the owner, 2026-10-15); the engine refuses a role account that is not postable or of the role's type rather than renumber the chart: CHOICE (the owner, 2026-10-13). Receivables and payables are different (B-38, 2026-10-23): their documents read their figures from their lines. @@ -164,6 +178,8 @@ frees its code); the control guard and `Ledger::control_check` (B-38). **Claims:** yes +**Pick (BS-ledger-9):** `facts-in-the-books`, the owner, 2026-10-16. + **Pick:** `facts-in-the-books`: CHOICE (plan/served.md I-3, owner decisions of 2026-10-16: "the journal holds all books state"; light governance: decisions are recorded with who made them and when, not as paperwork). IRS Pub. 538 and the rules of B-1 to B-28 say what each setting means. **Enforced:** `ledger_core::settings` (`check`, `Settings::check_changes`, @@ -210,6 +226,8 @@ checked to change no figure or entry; **Claims:** yes +**Pick (BS-ledger-10):** `label-only`, the owner, 2026-10-20. + **Pick:** `label-only`: CHOICE (the owner, `plan/served.md` 4.9 and P3 "Settled in design", 2026-10-20: "a new account named like a sibling (ignoring capitals), or holding a nine-digit number, is refused"). Posted is forever (B-8) stands behind it, and Rev. Proc. 98-25 §5.01 (`sources/irs-records.md`) for keeping the old name. The nine-digit refusal is B-26's: every report prints a name. The 200-character bound is `account::MAX_ACCOUNT_NAME`, the bound of the company's own name. **Enforced:** `Ledger::rename_account` / `check_rename_account`, @@ -245,6 +263,10 @@ bookspec `examples/rename-changes-no-amount.toml`. **bookspec:** `BS-ledger-11` +**Pick (BS-ledger-20):** `warn-by-default`, the owner, 2026-10-20 + +**Pick (BS-ledger-21):** `round-once-on-the-total`, the owner, 2026-11-07, D-67 + **Claims:** yes **Pick:** warn versus refuse: CHOICE (Pub. 583: "the law does not require any specific kind of records"; the owner, 2026-10-20: warn by default, header accounts exempt, the first company set to refuse at the P3 cutover). A category's deductible amount rounds once, on the category total: CHOICE (the owner, 2026-11-07, D-67). The arithmetic is `kernel::deductible_amount`, so Kani proves the one rounding and the bridge carries it to `Decimal`. diff --git a/docs/spec/claims/partner.md b/docs/spec/claims/partner.md index 36b90a81..3318e8b4 100644 --- a/docs/spec/claims/partner.md +++ b/docs/spec/claims/partner.md @@ -14,6 +14,15 @@ Rules: B-13, B-26, B-35, B-36. **Pick:** a share is rounded to the base currency's minor unit by largest remainder, a tied odd unit to the member the count's first close listed first (the owner, 2026-10-13; closes made before then replay with the last member absorbing it); members closes are counted cumulatively from the company's first close (D-10, 2026-10-16); the statement of members' equity splits unclosed earnings the same running way (D-38, 2026-10-20); a prepaid service contract credited straight to capital is contributed property, while a prepaid service a member paid a vendor for on the company's behalf, booked through Due to Shareholders, is cash (the owner, 2026-10-15); a period closes at the shares in force at the close. +**Pick (BS-partner-5):** `largest-remainder-first-listed`, the owner, 2026-10-13. + +**Pick (BS-partner-6):** `cumulative-from-first-close`, the owner, D-10, 2026-10-16. + +**Pick (BS-partner-7):** `running-split`, the owner, D-38, 2026-10-20. +**Pick (BS-partner-15):** `contract-is-property-vendor-paid-is-cash`, the owner, 2026-10-15. + +**Pick (BS-partner-16):** `close-at-the-change`, the owner, 2026-10-16. + **Enforced:** `CloseTo::Members`, `CloseTo::MembersCumulative`, `Ledger::members_regime`, `Regime::allocate`, `periods::allocate_cumulative`, `kernel::apportion_cumulative`, @@ -99,6 +108,9 @@ journal (the owner, 2026-10-15); any party may have its TIN in the vault, whatever its roles (the owner, 2026-10-15); a party's last four is its TIN facts', else its W-9 facts'. +**Pick (BS-partner-8):** `outside-the-books`, the owner, 2026-10-15. + + **Enforced:** `crate::parties` (has_full_tin, check_text, W9Facts::check, W4Facts::check), `Ledger::add_party`, `update_party`, `set_party_role`, `set_party_w9`, `set_party_w4`, `set_party_tin` (TinFacts::check; TIN and @@ -292,6 +304,14 @@ owner, 2026-10-20); property distributed counts at the books' carrying amount; party totals take basis cash by default, or all, always labelled. +**Pick (BS-partner-9):** `cash-cards-and-financing`, the owner, 2026-10-20. + +**Pick (BS-partner-10):** `capital-movement-counted-once`, the owner, 2026-10-15 and 2026-10-20. + +**Pick (BS-partner-11):** `books-carrying-amount`, the owner, 2026-10-20. + +**Pick (BS-partner-12):** `labelled-cash-default-or-all`, the owner, 2026-10-20. + **Enforced:** `kernel::party_target`, `kernel::reverse_target`, `shares::{target, split, resolve}`, `parties::{flow, money_accounts, card_accounts, MoneyAccounts::for_parties, activity_with, Activity::totals, @@ -376,6 +396,11 @@ contributed to a prepaid account with no fixed asset for it enters at its book amount, with a note (P3 review, 2026-10-21; the CPA to confirm). +**Pick (BS-partner-13):** `tax-basis-beside-book`, the owner, D-41, 2026-10-20. + +**Pick (BS-partner-14):** `running-cumulative`, the owner, D-38's rule applied 2026-10-22. +**Pick (BS-partner-17):** `book-amount-with-note`, the owner, P3 review, 2026-10-21. + **Enforced:** `ledger_core::tax_capital::tax_basis_capital`; `ledger-package` `k1_tax` (`k1-tax-basis-capital.csv` in the CPA package); the odd cents, `ledger_core::tax_capital::RunningSplit` on diff --git a/docs/spec/claims/period.md b/docs/spec/claims/period.md index 682e81f4..386ac05d 100644 --- a/docs/spec/claims/period.md +++ b/docs/spec/claims/period.md @@ -25,6 +25,8 @@ decision, D-73, 2026-11-08). **Checked:** Kani **bookspec:** `BS-period-2` +**Pick (BS-period-4):** `nest-never-partially-overlap`, the owner, 2026-10-13 + **Claims:** yes **Pick:** periods nest and never partially overlap (the owner, 2026-10-13). @@ -51,6 +53,8 @@ untouched. **bookspec:** `BS-period-3` +**Pick (BS-period-5):** `fiscal-year-to-date-by-default`, the owner, 2026-10-20 + **Claims:** partly (the bookspec record states the one default rule; the surfaces it binds are wanderbooks product, below) **Pick:** a report asked for without dates covers this fiscal year so far, everywhere (the owner, 2026-10-20, `plan/served.md` P3 "Settled in design": "a report asked for without dates covers this fiscal year so far, everywhere, and an account's register opens on it with 'Show all dates' one click away"). diff --git a/docs/spec/claims/prepaid.md b/docs/spec/claims/prepaid.md index 36c8f83c..c41c9010 100644 --- a/docs/spec/claims/prepaid.md +++ b/docs/spec/claims/prepaid.md @@ -10,6 +10,12 @@ Rules: B-16. **bookspec:** `BS-prepaid-1` +**Pick (BS-prepaid-2):** `daily`, the owner, 2026-10-20, D-11 and D-37 + +**Pick (BS-prepaid-3):** `start-on-the-first`, the owner, 2026-10-20, D-37 + +**Pick (BS-prepaid-4):** `minor-unit-for-new-schedules`, the owner, 2026-11-08, D-72 + **Claims:** yes **Pick:** new schedules spread by the day (`daily`), the owner, D-11 confirmed in D-37, 2026-10-20; an equal-months schedule starts on the 1st of a month for prepaid expenses and deferred revenue alike (the owner, D-37, 2026-10-20); new monthly-even schedules round to the currency's minor unit (the owner, D-72, 2026-11-08). diff --git a/docs/spec/claims/statement.md b/docs/spec/claims/statement.md index f3ffaa28..85000e1e 100644 --- a/docs/spec/claims/statement.md +++ b/docs/spec/claims/statement.md @@ -30,6 +30,10 @@ Lean `trial_balance_iff`, `Reachable.trial_balance`, **bookspec:** `BS-statement-3` +**Pick (BS-statement-6):** `direct`, the owner, 2026-10-20 + +**Pick (BS-statement-7):** `constructive`, the owner, 2026-10-20, D-42 + **Claims:** partly (bookspec's record states rules 1-12; the picks and the product surface are below) **Pick:** the direct method; an entry's cash allocated to its sections in the order operating, investing, financing (CONVENTION, the ASC silent, disclosed); within a section, the cash split among its kinds in the order the rest of the section's kinds, interest received, interest paid (CONVENTION, as the engine splits it); what a member or a lender pays or receives for the company presented as constructive cash, borrowed (or contributed) and spent (the owner, D-42, 2026-10-20, revising D-35's first point); a payment shared between a government and others split by their resolved shares, the government's part rounded half to even to the base currency's places and the rest exact (CONVENTION); payroll entries keep their (d) class whoever they name (CONVENTION). @@ -152,6 +156,8 @@ with `books.close_period`, whose entries are never in the statement. **bookspec:** `BS-statement-4` +**Pick (BS-statement-8):** `year-through-as-of`, the owner, 2026-10-20, D-36 + **Claims:** partly (bookspec's record states the as-of principle and the calendar-year counting; the CPA package itself is wanderbooks product, below) **Pick:** the 1099 worksheet stops at as_of too (the owner, 2026-10-20, plan D-36). @@ -207,8 +213,12 @@ given no accounts, uses the settings', as a package given none does. **bookspec:** `BS-statement-5` +**Pick (BS-statement-9):** `one-project-per-line`, the owner, 2026-10-22, D-43 + **Claims:** partly (bookspec's record states the class, the figures, on-spec and document-line rules; the project facts and the snapshot presentation are wanderbooks product, below) +**Pick (BS-statement-5):** `project-is-a-class`, the owner, 2026-10-21. + **Pick:** a project is a class (the owner, 2026-10-21: "a Projects page that treats a class as a project ... Projects are entities too and can have name, description, whatever other metadata you think they should have"; the convention `link-to-projects` in the books: "whenever applicable, we link things to [projects]"); an invoice's or bill's lines take a project, each line one or none (the owner, 2026-10-22, plan D-43). **Enforced:** `ledger_core::classes::{ProjectFacts, ProjectStatus, diff --git a/plan/p14-bookspec.md b/plan/p14-bookspec.md index eb12bd05..25a2de7d 100644 --- a/plan/p14-bookspec.md +++ b/plan/p14-bookspec.md @@ -75,12 +75,13 @@ workers have been faster). | **X-H0** | Split the 4,647-line adapter `crates/ledger-core/tests/bookspec.rs` into modules, no behaviour change | none | `crates/ledger-core/tests/bookspec/**` | S-M | | **X-H1** | Schema additions for the missing examples (balance sheet, general ledger, tax summary, 1099 worksheet, aging, payments, drafts and evidence, refused input); and examples for every CHOICE record on `rules/allow-no-example.txt` (the EM, 2026-11-08, revised: every embedded CHOICE becomes its own record now so an engine can declare a pick for it; a record's examples must genuinely exercise it, an example is never linked to a choice it doesn't depend on, so the CHOICEs no example can show yet go on the allow-list, whose cap is raised once for them, from 9, and only shrinks after; X-H1/X-H2 work it down. Among them, from S-C7b's `s-c7b-noexample`: partner prepaid-contract, shares-in-force, prepaid basis; asset §704(c) method; 1099 payee's share; arap due-today, as-of reading, payment before its document, vendor reference compare, recovery form, gross discount, gross fee, discount apportioning; format closing entries, the customer/vendor NAME, the two-A/R refusal; and from S-C7a the records no example exercises: BS-entry-6..8, BS-ledger-14, -17, -18, -19, -21, BS-period-4, BS-prepaid-4, subject to its review) | S-A, X-H0 | bookspec `checker/src/schema.rs`; the adapter | L | | **X-H2** | Examples from the 2026-11-07 goldens, each from its worksheet | X-H1 (4 need nothing) | bookspec `examples/*.toml` | M | -| **X-I** | Per-rule coverage in the runner with a floor (stated rules with an example never decrease) | S-A, X-H2 | bookspec `runner/`, `checker/tests/coverage.rs` | S-M | +| **X-I** | Per-rule coverage in the runner with a floor (stated rules with an example never decrease); a CI step, like `scripts/parity-floor.sh`, that fails when `rules/ids-issued.txt` loses a line or the allow-list grows against the base commit (the in-tree checks can't see a record and its ids-issued line deleted together) | S-A, X-H2 | bookspec `runner/`, `checker/tests/coverage.rs` | S-M | | **X-J** | wanderbooks traceability gate: every claimed BS id has an enforcement site and a test, every law a Lean theorem, every CHOICE a declared pick, every kernel function a Kani harness, a bridge property and a law | S-D, S-E, L-F2 | `crates/ledger-core/tests/traceability.rs`, `docs/spec/claims/**` | M | | **X-K2** | Profiles (core, documents, partners, us-tax, formats) and an engine builder's guide; the hard-coded accounts become setup keys | S-A, X-H1 | bookspec `checker/src/{engine,schema}.rs`, `spec/00-model.md` | M | | **X-O** | hledger as a second oracle: a pinned container (official static 1.52.4, sha256 in the Dockerfile), a bookspec engine adapter, and wanderbooks' random-book differential beside GnuCash's (task C; `plan/kernel-sweep-audit.md` section 4) | S-K1 | bookspec `hledger/**`; wanderbooks `tests/oracle_hledger.rs`, `justfile` | M | | **K-U0** | Kernel and proofs into modules (`kernel/`, `proofs/`, `tests/kernel_bridge/`), `_kani` updated, `just prove` unchanged | none | `crates/ledger-core/src/{kernel,proofs}/**`, `tests/kernel_bridge/**`, `justfile` | S | | **K-U1..U9** | The sweep (`plan/kernel-sweep-audit.md` section 3), in value order: U1 FX, U3 shares (six copies to one; legacy replay policies only named, never changed), U2 rounding, U5 schedules (D-72), U4 totals (the raw-operator panic class), U6 ratios, U7 payroll, U8 control and aging, U9 display rounding. Each: kernel functions, Kani, bridge, its law in bookspec's Lean, its rule cited by BS id | K-U0; Lean laws after L-F2 | its own `kernel/.rs`, `proofs/.rs`, bridge module, call sites | S-M each | +| **K-U10** | `impl Amount for Decimal`'s `checked_add` (and its siblings) exact at the edge: `rust_decimal` rounds dust away within one unit of `Decimal::MAX` (`MAX + 0.4` gives `Some(MAX)`), breaking the kernel's exact-or-None contract (found by K-U4, 2026-11-08; pinned by the canary `finding_decimal_add_rounds_dust_at_the_edge`): refuse a sum whose result scale fell below the operands'; after the sweep units merge (the file is shared) | K-U4 merged | `kernel/entries.rs`, the canary, the bridge | S | | **V-D** | Coverage report and floor; `rust_decimal` checked against exact rationals (task D) | none | in flight 2026-11-08 | S | ## Order diff --git a/plan/served.md b/plan/served.md index fff9056a..3895d011 100644 --- a/plan/served.md +++ b/plan/served.md @@ -2196,6 +2196,8 @@ The owner decisions of 2026-10-16 (at the top of this document) replace the form | D-71 | Product rules and licence (owner, 2026-11-08, the question tool: "Generic in bookspec, rest WB-n"; "Yes, CC BY 4.0") | **bookspec keeps only the general principle of a product rule, inside an engine-independent rule; wholly product ids (`BS-format-1`, `BS-ledger-12`, `BS-ledger-13`) are retired, never reused; wanderbooks keeps its product rules as WB-n. Rule text moved from rules.md is CC BY 4.0 in bookspec.** | | D-72 | Amortization rounding by currency (owner, 2026-11-08, the question tool: "Version the rule") | **New monthly-even schedules round to the currency's minor unit (was 2 places for every currency, wrong for JPY and KWD); schedules written before the format feature replay the cent rule, so nothing journaled moves.** | | D-73 | A reversal's date (owner, 2026-11-08, the question tool: "Every reversal on or after") | **Every reversal MUST be dated on or after the entry it reverses, for every kind of entry (was enforced only for document reversals and schedule runs): a correction comes after what it corrects. bookspec BS-ledger-5 states it; the engine's `check_reversal` refuses an earlier date; the Lean model's `reverse` step requires it (unit L-G1).** Found when the Lean model was made executable. In the same pass, a close with nothing to close was confirmed to post no entry and still close the period (the engine's INVARIANT 5; an entry needs two lines), and BS-period-1 is worded to say so. | +| D-74 | A refusal when several rules are broken (owner, 2026-11-08, the question tool: "Any broken rule counts") | **When one command breaks several rules, an engine may refuse it with any rule it actually breaks; bookspec's examples test one broken rule at a time, and the Lean-model differential test (L-G5) checks that the engine's reason is one of the rules the command breaks.** Found by L-G5: the engine checks each line as it is added, the model checks the date and the whole entry first, so a command with two faults was refused with different words. | +| D-75 | Foreign amounts and FX rates are bounded (owner, 2026-11-08, the question tool: "Cap them at 10 places") | **A new line's foreign amount and its FX rate take at most 10 decimal places each, as a base amount already does (B-28's bounds; never on replay), so foreign × rate always fits a Decimal exactly and the booked base amount is rounded once.** Found by the K-U1 review: with a 26-place foreign amount, rust_decimal rounded the product to 28 places before the engine rounded it to the cent, booking a cent the exact product doesn't reach. | ### 10.2 Deferred diff --git a/verify/lean/lake-manifest.json b/verify/lean/lake-manifest.json index 797d8506..20c272cd 100644 --- a/verify/lean/lake-manifest.json +++ b/verify/lean/lake-manifest.json @@ -5,10 +5,10 @@ "type": "git", "subDir": "lean", "scope": "", - "rev": "c46709379781593139f5a23e8198f027bffaa44b", + "rev": "218b5c89799f6b9df80607e711c29bb559a485ac", "name": "bookspec", "manifestFile": "lake-manifest.json", - "inputRev": "c46709379781593139f5a23e8198f027bffaa44b", + "inputRev": "218b5c89799f6b9df80607e711c29bb559a485ac", "inherited": false, "configFile": "lakefile.toml"}], "name": "wanderbooks", diff --git a/verify/lean/lakefile.toml b/verify/lean/lakefile.toml index 0fb79715..b1b98eb2 100644 --- a/verify/lean/lakefile.toml +++ b/verify/lean/lakefile.toml @@ -9,7 +9,7 @@ packagesDir = ".lake/packages" [[require]] name = "bookspec" git = "https://git.swaits.com/swaits/bookspec" -rev = "c46709379781593139f5a23e8198f027bffaa44b" +rev = "218b5c89799f6b9df80607e711c29bb559a485ac" subDir = "lean" [[lean_lib]]