cadrumo.application.modelo.pulled_filing_reconcile module¶
Reconcile a local calculation against this taxpayer’s own pulled AEAT filing.
The filed-history sweep persists, per pullable modelo, the per-casilla values AEAT holds for a filing the taxpayer already made. The local calculation for the same modelo and period persists its own casilla values. Both sides live in the same encrypted bucket, and nothing compared them: a taxpayer whose local figures disagree with what AEAT records them as having filed learned it from neither surface.
WHAT THIS IS NOT. It is not the engine-drift check. That already ships: the filed-state verification path re-runs the registry calculation using the FILED declaration’s own input casillas and compares the computed outputs, which asks whether this engine reproduces AEAT’s arithmetic from AEAT’s inputs. It never consults the taxpayer’s own calculation, so it cannot answer whether the taxpayer’s working disagrees with their filing. That second question is this module’s, and the two must not be collapsed.
WHY IT IS SCOPED RATHER THAN TOTAL. A freshly onboarded profile computes zero
nearly everywhere, so comparing every pulled figure against it would raise a
mismatch on essentially every reconciled casilla — the alert fatigue that trains
an operator to ignore a channel. The comparison is therefore restricted to the
casillas the local revision supplied independent evidence for, resolved by
resolve_casilla_population_scope(). An untouched bucket
produces no findings at all, which is the intended behaviour and not a failure
to detect.
GROUNDING IS CARRIED, NEVER MINTED. A divergence finding makes no independent
legal claim: it says the value the registry grounds at these references does not
match what was filed. So each finding carries the diverging casilla’s own
legal_refs and source_refs rather than references invented for the
finding. The registry schema types both as minimum-length-one tuples on every
casilla definition, so there is always something to carry and no substitution
path exists.
THE AGREEMENT THRESHOLD IS THE REGISTRY’S, NOT THIS MODULE’S. How close two
values must be to count as agreeing is a regulatory question versioned by filing
year and revision: the registry publishes a tolerance per verification
expectation and folds the strictest across them. Some revisions publish one cent;
others publish 0.00 and so demand exact equality. This module therefore reads
verification_policy().tolerance from the law-resolved snapshot rather than
carrying a constant of its own — a hardcoded cent would silently absorb a
one-cent divergence on every revision of the second kind, which is an
under-declaration this channel exists to surface.
See also
detect_casilla_divergences()The pure comparison this delegates to.
resolve_casilla_population_scope()Supplies the casilla scope that keeps an empty bucket silent.
CalculationRevisionThe local side of the comparison.
ModeloRevisionLaw-resolved from the work unit’s own triple, never from a stored revision id. Supplies the formula graph the population scope walks and the casilla definitions each finding carries its grounding from, so a divergence cites the same references the registry grounds the value at.
RegistrySnapshotCarries that revision together with the verification policy the comparison tolerance is published on.
- pulled_filing_divergence_findings(*, work_unit, target, observation_repository)[source]¶
Compare the local calculation against this taxpayer’s pulled filing.
- Parameters:
work_unit (
WorkUnit) – The work unit being verified. Supplies the modelo and period the pulled observation is looked up by, and the triple the registry revision is law-resolved from.target (
CalculationRevision) – TheCalculationRevisionunder verification, supplying the local side and the supplied-input evidence the scope is resolved from.observation_repository (
CalculationObservationRepositoryProtocol) – Injection point for the pulled-observation store. Production passes nothing.
- Return type:
- Returns:
One non-blocking WARNING finding per diverging casilla, empty when no filing was pulled, when no revision resolves, when the local calculation supplied no independent evidence, or when every compared casilla agrees within tolerance.