cadrumo.application.modelo.verification_actions module

Verification actions and predicates for modelo filings.

verify_modelo_revision() evaluates a draft CalculationRevision against its RegistrySnapshot, workflow TaxpayerProfile, ledger diagnostics, registry verification predicates, and cross-period clean-state verdicts before persisting a VerificationReport.

Verification findings are the operator-facing gate vocabulary. BLOCKING-severity findings refuse the verified-complete transition; WARNING-severity ADVISORY findings remain visible in the report without bricking verify, file, or export. Calculate-path source diagnostics are separate CalculationSourceDiagnostic advisories; this module converts only verify-time registry, profile, provenance, and cross-period facts into ModeloVerificationFinding records.

Verification emits bucket-history entries through BucketEventHistoryRepository, stores casilla-level CasillaObservation provenance, and consumes the required VerificationRepositoryBundle for all persistence capabilities.

Draft-construction structural validation is a distinct, nested stage, not a parallel pipeline. When verification grants, this module runs the revision workflow gate with VERIFY; that gate builds a filing draft, and the draft builder stamps ModeloValidationFinding rows produced by ModeloValidator onto the draft, which the workflow engine re-scans for ERROR severity. Those structural findings answer whether the draft is well-formed against the casilla collection; ModeloVerificationFinding answers operator-facing filing readiness and carries registry legal_refs provenance the structural model does not. The two vocabularies are not interchangeable.

See also

ModeloValidator:

Draft-construction structural validator reached through the workflow gate’s draft builder; owns ModeloValidationFinding.

evaluate_cross_period_clean_state():

Shared cross-period gate used by verify, file, and export.

calculation_diagnostics:

Calculate-path diagnostics that feed advisory observations before verify.

modelos:

Finding kind, severity, and completeness-status authority.

Core types: ModeloRevision.

m210_unresolved_outcome_findings(unresolved_outcomes, *, profile, snapshot, year, devengo_date, tipo_renta, blocking_finding_observer=None)[source]

Convert typed M210 unresolved engine outcomes into verification findings.

Core types: RegistrySnapshot, TaxpayerProfile.

Return type:

list[ModeloVerificationFinding]

Parameters:
missing_evidence_findings(*, target, work_unit, transaction_repository, blocking_finding_observer=None)[source]

Build verification findings for evidence-less positive IVA rows.

Loads the CalculationRevision source transactions for the supplied WorkUnit and projects each CalculationSourceDiagnostic (reason missing_transaction_evidence) into a ModeloVerificationFinding. A deductible input-IVA gap BLOCKS the verified-complete transition; an output-IVA gap stays advisory. A revision with no contributing transactions, or whose significant rows all carry evidence, yields no findings.

The split is deliberate and legally grounded rather than a severity preference. Deducting input IVA requires the original factura, so a deductible row without one is not a filing the operator may complete. Output IVA has no equivalent constitutive requirement and no CLI path that mints issued-invoice evidence, so blocking it would refuse a taxpayer who has no way to comply.

Blocking here is what keeps the export and local-filing refusals on the same condition unreachable rather than merely later: they remain in place as defence in depth over a state this gate no longer lets form.

Return type:

list[ModeloVerificationFinding]

Parameters:
verify_modelo_revision_with_preconditions(calculation_revision_id, *, certificate_secret_backend_factory, operator_scope_ports, actor, workflow_profile, verification_repositories, cross_period_expected_member_sets=(), workflow_engine=None, workflow_runs_dir=None, settings=None, clock=None, operation, profile=None)[source]

Evaluate a draft revision against registry, clean-state, provenance, and workflow gates.

The verifier loads the draft CalculationRevision, resolves its work unit and RegistrySnapshot, builds verify-time findings, classifies the outcome, persists a VerificationReport, records bucket history, and updates the CalculationRevision only when the verified-complete transition is granted.

The supplied TaxpayerProfile scopes deadline/applicability decisions. The transaction port in the required VerificationRepositoryBundle supplies non-blocking transaction-evidence advisories for source rows attached to the revision. WARNING-severity advisories remain report content; only BLOCKING severity can refuse the transition.

Parameters:
  • calculation_revision_id (TypeAliasType) – Stable id of the draft CalculationRevision to verify.

  • certificate_secret_backend_factory (CertificateSecretBackendFactory) – Factory for the certificate-secret capability used by the workflow gate when verification grants.

  • operator_scope_ports (OperatorScopePorts) – Operator-scope capabilities used by the workflow gate when verification grants.

  • actor (str) – Operator label recorded on the verification report and bucket history event.

  • workflow_profile (TaxpayerProfile) – TaxpayerProfile supplying profile facts for workflow, deadline, applicability, and registry predicate gates.

  • verification_repositories (VerificationRepositoryBundle) – Required application-owned bundle containing every repository capability used by the verification gates and persistence path. The outer composition root binds all concrete implementations for one profile bucket.

  • cross_period_expected_member_sets (Iterable[CrossPeriodExpectedMemberSet]) – Optional expected-member overrides for the cross-period clean-state gate.

  • workflow_engine (WorkflowEngine | None) – Optional WorkflowEngine override for tests and controlled workflow runs.

  • workflow_runs_dir (Path | None) – Optional workflow-runs directory override.

  • settings (Settings | None) – Optional runtime settings for workflow-engine construction.

  • clock (datetime | None) – Optional timestamp override for deterministic verification.

  • operation (PinnedAuthorityOperation) – Caller-owned generation-pinned authority operation. When supplied, every registry snapshot and point consumer in this path reads from that operation generation.

  • profile (ModeloWorkProfile | None) – The work profile the calling command already loaded for the revision’s bucket. When omitted, this entry loads it once; every profile read below uses the record the readiness gate checked.

Return type:

ModeloVerificationResult

Returns:

The application result containing the persisted VerificationReport and its ordered typed preconditions.

Raises:
verify_modelo_revision(calculation_revision_id, *, certificate_secret_backend_factory, operator_scope_ports, actor, workflow_profile, verification_repositories, cross_period_expected_member_sets=(), workflow_engine=None, workflow_runs_dir=None, settings=None, clock=None, operation, profile=None)[source]

Persist and return the domain verification report without transport recovery data.

The thin arm over verify_modelo_revision_with_preconditions(), for callers that want the report and none of the transport-recovery envelope. It takes the same required application-owned repository bundle the gates are evaluated against.

Core types: TaxpayerProfile.

Return type:

VerificationReport

Parameters: