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: object

Load, validate, and cache registry material behind one access point.

Parameters:
root: Path
source_root: Path
modelos: tuple[ModeloDefinition, ...]
catalogues: RegistryCatalogues
classmethod load(root, *, source_root)[source]

Load registry TOML and construct a reusable ValidatedRegistryAuthority instance.

Return type:

ValidatedRegistryAuthority

Parameters:
modelo(modelo_id)[source]

Return a modelo definition by id.

Return type:

ModeloDefinition

Returns:

The ModeloDefinition for modelo_id.

Parameters:

modelo_id (str)

validate_modelo(modelo_id)[source]

Validate one modelo once and return its definition.

Return type:

ModeloDefinition

Returns:

The validated ModeloDefinition for modelo_id.

Parameters:

modelo_id (str)

validate_registry()[source]

Validate the full registry tree once.

Return type:

None

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 AuthorizationManifest object.

modelo_has_engine(modelo_id)[source]

Return whether modelo_id declares a calculation surface.

A modelo “has an engine” when any of its revisions declares an application-link whose surface is "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 at work create). Returns False for 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.

Return type:

bool

Parameters:

modelo_id (str)

authorization(modelo_id)[source]

Return the derived per-modelo authorization capability.

This is the layer-(b) derivation of the modelo-multiyear-renta gate: 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 to UNAUTHORIZED with has_engine = False, which is the correct default for the engine-build modelos that carry no loadable definition yet.

Return type:

ModeloAuthorization

Returns:

The derived ModeloAuthorization for modelo_id.

Parameters:

modelo_id (str)

snapshot(modelo_id, *, filing_year, period, on=None, revision_id=None)[source]

Return a cached validated RegistrySnapshot for one filing context.

Return type:

RegistrySnapshot

Parameters:
  • modelo_id (str)

  • filing_year (int)

  • period (str)

  • on (date | None)

  • revision_id (str | None)

deadline_windows(year, *, modelos=None)[source]

Return validated deadline windows registered for year.

Return type:

tuple[tuple[str, ModeloRevision, DeadlineWindowDefinition], ...]

Parameters:
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:

ValidatedRegistryAuthority

Returns:

A ValidatedRegistryAuthority loaded from the bundled registry tree.