aeat.application.filing.runtime module¶
Production runtime helpers for application.filing.
Exposes concrete profile helpers used by the CLI and workflow surfaces.
The production schema provider requires validated registry snapshots and
projects them into the CasillaSchemaProvider
surface consumed by build_draft().
The filing runtime must not depend on
application.filing.testing; this module is the production
entry point that callers (CLI, workflow, services) construct profiles
and schema providers through.
Key entry points:
ModeloOperatorProfile— pydantic v2 record satisfying the filing-profile Protocol.filing_profile_from_taxpayer()— projects taxpayer identity from a domainTaxpayerProfileinto the runtime profile shape without deriving legal filing obligations.load_default_filing_profile()— loads the active profile bucket and returns a runtime profile.build_runtime_schema_provider()— requires registry-backed snapshots.
The schema provider consumes a
RegistrySnapshot built from a
ModeloRevision within a
ModeloDefinition, accessed through
a ValidatedRegistryAuthority loaded
from the configured registry root.
See also
application.wizard._status.load_active_taxpayer_profile()Active-profile bridge that supplies the
domain.deadlines.TaxpayerProfileprojected here.application.modelo._workflow_gateCalculation-revision workflow gate that uses this runtime provider to build and approve filing drafts.
application.modelo._revision_replay_inputsConverts stored calculation revisions into the flat filing inputs accepted by this runtime surface.
- class TaxpayerProfileIdentity(*args, **kwargs)[source]¶
Bases:
ProtocolStructural identity surface accepted by the filing profile projector.
- property tax_id: SubjectTaxId¶
Validated tax identity copied into the filing runtime profile.
- class ModeloOperatorProfile(**data)[source]¶
Bases:
BaseModelConcrete runtime implementation of the filing-profile Protocol.
Strict, frozen pydantic v2 model satisfying the filing layer’s profile Protocol.
- Variables:
tax_id – Validated NIF / NIE / CIF of the filing operator.
display_name – Human-readable label for the profile.
- Parameters:
tax_id (SubjectTaxId)
display_name (str)
- tax_id: SubjectTaxId¶
- display_name: str¶
- class RegistryCasillaSchema(**data)[source]¶
Bases:
BaseModelFiling schema projection for one registry casilla.
Strict, frozen pydantic v2 projection preserving typed IDs,
Decimalbounds, and the regulatory grounding (legal_refs,source_refs) from the authoritativeCasillaDefinition.- Parameters:
- casilla_id: CasillaId¶
- value_type: str¶
- required: bool¶
- formula: FormulaId | None¶
- formula_input_casilla_ids: tuple[CasillaId, ...]¶
- legal_refs: tuple[LegalRefId, ...]¶
- source_refs: tuple[SourceRefId, ...]¶
- min_value: Decimal | None¶
- max_value: Decimal | None¶
- default: object | None¶
- class RegistryCasillaCollection(casillas, schema_version)[source]¶
Bases:
objectFiling schema collection projected from one modelo registry definition.
- Parameters:
casillas (tuple[RegistryCasillaSchema, ...])
schema_version (str)
-
casillas:
tuple[RegistryCasillaSchema,...]¶
- get(casilla_id)[source]¶
Return the
CasillaSchemaforcasilla_id, orNoneif absent.- Return type:
- Parameters:
casilla_id (CasillaId)
- all()[source]¶
Return all casilla schemas in declaration order.
Each element is a
CasillaSchema.- Return type:
- class CasillaRecordMetadata(casilla_id, number, segmento)[source]¶
Bases:
objectRegistry-declared official record-design metadata for one casilla.
Projected verbatim from the authoritative
CasillaDefinition— the same authority the calculation engine consumes — so the fichero-BOE export parity gate can re-ground the rendered casilla’s number and segmento against the registry declaration at the render choke point rather than trusting the completeness manifest’s own copy of that metadata.- Variables:
casilla_id – Canonical registry casilla identity.
number – AEAT record-design casilla number.
segmento – AEAT record-segment code for multi-segment modelos, or
Nonefor single-segment modelos.
- Parameters:
-
casilla_id:
TypeAliasType¶
- class RegistryModeloSubview(modelo_id, revision_id, schema_version, cadence, period_selector_periods, legal_ref_ids, source_ref_ids, extraction_profile_ids, verification_expectation_ids, reconciliation_total_casilla_ids, export_layout_ids, export_layouts, application_link_ids, deadline_window_ids, completeness_manifest, casilla_record_metadata=())[source]¶
Bases:
objectSnapshot-backed filing details for one modelo revision.
- Parameters:
modelo_id (str)
revision_id (str)
schema_version (str)
cadence (str)
legal_ref_ids (tuple[LegalRefId, ...])
source_ref_ids (tuple[SourceRefId, ...])
reconciliation_total_casilla_ids (Mapping[Literal['ingresar', 'devolver'], CasillaId])
export_layouts (tuple[ExportLayoutDefinition, ...])
completeness_manifest (CalculationCompletenessManifest | None)
casilla_record_metadata (tuple[CasillaRecordMetadata, ...])
-
export_layouts:
tuple[ExportLayoutDefinition,...]¶
-
completeness_manifest:
CalculationCompletenessManifest|None¶
-
casilla_record_metadata:
tuple[CasillaRecordMetadata,...]¶
- has_completeness_manifest()[source]¶
Return whether this revision carries a calculation-completeness manifest.
The manifest is the AEAT Diseño de Registros calculation-closure projection (
CalculationCompletenessManifest) that grounds the fichero-BOE export parity gate. A revision without one cannot have its .boe export checked for casilla completeness, so the export path surfaces a coverage advisory rather than asserting parity.- Return type:
- class RegistrySchemaAccessor(collections, subviews, source_root=None, sources=<factory>)[source]¶
Bases:
objectRegistry-backed filing schema accessor.
The concrete registry-schema accessor (it provides casilla collections and modelo subviews from validated registry TOML); structurally satisfies the
CasillaSchemaProviderprotocol. Named an accessor to stay distinct from the settled calculate-mesh resolver port.- Parameters:
collections (dict[str, RegistryCasillaCollection])
subviews (dict[str, RegistryModeloSubview])
source_root (Path | None)
sources (Mapping[SourceRefId, SourceReference])
-
collections:
dict[str,RegistryCasillaCollection]¶
-
subviews:
dict[str,RegistryModeloSubview]¶
-
sources:
Mapping[TypeAliasType,SourceReference]¶
- get_collection(modelo)[source]¶
Return the casilla collection for
modelo.Returns a
CasillaCollectionfor the modelo. RaisesModeloBuilderErrorwhen the modelo is absent.- Return type:
- Parameters:
modelo (str)
- get_subview(modelo)[source]¶
Return the
RegistryModeloSubviewbackingmodelo.- Return type:
- Parameters:
modelo (str)
- filing_profile_from_taxpayer(profile, *, display_name=None)[source]¶
Project taxpayer identity into a
ModeloOperatorProfile.The common caller passes
TaxpayerProfile, but the accepted contract is the narrowerTaxpayerProfileIdentityProtocol. This helper deliberately copies only taxpayer identity. Modelo applicability is legal filing truth and must come from validated registry data, not a filing-runtime tuple or the deadline engine.- Parameters:
profile (
TaxpayerProfileIdentity) – Source identity object exposingtax_id.display_name (
str|None) – Optional friendly label; defaults toprofile.tax_id.
- Return type:
- Returns:
A frozen
ModeloOperatorProfile.
- load_default_filing_profile(*, display_name=None)[source]¶
Load the active profile bucket for runtime filing commands.
Resolves the active workflow profile via the wizard descriptor’s typed projection and re-shapes it as a runtime
ModeloOperatorProfile. Operator profile values stored in the profile bucket are the single source of truth.- Parameters:
display_name (
str|None) – Optional friendly label propagated to the returned profile.- Return type:
- Returns:
The loaded
ModeloOperatorProfile.- Raises:
ModeloBuilderError – When no profile is active in the workflow state.
- build_runtime_schema_provider(registry_root=None, *, source_root=None, filing_year=None, period=None, modelos=None)[source]¶
Build a
RegistrySchemaAccessorfrom validated registry TOML.When
filing_yearandperiodare supplied, both are required andperiodmust be a typedPeriod; raw registry tokens are rejected before snapshot lookup. Without an explicit period, the provider selects the current open revision for each modelo.- Parameters:
registry_root (
Path|None) – Optional registry root. Defaults to the bundled AEAT registry.source_root (
Path|None) – Optional source-material root used byValidatedRegistryAuthority.filing_year (
int|None) – Optional filing year; must be paired withperiod.period (
object|None) – Optional typedPeriod; must matchfiling_year.modelos (
Sequence[str] |None) – Optional modelo id selection. Blank ids are rejected.
- Return type:
- Returns:
A
RegistrySchemaAccessorimplementing the filingCasillaSchemaProvidersurface.- Raises:
ModeloBuilderError – When the registry is empty, a requested modelo is missing, the period arguments are invalid, or no snapshot exists for the requested filing context.
- clear_runtime_fingerprint_cache()[source]¶
Clear the time-based TTL cache for registry tree fingerprints.
- Return type:
- registry_tree_fingerprint(root)[source]¶
Return the TTL-cached registry tree fingerprint for runtime schema loading.
The fingerprint covers
legalandmodelosTOML files underrootand is keyed by relative path, mtime, and size. It is used as a cache key forbuild_runtime_schema_provider(); callclear_runtime_fingerprint_cache()when tests or tooling mutate the registry tree inside the one-second TTL.
- collection_from_snapshot(snapshot)[source]¶
Project a validated registry snapshot into a runtime casilla collection.
- Parameters:
snapshot (
RegistrySnapshot) – TheRegistrySnapshotwhoseModeloRevisionis projected into filing-runtime casilla schemas.- Return type:
- Returns:
A
RegistryCasillaCollectionwith the snapshot revision’s casillas andregistry:{modelo}:{revision}schema version.- Raises:
ModeloBuilderError – When the snapshot revision contains ambiguous casilla references and cannot be projected safely.
- registry_value_type(data_type)[source]¶
Map a registry casilla data type to the filing runtime value type.
Returns one of the value-type tags consumed by
domain.filing.CasillaSchema:"decimal","int","str","bool", or"date".- Raises:
ModeloBuilderError – When
data_typeis not a supported registry casilla type.- Return type:
- Parameters:
data_type (str)