cadrumo.domain.calculations.registry.schema_surfaces module¶
Casilla, relation, export, and record schema models.
- class CasillaEvolutionKind(*values)[source]¶
Bases:
StrEnumHow a casilla changed between two revisions.
REPURPOSEDandRETIREDare not degrees of change: a repurposed casilla still exists and now means something else, a retired one is gone. Reading one as the other would carry a prior year’s value into a box that no longer holds it.- UNCHANGED¶
- LABEL_EVOLVED¶
- SECTION_EVOLVED¶
- REPRESENTATION_EVOLVED¶
- LEGAL_REFS_EVOLVED¶
- LABEL_AND_LEGAL_REFS_EVOLVED¶
- REPURPOSED¶
- RETIRED¶
- class SemanticRoleCardinality(*values)[source]¶
Bases:
StrEnumWhether a semantic role is shared across casillas or deliberately unique.
- SHARED¶
- INTENTIONAL_SINGLETON¶
- class CasillaContinuidadEvolutionDefinition(**data)[source]¶
Bases:
RegistryModelDeclared cross-revision evolution for one casilla continuity chain.
- id: RecordId¶
- continuidad_id: ContinuidadId¶
- from_revision: RevisionId¶
- to_revision: RevisionId¶
- evolution_kind: CasillaEvolutionKindField¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶
- class CasillaAlias(**data)[source]¶
Bases:
RegistryModelA localized label variant for a casilla, carrying its own grounding.
Used by Plan C’s semantic-role validator: two casillas in different modelos can share a
semantic_roleeven though their primary labels differ, provided each declares the divergent phrasing via analiasesentry with a documented BOE or AEAT source. The text is resolved from the shared locale catalogue; the revision loader deriveslocalization_keyfrom the containing casilla and alias occurrence.- localization_key: str¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶
- class CasillaConstraints(**data)[source]¶
Bases:
RegistryModelDeclarative value constraints applied after a casilla is evaluated.
Captures the legal sign / range rules AEAT mandates per LIRPF / LIVA / LIS articles: a withholding casilla cannot carry a negative value, a deductibility cap restricts the maximum, a non-negativity floor on a cuota líquida prevents arithmetic underflow propagating through downstream formulas.
Each constraint declares its own legal grounding so the engine can surface a BOE permalink in the violation envelope when a computed value falls outside the declared bounds. The runtime raises a typed CasillaConstraintViolationError; the Sheets apply adapter renders the same record as a setDataValidation rule on the corresponding cell so the operator sees the constraint directly in the workbook UI.
- sign: CasillaSignConstraintField¶
- min_value: DecimalValue | None¶
- max_value: DecimalValue | None¶
- pattern: str | None¶
- min_length: int | None¶
- max_length: int | None¶
- enum: tuple[str, ...] | None¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶
- violates(value)[source]¶
Return a short reason string if a Decimal value violates this constraint, else None.
Numeric-only violation check preserved for downstream consumers of computed casilla values. Text constraints (pattern, min_length, max_length, enum) are surfaced through the sibling
violates_text()method.
- violates_text(value)[source]¶
Return a short reason string if a text value violates the text constraints, else None.
Checks the four text-shape constraints introduced by Plan B:
pattern,min_length,max_length, andenum. Used by consumers that resolve a casilla value into a string at evaluation time.
- class CasillaDefinition(**data)[source]¶
Bases:
RegistryModelA single AEAT casilla within a modelo revision.
idis the canonical reference identity.numberandsegmentoare reviewed AEAT record-design metadata. For single-segment modelossegmentois unset andnumberalone is unique within the revision. Multi-segment AEAT modelos (e.g. Modelo 200) reuse the same five-digitnumberacross distinct record segments with a different meaning in each; those casillas carry the AEAT record-segment code insegmentoto disambiguate metadata.- id: CasillaId¶
- number: str¶
- segmento: str | None¶
- localization_keys: tuple[str, ...]¶
- section: tuple[str, ...]¶
- data_type: CasillaDataTypeField¶
- required: bool¶
- input_kind: InputKindValue¶
- formula: FormulaId | None¶
- binding: BindingId | None¶
- alternate_bindings: tuple[BindingId, ...]¶
- export_refs: tuple[ExportFieldId, ...]¶
- export_exemption_reason: ExportExemptionReasonValue | None¶
- constraints: CasillaConstraints | None¶
- form_number: AeatBoxNumber | None¶
- continuidad_id: ContinuidadId | None¶
- continuidad_origin: CasillaLineageOriginField | None¶
- continuidad_evidence: str | None¶
- inherited_from: RevisionId | None¶
- semantic_role: str | None¶
- semantic_role_cardinality: SemanticRoleCardinalityField¶
- semantic_role_cardinality_reason: str | None¶
- aliases: tuple[CasillaAlias, ...]¶
- internal_only: bool¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶
- class CalculationCompletenessCasilla(**data)[source]¶
Bases:
RegistryModelOne required canonical
casilla.idin a calculation-completeness manifest.casilla_idis the authoritative reference key consumed by the validator.numberandsegmentoremain official record-design metadata for drift review: the validator cross-checks them against the referenced casilla, but no consumer may resolve the manifest by those metadata fields.The manifest enumerates only the casillas inside a modelo’s calculation closure — formula targets, the casillas referenced inside any formula expression, formula and binding endpoint casillas, and verification-expectation operands. Pure accounting-statement data-entry fields that feed no calculation are intentionally absent from this required set.
- casilla_id: CasillaId¶
- number: str¶
- segmento: str | None¶
- class CalculationCompletenessManifest(**data)[source]¶
Bases:
RegistryModelThe required calculation-closure casilla set for a modelo revision.
Enumerates the canonical
casilla.idvalues in a modelo’s calculation closure — the casillas the cross-connecting calculation engine traverses: every formula target, every casilla referenced inside a formula expression, every binding and relation endpoint casilla, and every verification-expectation operand. It is derived from the official AEAT Diseño de Registros intersected with the modelo’s calculation surface — Diseño-authoritative on each casilla’s segment, number, and label, but the checked-in reference key is the registry’s canonicalcasilla.id. The segment/number metadata is retained as reviewed evidence and cross-checked against that id.The registry validator enforces
manifest-required ⊆ declaredby canonicalcasilla.idplus a segment/number metadata check and alegal_refs/source_refsgrounding check on each required casilla. A casilla the revision declares but the manifest does not list (a pure accounting-statement field) is not a failure.manual_extractionflags a manifest authored from a manual read of a PDF-only Diseño that resists machine extraction; the off-load-path drift re-verification skips the machine re-derivation for such manifests and recordsmanual_extraction_reasoninstead of failing silently.- source_ref: SourceRefId¶
- casillas: tuple[CalculationCompletenessCasilla, ...]¶
- manual_extraction: bool¶
- manual_extraction_reason: str | None¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶
- validate_family_identity_uniqueness(family, identities)[source]¶
Refuse a revision declaring two members of
familyunder one identity.A family inherits across editions by identity, so a revision holding the same identity twice makes the merge unanswerable: neither member can be said to supersede the predecessor’s, and neither can be retired without also withdrawing the other. The collision is refused rather than resolved by renaming one of them, because a generated suffix would invent a distinction the corpus does not state.
- Parameters:
- Raises:
RegistryValidationError – Two or more members share an identity.
- Return type: