Source code for cadrumo.domain.calculations.registry.casilla_lineage
"""How a casilla row stands toward its predecessor edition.A successor edition's casilla either continues a row of the edition before itor it does not, and each answer comes in kinds that must not be confused:- a continuation may be GROUNDED -- established from cited evidence such as an official record design -- or SEEDED, inferred mechanically from agreeing identifier, semantic role and data type. Inference written down is not a statement, so the two are kept apart;- an absence may mean the box did not exist on the predecessor form (NEW_ON_FORM), that it existed but the corpus's predecessor edition does not declare it (PREDECESSOR_EDITION_SILENT), or that the row is a product concept no official form prints at all (NOT_ON_FORM). Writing a declaration gap as "new" is true of the corpus and false of the law.The TOML token is hydrated into the closed :class:`CasillaLineageOrigin`vocabulary at the registry boundary, so an unknown token is refused at loadwith the accepted set named."""from__future__importannotationsfromenumimportStrEnumfromtypingimportAnnotatedfrompydanticimportBeforeValidatorfrom....core.errors.hierarchyimportpydantic_validation_boundaryfrom.errorsimportRegistryValidationError__all__=["CasillaLineageOrigin","CasillaLineageOriginField"]
[docs]classCasillaLineageOrigin(StrEnum):"""The relationship a casilla row declares toward its predecessor edition."""GROUNDED="grounded"SEEDED="seeded"NEW_ON_FORM="new_on_form"PREDECESSOR_EDITION_SILENT="predecessor_edition_silent"NOT_ON_FORM="not_on_form"@propertydefcontinues_a_chain(self)->bool:"""Whether this origin asserts the row continues a predecessor-edition row. NOT A GROUNDING PREDICATE, and it is the first thing a reader looking for one finds. ``SEEDED`` asserts a continuation on the mechanical predicate and GROUNDS NOTHING: a seeded link discharges no role exemption and satisfies no grounding check. The two sets differ by the whole seeded population, which is thousands of rows, so using this property to answer "is this link grounded" silently over-counts by all of them. For grounding, test against ``GROUNDED`` alone. """returnselfin{CasillaLineageOrigin.GROUNDED,CasillaLineageOrigin.SEEDED}@propertydefrequires_evidence(self)->bool:"""Whether this origin must name the evidence it rests on. A seeded chain is justified by the mechanical predicate its value names; every other origin is a claim about the form or the corpus that a reader must be able to check. """returnselfisnotCasillaLineageOrigin.SEEDED
@pydantic_validation_boundarydef_coerce_casilla_lineage_origin(value:object)->object:"""Coerce a TOML string literal to the canonical CasillaLineageOrigin member."""ifisinstance(value,CasillaLineageOrigin):returnvalueifisinstance(value,str):try:returnCasillaLineageOrigin(value)exceptValueError:raiseRegistryValidationError(f"continuidad_origin {value!r} is not a recognised CasillaLineageOrigin "f"member; expected one of {[member.valueformemberinCasillaLineageOrigin]}",)fromNoneraiseRegistryValidationError(f"continuidad_origin must be a string, got {type(value).__name__!r}",)CasillaLineageOriginField=Annotated[CasillaLineageOrigin,BeforeValidator(_coerce_casilla_lineage_origin),]"""Annotated CasillaLineageOrigin that coerces TOML string literals to enum members."""