cadrumo.application.modelo._registry_helpers module¶
Registry lookup and casilla validation helpers for modelo actions.
The helper layer resolves
RegistrySnapshot instances through
cadrumo.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
cadrumo.domain.calculations.registry.authority.bundled_indexed_authority()Generation-pinned authority 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.
- absent_authority_file(exc)[source]¶
Name the file whose absence refused an authority read.
The refusal this feeds means one thing only: a published authority descriptor resolved, and the generation it names is not on disk. Nothing resolving at all is a different state, reported by
AuthorityDescriptorUnavailableErrorat the resolution seam itself, which already names the searched location and the command that publishes one.The path is read from the raised error rather than by re-resolving the descriptor. Re-resolving would name the descriptor, which in this state exists – so the operator would be sent to inspect the one file that is not the problem – and the resolution seam can itself refuse, which inside an exception handler would replace the refusal being built with an unrelated one.
- Parameters:
exc (
FileNotFoundError) – The refusal raised by the authority read.- Return type:
- Returns:
The absent file’s path, or the error’s own text when the platform supplied no filename.
- reject_incomplete_amendment_casillas(*, modelo, filing_year, period, casilla_values)[source]¶
Mirror the verify-modelo-revision required-manual gate on amend.
The supplied
Periodselects theRegistrySnapshotused to read required manual casillas. Missing required manual casillas raiseAmendmentVerificationRefusedErrorbefore an amendment can be accepted as complete.
- validate_casilla_input_ids(revision, casilla_inputs)[source]¶
Validate operator-supplied numeric input casillas against the revision.
The
ModeloRevisionsupplies 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 canonicalCasillaIdvalues and contains onlyDecimalnumeric inputs that the registry engine may consume.Two declared families may carry a value: the numeric ones over their full range, and the boolean family restricted to
0/1, which is how the engine itself reads a boolean casilla. Both arrive asDecimal; a Pythonboolis refused for either, so widening to booleans never widens toward writing aTrueonto an amount row.- Return type:
- Parameters:
revision (ModeloRevision)
casilla_inputs (Mapping)
- reject_unknown_override_casillas(*, modelo, filing_year, period, overrides, operation=None)[source]¶
Refuse amendment override casillas outside the resolved revision.
Keys are canonicalised as
CasillaIdvalues and checked against theRegistrySnapshotselected bymodelo,filing_year, andPeriod. Printed-number aliases and ambiguous reused numbers raiseAmendmentOverrideCasillaErrorinstead of being projected to a declared casilla.
- reject_unknown_import_casillas(*, modelo, filing_year, period, casilla_values, operation=None)[source]¶
Validate imported casilla ids and return the resolved registry snapshot.
The snapshot is a
RegistrySnapshot. The returned mapping is keyed by canonicalCasillaIdvalues declared by the selectedModeloRevision. Unknown, malformed, and non-canonical printed numbers raiseExternalModeloImportErrorso 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
Nonewhen the registry root orRegistrySnapshotcannot be loaded. The first tuple contains required manual casillas from the selectedModeloRevision; the second contains declared manual, bound, and computedCasillaIdvalues that amendment/import paths may need to carry through replay.
- assert_revision_content_integrity(revision)[source]¶
Check revision integrity; raise stored-calculation drift on mismatch.
The supplied
CalculationRevisionis re-hashed from its persisted inputs, bindings, relations, casilla values, and source metadata before its provenance observations are compared withcasilla_values. This is a defense-in-depth read-side check for raw storage corruption that bypassed normal model construction; a mismatched observation envelope raisesStoredCalculationDriftErrorbefore the revision is treated as authoritative.- Return type:
- Parameters:
revision (CalculationRevision)