cadrumo.application.ledger.column_roles module

Inward port for semantic column-role resolution.

Financial-source adapters consume the result of column-role inference, but the inference implementation is an optional outbound capability. This structural port keeps the inbound provider independent of that concrete adapter while preserving the existing role tuple as the only required contract.

class ColumnRoleMappingPort(*args, **kwargs)[source]

Bases: Protocol

One accepted role for each normalized table column.

property roles: tuple[FieldRole, ...]

Return roles in the same positional order as table headers.

ColumnRoleMappingResolverPort

Resolve one normalized table into a role mapping, or decline it.

alias of Callable[[NormalizedTable], ColumnRoleMappingPort | None]

bind_column_role_mapping_resolver(resolver)[source]

Bind the outward column-role implementation for one runtime scope.

Return type:

Generator[Callable[[NormalizedTable], ColumnRoleMappingPort | None]]

Parameters:

resolver (Callable[[NormalizedTable], ColumnRoleMappingPort | None])

column_role_mapping_resolver()[source]

Return the resolver installed by an outer composition root, if any.

Return type:

Callable[[NormalizedTable], ColumnRoleMappingPort | None] | None

resolve_column_roles(table)[source]

Resolve table through the currently composed column-role port.

Return type:

ColumnRoleMappingPort | None

Parameters:

table (NormalizedTable)