Three properties the traceability gate can see as calls, not mentions:
- `reverse_target_agrees`: the earlier party bridge only passed
`reverse_target` to `and_then`, which proves nothing about the `i64`
and `Decimal` instantiations agreeing; the property now calls both.
- `direction_of_agrees`: `Direction::of` classifies the same sign at
both types, each case keeping its meaning.
- `part_weight_agrees`: `part_weight` is the same weight at `i32`,
`i64` and `i128`, and `None` exactly for a part no month has.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
The traceability gate asks every public kernel function for a bridge
property. Three amount-generic helpers had none: take, entry_movements
and flows_of (the statement of cash flows' split) and running_bounds and
bounds_kept (a document's position against its total). The properties
compare the i64 instantiation Kani proves with the Decimal one the engine
runs, on random inputs, so law 10 and law 34 hold at both types.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
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
The K-U1 review: foreign 0.99999999999999999999999999 (26 places) x rate
0.005 into USD booked 0.01, though the exact product
0.00499999999999999999999999995 is under half a cent. Decimal::checked_mul
rounds a product finer than 28 places to 28 before fx_booked rounds it to
the cent: two roundings, one cent off. A ledger in one money books the
exact product rounded once (BS-ledger-1, BS-ledger-14).
Owner decision D-75 (2026-11-08): a new line's foreign amount and its rate
take at most MAX_LINE_SCALE (10) decimal places each, as a base amount does
(B-28), so their product has at most 20 places, under Decimal's 28.
Ledger::add_line_fx refuses past it with ValueOutOfRange ("foreign amount
..." / "FX rate ..."; the variant for an amount that is not a journal
line's), trailing zeros not counted, before computing, and never on replay
(is_replaying; replay_add_line_fx books a journal's older line verbatim).
Tests: 11-place foreign amount and rate refused; ten and ten accepted with
hand-checked books; the review's input refused, not mis-booked; trailing
zeros are not places; replay keeps a 26-place foreign line in core, and a
store journal holding one opens with its figures.
fx_booked's spec block states the precondition (scales within 10 each, and
the mantissas' product within Decimal's 96 bits) and that the result is
exact under it, and documents Decimal::checked_mul's behaviours outside it
(rounding past scale 28 and past 96 bits; 1e-28 x 1e-28 underflowing to
zero); invariant 1 now says None when T's checked_mul cannot hold the
product. The bridge covers every D-75 scale (0..=10 each, products to 20
places) against an independent exact reference, shows 26 places is where the
reference and Decimal part (and the engine refuses), and pins an open edge
this bridge found: ten places each still allow a 20-place product past
~7.9e8 that outgrows 96 bits (1050000010.0000000001 x 9.9999999999 books
10500000099.90, exact 10500000099.89). B-28 and B-3 claims record the
enforcement and checks.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
periods.rs conflicted with K-U2: the frozen replay rules delegate to
K-U4's checked twins, whose rounding now goes through K-U2's
round_places (so every rounding stays in the kernel); no figure changes.
The K-U4 note gains the review's list of bounded raw sums left, and the
caveat that the twin test checks delegation (the review's independent
20,000-case comparison found the twins identical).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/proofs/k-u4.md: the six harnesses with bounds and times, the Lean
counterparts (Basic.net_append is total_append for the signed sum; no new
law), the bridge, the sites replaced with file:line, the sites left raw
because their signatures are infallible, the regression tests, and two
findings: Decimal's checked_add rounds dust within a unit of Decimal::MAX,
and the audit's reachability claims for section 2.1 were overstated.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Four Kani harnesses on i64 with fixed steps (a symbolic step is
intractable for CBMC's division, as K-U2 found; written down in
docs/proofs/k-u1.md): whole unit, within half a unit with tie covers,
positive for positive, and overflow/non-positive rate refused. The
bridge checks i64 against Decimal and Decimal against an independent
i128 exact-product reference at 0, 2 and 3 minor units (JPY, USD,
KWD), with Decimal::MAX, scale 28, and both-sign tie edges. The law
itself is proved in bookspec's Lean (Fx.booked_whole/near/pos, law
41) on the k-u1 branch there.
Co-Authored-By: Muse Wonder 1.0
Review found two holes in K-U2's evidence.
1. The spec block's invariants 3, 4 and 6 (toward zero: |r| <= |x| and
|r - x| < step; toward negative infinity: r <= x < r + step; no mode
flips the sign) had no proof: Kani checked those modes only at exact
ties. Three harnesses now assert them for every amount over the fixed
steps (round_step_toward_zero_bounds, round_step_toward_neg_inf_is_floor,
round_step_sign_preserved), each with covers for a non-tie and a negative
non-multiple; bookspec's Lean carries the same laws for any step. With
TowardZero mutated to round 7 at step 10 up to 10, the first harness
fails ("magnitude never grows"); reverted.
2. The bridge never ran checked_round_to_step's finer-step branch (step
with more places than the amount and a mantissa above one). Three
properties compare the kernel with a second, independent i128 reference
that takes any step (mantissa 1..1000 at scales 0..10, amounts at scales
0..28, small amounts, and constructed exact ties). Replacing
.checked_add(remainder / b) with .checked_add(0) in the digit loop fails
all three; reverted.
docs/proofs/k-u2.md also states the one exception to "no result changes":
a negative-zero input (round_dp keeps -0.00; round_places gives 0.00; no
call site can produce one).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Kani checks the primitive on i64 over fixed steps: a whole multiple, the
half modes nearest, each mode's tie, idempotence, no negative zero, and a
non-positive step refused. A symbolic divisor did not finish in 30 minutes
(CBMC's bit-blasted division), so the steps are fixed constants; the
bridge's exact-reference property carries the laws to every Decimal step.
The bridge agrees i64 with Decimal, checks Decimal against an independent
i128 reference over amounts of up to ten places and steps down to 1e-4,
checks round_places against round_dp_with_strategy to the character, and
has the edge table (.5, -.5, 0.004, 1.005, -1.005, scale 28, Decimal::MAX).
docs/proofs/k-u2.md records the harnesses, bounds, times, bridge properties
and the bookspec Lean theorem names.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
A raw Decimal + / += / .sum() panics at Decimal::MAX; a replayed journal
line is accepted 'of any size' (rules.md B-28) so a restored figure is the
realistic path to that edge, and amounts are exact (B-21): a total is the
exact sum or it is refused. kernel::total sums any figures, total_of a
mapped field, total_try a fallible mapping (a difference), each None on
overflow. The signed sum of (Side, amount) lines stays kernel::net/totals.
Kani (proofs/total.rs, fixed arrays): total_empty_is_zero, total_append,
total_is_sound (any i64), total_of_is_map_sum (= net), total_try_is_map_sum,
total_overflow_is_none, each with covers. Bridge (kernel_bridge/total.rs):
i64 vs Decimal on random runs, a Decimal edge table, and a canary for the
finding that rust_decimal rounds dust when a sum lands on Decimal::MAX.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kernel.rs is now kernel/: mod.rs keeps the laws and re-exports entries
(the old file, unchanged) plus one file per kernel-sweep unit (U1 fx, U2
round, U3 allocate, U4 total, U5 schedule, U6 ratio, U7 payroll, U8
control). proofs.rs is proofs/: mod.rs holds the original 63 harnesses and
each unit gets a file of its own. tests/kernel_bridge.rs is now
tests/kernel_bridge/main.rs plus one file per unit; Cargo still builds the
single test target named kernel_bridge.
`_kani` now scans proofs/mod.rs and proofs/*.rs and passes the fully
qualified name each file gives its harness (Kani's --exact matches only a
fully qualified name), so a harness resolves wherever it lives. It fails
when kani_slow names no harness, or when two harnesses share a name and
would make the slow list ambiguous; `just prove-list` prints every harness
with its module path and set, showing the slow list resolved without
running it.
Nothing moves in the books: the same 53 fast Kani harnesses and 118 Lean
theorems verify, and the same 1096 tests pass (27 in the bridge).
Docs: verification.md gains the kernel-sweep policy (each unit writes
docs/proofs/<unit>.md; the integrator folds the notes into
verification.md and Audit.lean in one edit per batch), and the file
references in AGENTS.md, testing.md, architecture.md, oracle.md and
spec/rules.md follow the new paths.
Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>