[WIP] Add Rule: usage constraints as their own content-addressed entity - #33
Open
djarecka wants to merge 1 commit into
Open
[WIP] Add Rule: usage constraints as their own content-addressed entity#33djarecka wants to merge 1 commit into
djarecka wants to merge 1 commit into
Conversation
required/multivalued/pattern/min/max don't live on RegistryProperty (a property required in one source's usage and optional in another's would never share a hash otherwise). They now live on a separate Rule entity that references the property it constrains via applies_to (its hash_id) - part of Rule's own content hash, so identical constraints on two different properties are different rules, and identical constraints on the same property from two sources collapse to one Rule with two ProvenanceEntry records, exactly like RegistryProperty/RegistryClass already do. Scoped to RegistryProperty only for now, as agreed - class-level rules are a possible future extension. - schemas/meta_model.yaml: Rule is_a RegistryEntity, new slots applies_to/ required/multivalued/pattern/minimum_value/maximum_value. - schema_registry_utils/: Rule Pydantic model added; hashing.py widened to accept it. - neuro_ghost/db.py: new APPLIES_TO_P (Rule -> RegistryProperty) and HAS_PROVENANCE_RULE edges (named explicitly - HAS_PROVENANCE_R was already claimed by Relation). write_registry_entities() and a new write_rule_edges() generalize the existing write-if-new/attach- provenance-if-new pattern to Rule, shared with ingest_linkml.py. - neuro_ghost/ingest_linkml.py: _slot_to_dict() now extracts minimum_value/ maximum_value from LinkML. build_registry_entities() builds a Rule for any property declaring at least one constraint - a plain property gets no Rule at all, so unconstrained properties don't accumulate noise. CLI/ --wipe/SchemaVersionSnapshot.rule_count wired through. Verified: a real schema (bbqs.yml) organically produced 10 correct Rules with correct APPLIES_TO_P edges; cross-source Rule collapsing; required affecting Rule but not RegistryProperty identity; full seed -> ingest -> align -> export pipeline end to end. All 17 tests pass. docs/ingestion.md updated with a Rule section. Added docs/comparison-with- undata.md noting this is a NeuroGhost-specific extension beyond what undata's VISION.md describes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
required/multivalued/pattern/min/max don't live on RegistryProperty (a property required in one source's usage and optional in another's would never share a hash otherwise). They now live on a separate Rule entity that references the property it constrains via applies_to (its hash_id) - part of Rule's own content hash, so identical constraints on two different properties are different rules, and identical constraints on the same property from two sources collapse to one Rule with two ProvenanceEntry records, exactly like RegistryProperty/RegistryClass already do. Scoped to RegistryProperty only for now, as agreed - class-level rules are a possible future extension.
Verified: a real schema (bbqs.yml) organically produced 10 correct Rules with correct APPLIES_TO_P edges; cross-source Rule collapsing; required affecting Rule but not RegistryProperty identity; full seed -> ingest -> align -> export pipeline end to end. All 17 tests pass.
docs/ingestion.md updated with a Rule section. Added docs/comparison-with- undata.md noting this is a NeuroGhost-specific extension beyond what undata's VISION.md describes.