Files
wanderbooks/crates/ledger-core
swaitsandClaude Sonnet 5.5 294cb99a58 fix(core): a tie between shares goes to the earlier part, exactly (held for the owner's decision)
split_by_weights_into's largest-remainder policy ranked the leftover
cents by the rounded quotient's remainder (Decimal keeps 28 significant
digits), so an exact tie was decided by the quotient's last digit, not
given to the earlier part as apportion's docs and bookspec's Lean model
(Apportion.lean: remW = x*w % W, ties to the earlier member) say.
20.00 by 4/1/1 over 6 gave 13.33, 3.34, 3.33 where the exact tie of
remainders (0.02 over 6 each) belongs to the first: 13.34, 3.33, 3.33.

It now ranks the exact integer remainder whole x weight - part x total
(the quantity share_floor_with returns), sign-flipped for a negative
total so the order stays the share's own. The parts still sum to the
whole and each is within one step; only which part takes a tied cent
changes. Stored entries never move (posted is forever); a report
recomputed for a past period can move a cent between parties.

The finding test is flipped into the law (ties_go_to_the_earlier_part),
the bridge's ranking property now includes ties, and the spec block,
k-u3.md and verification.md say ties go to the earlier part, exactly.

This branch is held: the owner decides whether the cents may move
(see tests/kernel_bridge/ties.rs for what it moves).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 15:37:06 -07:00
..