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 of implies_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_surfaces is the gate against typos reaching this branch.

Core types: TaxpayerProfile.

Return type:

bool

Parameters:
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.

Return type:

bool

Parameters:
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.

predicates are VerificationPredicateDefinition entries from the selected registry snapshot. The returned records are ModeloVerificationFinding values.

text_values carries operator-entered raw strings (e.g. input_values_by_casilla_id), independent of the Decimal casilla_values projection. It defaults to an empty mapping and is consumed by text-aware ADVISORY operators such as casilla_equals_implies_nonzero; every other operator ignores it.

BLOCKING_RULE predicates use negative logic: the predicate expression must hold, and a violation emits a BLOCKING finding. ADVISORY predicates 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.

profile is a TaxpayerProfile threaded through to support profile-state-aware predicate operators such as profile_field_required and profile_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:

list[ModeloVerificationFinding]

Parameters: