aeat.application.modelo._binding_resolution module¶
Application-owned binding input resolution for modelo calculations.
This module prepares binding, enum, and informational inputs for one
RegistrySnapshot before the registry
engine evaluates its ModeloRevision.
Profile, backend mesh, borrador, and caller values are normalised as
CalculationSourceResolution tiers, then
the calculation assembly layer overlays them by precedence: profile, backend
mesh, borrador, and finally caller overrides.
The module also owns the application-specific partial projection from available
binding values to CasillaId inputs.
That differs from the domain registry’s strict bound-input projection: live
calculate paths may carry absent optional bindings while still projecting every
value that did resolve.
See also
_calculation_resolution:Merges these tiers and builds the canonical engine input maps.
resolve_bound_inputs_by_casilla_id():Strict registry projection that requires every bound fact to be present.
_profile_binding:Resolves profile-sourced bindings into decimal, enum, and date channels.
_borrador_binding:Resolves Modelo 100 borrador snapshots as a precedence tier.
- resolve_borrador_source_tier(*, bucket_id, snapshot, filing_year, period, borrador_snapshot_id, caller_binding_values, caller_enum_binding_values, borrador_snapshot_repository)[source]¶
Resolve the borrador precedence tier as a source-mesh resolution.
The
RegistrySnapshotsupplies the revision and modelo identity used to resolve the borrador source through the source mesh; the returnedCalculationSourceResolutioncarries the typedborrador_provenance(snapshot id + sourced-binding trace) the persistence boundary consumes.Caller-supplied
BindingIdvalues remain higher precedence than the snapshot, so the resolver receives both decimal and enum caller channels and omits any borrador value already owned by the caller.See also
CalculationSourceResolution:The shared carrier used by the precedence overlay.
Borrador100SnapshotRepository:Loads the optional captured snapshot when a borrador id is supplied.
- Return type:
- Parameters:
bucket_id (str)
snapshot (RegistrySnapshot)
filing_year (int)
period (Period)
borrador_snapshot_id (str | None)
borrador_snapshot_repository (Borrador100SnapshotRepository | None)
- resolve_profile_source_tier(*, bucket_id, snapshot, caller_binding_values, caller_enum_binding_values, borrador_resolution, backend_binding_values)[source]¶
Resolve the profile precedence tier as a source-mesh resolution.
The
RegistrySnapshotidentifies the revision whosesource = "profile"bindings are enrolled through the source mesh. Profile is the LOWEST precedence tier, so every binding the caller, borrador, or mesh backend already supplied is excluded here (the profile resolver never overrides a higher tier).The
borrador_resolutionand backend values are passed only as ownership exclusions. They do not change profile facts; they prevent the profile tier from claiming aBindingIdthat a higher-precedence source already supplied.See also
ProfileSourceResolver:Source resolver that reads the stored user profile facts.
resolve_calculation_binding_channels():Places this profile tier below backend, borrador, and caller tiers.
- Return type:
- Returns:
A
CalculationSourceResolutioncarrying the profile-owned bindings not already claimed by higher-precedence tiers.- Parameters:
bucket_id (str)
snapshot (RegistrySnapshot)
borrador_resolution (CalculationSourceResolution)
- reject_binding_channel_mismatch(revision, binding_values, enum_binding_values)[source]¶
Reject binding values supplied on the wrong engine channel.
The
ModeloRevisiondetermines channel ownership from formula consumption: enum dispatch bindings must arrive throughenum_binding_values; decimal operands must arrive throughbinding_values. A mismatch raisesModeloErrorbefore the engine sees an apparently missing binding.See also
enum_consumed_binding_ids():Identifies bindings consumed by enum-dispatch formulas.
- lift_previous_filing_casilla_overrides_to_bindings(revision, casilla_inputs, resolved_bindings)[source]¶
Promote eligible previous-filing casilla overrides into binding values.
The
ModeloRevisionsupplies the bound casilla and binding metadata. A caller may supply aCasillaIdoverride for a bound casilla whose binding source isprevious_filingwhen no resolver-produced binding value exists. This helper mirrors that override onto the matchingBindingIdso the registry engine’s bound-input consistency guards see the same source of truth in both channels. Existing resolved bindings are never overwritten.See also
resolve_calculation_binding_channels():Calls this after the precedence overlay settles.
- resolve_declaration_period_inputs(revision, *, filing_year, period)[source]¶
Resolve work-unit period metadata into informational casilla inputs.
The
ModeloRevisionsupplies the informational casillas eligible for metadata projection. Only casillas with uniquefiling_yearorfiling_periodsemantic roles are populated. ThePeriodregistry token is mapped to the ordinal expected by the registry snapshot; unsupported tokens or non-informational role targets raiseModeloError.See also
casilla_id_for_unique_revision_semantic_role():Enforces that each populated semantic role resolves to one casilla.
- Return type:
- Parameters:
revision (ModeloRevision)
filing_year (int)
period (Period)
- resolve_available_bound_inputs_by_casilla_id(revision, binding_values)[source]¶
Project available binding values into input values keyed by bound
casilla.id.The
ModeloRevisionsupplies the bound casilla-to-binding mapping; only values already present inbinding_valuesare projected. Missing optional bindings are skipped rather than treated as registry errors, which lets application calculate paths combine partial source mesh output with caller overrides before the engine runs.- Parameters:
revision (
ModeloRevision) – TheModeloRevisionwhose bound casillas are inspected.binding_values (
Mapping[TypeAliasType,Decimal]) – Decimal values keyed byBindingId.
- Return type:
- Returns:
A
dictkeyed byCasillaIdfor every bound casilla whose binding value is currently available.
See also
resolve_bound_inputs_by_casilla_id():Strict domain helper that rejects unknown or missing binding facts.
resolve_calculation_inputs():Uses this partial projection when assembling engine inputs.