polycratia

The cost of a bug is not its wrongness. It is how long it can keep looking plausible.

Rounding in money splits is the clearest case. Split a payout pro-rata between several investors, round each share to the minor unit, and the shares stop summing to the amount you received. Off by one minor unit, sometimes two.

Nothing crashes. Every row passes validation. Every share looks correct to the person it belongs to.

So the system keeps running, and the gap repeats per payout, across every deal, for as long as nobody reconciles against what the bank actually settled. When it finally surfaces there is no broken row to point at: none of them is broken on its own. The defect lives in the relationship between them, and that relationship is the one thing row-level validation never looks at.

I treat splits as allocation rather than arithmetic: compute the parts, push the remainder onto one deterministic recipient by a stable ordering, and assert that the parts sum to the whole inside the same transaction that writes them. A failed assert at write time costs you minutes. The same discrepancy found later in a settlement report costs an investigation across everything that ran in between.

The real size of a bug is wrongness times volume times time to detection. Crashes are cheap because that last term sits close to zero.

Where to enforce parts-equal-the-whole I am still not sure about: in the allocation code, as a database constraint, or in a nightly reconciliation job...

react

$ new-project --brief

or email hey@polycratia.com