cadrumo.domain.calculations.registry.profile_grounding module¶
Reverse grounding index from profile keys to their consuming registry bindings.
The interactive profile setup flow renders a legal-provenance zone on every
question page: which modelos consume the fact being asked, and under which
legal provisions. That grounding is never hand-authored — it is a projection
over the validated registry: every source = "profile"
BindingDefinition names the profile key(s) it consumes in its
selector and carries its own legal_refs / source_refs, so the index
inverts that relation once per published authority generation and the
flow reads it at flow-compile time.
Only value-consuming selector members contribute (the scalar profile_key
and the composite profile_keys). A required_when_profile_key gate
names a key to test, not to file, so counting it would over-claim the
gated key’s legal basis; it is deliberately excluded.
- class ProfileKeyGrounding(**data)[source]¶
Bases:
BaseModelUnion grounding for one profile key across every consuming binding.
modelosnames every modelo with at least one revision whosesource = "profile"binding consumes the key;legal_refsandsource_refsare the sorted unions of those bindings’ grounding.- Parameters:
data (Any)
- profile_key: str¶
- modelos: tuple[Modelo, ...]¶
- legal_refs: tuple[str, ...]¶
- source_refs: tuple[str, ...]¶
- build_profile_grounding_index(operation)[source]¶
Invert every profile-sourced binding into a per-profile-key grounding map.
Walks every revision the operation’s pinned generation publishes and each revision’s bindings; a key never consumed by any profile binding is simply absent (the flow renders no legal zone for it — nothing is invented).
Memoised per published logical generation: this is a full registry-wide walk, and the profile-preflight report path (blocking gate,
config profile preflight,app modelo readiness) can call it several times per operator invocation. Every lease of the same generation yields the same index, so the cache keys on the generation’s logical identity in a small FIFO-bounded dict: at most_GROUNDING_INDEX_CACHE_MAXSIZEentries are retained, evicting the oldest when a new generation is published into a long-running process.- Return type:
- Parameters:
operation (PinnedAuthorityOperation)
- binding_profile_keys(binding)[source]¶
Return the value-consuming profile keys named by a profile binding’s selector.
Only value-consuming selector members contribute: the scalar
profile_keyand the compositeprofile_keys. Arequired_when_profile_keygate names a key to TEST, not to file, so including it would over-claim that key’s legal basis.Shared with the surfaces that must name the profile fact behind an unresolved profile binding, rather than the binding’s own identifier - the grounding index below inverts the same relation across the whole registry, and a per-binding caller needs the same extraction without building that index.
- Return type:
- Parameters:
binding (BindingDefinition)