aeat.application.modelo._work_addressing module¶
Application-level addressing for modelo work commands.
The address facade converts visible modelo/year/period filing targets and exact
work-unit ids into ModeloWorkAddress values, resolves them through the
central selector contract, and returns the matching
WorkUnit or CalculationRevision.
This module is the application facade over the accepted addressing policy:
operators address the active bucket/profile plus modelo, filing year, and period;
raw ids remain advanced exact-addressing escape hatches. Ambiguous visible
targets, contradictory exact-id plus natural-key flags, and discarded default
matches are handled by _selectors rather than by
CLI-local string logic.
Creation flows validate the law-determined registry revision before delegating
to create_work_unit(); an explicit
--revision is an assertion of the selected legal revision, not a free
override. Revision flows apply
ModeloCalculationRevisionSelector
defaults so verify, file, and export commands consume only the lifecycle states
they are allowed to handle.
See also
_selectors:The authoritative visible-target and revision-selector resolver.
_modelo:CLI commands that project operator flags into this facade.
- exception ModeloRevisionPickError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
ModeloError,ValueErrorRaised when a calculation-revision selector is internally inconsistent.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class ModeloVisibleFilingTarget(modelo, filing_year, period, registry_revision_id=None, bucket_id=None)[source]¶
Bases:
objectOperator-visible modelo filing target under one bucket/profile.
This is the normal user-facing address: bucket/profile plus modelo, filing year, and period, with an optional registry-revision assertion for disambiguation.
- Parameters:
- to_work_address()[source]¶
Project the visible target into the shared
ModeloWorkAddressshape.- Return type:
- class ModeloExactWorkUnitTarget(work_unit_id, bucket_id=None)[source]¶
Bases:
objectAdvanced exact-addressing target for one content-addressed work unit.
Use this only when the caller already has an authoritative
WorkUnitId; visible filing targets remain the default operator path.- Parameters:
- to_work_address()[source]¶
Project the exact target into the shared
ModeloWorkAddressshape.- Return type:
- class ModeloRevisionPick(selector=ModeloCalculationRevisionSelector.CURRENT, calculation_revision_id=None, default_for=None)[source]¶
Bases:
objectCommand-specific calculation-revision pick under a resolved work target.
default_forapplies the command policy owned by_selectors: verify selects a draft, file selects a verified-complete revision, and export prefers the current filed revision before falling back to an unambiguous verified revision.- Parameters:
selector (ModeloCalculationRevisionSelector)
calculation_revision_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)] | None)
default_for (ModeloCalculationRevisionDefault | None)
-
selector:
ModeloCalculationRevisionSelector¶
- classmethod explicit(calculation_revision_id)[source]¶
Create an exact calculation-revision
ModeloRevisionPick.
- class ModeloResolvedWorkProjection(work_unit_id, short_work_unit_id, bucket_id, modelo, filing_year, period, registry_revision_id, state, current_calculation_revision_id, filed_calculation_revision_id, current_filing_record_id, created_at, updated_at)[source]¶
Bases:
objectSupport-safe projection of a resolved modelo work target.
The projection exposes the visible filing coordinates plus short ids for support guidance without making raw ids the normal operator workflow.
- Parameters:
work_unit_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)])
short_work_unit_id (str)
bucket_id (str)
modelo (str)
filing_year (int)
period (Period)
registry_revision_id (str)
state (str)
current_calculation_revision_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)] | None)
filed_calculation_revision_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)] | None)
current_filing_record_id (str | None)
created_at (str)
updated_at (str)
- classmethod from_work_unit(work_unit)[source]¶
Project an internal
WorkUnitinto aModeloResolvedWorkProjection.- Return type:
- Parameters:
work_unit (WorkUnit)
- class ModeloResolvedRevisionProjection(calculation_revision_id, short_calculation_revision_id, work_unit_id, short_work_unit_id, selector, state, created_at, updated_at, verified_at=None, filed_at=None)[source]¶
Bases:
objectSupport-safe projection of a resolved calculation revision.
Carries the selected revision, selector policy, lifecycle state, and short ids used by CLI guidance after a work target has been resolved.
- Parameters:
calculation_revision_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)])
short_calculation_revision_id (str)
work_unit_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)])
short_work_unit_id (str)
selector (ModeloCalculationRevisionSelector)
state (str)
created_at (str)
updated_at (str)
verified_at (str | None)
filed_at (str | None)
-
selector:
ModeloCalculationRevisionSelector¶
- classmethod from_revision(revision, *, selector)[source]¶
Project a
CalculationRevisioninto aModeloResolvedRevisionProjection.- Return type:
- Parameters:
revision (CalculationRevision)
selector (ModeloCalculationRevisionSelector)
- class ModeloWorkAddress(work_unit_id=None, modelo=None, filing_year=None, period=None, registry_revision_id=None, bucket_id=None)[source]¶
Bases:
objectOperator-facing or exact modelo work address.
This is the shared transport shape consumed at the application facade boundary. Prefer
ModeloVisibleFilingTargetfor model/year/period addressing orModeloExactWorkUnitTargetfor the advanced exact-id escape hatch, then project into this shape before selector resolution.- Parameters:
work_unit_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=64, max_length=64, pattern=^[0-9a-f]{64}$, ascii_only=None)] | None)
modelo (str | None)
filing_year (int | None)
period (Period | None)
registry_revision_id (str | None)
bucket_id (str | None)
- classmethod from_visible_target(target)[source]¶
Create a
ModeloWorkAddressfrom a natural modelo filing target.- Return type:
- Parameters:
target (ModeloVisibleFilingTarget)
- classmethod from_exact_target(target)[source]¶
Create a
ModeloWorkAddressfrom an exact work-unit target.- Return type:
- Parameters:
target (ModeloExactWorkUnitTarget)
- exception ModeloWorkAddressNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
ModeloError,LookupErrorRaised when a natural modelo work address resolves no active work unit.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception ModeloWorkRegistryYearMismatchError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
ModeloError,ValueErrorRaised when an explicit revision diverges from the law-determined one.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception ModeloWorkPeriodTokenError(*, year, token, modelo, declared_tokens, fallback=None)[source]¶
Bases:
ModeloError,ValueErrorRaised when an operator-facing period token cannot be normalized.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class ModeloWorkEnsureResult(work_unit, reused, name_applied=None)[source]¶
Bases:
objectResult of resolving or creating a visible-target work unit.
- work_address_for_modelo_target(target)[source]¶
Coerce a typed modelo work target into a
ModeloWorkAddressselector shape.- Return type:
- Parameters:
target (ModeloWorkTarget)
- modelo_work_address_from_operator_target(*, work_unit_id, modelo, year, period, registry_revision_id, bucket_id=None)[source]¶
Build a
ModeloWorkAddressfrom exact or visible operator input.A complete visible target is
modelo+year+ typedPeriod. If no visible target is supplied, an exactwork_unit_idis required. Period year mismatches fail here before the selector sees the request.
- resolve_modelo_work_unit_for_operator_target(*, work_unit_id=None, modelo=None, year=None, period=None, registry_revision_id=None, bucket_id=None)[source]¶
Resolve exact or visible operator input to one active
WorkUnit.The result comes from the shared selector boundary, so ambiguity and exact-id/natural-key contradictions surface as typed selector errors.
- resolve_modelo_revision_for_operator_target(*, calculation_revision_id, work_unit_id, modelo, year, period, registry_revision_id, bucket_id=None, selector=ModeloCalculationRevisionSelector.CURRENT, default_for=None)[source]¶
Resolve one
CalculationRevisionfrom exact or visible operator input.An explicit calculation-revision id can stand alone as the exact escape hatch. Otherwise the work target is resolved first and the selector/default policy is applied under that work unit.
- Return type:
- Parameters:
- resolve_modelo_work_target(target)[source]¶
Resolve any supported modelo target through the shared selector boundary.
Returns a
ModeloWorkResolutioncontaining the resolved work unit or typed absence/ambiguity metadata from_selectors.- Return type:
- Parameters:
target (ModeloWorkTarget)
- resolve_modelo_work_unit_id(target)[source]¶
Resolve a visible or exact modelo target to the authoritative work-unit id.
- Return type:
- Parameters:
target (ModeloWorkTarget)
- project_modelo_work_unit(work_unit)[source]¶
Project an internal work unit into the visible
ModeloResolvedWorkProjectionaddressing contract.- Return type:
- Parameters:
work_unit (WorkUnit)
- project_modelo_work_target(target)[source]¶
Resolve a target and project it back to a
ModeloResolvedWorkProjection.- Return type:
- Parameters:
target (ModeloWorkTarget)
- resolve_registry_revision_for_work_target(*, modelo, filing_year, period, registry_revision_id)[source]¶
Resolve and validate the registry revision for a visible filing target.
When
registry_revision_idisNonethe law-determined revision for(modelo, filing_year, period)is returned unconditionally.When
registry_revision_idis supplied it is treated as an assertion parameter (perselect_revision()): an explicit--revisionis accepted only when it names exactly the revision thatselect_revisionwould pick from(filing_year, period)alone. If the supplied id diverges from the law-determined revision the call refuses with an instructive error naming both the requested and the law-determined revision and stating that the binding is fixed by law (per the CLI-boundary instructive-refusal mandate inaeat-architecture-boundaries).--revisionis thereby demoted from a free override to an idempotence/assertion handle, mirroring the operator-surface ADR’s D8 shape forpreflight --revision-id.- Return type:
- Returns:
The revision id selected by
select_revision().- Raises:
ModeloWorkRegistryYearMismatchError – The supplied revision id is not the law-determined revision for the visible filing period.
- Parameters:
- ensure_modelo_work_unit_for_visible_target(*, bucket_id, modelo, filing_year, period, registry_revision_id, name=None, actor='operator', causante_ccaa=None, enforce_applicability=True)[source]¶
Resume or create the active work unit for one visible filing target.
The visible target is resolved first. If one active unit exists, it is reused after profile-readiness validation and optional rename. If none exists, the law-determined registry revision is selected and a work unit is created.
- Return type:
- Returns:
A
ModeloWorkEnsureResultmarking whether the unit was reused or newly created.- Parameters:
- resolve_modelo_work_address(address)[source]¶
Resolve an operator-facing modelo work address to a required
ModeloWorkResolution.- Return type:
- Parameters:
address (ModeloWorkAddress)
- resolve_optional_modelo_work_address(address)[source]¶
Resolve an operator-facing modelo work address to a
ModeloWorkResolution.- Return type:
- Parameters:
address (ModeloWorkAddress)
- resolve_modelo_work_address_unit(address)[source]¶
Resolve an operator-facing modelo work address to one
WorkUnit.- Return type:
- Parameters:
address (ModeloWorkAddress)
- resolve_modelo_calculation_revision_address(*, address, calculation_revision_id=None, selector=ModeloCalculationRevisionSelector.CURRENT, default_for=None)[source]¶
Resolve a
CalculationRevisionby exact id or under a modelo work address.default_forapplies the command-specific selector default after the work unit is resolved. A bare exact calculation-revision id bypasses work-address resolution and loads the revision directly.- Return type:
- Parameters:
address (ModeloWorkAddress)
calculation_revision_id (str | None)
selector (ModeloCalculationRevisionSelector)
default_for (ModeloCalculationRevisionDefault | None)
- resolve_modelo_revision_pick(*, target, pick=None)[source]¶
Resolve and project a revision selection as
ModeloResolvedRevisionProjection.- Return type:
- Parameters:
target (ModeloWorkTarget)
pick (ModeloRevisionPick | None)
- resolve_verifiable_modelo_calculation_revision_address(*, address, calculation_revision_id=None, selector=ModeloCalculationRevisionSelector.CURRENT)[source]¶
Resolve the draft
CalculationRevisionthatwork verifymay consume.- Return type:
- Parameters:
address (ModeloWorkAddress)
calculation_revision_id (str | None)
selector (ModeloCalculationRevisionSelector)
- resolve_fileable_modelo_calculation_revision_address(*, address, calculation_revision_id=None, selector=ModeloCalculationRevisionSelector.CURRENT)[source]¶
Resolve the verified-complete
CalculationRevisionthatwork filemay consume.- Return type:
- Parameters:
address (ModeloWorkAddress)
calculation_revision_id (str | None)
selector (ModeloCalculationRevisionSelector)
- resolve_exportable_modelo_calculation_revision_address(*, address, calculation_revision_id=None, selector=ModeloCalculationRevisionSelector.CURRENT)[source]¶
Resolve the filed or verified-complete
CalculationRevisionthatmodelo exportmay consume.- Return type:
- Parameters:
address (ModeloWorkAddress)
calculation_revision_id (str | None)
selector (ModeloCalculationRevisionSelector)