cadrumo.core.unit_proportion module¶
A share of a whole, bounded to the inclusive zero-to-one interval.
Business-use percentages, usage ratios, prorrata shares and classifier
confidences are all the same quantity: a Decimal share of one. The bound was
open-coded as Decimal("0") <= value <= Decimal("1") at nine sites across
the ledger, renta, transactions and usage-ratio surfaces and the CLI, plus two
further local constant pairs spelling the same two numbers.
The predicate lives here so every caller asks the same question. Callers keep
their own refusal: the ledger raises a transaction error, the renta models a
renta error, and the CLI raises an operator-facing message naming the offending
value and its percentage. That difference is deliberate and worth preserving –
the operator’s first instructive surface should say 0.5 means 50 % where
the domain need only say the invariant broke. What must not differ is where the
interval ends.
The interval is INCLUSIVE at both ends: a zero share and a whole share are both legitimate answers, and a caller that needs to exclude one says so itself.