cadrumo.domain.calculations.registry.keyed_families module¶
The canonical policy for revision declaration-family inheritance.
SCHEMA_FAMILY answers a coverage question: which revision fields are
collections of typed declarations. It deliberately does not answer the
different question of whether a successor may omit one of those declarations
and inherit it from its predecessor. Keeping that second decision here gives
the compiler, the migration authoring tool, and the delta signal one vocabulary
for the union rule.
The table is intentionally dependency-light. It does not import
ModeloRevision (which imports the restated-family schema), so the domain
schema can import this module without a cycle. Consumers validate the table
against their local schema-family census where they have that schema available.
- ROW_SOURCE_ADDITIONS_FIELD: Final[str]¶
The member field extending, rather than replacing, its family’s edition default.
- class FamilyInheritanceMode(*values)[source]¶
Bases:
StrEnumHow a revision family participates in predecessor materialisation.
- CASILLA¶
Casillas use continuity lineage rather than a member-owned id and need their own merge for locale and row-attestation handling.
- KEYED¶
A collection whose members are joined by the declared
identity.
- PER_EDITION¶
A declaration about the edition’s own generated/evidence surface.
- NONE¶
A typed family that is intentionally full-copy for now.
- class KeyedFamilySpec(section, identity, storage_identity='id', identity_fields=(), casilla_identity_fields=(), period_scoped=False, inheritance=FamilyInheritanceMode.KEYED, restatable=True, drop_eligible=False, source_default_key=None, holdback_reason=None, schema_family=True, scoped=False, singleton=False)[source]¶
Bases:
objectImmutable policy for one declaration family.
identityis retained even for aNONE/PER_EDITIONfamily when the schema has one. That lets diagnostics report the family accurately without accidentally enrolling it in the predecessor union. Theinheritancemode, not the presence of an id, is the enrolment decision.- Parameters:
-
storage_identity:
str¶ Edition-local key used only to address a member in the immediately declared predecessor for lossless storage patches. This is deliberately separate from semantic continuity: for casillas it is
id, notcontinuidad_id.
-
casilla_identity_fields:
tuple[str,...]¶ Identity fields that name edition-local casillas; compare their declared continuity rather than mistaking a printed-number change for repurposing.
-
inheritance:
FamilyInheritanceMode¶
-
restatable:
bool¶ Whether a typed
restated_familiesdeclaration is meaningful. The casilla merge is inherited but does not yet honour that manifest list.
-
drop_eligible:
bool¶ Whether the migration drop operation may remove an identical member. Conditional period-scoped inheritance is deliberately not droppable.
- family_identity_value(member, path)[source]¶
Read one identity-bearing field, including a dotted nested path.
Authoring and compiler boundaries carry raw TOML mappings, while focused callers may hold typed registry models. Resolve both shapes without coercing the value: identity comparisons must distinguish missing values, enums, and scalar values exactly as their source declared them.
- family_spec(section)[source]¶
Return the canonical policy for
section, if it is known.- Return type:
- Parameters:
section (str)
- family_source_default_fields(*, include_casillas=False)[source]¶
Return each family paired with the manifest field carrying its
source_refsdefault.The pairing lives on
CANONICAL_FAMILY_SPECSso a family can never be defaulted from another family’s grounding, and so enrolling one is adding itssource_default_keyrather than extending a second table that has to be kept in step. Casillas are excluded by default because their default is applied by the casilla rule, which also fillslegal_refsfrom the edition’s approving ordenes and defaults a row’sconstraintstable.
- bound_family_source_refs(default, additions)[source]¶
Return the edition default followed by a member’s additions, each reference once.
The default comes first and duplicates are dropped, so a member extending its edition’s grounding reads as that grounding plus what it adds. Values are carried through uncoerced: a malformed default or addition reaches typed construction and is refused there with the field’s own error rather than being silently repaired here.
- inline_family_source_default(member, edition, default_key)[source]¶
Return
memberwith its family’s edition-levelsource_refsdefault bound onto it.One rule, shared by every consumer that has to reason about what a member’s grounding EFFECTIVELY is: the compiler, which pins an inherited member to the default effective where it was stated; the delta signal, which must not report a field difference that is only the two editions’ defaults; and the migration chain proof, whose equivalence claim is about meaning rather than physical representation. A second implementation of it would let those three disagree about what a registry says.
A member stating its own
source_refsreplaces the default whole and is returned unchanged, as is one whose family has no default key or whose edition declares no usable default. Otherwise the member takes the default, extended by anyadditional_source_refsit states, and the additions key is consumed.memberitself is returned when nothing is bound, so a caller can test identity to learn whether the edition changed anything.