cadrumo.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.
Projecting resolved binding values onto bound
CasillaId inputs is registry-owned rather than an
application concern: see
resolve_available_bound_inputs_by_casilla_id().
Completeness and unrouted-input concerns remain advisory or verify-gate
responsibilities rather than a second projection contract.
See also
calculation_resolution:Merges these tiers and builds the canonical engine input maps.
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, operation)[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)
caller_binding_values (Mapping[BindingId, Decimal])
caller_enum_binding_values (Mapping[BindingId, str])
borrador_snapshot_repository (Borrador100SnapshotRepository | None)
operation (PinnedAuthorityOperation)
- resolve_profile_source_tier(*, bucket_id, snapshot, caller_binding_values, caller_enum_binding_values, borrador_resolution, backend_binding_values, operation, profile)[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)
operation (PinnedAuthorityOperation)
profile (ModeloWorkProfile)
- reject_binding_channel_mismatch(revision, binding_values, enum_binding_values, boolean_binding_values=None)[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. Channel ownership for the BOOLEAN channel comes from the binding’s own declared value contract rather than from consumption, and is enforced for the profile-sourced bindings whose resolver owns that channel. 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.
- class DeclarationPeriodInputs(casilla_inputs=<factory>, text_casilla_inputs=<factory>)[source]¶
Bases:
objectWork-unit metadata projected onto its two typed engine channels.
casilla_inputscarries the int-familyfiling_yearrole on the Decimal channel;text_casilla_inputscarries the string-familyfiling_periodrole, whose registrydata_type = "period_code"binds it to the typed text-scalar channel and itsperiod_codevalidator.
- 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. Thefiling_yearrole lands as aDecimaland thefiling_periodrole as the canonicalPeriodregistry token ("1T","EXT-1T"), which is the form AEAT accepts and the only representation total over every declared period. A non-informational role target raisesModeloError.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)