aeat.application.modelo._registry_helpers module

Registry lookup and casilla validation helpers for modelo actions.

The helper layer resolves RegistrySnapshot instances through aeat.application.modelo._registry_resources, validates operator/imported casilla maps against the selected ModeloRevision, and refuses non-canonical printed-number tokens before the calculation engine or persistence layer sees them.

It also verifies stored CalculationRevision payloads by re-deriving their content-addressed identifiers and checking CasillaObservation/value consistency before stored payloads are trusted by verification or filing workflows.

See also

aeat.application.modelo._registry_resources.authority_via_resources()

Central registry authority loader used by snapshot-backed guards.

validate_casilla_input_ids()

Boundary validator for operator-supplied casilla maps.

assert_revision_content_integrity()

Read-side guard for stored calculation revision drift.

reject_incomplete_amendment_casillas(*, modelo, filing_year, period, casilla_values)[source]

Mirror the verify-modelo-revision required-manual gate on amend.

The supplied Period selects the RegistrySnapshot used to read required manual casillas. Missing required manual casillas raise AmendmentVerificationRefusedError before an amendment can be accepted as complete.

Return type:

None

Parameters:
validate_casilla_input_ids(revision, casilla_inputs)[source]

Validate operator-supplied numeric input casillas against the revision.

The ModeloRevision supplies the declared casilla ids, data types, and non-canonical reference targets used to reject ambiguous or malformed operator input. The returned mapping is keyed by canonical CasillaId values and contains only Decimal numeric inputs that the registry engine may consume.

Return type:

dict[TypeAliasType, Decimal]

Parameters:
reject_unknown_override_casillas(*, modelo, filing_year, period, overrides)[source]

Refuse amendment override casillas outside the resolved revision.

Keys are canonicalised as CasillaId values and checked against the RegistrySnapshot selected by modelo, filing_year, and Period. Printed-number aliases and ambiguous reused numbers raise AmendmentOverrideCasillaError instead of being projected to a declared casilla.

Return type:

dict[TypeAliasType, Decimal]

Parameters:
reject_unknown_import_casillas(*, modelo, filing_year, period, casilla_values)[source]

Validate imported casilla ids and return the resolved registry snapshot.

The snapshot is a RegistrySnapshot. The returned mapping is keyed by canonical CasillaId values declared by the selected ModeloRevision. Unknown, malformed, and non-canonical printed numbers raise ExternalModeloImportError so imported AEAT values enter observation projection only under registry ids.

Return type:

tuple[RegistrySnapshot, dict[TypeAliasType, Decimal]]

Parameters:
required_input_casilla_ids_for_revision(*, modelo, filing_year, period)[source]

Resolve required manual and replayable input casilla ids for a revision.

Returns None when the registry root or RegistrySnapshot cannot be loaded. The first tuple contains required manual casillas from the selected ModeloRevision; the second contains declared manual, bound, and computed CasillaId values that amendment/import paths may need to carry through replay.

Return type:

tuple[tuple[TypeAliasType, ...], tuple[TypeAliasType, ...]] | None

Parameters:
verification_predicates_for_revision(*, modelo, filing_year, period)[source]

Return verification predicate rows for the selected revision.

The rows are VerificationPredicateDefinition instances. Missing registry roots or unresolved RegistrySnapshot instances produce an empty tuple so callers can degrade to their existing verification paths.

Return type:

tuple[VerificationPredicateDefinition, ...]

Parameters:
assert_revision_content_integrity(revision)[source]

Check revision integrity; raise stored-calculation drift on mismatch.

The supplied CalculationRevision is re-hashed from its persisted inputs, bindings, relations, casilla values, and source metadata before its provenance observations are compared with casilla_values. This is a defense-in-depth read-side check for raw storage corruption that bypassed normal model construction; a mismatched observation envelope raises StoredCalculationDriftError before the revision is treated as authoritative.

Return type:

None

Parameters:

revision (CalculationRevision)