Skip to content

Run the structural ontology check for every load format - #187

Draft
yohei1126 wants to merge 1 commit into
mainfrom
feat/186-ontology-load-check-all-formats
Draft

yohei1126 wants to merge 1 commit into
mainfrom
feat/186-ontology-load-check-all-formats

Conversation

@yohei1126

Copy link
Copy Markdown
Collaborator

Closes #186

Why

The load-time structural check (declared class references, unique class and relationship names, unique owner/property pairs) only ran for native YAML. OWL/Turtle, JSON-LD and OBO ontologies with a typo or an undeclared class still loaded silently. The check could not simply be turned on for every format because the committed OWL, JSON-LD and OBO examples themselves produced undeclared classes: datatype rdfs:range values became relationships pointing at string / integer, and [Typedef] stanzas became classes under an undeclared relationship superclass.

Done when

  • otg schema on examples/manufacturing.owl.ttl, examples/manufacturing.jsonld and examples/manufacturing.obo exits 0 and writes a schema.json (also exit 0 for the LinkML and native YAML examples).
  • Loading those examples with the check enabled reports no undeclared string, integer or relationship classes.
  • A genuine undeclared class, duplicate relationship name, or duplicate class name in OWL, JSON-LD and OBO fails load and names the offender, for example validation error: undeclared class 'Ghost' in to_class of relationship 'has_ghost', duplicate relationship name 'linked', duplicate class name 'Widget', undeclared class 'MFG:9999999' in super_classes of class 'Sprocket'.
  • The check runs for every format load_ontology / load_ontology_from_path can load, with no per-format skip and no weaker check.
  • Malformed native YAML still fails load and the committed native examples still load.
  • cargo test --workspace passes (157 passed, 0 failed) and cargo clippy --workspace --all-targets -- -D warnings passes.

Notes

  • schema.json for manufacturing.owl.ttl is now identical to the one produced from manufacturing.linkml.yaml. Compared with main, the OWL and JSON-LD output no longer lists datatype properties (sku, name, quantity, ...) as relationship types, and XSD ranges now set the property datatype (quantity, lead_time_days, tier become integer) instead of always string.
  • OBO: [Typedef] stanzas now become relationship types, and the [Term] before them is no longer lost (main dropped Lot from the example's schema.json). is_a and relationship: targets are resolved from term ids to term names. When one relationship type is used from several terms, the first use sets its endpoints; later uses do not add duplicate entries.
  • Two IRIs that share a local name are no longer merged silently in OWL/JSON-LD; they now fail load as a duplicate name.
  • SKOS always declares Concept, since its injected broader / narrower / related relationships reference it.
  • No docs, version, dependency or workflow changes.

The load-time structural check now runs in AdapterRegistry::load, so
OWL/Turtle, JSON-LD, OBO, SHACL, SKOS, LinkML and native YAML all fail
closed on undeclared class references and duplicate class or
relationship names.

The committed OWL, JSON-LD and OBO examples previously produced
undeclared classes (datatype ranges mapped to relationships with a
string/integer to_class, and Typedef stanzas mapped to classes under
an undeclared relationship superclass). Those mappings now produce
properties and relationships that pass the check.

Closes #186
@yohei1126

Copy link
Copy Markdown
Collaborator Author

Model: Gemini 4 Argon (gemini-4-argon) (Gemini API)
gemini-batch-head: 60c74b2
Findings: 0 blocker, 0 major, 1 minor, 0 nit.
minor: crates/ontographia-adapters/src/obo.rs
Tags (id: , name: , is_a: , relationship: ) are parsed unconditionally inside the line loop regardless of the active stanza variant. If a non-Term/Typedef stanza (such as [Instance]) appears after the header and before a [Term] or [Typedef] stanza, its fields stay in current only until the next [...] header resets current, which is safe; however, while stanza is Stanza::Other (including the file header before the first stanza), any header lines matching those prefixes would populate current unnecessarily. Gating field collection on matches!(stanza, Stanza::Term | Stanza::Typedef) would be cleaner and avoid extra work on non-Term/Typedef stanzas.
Verdict: PASS

This branch has not been deployed

No deployments
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.

Structural ontology check does not apply to OWL, JSON-LD and OBO

1 participant