cadrumo.domain.calculations.registry.schema_extraction module¶
Extraction-profile schema contracts for registry revisions.
These RegistryModel
definitions describe how a registry revision maps declaration PDFs, submitted
files, justificantes, and official workbooks into target casillas. The contract
records parser identity, accepted artefact kind, match strategy, confidence,
coverage, legal grounding, source grounding, and the explicit specimen /
round-trip flags that prevent silent provisional extraction.
The schema remains declarative authority only: it does not import parser
adapters, read artefacts, or run extraction. Registry validation checks local
reference closure and evidence sufficiency before
RegistrySnapshot exposes the profiles to
application and adapter consumers.
Registry-build validation checks casilla, export-field, legal, and source closure for each profile, together with artefact kind, dotted parser, bbox anchor, specimen, and round-trip conformance for these contracts.
See also
ModeloRevisionRevision record that owns committed extraction-profile rows.
RegistrySnapshotValidated filing-context view that exposes extraction profiles by id.
CasillaDefinitionTarget casilla metadata each extraction target must reference.
LegalReferenceLegal evidence rows cited through
legal_refs.SourceReferenceSource evidence rows cited through
source_refs.
- class ExtractionSurface(*values)[source]¶
Bases:
StrEnumThe artefact an extraction profile reads casilla values out of.
- BORRADOR_PDF¶
- DECLARACION_PDF¶
- JUSTIFICANTE_PDF¶
- EXPORT_RECORD¶
- OFFICIAL_WORKBOOK¶
- class ExtractionArtefactKind(*values)[source]¶
Bases:
StrEnumA stored artefact an extraction profile will accept as its input.
Deliberately NOT the same vocabulary as
ExtractionSurface, despite the overlap: a surface says what the profile was designed to read, an artefact kind says what a caller may hand it.submitted_fileis an artefact and never a surface, andborrador_pdfis a surface with no artefact kind of its own.- SUBMITTED_FILE¶
- DECLARATION_PDF¶
- JUSTIFICANTE_PDF¶
- OFFICIAL_WORKBOOK¶
- class ExtractionMatchStrategy(*values)[source]¶
Bases:
StrEnumHow a target casilla is located on the surface.
- NUMERIC_CASILLA¶
- NAMED_LABEL¶
- BBOX_ANCHORED¶
- class ExtractionValueKind(*values)[source]¶
Bases:
StrEnumWhat kind of value the extractor expects to read.
- AMOUNT¶
- TEXT¶
- ENUM¶
- class BboxValueOffset(*values)[source]¶
Bases:
StrEnumWhere the value sits relative to its anchoring box number.
- LEFT_OF_NUMBER¶
- ABOVE_NUMBER¶
- RIGHT_OF_NUMBER¶
- class ExtractionConfidence(*values)[source]¶
Bases:
StrEnumHow far a profile’s output may be trusted without review.
- STRICT¶
- REVIEW_REQUIRED¶
- class ExtractionVerificationSource(*values)[source]¶
Bases:
StrEnumWhat evidence backs a profile’s extraction accuracy.
NOT_APPLICABLEandHISTORICAL_SUPPRESSIONare distinct on purpose: the first says verification does not apply, the second says it was deliberately withheld for a historical revision. Collapsing them would report a suppression as an absence.- REAL_AEAT_CORPUS_PDF¶
- SYNTHETIC_FROM_AEAT_PUBLISHED_TEXT¶
- HISTORICAL_SUPPRESSION¶
- NOT_APPLICABLE¶
- class BboxAnchorSpec(**data)[source]¶
Bases:
RegistryModelSpatial anchor configuration for the
bbox_anchoredextraction strategy.- box_number_pattern: str¶
- value_offset: BboxValueOffsetField¶
- anchor_x_min: float | None¶
- anchor_x_max: float | None¶
- value_x_max: float | None¶
- column_anchor: str | None¶
- class ExtractionTargetDefinition(**data)[source]¶
Bases:
RegistryModelPer-target descriptor for a registry extraction profile.
value_kindis a PARSE DIRECTIVE, not a declaration of the target’s type. It answers only “how is the captured token turned into a value?”, and the parser branches on it exactly one way:amountgets Spanish-decimal parsing, the blank-box guard and the word-level positional pass, while everything else carries the raw token through unchanged.enumis therefore a documentation refinement oftextand makes no enforceable claim about the value space. Nothing in this schema declares the permitted members of any target’s enumeration, so there is no set to validate against and no consumer that would consult one. A reader meetingvalue_kind = "enum"should read “expected to be one of a closed set, and nothing checks that”, not “constrained”.The consequence is that
value_kindanddata_typeanswer different questions and cannot be compared for coherence. A target declaringenumover a casilla whosedata_typeistextorintegeris not incoherent – the first says how to read the printed token, the second says what the casilla holds. Under this reading such targets are documentation rather than defects, which is why none of them is “corrected” totext.Measured 2026-07-28 by walking every profile on every revision through the authority, eight targets declare
enumand all eight sit overtextorinteger. Four are on thedeclaracion_pdfsurface and are the ones this ruling was raised against (Modelo 036decl.event-kind, Modelo 232decl.tipo-ejercicioin both revisions, Modelo 840decl.tipo-declaracion). The other four areexport_recordtargets on Modelo 180, and they are if anything a stronger case for the same reading: no consumer readsvalue_kindon that surface at all.Making
enumload-bearing later is a real option, but it requires declaring the value space first – a member list per target, grounded in AEAT’s published values – because a constraint no one can enumerate cannot be enforced. Until then the parser must treatenumandtextidentically, which is pinned byadapters.inbound.declaracion.tests.test_extraction_value_kind_contract.- casilla_id: CasillaId¶
- match_strategy: ExtractionMatchStrategyField¶
- value_kind: ExtractionValueKindField¶
- label_pattern: str | None¶
- bbox_anchor: BboxAnchorSpec | None¶
- class ExtractionProfileDefinition(**data)[source]¶
Bases:
RegistryModelRegistry extraction profile for declaration/borrador/workbook artefacts.
- id: ExtractionProfileId¶
- surface: ExtractionSurfaceField¶
- artefact_kind: str¶
- accepted_artefact_kinds: tuple[ExtractionArtefactKindField, ...]¶
- parser: str¶
- target_casillas: tuple[ExtractionTargetDefinition, ...]¶
- confidence: ExtractionConfidenceField¶
- provisional_pending_specimen: bool¶
- corpus_round_trip_verified: bool¶
- verification_source: ExtractionVerificationSourceField | None¶
- min_coverage: DecimalValue¶
- failure_semantics: Literal['fail_hard']¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶