Skip to content

Fail closed on malformed native YAML ontologies - #185

Merged
yohei1126 merged 1 commit into
mainfrom
feat/165-ontology-load-checks
Dec 1, 2026
Merged

yohei1126 merged 1 commit into
mainfrom
feat/165-ontology-load-checks

Conversation

@yohei1126

Copy link
Copy Markdown
Collaborator

Why

Loading a native YAML ontology accepted undeclared class references, duplicate relationship names and unknown keys without error, and an unrecognised direction fell back to out. A typo in the ontology file passed silently and surfaced later as a confusing intent error or not at all.

Done when

  • The issue reproduction fails load: with bogus_key present, serde reports unknown field `bogus_key` ; without it, the error is undeclared class 'Ghost' in to_class of relationship 'R'; duplicate relationship name 'R'.
  • Tests cover each case: undeclared from/to/owner/superclass, duplicate class, relationship and (owner, property) names, unknown keys at every level, bad direction (OUT, bogus, empty), omitted and explicit directions, and the committed native examples still loading.
  • cargo test --workspace passes.

Notes

  • Two relationships with the same name now fail load, so otg schema can no longer emit a schema.json that kept only the last from/to pair.
  • Unknown datatype strings still map to string; that is out of scope here.
  • Unknown keys are rejected. There is no lenient opt-in. Omitted direction still defaults to out.
  • This change applies to native YAML only. The same structural check is not yet run for the other formats. Running it on every adapter fails the committed manufacturing.owl.ttl and manufacturing.jsonld examples (datatype ranges become relationships to undeclared string / integer classes) and manufacturing.obo (a [Typedef] stanza becomes a class with undeclared superclass relationship). Those adapters need a separate fix first.

Closes #165

Add CanonicalOntology::validate_structure and run it from the native YAML
adapter: undeclared class references, duplicate class, relationship and
(owner_class, property) names fail load and name the offender. Reject
unknown keys and unrecognised direction values; omitted direction still
defaults to out.

Closes #165
@yohei1126

Copy link
Copy Markdown
Collaborator Author

Model: Gemini 4 Argon (gemini-4-argon) (Gemini API)
gemini-batch-head: c510849
Findings: 0 blocker, 0 major, 0 minor, 0 nit.
Verdict: PASS

@yohei1126
yohei1126 marked this pull request as ready for review December 1, 2026 13:17
@yohei1126
yohei1126 merged commit 9c4e331 into main Dec 1, 2026
21 checks passed
@yohei1126
yohei1126 deleted the feat/165-ontology-load-checks branch December 1, 2026 13:17
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.

Ontology load accepts undeclared classes, duplicate relationship names and unknown keys

1 participant