cadrumo.domain.filing.validator module

Cross-cutting validator for domain.filing drafts.

The validator is intentionally pure: it consumes a draft + the casilla collection it was built against and returns a tuple of ModeloValidationFinding records. It never raises — strict behaviour is the caller’s responsibility via fail_on_warning on build_draft().

This is draft-construction-time structural validation, and it is one stage inside the pre-file verification gate rather than an alternative to it. build_draft() runs this validator on every draft it constructs and stamps the result onto the findings tuple of the resulting ModeloDraft, so the stage is reached from all three operator verbs that build a draft: verify and file via the revision workflow gate, and export via the draft-export action. The workflow engine then re-scans those stamped findings in its VALIDATING_DRAFT stage and aborts on any ERROR-severity row.

The two finding vocabularies are deliberately distinct and answer different questions. ModeloValidationFinding answers “is this draft structurally well-formed against the casilla collection?” — schema version, declared and required casillas, value ranges, formula traces, and the deadline check — and grounds itself in Manual práctico rule ids via references_rules. The verify gate’s ModeloVerificationFinding answers the broader operator-facing readiness question, carries a closed kind/severity taxonomy, and requires registry legal_refs provenance. Neither model subsumes the other; do not collapse them.

See also

verify_modelo_revision():

The pre-file verification gate this validator runs inside, which owns ModeloVerificationFinding and the persisted VerificationReport.

class ModeloValidator(*, schema_provider, deadline_checker=None)[source]

Bases: object

Apply cross-cutting validation rules to a ModeloDraft.

The validator depends on Protocols, not concrete subpackages, so alternative casilla, formula, or deadline implementations can be supplied without touching the validator.

Parameters:
validate(draft)[source]

Run every validation rule against draft.

Parameters:

draft (ModeloDraft) – The ModeloDraft to validate.

Return type:

tuple[ModeloValidationFinding, ...]

Returns:

A tuple of ModeloValidationFinding items, possibly empty.

apply_validation(draft, findings)[source]

Return a ModeloDraft copy of draft with findings and a fresh status.

Status promotion logic:

Return type:

ModeloDraft

Parameters:
derive_validation_status(findings)[source]

Return the machine validation status implied by findings.

Return type:

ModeloDraftStatus

Returns:

The ModeloDraftStatus derived from the severity of the findings.

Parameters:

findings (tuple[ModeloValidationFinding, ...])