aeat.application.calculations._multi_year module¶
Enrollment evidence and the previous-filing source-mesh adapter.
The enrollment surface records the real renta years exercised by continuity
tests through EnrollmentRecorder, emits EnrollmentEvidence,
and checks those observations against the
ModeloAuthorizationEntry claimed by the bundled
authorization manifest.
The calculation surface is PreviousFilingSourceResolver, the source
mesh adapter for PREVIOUS_FILING. It
selects the caller’s RegistrySnapshot, delegates local observation
reading to resolve_bindings_from_local_store(), and
returns a CalculationSourceResolution
for the aggregation mesh.
The direct value-resolution contract lives in
_binding_prefill; this module records
enrollment proof and adapts its BindingPrefillReport
into source-mesh output.
- exception EnrollmentEvidenceError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
CoreValidationErrorRaised when an enrollment recording is missing its un-fakeable evidence.
Calculation-mode recordings require a strictly-positive produced-value count (a real calculation emitted casillas); non-calculation-mode recordings require both a non-empty context label AND a strictly-positive persisted-observation count (at least one real
RegistryModeloObservationwas saved to the realCalculationObservationRepositoryfor that year). A recording that supplies a label alone — without a persisted observation count — is label-only and therefore fakeable; the recorder refuses it.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class EnrollmentYearObservation(**data)[source]¶
Bases:
BaseModelOne renta year an enrolling test proved the backend exercised.
- Variables:
modelo – The modelo id whose backend was exercised.
filing_year – The distinct renta (annual) year exercised.
calculation_mode –
Truewhen the year was produced by a real calculation (calculate_modelo_revision/ registry calculate);Falsefor the non-calculation two-year-context registration used by informativa / reconciliation / structural modelos.produced_value_count – For calculation mode, the number of casilla values the real calculation produced — strictly positive, the evidence a calculation actually ran. Zero for non-calculation mode.
context_label – For non-calculation mode, the named real two-year context the test constructed (e.g. a fidelity-comparison label). Empty for calculation mode.
persisted_observation_count – For non-calculation mode, the number of
RegistryModeloObservationrecords the test actually persisted to the realCalculationObservationRepositoryfor this year — must be strictly positive, the evidence a real repository interaction occurred. Zero for calculation mode. Mirrors the role ofproduced_value_countin calculation mode: a context-mode year claimed with zero persisted observations is label-only and therefore fakeable; the recorder refuses it.
- Parameters:
- modelo: str¶
- filing_year: int¶
- calculation_mode: bool¶
- produced_value_count: int¶
- context_label: str¶
- persisted_observation_count: int¶
- class EnrollmentEvidence(**data)[source]¶
Bases:
BaseModelThe verified cross-year evidence an enrolling test produced for one modelo.
Constructed by
EnrollmentRecorder.evidence(). The>=2 distinct renta yearsinvariant is enforced here so an enrollment that did not actually span two distinct years cannot construct — the contract is unconstructable to violate, mirroringModeloAuthorizationEntry.- Parameters:
modelo (str)
observations (tuple[EnrollmentYearObservation, ...])
- modelo: str¶
- observations: tuple[EnrollmentYearObservation, ...]¶
- class EnrollmentRecorder(modelo)[source]¶
Bases:
objectAccumulates the renta years an enrolling test proves the backend exercised.
The enrolling test constructs one recorder per modelo, records each year it drives through the real backend, then calls
evidence()to obtain the verifiedEnrollmentEvidenceand assert it against the modelo’s manifest claim. The recorder is the natural home named by themodelo-multiyear-rentaADR for the un-fakeable enrollment contract.- Parameters:
modelo (str)
- record_calculation_year(*, filing_year, produced_value_count)[source]¶
Record a renta year produced by a real calculation.
- Parameters:
- Raises:
EnrollmentEvidenceError – When
produced_value_countis not strictly positive (no real calculation output to evidence the year).- Return type:
- record_context_year(*, filing_year, context_label, persisted_observation_count)[source]¶
Record a renta year exercised through a real non-calculation context.
For informativa / reconciliation / structural modelos that do not run a numeric calculation, the enrolling test still drives the real adapters for the year and names the context it constructed. To be un-fakeable the call must supply both a non-blank
context_labelAND a strictly positivepersisted_observation_count— the number ofRegistryModeloObservationrecords actually saved to the realCalculationObservationRepositoryfor this year. A label alone is not sufficient evidence: any string can be passed without touching the real adapters. The observation count proves a real repository interaction happened; it mirrors the role ofproduced_value_countinrecord_calculation_year().- Parameters:
filing_year (
int) – The renta year the test exercised.context_label (
str) – A non-empty label naming the real two-year context (e.g."347-fidelity-year-over-year").persisted_observation_count (
int) – The number ofRegistryModeloObservationrecords the test saved to the realCalculationObservationRepositoryfor this year. MUST be strictly positive — it is the evidence a real adapter interaction occurred.
- Raises:
EnrollmentEvidenceError – When
context_labelis blank or whenpersisted_observation_countis not strictly positive.- Return type:
- evidence()[source]¶
Return the verified cross-year evidence accumulated so far.
The recorder validates the
>=2 distinct renta yearsfloor here so the public API raises the documentedEnrollmentEvidenceErrordirectly;EnrollmentEvidencere-enforces the same invariant at its own type boundary as an unconstructable-to-violate backstop (a pydanticValidationErrorthere would wrap this error type).- Return type:
- Returns:
The verified
EnrollmentEvidence.- Raises:
EnrollmentEvidenceError – When fewer than two distinct renta years were recorded.
- assert_enrollment_matches_manifest(evidence, *, repository_root=None)[source]¶
Assert recorded enrollment evidence matches the modelo’s manifest claim.
The enrolling end-to-end test calls this after recording its years. It is the load-bearing cross-check that converts the manifest from an honour claim into a verified one: the recorded distinct-year set MUST equal the manifest entry’s declared
renta_yearsonModeloAuthorizationEntry. A mismatch (the test exercised different years than the manifest claims) raises, turning the enrolling test RED.- Parameters:
evidence (
EnrollmentEvidence) – The verified evidence fromEnrollmentRecorder.evidence().repository_root (
Path|None) – Optional registry root override (tests). WhenNonethe bundled registry authority’s manifest is used.
- Raises:
EnrollmentEvidenceError – When no manifest entry enrolls the modelo, or the recorded distinct-year set differs from the claimed
renta_years.- Return type:
- class PreviousFilingSourceResolver(*, repository=None, registry_snapshot=None, excluded_binding_ids=None)[source]¶
Bases:
objectSource mesh resolver for
source = "previous_filing"calculation bindings.Registered under
resolver_id = "previous_filing"in the source mesh and claimingPREVIOUS_FILING. When the calculation engine encounters a binding whose source is"previous_filing", this resolver reads the relevant prior-yearRegistryModeloObservationrecords from the localCalculationObservationRepositorythroughresolve_bindings_from_local_store(), then maps them into theCalculationSourceResolutionbinding channel. Storage-degradation errors (classification, decryption, version) are caught and returned as astorage_degradation_resolution()rather than propagated.- Parameters:
repository (CalculationObservationRepository | None)
registry_snapshot (RegistrySnapshot | None)
excluded_binding_ids (frozenset[BindingId] | None)
- resolver_id¶
-
owned_sources:
tuple[BindingSourceKind,...]¶
- resolve(context)[source]¶
- Return type:
- Parameters:
context (CalculationSourceContext)