cadrumo.domain.modelos.calculation_revision_identity module¶
Private canonicalization and hashing mechanics for calculation revisions.
The public construction and derivation functions remain canonical in
cadrumo.domain.modelos.calculation_revision. This module owns only the
private deterministic projections they use.
- canonical_row_binding_values(row_binding_values, *, surface)[source]¶
Return row-binding values with validated keys, canonically sorted, or raise.
- canonical_row_source_identities(value)[source]¶
Return row source identities as canonically sorted, JSON-shaped rows.
- canonical_row_casilla_values(value)[source]¶
Return row casilla values as canonically sorted, JSON-shaped rows.
- canonical_row_casilla_provenance(value)[source]¶
Return row casilla materialization provenance as canonically sorted, JSON-shaped rows.
- derive_calculation_revision_id_from_identity_inputs(identity_inputs)[source]¶
Hash a value returned only by
calculation_revision_identity_inputs().The id is content-addressed by the parent work unit plus the three payload mappings: input casilla values, scalar binding overrides, and computed casilla outputs. Row-indexed binding values are carried as their own nested map so repeating-record coordinates participate in identity without being flattened into synthetic binding ids. Two structurally identical re-runs produce the same id; the catalogue’s content-addressing invariant then makes a second
calculatecall idempotent (the existing revision is returned, no duplicate is persisted).detail_rowscarries typed row observations for informational modelos (M184, M232) that declare row-producer bindings. When rows are present they are serialised into the hash so structurally identical re-runs with the same rows produce the same id.source_issuescarries unresolved source conditions that block verification. It participates in identity so distinct resolution outcomes cannot collapse to one revision. Typed filing-instance evidence likewise participates, so changing Modelo 303 joint-return or insolvency facts creates a distinct immutable revision rather than mutating a draft.- Return type:
- Parameters:
identity_inputs (CalculationRevisionIdentityInputs)
- outputs_for_hash_from_mapping(casilla_values)[source]¶
Canonical
{casilla_id: canonical_decimal_str}projection from the flat mapping.Pure function — same input → same output, no side effects, no dependence on observation order. Used by
derive_calculation_revision_id()to produce theoutputspayload key consumed by the SHA-256 hash, AND byoutputs_for_hash_from_observations()to project the typed envelope into the same canonical form so the validator’s consistency check is byte-exact.Validated
casilla_idkeys,_canonical_decimalvalues, sorted by casilla_id — matches the original inline projection inderive_calculation_revision_id()byte-for-byte. The A hash-stability contract guards this projection.
- outputs_for_hash_from_observations(observations)[source]¶
Same canonical projection as
outputs_for_hash_from_mapping(), sourced from observations.The typed
observationsenvelope is the logical source of truth for derivation. This helper materialises the same{casilla_id: canonical_decimal_str}projection the flat-mapping helper produces, sourced fromCasillaObservation.value. The validator uses this to assert the persistedcasilla_valuesfield is byte-identical to the projection ofobservations.A future cycle drops the flat field and routes the hash directly through this helper; currently both fields are kept and this helper is used for the consistency check only.
Core types:
CasillaObservation.- Return type:
- Parameters:
observations (Sequence[CasillaObservation])