cadrumo.application.workflow.protocols module¶
Protocol contracts for every component the workflow engine composes.
The composite workflow engine is defined against typing.Protocol
surfaces — not concrete classes — for two reasons:
Cross-subpackage decoupling. Each Protocol lets the workflow engine integrate with an in-house subpackage without forcing a hard import dependency at the engine layer; adapters in
application.workflow.adapterstranslate the richer real surfaces onto these narrow Protocols.Protocol-shaped tests. Tests can supply narrow Protocol-conforming classes per scenario without importing the production adapters at the workflow layer.
Every Protocol here describes only the attributes the workflow
engine actually reads. DeadlineEngineProtocol wraps the
deadline engine’s compute method that returns a Schedule
for a given TaxpayerProfile.
See also
WorkflowEngineOrchestrates these contracts stage by stage.
application.workflow.adaptersAdapts production deadline, draft-building, submission, and live-read components to these contracts.
SubmissionEngineImplements the read-only preflight surface described by
SubmissionEngineProtocol.WorkflowPurposeDecides when workflow callers skip the AEAT filing-window preflight gate for local verification or local mark-as-filed paths.
- class WorkflowFindingLike(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow structural port over one registry-backed draft finding.
Wider than
domain.submission.protocols.ModeloFindingLike, which declares onlyseverity– the preflight gate reads severity alone and needs nocode. Every finding aRegistryModeloDraftProtocoldraft actually carries is adomain.filing.schema.ModeloValidationFinding, which declares bothseverityandcodeas required fields with no default. TypingRegistryModeloDraftProtocol.findingsthrough this Protocol lets workflow-layer readers usefinding.severity/finding.codedirectly instead of agetattr(..., None)guess – a field rename now fails loud instead of silently excluding every finding from whatever reads through it.- property severity: BaseSeverity¶
Return the severity that the workflow preflight should report.
- class DeadlineEngineProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow surface over
domain.deadlines.engine.DeadlineEngine.- compute(profile, year, *, today=None)[source]¶
Return a
Scheduleforprofileinyear.- Parameters:
profile (
TaxpayerProfile) – TheTaxpayerProfilewhose filing obligations are scheduled.year (
int) – The calendar year for which the schedule is computed.today (
date|None) – Optional reference date for open-period classification.
- Return type:
- class RegistryModeloDraftProtocol(*args, **kwargs)[source]¶
Bases:
ModeloDraftLike,ProtocolWorkflow draft surface after registry-backed filing construction.
- property findings: tuple[WorkflowFindingLike, ...]¶
Return the validation findings the error-severity gate reads.
- class ModeloDraftBuilderProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow surface over
application.filing.draft_construction.build_draft().- build(*, modelo, period, profile, inputs, fail_on_warning=False)[source]¶
Build a registry-backed filing draft for the given
TaxpayerProfile.Returns a
RegistryModeloDraftProtocol.- Return type:
- Parameters:
modelo (str)
period (Period)
profile (TaxpayerProfile)
inputs (ModeloInputs)
fail_on_warning (bool)
- class SubmissionEngineProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolRead-only preflight surface over
SubmissionEngine.- preflight(draft, *, today, skip_deadline_window=False, skip_auth_readiness=False)[source]¶
Run preflight gates against
draft; raise on failure.skip_deadline_windowskips the AEAT filing-window gate. The local workflow uses this for bothWorkflowPurpose.VERIFYandWorkflowPurpose.FILE: VERIFY is calendar-independent, while FILE is a local mark-as-filed path whose obligation existence has already been enforced by the deadline stage.skip_auth_readinessskips the auth-provider readiness gate. Both workflow purposes are local (the app never performs an actual AEAT submission), so auth is not required to complete the local build/verify/file/export flow; only live/AEAT-touching callers keep the gate enabled.- Return type:
- Parameters:
draft (RegistryModeloDraftProtocol)
today (date)
skip_deadline_window (bool)
skip_auth_readiness (bool)
- class CertificateBundleProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow contract for the auth-provider probe used by workflow preflight.
The workflow engine calls
describe()once during the preflight stage to prove the configured auth provider is present and healthy. Any exception raised here is translated intoapplication.workflow.abort.WorkflowAbortReason.CERT_INVALIDto preserve the existing workflow abort taxonomy.- describe()[source]¶
Return the current auth-provider description; raise on failure.
Returns a
core.auth_provider.AuthProviderDescriptionwith the provider’s configured and available state.- Return type:
- class ModeloInputsProviderProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolProvides filing inputs for the draft stage.
Production adapters load inputs from bucket-scoped, secure application services rather than operator-supplied files.
- load_inputs(*, modelo, period, profile)[source]¶
Return the filing inputs for the draft build against the given
TaxpayerProfile.- Return type:
TypeAliasType- Parameters:
modelo (str)
period (Period)
profile (TaxpayerProfile)
- class WorkflowExpedienteProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow read surface for one AEAT expediente (open proceeding) entry.
An expediente is an administrative dossier AEAT associates with one modelo (e.g.
"303") and one ejercicio (tax year). The workflow engine reads these two fields to decide whether an open proceeding blocks filing.
- class WorkflowNotificationProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolNarrow read surface for one AEAT inbox notification entry.
The workflow engine reads
tipo,leida,certificado_id, andconceptoto decide whether an unread blocking notification (typically a requerimiento) should abort the current run.
- class WorkflowNotificationsSnapshotProtocol(*args, **kwargs)[source]¶
Bases:
ProtocolContainer protocol for a point-in-time AEAT inbox snapshot.
Wraps a sequence of
WorkflowNotificationProtocolrows returned by the AEAT inbox adapter. The engine iteratesrowsonce to find blocking requerimientos.- property rows: Sequence[WorkflowNotificationProtocol]¶
Return the notification rows contained in this snapshot.