cadrumo.domain.calculations.registry.reference_checker module

Reference-checker accumulator for snapshot validation.

IdReferenceChecker collects all typed-ID sets from a RegistrySnapshot and accumulates dangling-reference diagnostics used by the per-section reference walkers.

Core types: ModeloRevision.

class IdReferenceChecker(snapshot)[source]

Bases: object

Accumulates dangling typed-ID reference diagnostics for one snapshot.

Holds the per-kind ID sets and a failures buffer so per-kind reference walkers can stay focused on their own field paths instead of juggling closure state.

Deliberately NOT an instance of the failures= parameter convention the rest of the registry’s section validators moved away from (see the accumulator-convention reconciliation this module was audited under). That convention passes a FOREIGN accumulator into an otherwise- independent function – the caller must pre-create the list, the signature hides the output, and the function cannot be tested without manufacturing one. This class is a COHESIVE COLLABORATOR instead: it owns its own state (the id sets AND the failures buffer together), is constructed exactly once per referential-integrity sweep, is shared by roughly twenty related _check_* helpers that all genuinely operate over the same index, and is drained in exactly one place (_validate_references._check_all_id_references). Testing it means constructing one, running a check, and reading .failures – which already IS isolated testing, not a symptom of leaked mutable state. Converting chk/chk_opt/chk_tuple/chk_legal_source_refs to return their own findings would touch every one of those ~25 call sites for no structural gain, on the exact module that raises the referential- integrity gate. Leave this class’s accumulation as-is; the boundary between the two conventions is the point, not an oversight to converge away.

Parameters:

snapshot (RegistrySnapshot)

prefix
failures: list[str]
casilla_ids
casilla_data_types
formula_ids
parameter_ids
binding_ids
export_layout_ids
export_field_ids
extraction_profile_ids
cross_reference_ids
workbook_parity_ids
verification_expectation_ids
deadline_window_ids
filing_schedule_ids
construct_ids
dependency_classification_ids
legal_ids
legal_evidence_tiers
source_ids
provenance_only_source_ids

Sources the catalogue declares as corpus evidence rather than a machine-readable authority. An export layout may never write against one: the design it names is not a layout map, so a layout claiming it would render against something the parser is required to refuse.

chk(field_path, value, id_set)[source]

Record a failure when a required reference is not indexed.

Return type:

None

Parameters:
chk_opt(field_path, value, id_set)[source]

Record a failure when an optional reference is present but unknown.

Return type:

None

Parameters:
chk_tuple(field_path, values, id_set)[source]

Record failures for unknown IDs in a reference tuple.

Return type:

None

Parameters:

Single-call helper for the (legal_refs, source_refs) pair every record carries.

Return type:

None

Parameters:
  • owner (str)

  • legal_refs (tuple[LegalRefId, ...])

  • source_refs (tuple[SourceRefId, ...])