cadrumo.domain.calculations.registry.binding_value_contract module¶
The declared value contract a binding promises its consumers.
A binding’s value contract answers two questions that the authored declaration
previously left implicit and a consumer had to re-derive: what the value means
(BindingDataType) and which typed channel carries it
(BindingValueChannel). The two axes are kept separate rather than
collapsed to one token because they are not the same statement – money and
integer are distinct legal quantities that a formula rounds and signs
differently, while the channel is the transport a resolver and an export share.
They are, however, not independently choosable: CHANNEL_FOR_BINDING_DATA_TYPE
pins exactly one channel per data type, so a declaration that pairs them wrongly
is a contradiction the schema refuses rather than a preference it honours.
Row-shaped values carry a third axis: the row-assembly grouping. It reuses
RowSetGroupingKind, the same canonical
cross-layer enum the detail-record source tokens map onto, so the grouping a
binding declares and the grouping the assembly layer consumes cannot drift.
- class BindingDataType(*values)[source]¶
Bases:
StrEnumThe legal quantity a binding value represents.
- MONEY¶
A monetary amount, signed and rounded by its owning casilla contract.
- DECIMAL¶
A non-monetary decimal quantity.
Distinct from
money: it carries no currency and is not rounded or signed by a monetary casilla contract, and distinct frominteger: it is genuinely fractional. A prorrata-weighted count is the canonical shape — truncating it tointegerwould discard the prorrata, and calling itmoneywould label a quantity as currency.
- INTEGER¶
A whole count with no monetary rounding or currency.
- BOOLEAN¶
A declared yes/no fact, distinct from a zero amount.
- TEXT¶
Free or catalogued text carried verbatim to an export.
- DATE¶
A calendar date, never a period token.
- ENUM¶
A member of a closed substrate enum named by
typed_enum.
- class BindingValueChannel(*values)[source]¶
Bases:
StrEnumThe typed transport a resolver produces and a consumer narrows on.
- DECIMAL¶
- INTEGER¶
- BOOLEAN¶
- TEXT¶
- DATE¶
- ENUM¶
- ROW_SET¶
- CHANNEL_FOR_BINDING_DATA_TYPE: Final[Mapping[BindingDataType, BindingValueChannel]]¶
The one permitted channel per data type.
moneyis the only pairing whose two tokens differ in spelling: a monetary quantity travels thedecimalchannel, because the channel names the carrier type and not the legal quantity. Every other data type names its channel identically, which makes the pairing look redundant – it is not, because the two axes are declared independently and the map is what refuses a contradiction.moneyanddecimalare the one pair of data types that share a channel: both travel as aDecimal, and what separates them is the legal quantity, not the carrier. The map stays a function from data type to channel, so the pairing check remains exact in the direction it is asked.
- class BindingValueContract(**data)[source]¶
Bases:
RegistryModelThe typed value shape one binding declaration promises.
typed_enumnames the closed substrate enum anenum-channel value bridges;row_groupingnames the row-assembly axis arow_setvalue is grouped by. The row-set channel carries the same scalardata_typevocabulary as a scalar value; cardinality is stated bychannelalone.- Parameters:
data (Any)
- data_type: Annotated[BindingDataType, BeforeValidator(coerce_enum_member(BindingDataType))]¶
- channel: Annotated[BindingValueChannel, BeforeValidator(coerce_enum_member(BindingValueChannel))]¶
- typed_enum: Annotated[BindingTypedEnumKind | None, BeforeValidator(coerce_enum_member(BindingTypedEnumKind))]¶
- row_grouping: Annotated[RowSetGroupingKind | None, BeforeValidator(coerce_enum_member(RowSetGroupingKind))]¶