Skip to content

fix: validate AI-generated ontologies against Fabric IQ rules - #94

Open
Mathew Benjamin (mathewtbenjamin) wants to merge 1 commit into
microsoft:mainfrom
mathewtbenjamin:fix/nl-builder-validation
Open

fix: validate AI-generated ontologies against Fabric IQ rules#94
Mathew Benjamin (mathewtbenjamin) wants to merge 1 commit into
microsoft:mainfrom
mathewtbenjamin:fix/nl-builder-validation

Conversation

@mathewtbenjamin

Copy link
Copy Markdown

Summary

Fixes #84 — ontologies generated by the NL builder bypassed validateOntology entirely: NLBuilderModal applied the /api/generate-ontology response straight into useAppStore.loadOntology, so generated ontologies with conflicting attribute types, invalid identifier types, or missing required identifiers loaded silently and only failed later (e.g. when pushing to Fabric IQ — same failure mode as #68).

Changes

  • handleGenerate: run validateOntology (the designer's existing Fabric IQ rule set, src/store/designerStore.ts) on the generated ontology immediately after the API response. Failures route through the modal's existing error step (AlertCircle + "Try Again"), truncated at 5 errors with an …and N more suffix.
  • handleApply: validate again before loadOntology, so JSON hand-edited in the preview step can't bypass the same rules.

Kept client-side and minimal by design; happy to follow up with defense-in-depth validation in api/generate-ontology/index.ts if you'd prefer it server-side too.

Validation

  • npx tsc --noEmit — clean
  • npx vitest run — 24 files, 394/394 tests pass (validation rules themselves are covered by the existing designerStore.test.ts suite)

Notes

No new dependencies; no changes to the validation rules themselves — this only wires the existing rule set into the NL builder path suggested in #84.

The NL builder applied /api/generate-ontology output directly via
loadOntology without ever running validateOntology, so generated
ontologies with conflicting attribute types, invalid identifier types,
or missing identifiers loaded silently and only failed later (e.g. when
pushing to Fabric IQ).

- Run validateOntology after generation; surface errors through the
  modal's existing error step (truncated at 5).
- Also validate in handleApply so hand-edited JSON in the preview step
  cannot bypass the same rules.

Fixes microsoft#84
@mathewtbenjamin

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@mathewtbenjamin

Copy link
Copy Markdown
Author

Friendly nudge 🙂 — this PR has been open ~3 weeks, the CLA check is green, and it's currently mergeable with no conflicts. Is there anything I can do to help move it toward review (rebase, split, or extra context)? Happy to help. Thanks!

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.

AI builder output bypasses the validateOntology checks

1 participant