cadrumo.application.modelo.calculation_resolution module¶
Calculation input-channel resolution helpers.
The helpers merge caller, backend, profile, and borrador channels for a
RegistrySnapshot, then build the canonical input map consumed by the
selected ModeloRevision.
This module is the calculation-service assembly layer between source resolution
and engine execution. It delegates source-specific work to the binding
resolution helpers, then returns typed channel bundles that
application.modelo.calculation_actions.calculate_modelo_revision() can pass to
domain.calculations.registry.formula_runtime.calculate_registry_snapshot() and the
CalculationRevision persistence boundary.
See also
application.modelo.binding_resolution.resolve_borrador_source_tier()Resolves the optional borrador tier before the final precedence merge.
application.modelo.binding_resolution.resolve_profile_source_tier()Resolves profile-sourced bindings as the lowest-precedence tier.
application.aggregation.source_resolution_operations.merge_source_resolutions_by_precedence()Applies the ordered overlay contract used by this module.
- class ResolvedCalculationChannels(bindings, enum_bindings, date_bindings, boolean_bindings, borrador_snapshot_id, bindings_sourced_from_borrador)[source]¶
Bases:
objectMerged engine binding channels for one calculation.
bindingsfeeds the Decimal channel,enum_bindingsfeeds string dispatch keys,date_bindingsfeeds date-valued profile bindings, andboolean_bindingsfeeds the truth values of bindings whose registry value contract declares the boolean channel. The borrador fields carry the typed snapshot trace fromCalculationSourceResolutionthrough to the persistedCalculationRevision.- Parameters:
- class ResolvedCalculationInputs(casilla_inputs, text_casilla_inputs)[source]¶
Bases:
objectCanonical per-channel casilla inputs for one engine run.
casilla_inputsfeedscalculate_registry_snapshot(inputs=...)andtext_casilla_inputsfeeds itstext_inputs=...channel. Callers receive both together so a string-family casilla cannot be silently dropped on the way to the engine.
- class CalculationReplayPayloads(input_values_by_casilla_id, binding_overrides, row_binding_values, relation_overrides)[source]¶
Bases:
objectCanonical string payloads stored for calculation replay.
The persistence layer stores user-visible inputs as strings, not live
Decimalinstances. These maps are derived after all source overlays have settled so replay and revision identity use the same canonical values the engine consumed. They are the persisted replay side of theCalculationRevisionhash domain, not an independent calculation path.- Parameters:
- resolve_calculation_binding_channels(*, work_unit, snapshot, casilla_inputs, caller_binding_values, caller_enum_binding_values, backend_binding_values, borrador_snapshot_id, borrador_snapshot_repository, operation, profile)[source]¶
Resolve all binding channels for
work_unitandsnapshot.The
work_unitis theWorkUnitwhose bucket, filing year, and period select the source-resolution axis. Thesnapshotis theRegistrySnapshotsupplying the revision whose binding channels are being resolved.The source-precedence ladder is profile, backend, borrador, then caller. The returned
ResolvedCalculationChannelscontains the merged Decimal, enum, date, and boolean channels, plus anyBorrador100SnapshotRepositoryprovenance, afterapplication.modelo.binding_resolution.reject_binding_channel_mismatch()verifies the registry-declared channel shape andapplication.modelo.binding_resolution.lift_previous_filing_casilla_overrides_to_bindings()mirrors eligible previous-filing casilla overrides onto their binding ids.- Return type:
- Parameters:
work_unit (WorkUnit)
snapshot (RegistrySnapshot)
borrador_snapshot_id (str | None)
borrador_snapshot_repository (Borrador100SnapshotRepository | None)
operation (PinnedAuthorityOperation)
profile (ModeloWorkProfile)
- resolve_calculation_inputs(*, revision, filing_year, period, backend_casilla_inputs, resolved_bindings, casilla_inputs, text_casilla_inputs=None)[source]¶
Build the canonical casilla input maps for engine execution.
The
revisionis theModeloRevisionwhose declaration-period and bound casilla inputs are being projected. ThePeriodsupplies the filing-period casilla values that the registry declares as inputs.Declaration-period bindings are projected first, followed by backend casilla inputs, bound casillas resolved from merged binding values, and finally the caller’s explicit casilla overrides. Both returned maps are sorted for stable replay payloads and revision identity.
The two channels are returned together, and never merged, because the registry assigns each casilla to exactly one of them by declared
data_typefamily: thefiling_periodrole isperiod_code(a string family whoseperiod_codevalidator accepts1T,EXT-1T, and every other declared token), whilefiling_yearisyearand stays on the Decimal channel.- Return type:
- Parameters:
- build_calculation_replay_payloads(*, resolved_inputs, resolved_bindings, resolved_enum_bindings, resolved_date_bindings, resolved_relations, resolved_row_bindings=None, resolved_boolean_bindings=None)[source]¶
Convert resolved engine inputs into persisted
CalculationReplayPayloads.Casilla and relation Decimals are canonicalized with the domain decimal formatter. Decimal, enum, date, and boolean binding channels share the single
binding_overridesreplay map (a truth value astrue/false) because that is the persisted scalarCalculationRevisioncontract. Row-indexed bindings are carried inrow_binding_valuesso the row coordinate remains structured for draft and export replay instead of being encoded into a synthetic binding id. The replay payload is built after source precedence and bound-casilla projection so its values match the engine inputs exactly.A carried relation value is keyed by the binding it folds into, so the relation prefill resolves it on both channels. Replay reads both channels into one namespace, so a relation entry that repeats its binding’s value is dropped; a relation entry that disagrees is kept, and the revision’s channel-uniqueness invariant refuses it rather than choosing a winner.