fix: validate AI-generated ontologies against Fabric IQ rules - #94
Open
Mathew Benjamin (mathewtbenjamin) wants to merge 1 commit into
Open
Conversation
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
Author
|
@microsoft-github-policy-service agree |
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! |
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.
Summary
Fixes #84 — ontologies generated by the NL builder bypassed
validateOntologyentirely:NLBuilderModalapplied the/api/generate-ontologyresponse straight intouseAppStore.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: runvalidateOntology(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 moresuffix.handleApply: validate again beforeloadOntology, 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.tsif you'd prefer it server-side too.Validation
npx tsc --noEmit— cleannpx vitest run— 24 files, 394/394 tests pass (validation rules themselves are covered by the existingdesignerStore.test.tssuite)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.