feat: fix SHACL discovery and enrich cross-domain references#4
Open
jdsika wants to merge 1 commit into
Open
Conversation
Fix queryDomainReferences to walk nested SHACL structures (sh:node → sh:or → rdf:list → sh:node → sh:targetClass) instead of relying on sh:class which finds nothing in the real ontology. Uses multi-strategy approach with separate queries to avoid Oxigraph WASM crashes from UNION + property path expansion. Parent discovery uses 3 fallback strategies: - Direct sh:targetClass on constraint shape - Walk up through sh:and conjunction list - Walk up through sh:or disjunction list Enrich sample scenario data: - All 50 scenarios now reference HD maps with full properties (format, content, quantity, quality, data source, georeference) - 20 scenarios additionally reference environment models - All property selection uses generic modular arithmetic — no manual mapping tables - Fix output path (packages/search/data/ not packages/ontology/data/) Strengthen discovery tests to assert actual results instead of using if-guard patterns that pass on empty results. Closes: cross-domain reference discovery and sample data enrichment Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>
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
Fix
queryDomainReferencesto properly discover cross-domain reference relationships from the ontology's nested SHACL structure, and enrich sample scenario data with rich referenced artifacts.Problem
The
queryDomainReferencesfunction usedsh:classto discover which domains reference others viamanifest:hasReferencedArtifacts. But the actual SHACL uses deeply nested structures (sh:node → sh:or → rdf:list → sh:node → sh:targetClass), so discovery found nothing. This meant cross-domain queries (e.g., "scenarios on motorways with many intersections") could not work.Additionally, sample data was sparse: only 17/50 scenarios had HD map references, each with just 2 stub properties. No environment model references existed.
Solution
SHACL Discovery Fix (
schema-queries.ts)Multi-strategy approach using separate queries (UNION + property paths crash Oxigraph WASM):
sh:class) — kept for forward compatibilitysh:node → sh:or → rdf:rest*/rdf:first → sh:node → sh:targetClasssh:targetClasson constraint shapesh:andconjunction listsh:ordisjunction listResult: Discovers
scenario → hdmapandscenario → environment-modelfrom the real ontology.Sample Data Enrichment
packages/search/data/notpackages/ontology/data/)Test Improvements
Strengthened discovery tests from weak
if (refs.length > 0)guards to assertive checks thatscenario → hdmapandscenario → environment-modelare actually discovered.Files Changed
packages/search/src/schema-queries.tspackages/search/src/__tests__/schema-queries.test.tsscripts/generate-sample-scenarios.jspackages/search/data/sample-scenarios.ttlValidation
pnpm run validatepasses