refactor(core): the control, aging and reconciliation identities in the kernel
Three identities were still hand-written chains at their call sites: an aging row's five buckets summing to what is owed (BS-arap-1), the control check's difference, balance less documents less unattached lines (BS-arap-2), and the K-1 reconciliation total, beginning plus built-in gain plus property without a basis less property distributed (BS-partner-4). They move to kernel::aging_total, control_difference and reconciliation_total, generic over Amount, returning None on overflow, so each is a named law with a harness and a Lean theorem rather than a sum. Behaviour is identical: the same checked steps in the same order, so figures, scales and TooLargeToCompute refusals are unchanged; every golden passes untouched. The next commit's bridge compares the old chains and the kernel as strings on 20,000 random Decimals of any scale. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e45c62348a
commit
0df463b703
4 files changed
+132
-16
No files matched your search
@@ -7494,10 +7494,9 @@ impl Ledger {
|
||||
}
|
||||
}
|
||||
let documents_total = doc_totals.get(&account).copied().unwrap_or_default();
|
||||
let difference = balance
|
||||
.checked_sub(documents_total)
|
||||
.and_then(|d| d.checked_sub(unattached_sum))
|
||||
.ok_or_else(too_large)?;
|
||||
let difference =
|
||||
crate::kernel::control_difference(balance, documents_total, unattached_sum)
|
||||
.ok_or_else(too_large)?;
|
||||
out.push(arap::ControlCheck {
|
||||
role: role.key.to_string(),
|
||||
account,
|
||||
|
||||
Reference in new issue
Block a user