From 797c41818487244c54f24afbf5efec96eccc47c3 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 9 Nov 2026 01:36:40 -0700 Subject: [PATCH] fix: the last rule citations in program output name bookspec ids The engine's last program-output citations were the retired wanderbooks numbers. Each moves to the bookspec id that states the rule: - B-43 -> BS-entry-5, in the eight evidence-source strings of `Ledger::origin_exemption` and the two golden lines that record them. - B-23 -> BS-ledger-8, in the CPA package README's aging tie-out. - B-38 -> BS-arap-2, in `books.bills_due`'s description. - B-37 -> BS-statement-5, in the project page's contribution note. The old "item 7" was the snapshot presentation in the retired numbering; in BS-statement-5 the figures are item 2 (a project's figures are exactly its tagged lines, net revenue less expenses) and item 4 (no cost is allocated), so the note cites those. None of the strings is stored. The evidence source is computed on every call by `evidence::requirement` from the ledger (`origin_exemption`); the journal records only a draft state's note and a discard's reason (`entry.draft_state_set`, `entry.draft_discarded`), never the gate's source. The CPA README is built on request into the package's bytes and exported for a token; it is never read back. Tool descriptions are compiled into the router. The GUI note is a `const`. So an old book replays unchanged and reports the new text; no compatibility layer is needed. Golden verification: `draft_states_and_evidence_gate.json` changes in exactly two strings, the reversal's and the closing entry's evidence sources. Both are recomputed from the same ledger by the test and compared whole; after the change the test passes against the file, and `git diff` shows no other line moved. The figures, decisions, journal lines and trial balances are untouched, as the hand worksheet `plan/golden-worksheets/draft-states-and-evidence-gate.md` derives. Co-Authored-By: DeepSeek V4.1 Flash --- crates/ledger-core/src/ledger.rs | 18 ++++++++++-------- crates/ledger-gui/src/pages/projects.rs | 2 +- crates/ledger-mcp/src/tools/settlements.rs | 2 +- crates/ledger-package/src/package.rs | 2 +- .../golden/draft_states_and_evidence_gate.json | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/ledger-core/src/ledger.rs b/crates/ledger-core/src/ledger.rs index e5a0c005..62e78825 100644 --- a/crates/ledger-core/src/ledger.rs +++ b/crates/ledger-core/src/ledger.rs @@ -2153,37 +2153,39 @@ impl Ledger { pub(crate) fn origin_exemption(&self, entry: &JournalEntry) -> Option<&'static str> { let id = entry.id(); if entry.reversal_of().is_some() { - return Some("a reversal: its evidence is its original's (B-43, D-47, D-12)"); + return Some("a reversal: its evidence is its original's (BS-entry-5, D-47, D-12)"); } if self.is_closing_entry(id) { - return Some("a period's closing entry: derived from the books (B-43)"); + return Some("a period's closing entry: derived from the books (BS-entry-5)"); } if self.schedule_month_of(id).is_some() { - return Some("a schedule month's posting: the schedule is the evidence (B-43)"); + return Some("a schedule month's posting: the schedule is the evidence (BS-entry-5)"); } if self .asset_runs .values() .any(|runs| runs.iter().any(|r| r.entry == id)) { - return Some("a depreciation run: the asset's schedule is the evidence (B-43)"); + return Some("a depreciation run: the asset's schedule is the evidence (BS-entry-5)"); } match self.entry_origins.get(&id) { Some(crate::evidence::Origin::AssetDisposal) => { - return Some("an asset's disposal: the register is the evidence (B-43)"); + return Some("an asset's disposal: the register is the evidence (BS-entry-5)"); } Some(crate::evidence::Origin::PayrollRemittance) => { - return Some("a payroll tax remittance: the payroll runs are the evidence (B-43)"); + return Some( + "a payroll tax remittance: the payroll runs are the evidence (BS-entry-5)", + ); } None => {} } if (0..entry.lines().len()).any(|i| self.line_docs.contains_key(&(id, i))) { return Some( - "a document's entry (invoice, bill, payment, write-off): the document is the evidence (B-43)", + "a document's entry (invoice, bill, payment, write-off): the document is the evidence (BS-entry-5)", ); } if self.payroll_runs.values().any(|r| r.entry_id == id) { - return Some("a payroll run: the run is the evidence (B-43)"); + return Some("a payroll run: the run is the evidence (BS-entry-5)"); } None } diff --git a/crates/ledger-gui/src/pages/projects.rs b/crates/ledger-gui/src/pages/projects.rs index 77722ee3..bfedd8cb 100644 --- a/crates/ledger-gui/src/pages/projects.rs +++ b/crates/ledger-gui/src/pages/projects.rs @@ -419,7 +419,7 @@ impl Snap { } /// The note on contribution: what it counts and what it leaves out. -pub const CONTRIBUTION_NOTE: &str = "Revenue less this project's direct costs: every expense line tagged to it, fixed and variable alike (what management accounting calls a segment margin, not a variable-cost contribution margin). Company overhead that isn't tagged to a project (rent, software, insurance, the owner's time) isn't counted, so a project in the black can still leave the company in the red. A management-accounting view (rules.md B-37 item 7), not a GAAP figure."; +pub const CONTRIBUTION_NOTE: &str = "Revenue less this project's direct costs: every expense line tagged to it, fixed and variable alike (what management accounting calls a segment margin, not a variable-cost contribution margin). Company overhead that isn't tagged to a project (rent, software, insurance, the owner's time) isn't counted, so a project in the black can still leave the company in the red. A management-accounting view (BS-statement-5 items 2 and 4), not a GAAP figure."; /// The snapshot: a header with where it stands to date and the to date / /// fiscal year switch, then its tiles (`shown`: to date, or for `year`, diff --git a/crates/ledger-mcp/src/tools/settlements.rs b/crates/ledger-mcp/src/tools/settlements.rs index 73959f8e..0efc010c 100644 --- a/crates/ledger-mcp/src/tools/settlements.rs +++ b/crates/ledger-mcp/src/tools/settlements.rs @@ -375,7 +375,7 @@ impl BooksServer { name = "books.bills_due", title = "Bills due", description = described( - "What to pay and when: every open bill due on or before a day (through; omitted: today), due date first, with its vendor, the vendor's invoice number and what it still owes, and the early-payment discount each vendor's terms give (the last day it is open, the most off, and what to pay to take it). by_date is the running total of what falls due through each date, for planning. The figures are read from the bills' ledger lines that stand (B-38).", + "What to pay and when: every open bill due on or before a day (through; omitted: today), due date first, with its vendor, the vendor's invoice number and what it still owes, and the early-payment discount each vendor's terms give (the last day it is open, the most off, and what to pay to take it). by_date is the running total of what falls due through each date, for planning. The figures are read from the bills' ledger lines that stand (BS-arap-2).", ledger_core::calendar::PeriodKind::AsOf ), annotations(read_only_hint = true, open_world_hint = false) diff --git a/crates/ledger-package/src/package.rs b/crates/ledger-package/src/package.rs index 25675141..e7ce1aab 100644 --- a/crates/ledger-package/src/package.rs +++ b/crates/ledger-package/src/package.rs @@ -575,7 +575,7 @@ pub fn build_package( let year_end = NaiveDate::from_ymd_opt(year, 12, 31) == Some(as_of); let include_tins = tins.is_some(); let readme = format!( - "{name} — books package for the CPA\n\nFiscal year to date: {fy_start} through {as_of_s}. {basis} basis.\nKept in wanderbooks: double-entry books from an append-only, hash-chained journal ({seq} events, verified).\n\nStatements (PDF and XLSX): profit and loss, balance sheet, cash flow, {members}tax summary, trial balance.\nLedgers (XLSX): general ledger by account; general journal entry by entry.\nAgings (CSV): ar_aging.csv and ap_aging.csv, one row per open invoice or bill, each ending with a TOTAL line that ties to its control account (B-23). Early-payment discounts are taken by the gross method (A-8); bad debts are written off directly (A-5).\n{iif}{worksheet}{k1}{receipts}{tins}\nThe tax summary maps accounts to return categories; it's a worksheet, not a filing. Questions go to the owners, who can ask their bookkeeping agent to trace any number to its entries and receipts.\n", + "{name} — books package for the CPA\n\nFiscal year to date: {fy_start} through {as_of_s}. {basis} basis.\nKept in wanderbooks: double-entry books from an append-only, hash-chained journal ({seq} events, verified).\n\nStatements (PDF and XLSX): profit and loss, balance sheet, cash flow, {members}tax summary, trial balance.\nLedgers (XLSX): general ledger by account; general journal entry by entry.\nAgings (CSV): ar_aging.csv and ap_aging.csv, one row per open invoice or bill, each ending with a TOTAL line that ties to its control account (BS-ledger-8). Early-payment discounts are taken by the gross method (A-8); bad debts are written off directly (A-5).\n{iif}{worksheet}{k1}{receipts}{tins}\nThe tax summary maps accounts to return categories; it's a worksheet, not a filing. Questions go to the owners, who can ask their bookkeeping agent to trace any number to its entries and receipts.\n", name = company.name, basis = company.basis, members = if company.members.is_empty() { diff --git a/crates/ledger-store/tests/golden/draft_states_and_evidence_gate.json b/crates/ledger-store/tests/golden/draft_states_and_evidence_gate.json index 6e6255bd..38fdc156 100644 --- a/crates/ledger-store/tests/golden/draft_states_and_evidence_gate.json +++ b/crates/ledger-store/tests/golden/draft_states_and_evidence_gate.json @@ -118,7 +118,7 @@ "receipts": 0, "requirement": { "decision": "exempt", - "source": "a reversal: its evidence is its original's (B-43, D-47, D-12)" + "source": "a reversal: its evidence is its original's (BS-entry-5, D-47, D-12)" } } ], @@ -220,7 +220,7 @@ "receipts": 0, "requirement": { "decision": "exempt", - "source": "a period's closing entry: derived from the books (B-43)" + "source": "a period's closing entry: derived from the books (BS-entry-5)" } }, "after_close": {