cadrumo.application.modelo.verification_predicates module¶
Generic registry-authored predicate evaluation mechanics.
- evaluate_predicate_expression(expression, casilla_values, profile)[source]¶
Return True when the predicate holds, False when it is violated.
Supports the DSL operators registered in
KNOWN_VERIFICATION_PREDICATE_OPERATORS:all_nonzero(["id1", "id2", ...])— all ids must have a non-zero value.any_nonzero(["id1", "id2", ...])— at least one id must have a non-zero value.at_most_one_positive(["id1", "id2", ...])— no more than one named casilla may be strictly positive.cap_le_when_positive(["limited_id", "ceiling_id"])— when the ceiling casilla is strictly positive, the limited casilla MUST NOT exceed it.equals(["lhs_id", "rhs_id"])— binary consistency invariant: predicate holds iff the two named casillas hold the same value.implies_nonzero(["antecedent_id", "consequent_id"])— material implication with strictly-positive antecedent: predicate holds iff antecedent <= 0 OR consequent != 0.implies_any_nonzero(["antecedent_id", "c1_id", ...])— N-consequent generalisation: predicate holds iff antecedent <= 0 OR at least one listed consequent != 0.profile_field_required("field_name", "applicability_filter")— profile-state-aware conditional non-zero requirement; sibling ofimplies_nonzero.
An expression that does not match any registered pattern is treated as holding (i.e. unknown predicates do not block the operator). The authoring-time validator in
domain.calculations.registry._validate_surfacesis the gate against typos reaching this branch.Core types:
TaxpayerProfile.
- evaluate_advisory_predicate_fires(expression, casilla_values, text_values=mappingproxy({}), profile=None)[source]¶
Return True when a registered ADVISORY predicate condition fires.
Core types:
TaxpayerProfile.
- evaluate_verification_predicates(predicates, casilla_values, profile, text_values=mappingproxy({}), blocking_finding_observer=None, *, modelo=None, filing_year=None, period=None, query_service=None, operation=None, as_of=None)[source]¶
Evaluate Layer 2 cross-casilla predicates into verification findings.
predicatesareVerificationPredicateDefinitionentries from the selected registry snapshot. The returned records areModeloVerificationFindingvalues.text_valuescarries operator-entered raw strings (e.g.input_values_by_casilla_id), independent of the Decimalcasilla_valuesprojection. It defaults to an empty mapping and is consumed by text-aware ADVISORY operators such ascasilla_equals_implies_nonzero; every other operator ignores it.BLOCKING_RULEpredicates use negative logic: the predicate expression must hold, and a violation emits a BLOCKING finding.ADVISORYpredicates use affirmative logic: when their condition fires, the operator receives a WARNING-severity ADVISORY finding and the verified-complete grant remains possible if no blocking findings exist.profileis aTaxpayerProfilethreaded through to support profile-state-aware predicate operators such asprofile_field_requiredandprofile_flag_enabled. Casilla-only operators ignore the parameter.See also
evaluate_predicate_expression():Evaluates the blocking-rule predicate DSL.
evaluate_advisory_predicate_fires():Evaluates the advisory predicate DSL.
_classify_verification_outcome():Converts finding severity into report completeness and grant status.
- Return type:
- Parameters:
predicates (tuple[VerificationPredicateDefinition, ...] | None)
profile (TaxpayerProfile)
blocking_finding_observer (Callable[[ModeloVerificationFinding, VerificationPredicateDefinition], None] | None)
modelo (str | None)
filing_year (int | None)
period (str | None)
query_service (RegistryQueryService | None)
operation (PinnedAuthorityOperation | None)
as_of (date | None)