cadrumo.application.modelo._reconcile_population module¶
Population scoping for casilla reconciliation against a filed declaration.
detect_casilla_divergences() is a pure comparison and takes no view on
whether the two sides are worth comparing. Reconciling a freshly onboarded
profile against a pulled AEAT filing is the case where that matters: the local
calculation computes zero nearly everywhere, so every reconciled casilla
diverges and the operator learns nothing except that the bucket is empty. This
module supplies the missing predicate — which casillas of a persisted
CalculationRevision carry enough locally-sourced input
that a divergence means genuine disagreement rather than emptiness — as a scope
the existing comparison already accepts, so no second differ is created.
The predicate is evaluated per casilla, not per revision. A revision that supplied one figure out of forty has one thing to say and thirty-nine it does not, and a whole-revision gate would either silence the one or surface the thirty-nine.
WHAT COUNTS AS POPULATION, and why the list is shorter than it looks. A leaf of
a casilla’s input closure is independent evidence when the operator supplied the
casilla directly, when the operator overrode the binding, when the binding reads
declared census facts, or when the binding is bucket-local and the revision
actually consumed ledger transactions. Carry bindings
(PREVIOUS_FILING,
RELATION_PREFILL) and relation references never
count, because their values originate in the same filed-observation store the
comparison’s filed side is read from: counting them would let the scope be
satisfied by the very figures under comparison.
WHAT THIS DELIBERATELY DOES NOT CATCH. A taxpayer whose true figure is non-zero and who supplied nothing leaves the casilla unpopulated, so no divergence is raised and a real under-declaration goes unreported on this channel. That is a false-negative bias, chosen because the alternative fires on every casilla of every empty bucket, which is the alert fatigue that trains an operator to ignore the channel. It must not be read as coverage of the absent-input case, which needs a different signal. Separately, clause four approximates “the bucket holds evidence” with “this revision consumed ledger transactions”, so a bucket populated only with invoices and no ledger transactions scores as empty — again a false negative, and again the safe direction.
See also
detect_casilla_divergences()The pure comparison this scope is passed to.
CalculationRevisionPersisted revision whose supplied inputs are read.
ModeloRevisionRegistry revision supplying the formula graph walked here.
BindingSourceKindCanonical source taxonomy separating carry bindings from evidence.
- class CasillaPopulationScope(**data)[source]¶
Bases:
BaseModelWhich casillas of one persisted revision are worth reconciling.
comparable_casilla_idsis the scope to pass todetect_casilla_divergences();unpopulated_casilla_idsis its complement over the same candidate set and is carried so a caller can report what was withheld rather than silently narrowing. The threesupplied_*fields record the evidence the verdict rested on, so a scope that surprises an operator can be explained without re-deriving it.- Parameters:
data (Any)
- comparable_casilla_ids: tuple[CasillaId, ...]¶
- unpopulated_casilla_ids: tuple[CasillaId, ...]¶
- supplied_input_casilla_ids: tuple[CasillaId, ...]¶
- supplied_binding_ids: tuple[BindingId, ...]¶
- ledger_contributed: bool¶
- resolve_casilla_population_scope(*, registry_revision, calculation)[source]¶
Resolve which of
registry_revision’s casillascalculationcan speak to.- Parameters:
registry_revision (
ModeloRevision) – The law-resolvedModeloRevisionsupplying the formula graph, the casilla input kinds and the binding definitions. Resolve it from(modelo, filing_year, period)through the registry authority; never from a stored revision id.calculation (
CalculationRevision) – The persistedCalculationRevisionwhose supplied inputs, binding overrides and ledger contribution decide population.
- Return type:
- Returns:
The
CasillaPopulationScope.comparable_casilla_idsis empty exactly when the revision supplied no independent evidence anywhere, so an untouched bucket reconciles to no divergences at all.