aeat.domain.calculations.registry._validate_semantic_role_required module

Required-role hard-flip gate and cross-reference accessor.

Enforces that every casilla whose label matches a registered pattern in _REQUIRED_ROLE_LABEL_PATTERNS declares the expected semantic_role. A miss-declared or absent declaration is a hard ModeloDefinition validation failure surfaced by _validate_required_role_declarations().

Also exposes collect_casillas_by_semantic_role(), the public cross-reference accessor used by downstream consumers to walk every casilla sharing a semantic role across the registry corpus.

collect_casillas_by_semantic_role(modelos)[source]

Cross-reference accessor: role -> tuple of (modelo_id, revision_id, casilla_id).

Used by downstream consumers that need to walk every casilla sharing a semantic role across the corpus. The returned mapping is immutable and document-order stable per role; the validator consumes the same accessor through _collect_role_observations() internally.

Parameters:

modelos (Iterable[ModeloDefinition]) – Iterable of ModeloDefinition instances to index by the semantic roles declared on their casillas.

Return type:

Mapping[str, tuple[TypeAliasType, ...]]