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>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-11-09 07:33:54 -07:00
commit 045e70bb0d
17 files changed
+5422 -26

No files matched your search

+19 -7
View File
@@ -1,4 +1,4 @@
//! The audit's statements checks (plan P8; BS-ledger-13): the books,
//! The audit's statements checks (plan P8; WB-ledger-16): the books,
//! read as an auditor would, through a date, as a list of findings.
//!
//! ```text
@@ -481,24 +481,36 @@ fn closes(ledger: &Ledger, through: NaiveDate) -> Vec<Finding> {
continue;
}
if let Some((_, split)) = ledger.member_close_split(p.id) {
out.extend(check_split(p.id, &p.name, &split, unit));
let trued_up = ledger.member_close_trued_up(p.id).unwrap_or(false);
out.extend(check_split(p.id, &p.name, &split, unit, trued_up));
}
}
out
}
/// One close's members: each one's running total of the closes must be
/// within a minor unit of its exact share (the cumulative rule,
/// `kernel::apportion_cumulative`).
/// under a minor unit from its exact share (the cumulative rule,
/// `kernel::apportion_cumulative`; BS-partner-1 statement 5).
///
/// `trued_up` says the count has had a close under the cumulative rule
/// that posted an entry ([`crate::Ledger::member_close_trued_up`]). Until
/// then the count may still carry the rounding of closes made under the
/// older rules, which the first such close trues up (BS-partner-1
/// statement 6; WB-partner-1), so only a drift beyond a unit is raised.
/// Once trued up, a drift of a unit or more is raised: the bound is strict.
pub fn check_split(
period: u64,
name: &str,
split: &[crate::periods::MemberSplit],
unit: Decimal,
trued_up: bool,
) -> Vec<Finding> {
split
.iter()
.filter(|m| (m.running - m.exact).abs() > unit)
.filter(|m| {
let drift = (m.running - m.exact).abs();
if trued_up { drift >= unit } else { drift > unit }
})
.map(|m| {
Finding::new(
"close_split_drifts",
@@ -670,7 +682,7 @@ fn settings_problems(problems: &[String]) -> Vec<Finding> {
}
// ---------------------------------------------------------------------------
// Scope, method and the attestation bar (BS-ledger-13; D-9)
// Scope, method and the attestation bar (WB-ledger-16; D-9)
// ---------------------------------------------------------------------------
/// What an audit covers.
@@ -763,7 +775,7 @@ impl Effort {
}
/// How an attestation was made, as the client says (self-reported: the
/// books record the claim, never prove it; BS-ledger-13).
/// books record the claim, never prove it; WB-ledger-16).
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
pub struct Method {
/// The model that checked, as it names itself.
+26
View File
@@ -3991,6 +3991,7 @@ impl Ledger {
closed: Decimal::ZERO,
given: vec![Decimal::ZERO; members.len()],
order: Vec::new(),
trued_up: false,
};
for p in closed {
let Some(m) = &p.members_closed else {
@@ -4000,6 +4001,8 @@ impl Ledger {
break;
}
regime.since_seq = p.close_seq;
regime.trued_up |= matches!(m.rule, periods::MemberRule::Cumulative { .. })
&& p.closing_entry.is_some();
regime.order.clone_from(&m.members);
regime.closed += m.net;
for ((capital, _), part) in m.members.iter().zip(&m.parts) {
@@ -4044,6 +4047,24 @@ impl Ledger {
Some((since_seq, split))
}
/// Whether a closed members period's count has been trued up by the
/// close or an earlier one of its count: a close under the cumulative
/// rule that posted an entry has run the first true-up of the rounding
/// of closes under earlier rules (WB-partner-1), so each member's
/// running total is then strictly under one minor unit from exact
/// (BS-partner-1 statement 5). Before that, a count that holds closes
/// from the older rules may still be a unit or more away. `None` for a
/// period not closed to members.
pub fn member_close_trued_up(&self, id: PeriodId) -> Option<bool> {
let p = self.periods.get(&id)?;
let m = p.members_closed.as_ref()?;
let seq = p.close_seq?;
Some(
self.regime_where(&m.members, |q| q.close_seq <= Some(seq))
.trued_up,
)
}
/// The net closed by the run of cumulative members closes, with exactly
/// these members and shares, that ends with the latest close: zero if
/// the latest close was anything else (or there is none).
@@ -9665,6 +9686,11 @@ pub(crate) struct Regime {
/// count the next members close begins, when it is these members'
/// ([`Ledger::members_regime`]). Empty when there is none.
pub order: Vec<(AccountId, Decimal)>,
/// Whether a close under the cumulative rule that posted an entry is
/// among the count's closes: its true-up has run, so each member's
/// running total is then under one minor unit from exact
/// (BS-partner-1 statement 5).
pub trued_up: bool,
}
impl Regime {