Skip to content

[WIP] Add Rule: usage constraints as their own content-addressed entity - #33

Open
djarecka wants to merge 1 commit into
sensein:mainfrom
djarecka:adding_rules
Open

[WIP] Add Rule: usage constraints as their own content-addressed entity#33
djarecka wants to merge 1 commit into
sensein:mainfrom
djarecka:adding_rules

Conversation

@djarecka

Copy link
Copy Markdown
Collaborator

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant