merge: the control, aging and reconciliation identities in the kernel (K-U8; reviewed, fixes applied)

Three identities the books rest on are kernel functions now, proved
rather than only summed: an aging's five buckets add to the document
total (aging_total), a control account's difference from its documents
and unattached lines (control_difference), and the K-1 reconciliation's
total (reconciliation_total). Kani proves each, None exactly on
overflow; bridge properties check them against an exact integer
reference and the replaced chains on 20,000 cases, scale included; law
46 in bookspec's Lean. The CPA package's aging now refuses a total past
exact arithmetic instead of panicking. The harnesses found the integer
model's subtraction negating first, so x - MIN was refused where it fits;
i64 and i32 now use the native subtraction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-11-09 13:52:10 -07:00
commit 8aa0ed985d
9 files changed
+815 -33

No files matched your search

+3 -4
View File
@@ -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,