cadrumo.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().
This module is the production entry point through which callers (CLI, workflow, services) construct profiles and schema providers.
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.build_runtime_schema_provider()— requires registry-backed snapshots.schema_provider_from_authority()— projects an explicitly supplied validated authority through the same provider surface.
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.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:
data (Any)
- 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, complete
CasillaConstraintscontract and regulatory grounding (legal_refs,source_refs) from the authoritativeCasillaDefinition.- Parameters:
data (Any)
- 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, ...]¶
- constraints: CasillaConstraints | 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 ordered by canonical
casilla_id.Deliberately not registry declaration order: the loader compiles
revision.casillasin casilla-fragment filename order, so declaration order tracks the corpus layout rather than anything the filing surface should depend on.collection_from_snapshot()sorts by canonical id so this projection stays stable under a fragment rename.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=(), rate_box_partitions=(), profile_export_bindings=())[source]¶
Bases:
objectSnapshot-backed filing details for one modelo revision.
- Parameters:
modelo_id (str)
revision_id (RevisionId)
schema_version (str)
cadence (str)
legal_ref_ids (tuple[LegalRefId, ...])
source_ref_ids (tuple[SourceRefId, ...])
reconciliation_total_casilla_ids (Mapping[Annotated[SettlementDirection, BeforeValidator(func=~cadrumo.domain.calculations.registry.schema_base.coerce_enum_member.<locals>._coerce, json_schema_input_type=PydanticUndefined)], CasillaId])
export_layouts (tuple[ExportLayoutDefinition, ...])
completeness_manifest (CalculationCompletenessManifest | None)
casilla_record_metadata (tuple[CasillaRecordMetadata, ...])
rate_box_partitions (tuple[RateBoxPartition, ...])
profile_export_bindings (tuple[BindingDefinition, ...])
-
revision_id:
TypeAliasType¶
-
reconciliation_total_casilla_ids:
Mapping[Annotated[SettlementDirection],TypeAliasType]¶
-
export_layouts:
tuple[ExportLayoutDefinition,...]¶
-
completeness_manifest:
CalculationCompletenessManifest|None¶
-
casilla_record_metadata:
tuple[CasillaRecordMetadata,...]¶
-
rate_box_partitions:
tuple[RateBoxPartition,...]¶ one rate-blind total casilla and the rate-specific casillas that break it down.
A derivation, not a second copy of the binding set: the whole ledger-IVA binding tuple would make this a shadow snapshot, so what is carried is only the pairing the export gate needs. The gate refuses a return whose rate boxes account for less than their total, and it cannot re-derive the pairing itself without a revision it does not hold.
Empty for every revision declaring no rate-specific binding, which is every revision until a modelo splits a tier casilla into its box and total layers.
- Type:
Two-layer rate partitions the revision declares
-
profile_export_bindings:
tuple[BindingDefinition,...]¶ Profile bindings that declare an address on the exported record.
Deliberately NOT every profile binding: only those carrying a
dictionary_field, which is what makes a binding addressable on the exported declaration. A subview carrying the whole binding set would stop being a projection and start being a second snapshot, which is the shape the registry authority owns and this class must not duplicate.The export header composer reads these to populate the identity slots AEAT’s dictionary names, so the join is driven by the registry’s own declarations rather than by a hand-written map per field.
- 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, snapshots, sources=<factory>, evidence=<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 (Mapping[str, RegistryCasillaCollection])
subviews (Mapping[str, RegistryModeloSubview])
snapshots (Mapping[str, RegistrySnapshot])
sources (Mapping[SourceRefId, SourceReference])
evidence (AuthorityEvidenceProjection)
-
collections:
Mapping[str,RegistryCasillaCollection]¶
-
subviews:
Mapping[str,RegistryModeloSubview]¶
-
snapshots:
Mapping[str,RegistrySnapshot]¶
-
sources:
Mapping[TypeAliasType,SourceReference]¶
-
evidence:
AuthorityEvidenceProjection¶
- source_payload(source_ref_id)[source]¶
Return published authority bytes for one runtime source reference.
- Return type:
- Parameters:
source_ref_id (SourceRefId)
- property source_payloads: Mapping[str, bytes]¶
Expose the immutable signed source projection for layout consumers.
- 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.
- build_runtime_schema_provider(*, filing_year, period, modelos=None, operation=None)[source]¶
Build a
RegistrySchemaAccessorfrom validated snapshots.filing_yearandperiodare required andperiodmust be a typedPeriod; raw registry tokens are rejected before snapshot lookup.The provider has no registry or source-root override: filing flows consume the immutable authority bundled with the installed package.
- Parameters:
filing_year (
int) – Filing year of the draft or request.modelos (
Sequence[str] |None) – Optional modelo id selection. Blank ids are rejected.operation (
PinnedAuthorityOperation|None) – Optional generation-pinned indexed authority operation. When supplied,modelosmust name the requested models explicitly and snapshots are loaded through point revision/directory access.
- 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.
- schema_provider_from_authority(authority, *, filing_year, period, modelos=None, operation=None)[source]¶
Build a
RegistrySchemaAccessorfrom an explicit validated authority.Applies the same period validation, modelo selection and snapshot projection as
build_runtime_schema_provider(), which delegates here with the bundled authority. Callers that hold a separately compiled authority (for example a development build of the registry source tree) use this entry point to project it through the identical filing surface.- Parameters:
authority (
ValidatedRegistryAuthority) – Validated registry authority to project.filing_year (
int) – Filing year of the draft or request.modelos (
Sequence[str] |None) – Optional modelo id selection. Blank ids are rejected.operation (
PinnedAuthorityOperation|None) – Optional generation-pinned indexed authority operation. When supplied, it takes precedence over the eager authority for the selected model point loads.
- 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.
Core types:
ValidatedRegistryAuthority.
- 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.
- subview_from_snapshot(snapshot)[source]¶
Project a validated snapshot into the modelo subview the filing handoff carries.
Core types:
RegistrySnapshot.- Return type:
- Parameters:
snapshot (RegistrySnapshot)
- 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.protocols.CasillaSchema:"decimal","int","str","bool", or"date".- Raises:
ModeloBuilderError – When
data_typeis not a supported registry casilla type.- Return type:
- Parameters:
data_type (str)