aeat.domain.calculations.registry._authority module¶
Validated access point for registry-backed modelo definitions.
ValidatedRegistryAuthority is the production boundary for all registry
access. It loads TOML sources via the compiler in _loader, compiles them
into ModeloDefinition and ModeloRevision objects, and
produces RegistrySnapshot instances on demand for each filing context.
- class ValidatedRegistryAuthority(root, source_root, modelos, catalogues, _modelos_by_id, _validator, _registry_validated, _validated_modelos, _snapshots, _authorization_manifest)[source]¶
Bases:
objectLoad, validate, and cache registry material behind one access point.
- Parameters:
root (Path)
source_root (Path)
modelos (tuple[ModeloDefinition, ...])
catalogues (RegistryCatalogues)
_modelos_by_id (dict[str, ModeloDefinition])
_validator (RegistryValidator)
_registry_validated (bool)
_snapshots (dict[tuple[str, int, str, date | None, str | None], RegistrySnapshot])
_authorization_manifest (AuthorizationManifest)
-
root:
Path¶
-
source_root:
Path¶
-
modelos:
tuple[ModeloDefinition,...]¶
-
catalogues:
RegistryCatalogues¶
- classmethod load(root, *, source_root)[source]¶
Load registry TOML and construct a reusable
ValidatedRegistryAuthorityinstance.- Return type:
- Parameters:
- modelo(modelo_id)[source]¶
Return a modelo definition by id.
- Return type:
- Returns:
The
ModeloDefinitionformodelo_id.- Parameters:
modelo_id (str)
- validate_modelo(modelo_id)[source]¶
Validate one modelo once and return its definition.
- Return type:
- Returns:
The validated
ModeloDefinitionformodelo_id.- Parameters:
modelo_id (str)
- property authorization_manifest: AuthorizationManifest¶
Return the loaded multi-year-renta authorization manifest.
The manifest is the single writable authorization surface; the CI meta-test reads it through this accessor to cross-check each enrolling claim against the recorder evidence.
- Returns:
The loaded
AuthorizationManifestobject.
- modelo_has_engine(modelo_id)[source]¶
Return whether
modelo_iddeclares a calculation surface.A modelo “has an engine” when any of its revisions declares an application-link whose
surfaceis"calculation"— the registry’s own marker that a runtime calculation consumer is wired for the modelo. This drives the authorization gate’s ADVISORY-vs-refusal split (an unauthorized modelo with an engine still computes with an advisory banner; one with no engine is refused atwork create). ReturnsFalsefor an unknown modelo rather than raising, so the fleet-wide capability sweep can ask about every canonical modelo id including the engine-build modelos that do not load yet.
- authorization(modelo_id)[source]¶
Return the derived per-modelo authorization capability.
This is the layer-(b) derivation of the
modelo-multiyear-rentagate: the capability is computed from the manifest (layer a) cross-checked against the loaded registry — never an independently authored per-revision flag — so it cannot drift from the manifest. An unknown / not-yet-loadable modelo derives toUNAUTHORIZEDwithhas_engine = False, which is the correct default for the engine-build modelos that carry no loadable definition yet.- Return type:
- Returns:
The derived
ModeloAuthorizationformodelo_id.- Parameters:
modelo_id (str)
- snapshot(modelo_id, *, filing_year, period, on=None, revision_id=None)[source]¶
Return a cached validated
RegistrySnapshotfor one filing context.
- bundled_authority()[source]¶
Return an authority loaded from the package-bundled AEAT registry.
Callers that always load the same default registry path use this instead of writing the bundled-path boilerplate inline. The result is backed by
_load_authority()’s LRU cache, so repeated calls within one process are free.- Return type:
- Returns:
A
ValidatedRegistryAuthorityloaded from the bundled registry tree.