refactor: rule references cite bookspec ids

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

Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
swaitsandMuse Wonder 1.0 committed 2026-11-08 19:40:22 -07:00
1 parent 7a177a3cfc
commit 489360f598
221 files changed
+1706 -1580

No files matched your search

+6 -6
View File
@@ -14,7 +14,7 @@ use rust_decimal::Decimal;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Rounding {
/// Nearest multiple; an exact half rounds away from zero
/// (2.5 -> 3, -2.5 -> -3). The FX booking rule (B-3).
/// (2.5 -> 3, -2.5 -> -3). The FX booking rule (BS-ledger-1).
HalfAwayFromZero,
/// Nearest multiple; an exact half rounds to the even multiple
/// (2.5 -> 2, 3.5 -> 4). Rust's `Decimal::round_dp`.
@@ -30,12 +30,12 @@ pub enum Rounding {
/// ```text
/// GOAL: one rounding primitive: money is rounded to a whole multiple of a
/// unit, once, with the mode named at the call.
/// SOURCE: docs/spec/claims/ledger.md B-3 (a ledger in one money holds no
/// SOURCE: docs/spec/claims/ledger.md BS-ledger-1 (a ledger in one money holds no
/// fractions of its smallest unit; FX books the base currency's
/// minor unit, half away from zero), claims/entry.md B-21 (exact
/// minor unit, half away from zero), claims/entry.md BS-entry-3 (exact
/// amounts in the books; round only where a rule says to), and
/// claims/ledger.md B-32; the call sites' own rules (B-13, B-14,
/// B-15, B-16, B-19, B-35, B-36, B-37); owner decision D-69 (the
/// claims/ledger.md BS-ledger-11; the call sites' own rules (BS-partner-1, BS-statement-3,
/// BS-asset-1, BS-prepaid-1, BS-1099-1, BS-partner-3, BS-partner-4, BS-statement-5); owner decision D-69 (the
/// laws live once, in bookspec's Lean).
/// INVARIANTS:
/// 1. Some(r) is a whole multiple of step: r = n x step for an integer
@@ -96,7 +96,7 @@ pub fn round_places(amount: Decimal, places: u32, mode: Rounding) -> Option<Deci
/// `amount` rounded to whole `currency` minor units in `mode`: cents for
/// USD, whole yen for JPY, thousandths for KWD. A currency ISO 4217 gives
/// no minor unit (gold, SDRs) is returned exactly, as the FX booking rule
/// has always done (B-3).
/// has always done (BS-ledger-1).
pub fn round_minor(amount: Decimal, currency: Currency, mode: Rounding) -> Option<Decimal> {
match currency.minor_units() {
Some(places) => round_places(amount, places, mode),