cadrumo.application.modelo._required_binding_gate module

Modelo lifecycle guard for required calculation bindings.

The gate compares required binding declarations on a registry ModeloRevision with the binding ids resolved for a work-unit action. Persisted replay checks derive those ids from a saved CalculationRevision.

This gate is deliberately M202-only and hard-blocking, with no exclusion for previous_filing / relation_prefill / manual_input sources — it is NOT a stricter reimplementation of the generic, all-modelos, non-blocking silent-zero advisory in expected_but_missing_binding_ids(), which explicitly excludes those three source kinds. The two gates answer different questions for different reasons: this one refuses M202 lifecycle actions outright when a declared binding has no resolved value at all (Ley 27/2014 art. 40.2/40.3 modalidad-cuota requires every input present before a pago fraccionado can be computed), while the generic advisory flags a narrower “present source produced no value” silent-zero shape across every modelo without blocking. Collapsing either gate into the other would either silence M202’s hard stop or over-block every other modelo’s advisory path — this is a constraint-shape mismatch, not duplication, and the divergence is intentional. Do not “fix” it by aligning the two.

require_modelo_required_bindings_resolved(*, work_unit, registry_revision, resolved_binding_ids, action)[source]

Refuse M202 lifecycle work when declared bindings are absent.

Parameters:
  • work_unit (WorkUnit) – Modelo work unit whose action is being gated.

  • registry_revision (ModeloRevision) – Registry ModeloRevision declaring the required bindings for the target modelo/year/period.

  • resolved_binding_ids (Iterable[TypeAliasType]) – Binding ids already supplied by the caller or source resolvers.

  • action (str) – Operator action name used in the refusal message.

Return type:

None

require_persisted_revision_required_bindings_resolved(*, work_unit, revision, action, operation)[source]

Refuse saved M202 revisions whose replay payload lacks required bindings.

Parameters:
  • work_unit (WorkUnit) – Modelo work unit whose persisted replay is being gated.

  • revision (CalculationRevision) – Saved CalculationRevision carrying binding overrides from the previous calculation payload.

  • action (str) – Operator action name used in the refusal message.

  • operation (PinnedAuthorityOperation) – Caller-held authority operation used to select the exact generation-pinned revision.

Return type:

None

missing_modelo_required_binding_ids(*, work_unit, registry_revision, resolved_binding_ids)[source]

Return required M202 binding ids absent from a resolved channel set.

Parameters:
  • work_unit (WorkUnit) – Modelo work unit whose target determines whether the M202 required-binding gate applies.

  • registry_revision (ModeloRevision) – Registry ModeloRevision whose binding declarations are inspected.

  • resolved_binding_ids (Iterable[TypeAliasType]) – Binding ids available from caller inputs or resolved source data.

Return type:

tuple[TypeAliasType, ...]

resolved_required_profile_binding_values(*, work_unit, registry_revision, profile)[source]

Return M202 required profile bindings even when they are not formula-consumed.

Parameters:
  • work_unit (WorkUnit) – Modelo work unit whose target determines whether the M202 required-binding profile lift applies.

  • registry_revision (ModeloRevision) – Registry ModeloRevision whose required profile-sourced binding declarations are inspected.

  • profile (ModeloWorkProfile) – The work profile the calculation already loaded and checked.

Return type:

dict[TypeAliasType, Decimal]