diff --git a/AGENTS.md b/AGENTS.md index 5f59d273..22372b80 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -218,6 +218,7 @@ clone, with status. Rules: | `docs/architecture.md` | Crate layout, command pattern, dependency rules | | `docs/oracle.md` | How we check correctness: golden files, property tests, fuzzing, cross-checks against other implementations (and who is right) | | `docs/spec/` | Wanderbooks' layer over bookspec: `claims/` (its picks, enforcement, product rules `WB-…`), `rules.md` (the B-n → bookspec-id index only), `sources/` (public-domain authorities vendored verbatim) | +| `docs/spec/claims/` | Wanderbooks' claims on each bookspec rule: the CHOICE picked, where the engine enforces it, which tests check it, and product rules `WB--` | | https://git.swaits.com/swaits/bookspec | Where the rules live (D-68): `rules/` records, `spec/rules/` reading pages, `spec/rules-index.md`; every rule is `BS--` | | `docs/verification.md` | The formal proofs: every accounting law, its Kani harness and Lean theorem, what they found | | `docs/parity.md` | Feature catalog and the non-regression floor | diff --git a/crates/ledger-core/src/kernel/mod.rs b/crates/ledger-core/src/kernel/mod.rs index 39d36030..c392f9b8 100644 --- a/crates/ledger-core/src/kernel/mod.rs +++ b/crates/ledger-core/src/kernel/mod.rs @@ -8,8 +8,8 @@ //! laws it implements hold for books of any size. See //! `docs/verification.md` for which proof covers which law. //! -//! The laws, in the order they appear (each traced to its authority in -//! `docs/spec/rules.md`): +//! The laws, in the order they appear (each traced to its bookspec rule +//! and to wanderbooks' claim in `docs/spec/claims/`): //! //! * a line's signed amount is `+amount` for a debit, `-amount` for a credit //! (BS-entry-2); diff --git a/crates/ledger-core/src/payouts.rs b/crates/ledger-core/src/payouts.rs index 24f9a338..b63ecbbb 100644 --- a/crates/ledger-core/src/payouts.rs +++ b/crates/ledger-core/src/payouts.rs @@ -86,7 +86,7 @@ pub type PayoutPlanLine = (AccountId, Side, Decimal, Option); /// collected; fees debit expense accounts), and the payout reconciles to /// the cent. /// A zero deposit (fees and adjustments ate the sales exactly) has no -/// deposit line: every planned line is positive (BS-entry-2, docs/spec/rules.md). +/// deposit line: every planned line is positive (BS-entry-2). pub fn payout_plan( payout: &Payout, chart: &ChartOfAccounts, diff --git a/crates/ledger-core/src/rules.rs b/crates/ledger-core/src/rules.rs index 381ae12d..dc5b4746 100644 --- a/crates/ledger-core/src/rules.rs +++ b/crates/ledger-core/src/rules.rs @@ -30,7 +30,8 @@ use chrono::NaiveDate; pub struct DatedRule { /// Plain name, e.g. "1099 reporting threshold". pub name: &'static str, - /// Its entry in docs/spec/rules.md, e.g. "BS-1099-1". + /// Its bookspec rule id, e.g. "BS-1099-1" (indexed in docs/spec/rules.md; + /// wanderbooks' claim is in docs/spec/claims/1099.md). pub catalog: &'static str, /// The vendored official text it comes from (a path in this repo, /// for the people who update the rule). diff --git a/crates/ledger-core/tests/model.rs b/crates/ledger-core/tests/model.rs index ad467199..7f0d3862 100644 --- a/crates/ledger-core/tests/model.rs +++ b/crates/ledger-core/tests/model.rs @@ -4,7 +4,8 @@ //! transcribed into the simplest Rust that has the same observable //! behavior: a list of accounts, a list of drafts, an append-only list of //! posted entries, a list of periods, and loops. It is written from the -//! spec (rules.md, the Ledger doc comments), not from ledger.rs. +//! spec (bookspec's rules and `docs/spec/claims/`, the Ledger doc +//! comments), not from ledger.rs. //! //! Random command sequences, weighted toward commands that interact (post //! a draft, reverse a posted entry, close a period with drafts in it, diff --git a/crates/ledger-core/tests/oracle_gnucash.rs b/crates/ledger-core/tests/oracle_gnucash.rs index 86294577..d6b81ddf 100644 --- a/crates/ledger-core/tests/oracle_gnucash.rs +++ b/crates/ledger-core/tests/oracle_gnucash.rs @@ -7,7 +7,8 @@ //! pinned container (bookspec's `gnucash/oracle/`, image //! `bookspec-gnucash-oracle`), and compares every account's //! balance at month ends and random dates, exactly. A difference is a -//! finding to adjudicate from principles (rules.md), never a reason to +//! finding to adjudicate from principles (bookspec's rules and +//! `docs/spec/claims/`), never a reason to //! change wanderbooks to match. //! //! Needs Docker: `just oracle` builds the image and runs this. @@ -283,7 +284,7 @@ fn balances_match_gnucash_on_generated_books() { ); assert!( diffs.is_empty(), - "{} difference(s) with GnuCash; adjudicate each from rules.md:\n{}", + "{} difference(s) with GnuCash; adjudicate each from bookspec's rules (docs/spec/claims/):\n{}", diffs.len(), diffs.join("\n") ); diff --git a/crates/ledger-core/tests/spec_ledger.rs b/crates/ledger-core/tests/spec_ledger.rs index a0303a28..fb1c6168 100644 --- a/crates/ledger-core/tests/spec_ledger.rs +++ b/crates/ledger-core/tests/spec_ledger.rs @@ -1,7 +1,8 @@ //! Spec-derived tests for the `Ledger` command surface. //! //! Written from the spec blocks (GOAL / SOURCE / INVARIANTS / SCENARIOS) in -//! the public interface and from `docs/spec/rules.md`, never from the +//! the public interface and from bookspec's rules (wanderbooks' claims +//! in `docs/spec/claims/`), never from the //! implementation. Every expected value is a literal computed by hand from //! the spec, or a law (a model kept by the test itself). A test whose name //! does not already say its oracle says it in its doc comment. diff --git a/crates/ledger-core/tests/spec_reports.rs b/crates/ledger-core/tests/spec_reports.rs index aae1ff36..6d737ec0 100644 --- a/crates/ledger-core/tests/spec_reports.rs +++ b/crates/ledger-core/tests/spec_reports.rs @@ -1,7 +1,8 @@ //! Spec-derived tests for the reports (`reports.rs`). //! //! Written from the spec blocks (GOAL / SOURCE / INVARIANTS / SCENARIOS) and -//! `docs/spec/rules.md` / `docs/requirements.md` only, never from the +//! bookspec's rules and wanderbooks' claims in `docs/spec/claims/` / +//! `docs/requirements.md` only, never from the //! implementation. Every expected value is either a literal computed by hand //! from the spec or a law (property) that pins the answer without calling the //! function under test to compute it. Where the random-book tests need a diff --git a/crates/ledger-package/src/attention.rs b/crates/ledger-package/src/attention.rs index 30715f15..caa75a04 100644 --- a/crates/ledger-package/src/attention.rs +++ b/crates/ledger-package/src/attention.rs @@ -510,8 +510,8 @@ pub fn find_with( }); } - // Rules set by law that wanderbooks may no longer know (rules.md; - // owner, 2026-10-13): the agent finds the figure from the authority + // Rules set by law that wanderbooks may no longer know (bookspec's + // rules and `docs/spec/claims/`; owner, 2026-10-13): the agent finds the figure from the authority // or asks, confirms it, and passes it explicitly (the handbook's // "Rules that change with the law"); the human reports it upstream. for rule in ledger_core::rules::stale_rules(today) { diff --git a/crates/ledger-package/tests/p3_seams.rs b/crates/ledger-package/tests/p3_seams.rs index 920f21f9..8a68815b 100644 --- a/crates/ledger-package/tests/p3_seams.rs +++ b/crates/ledger-package/tests/p3_seams.rs @@ -1,5 +1,5 @@ //! P3's seams: the same economic fact, computed by two pieces of the -//! engine, agrees (or rules.md says exactly why not). +//! engine, agrees (or bookspec's rules / `docs/spec/claims/` say exactly why not). //! //! One year of fictional books for a two-member LLC (Ana Example and Ben //! Example, 50/50), built through the real [`Store`]: cash and property diff --git a/crates/ledger-store/src/schema.rs b/crates/ledger-store/src/schema.rs index 0c75c2ae..1e9514eb 100644 --- a/crates/ledger-store/src/schema.rs +++ b/crates/ledger-store/src/schema.rs @@ -387,7 +387,7 @@ DROP TABLE asset_depreciation; ALTER TABLE asset_depreciation_v13 RENAME TO asset_depreciation; "#, r#" --- v15: a document keeps no figure of its own (plan P4b S1, D-45; rules.md +-- v15: a document keeps no figure of its own (plan P4b S1, D-45; -- BS-arap-2): what an invoice or bill has been paid, and its status, are read -- from the ledger lines tagged with it, as of any date, and a reversed -- payment no longer counts. The columns that summed its payment events diff --git a/docs/mcp-interface.md b/docs/mcp-interface.md index 50c348e0..121e36b4 100644 --- a/docs/mcp-interface.md +++ b/docs/mcp-interface.md @@ -12,7 +12,7 @@ locked to one assistant. | Crate | Role | Spec | |---|---|---| -| `ledger-core` | the engine: money, entries, the laws; every rule the tools enforce | `docs/spec/rules.md`, `docs/verification.md` | +| `ledger-core` | the engine: money, entries, the laws; every rule the tools enforce | bookspec's rules (`BS--`), `docs/spec/claims/`, `docs/verification.md` | | `ledger-package` | the read-only views shared with the viewer: reports, aging, the CPA package, Needs attention (the one list `books.start` and the viewer both draw) | `docs/architecture.md` | | `ledger-store` | the hash-chained journal (the source of truth), the SQLite projection, the blob store | `docs/receipt-store.md` | | `ledger-mcp` | the books server: the tools, resources and handbook over store + core | this document | diff --git a/docs/spec/README.md b/docs/spec/README.md index 2b3eaee5..4a4269df 100644 --- a/docs/spec/README.md +++ b/docs/spec/README.md @@ -1,8 +1,10 @@ # Specification sources wanderbooks' rules come from documents, not from anyone's memory. This -directory holds the authorities the engine's specs cite (`docs/spec/rules.md` -is the rule catalog), and every spec block in the code carries a `SOURCE:` +directory holds the authorities the engine's specs cite (the rules are +bookspec's `BS--` records; `docs/spec/rules.md` is only the +B-n to bookspec-id index and `docs/spec/claims/` holds wanderbooks' +claims), and every spec block in the code carries a `SOURCE:` line pointing into it. ## The authority stack @@ -15,7 +17,7 @@ layers differ in what they cover and in whether we may copy them: | **Pacioli (1494), Geijsbeek translation (1914)** | The mechanics of double entry: debits equal credits, the trial balance, one money, writing only forward, correcting by opposite entry, closing into capital. No modern standard restates these; they predate every regulator. | Public domain | Vendored verbatim: `sources/pacioli-1494.md` | | **IRS: Internal Revenue Code, Treasury Regulations, publications, form instructions** | Records and supporting documents, retention, accounting periods and methods, information returns (1099), capitalization (de minimis, 12-month rule), partners' capital, tax basis of purchased and contributed property (`sources/irs-partnership-basis.md`), payroll taxes, rounding on returns, return line items for tax categories (`sources/irs-tax-lines.md`) | Public domain (17 U.S.C. §105; IRS.gov's content policy) | Vendored verbatim: `sources/irs-*.md`, `sources/us-public-domain-status.md` | | **File formats: Intuit (QuickBooks Online bank CSV, QuickBooks Desktop IIF), ECMA-376 Office Open XML, Microsoft Excel limits, Avery label sheets** | What `ledger-import` reads and writes: bank/card CSV layouts and signs, IIF journal entries, how XLSX stores numbers and Excel's 15-digit precision, asset-label sheet geometry (Avery 5160) | © Intuit Inc.; © Ecma International; © Microsoft; © Avery Products Corporation | Cited with short quotes, URLs, and hashes: `sources/intuit-bank-csv.md`, `sources/intuit-iif.md`, `sources/xlsx-numbers.md`, `sources/avery-5160.md` | -| **FASB Accounting Standards Codification (ASC)** | Authoritative US GAAP: cash flows (ASC 230), revenue and principal vs agent (ASC 606), foreign currency (ASC 830), credit losses and aging (ASC 326), property and depreciation (ASC 360) | © Financial Accounting Foundation | Cited by paragraph with short quotes only (in `rules.md`; the paragraphs read, with where and when, in `sources/fasb-asc.md` and below) | +| **FASB Accounting Standards Codification (ASC)** | Authoritative US GAAP: cash flows (ASC 230), revenue and principal vs agent (ASC 606), foreign currency (ASC 830), credit losses and aging (ASC 326), property and depreciation (ASC 360) | © Financial Accounting Foundation | Cited by paragraph with short quotes only (in bookspec's rules and `docs/spec/claims/`; the paragraphs read, with where and when, in `sources/fasb-asc.md` and below) | | **FASB Concepts Statement No. 8, Chapter 4 (2021)** | Definitions of the five elements (it replaced Concepts Statement 6) | © Financial Accounting Foundation; non-authoritative | Cited with short quotes only | | **Textbooks (OpenStax *Principles of Accounting, Vol. 1*)** | Conventions no standard states: normal balances, closing-entry mechanics, straight-line depreciation arithmetic | CC BY-NC-SA 4.0 (incompatible with this repo's license) | Cited with short quotes and attribution only | | **Convention or decision** | Where no authority speaks: aging bucket edges, cent rounding among members, closed-period locks | — | Stated as CONVENTION or CHOICE, with who decided and when |