build(check): every crate is held at zero Decimal arithmetic outside the kernel (K-U12)

The viewer was the last crate with arithmetic of its own on amounts. With
it at zero, `just kernel-only` runs the detector over all eleven crates,
and it now fails when a folder under crates/ is not in its list, so a new
crate cannot do money arithmetic of its own from the day it is added.

Why it matters for the books: the proofs (Kani, Lean) are about the
kernel. A sum or a product computed anywhere else is one they say nothing
about, and rust_decimal's own operators either panic or round without
saying so. Bar item 1 of AGENTS.md is now a property the compiler checks
for the whole workspace, not a rule to remember.

Checked on main after the merge: the detector reads 0 places and 0
waivers for ledger-gui, the crate's whole test suite passes in one run
(300 passed, 0 failed, 1 ignored), clippy with warnings denied and fmt
are clean.

docs/proofs/k-u12.md is the account: the 183 places by crate, the rule
each kind followed, and the decision for every site that was not a plain
sum or sign.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude committed 2026-11-10 01:55:11 -07:00
1 parent e444a41071
commit ef86f7820a
7 files changed
+129 -16

No files matched your search

+12 -6
View File
@@ -20,7 +20,7 @@ books. The gaps are in what the gates do not see.
## P1: a promise of the manual that is not kept, or a correctness risk
1. **The kernel rule is not met and nothing enforced it.** Bar item 1
1. **The kernel rule was not met and nothing enforced it.** Done. Bar item 1
says money arithmetic lives in `kernel/` and nowhere else.
`scripts/raw-decimal-arith.sh` (95ae7717d) asks the compiler, and at
8ad55e82a it lists **210 places in ledger-core** that add, subtract,
@@ -43,10 +43,16 @@ books. The gaps are in what the gates do not see.
names it (`checked_add_rounded`, `checked_sub_rounded`). Four places
changed a figure's written places with `Decimal::rescale`, which can
round; `kernel::rescale_exact` cannot. `docs/proofs/k-u11.md`.
- K-U12, the outer crates. Worker or script, decided on the counts.
- K-U12, the outer crates: done (merged 1c28760d8, a167766dd,
e444a4107). All 183 places go through the kernel: ledger-store and
ledger-config by hand, the other four crates by two workers from a
rule table and a decision for every site that was not a plain sum
or sign, each diff read against it. No figure moves; a sum exact
arithmetic cannot hold is a blank or a refusal where it panicked or
was rounded. `docs/proofs/k-u12.md`.
- The script in `just check` at zero, so the count cannot rise again:
done for five crates; each of the other six joins
`kernel_only_crates` as K-U12 brings it to zero.
done for every crate of the workspace, and `just kernel-only` fails
on a crate that is not in its list.
2. **Decimal sums and products rounded silently.** Done (K-U10a, merged
e632855f1). `Decimal::checked_add` and `checked_mul` return a rounded
answer when the exact one needs more than 28 digits; the kernel's
@@ -190,8 +196,8 @@ signing (D-64); the re-audit (P10); Q-6 before P9b.
## Order of work
1. Land what is in flight: V-D3, K-U9, K-U10a, K-U10b (all four done).
2. K-U11a on top of them (done, and the detector is in `just check` for
the crates at zero), then K-U12.
2. K-U11a on top of them, then K-U12 (both done; the detector is in
`just check` for every crate).
3. `overflow-checks`, the CI split, `just prove`'s cap, `cargo-deny`
(all four done).
4. One gate at the end (`just check`, `just prove`), one push, four gates