Serve raw ontology graphs without RDFS inference; token-safe @typeof matching - #337
Open
namedgraph wants to merge 1 commit into
Open
Serve raw ontology graphs without RDFS inference; token-safe @typeof matching#337namedgraph wants to merge 1 commit into
namedgraph wants to merge 1 commit into
Conversation
…matching Resolve the application ontology's owl:imports closure natively via ontapi (OntModelFactory.createModel over a ScopedGraphRepository view) instead of manually flattening the closure and materializing an RDFS-inferred model. No inference is applied anymore — every consumer (constructor/constraint inheritance, client-side (rdfs:subClassOf)* queries) traverses hierarchies explicitly. rdfs:Class terms are promoted to owl:Class in a separate union member so no document graph is polluted; closure union graphs are cached in a bounded map on Application, keyed by ontology URI. The shared repository now only ever holds raw per-document graphs, which ProxyRequestFilter serves directly for closure documents — asserted triples only, identical to a direct document GET. The DESCRIBE fallback over the in-memory closure (terms minted in external namespaces) is inference-free as well. This fixes inferred rdf:type rdfs:Resource leaking into proxied namespace documents, where the extra type produced multi-token @typeof and silently degraded View blocks to a generic property list. Client-side, all exact-equality @typeof comparisons switch to token-aware tokenize(@typeof, ' '), per RDFa's whitespace-separated list semantics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
View blocks rendered as generic property lists instead of executing their
spin:query. Root cause:OntologyFiltermaterialized an RDFS-inferred imports closure, andProxyRequestFilter's namespace short-circuit served proxied?uri=requests via DESCRIBE over that inferred model.ldh:View a rdfs:Class+ rulesrdfs7b/rdfs9type every instancerdf:type rdfs:Resource, so proxied ontology documents carried an extra type on every term — producing multi-token@typeofthat the client's exact-equality*[@typeof = '&ldh;View']match no longer satisfied.Changes
No RDFS inference over application ontologies. An audit showed the reasoner was vestigial: constructors recurse over direct superclasses, SPIN constraint collection walks
rdfs:subClassOfitself, and every client ontology query already uses(rdfs:subClassOf)*property paths. Theowl:importsclosure is now resolved natively by ontapi (OntModelFactory.createModelover a newScopedGraphRepositoryview) as a live union graph — the manual flatten/infer/materialize pipeline is deleted.rdfs:Classterms are promoted toowl:Classin a separate union member (ontapi's OWL2 named-class factory doesn't recognize barerdfs:Class, and its legacy-compat config control only applies to OWL1/expression factories), so no document graph is polluted. Closure union graphs are cached in a bounded map onApplication; per-requestOntModelwrapping is preserved.Raw document graphs on the wire, uniformly. The shared repository now only holds raw per-document graphs.
ProxyRequestFilterserves closure documents with their raw graphs — asserted triples only, identical to a direct document GET — guarded byisCachedso arbitrary external URIs can't trigger repository loading outside the SSRF-validated external-client path. The DESCRIBE fallback remains for terms minted in external namespaces and is now inference-free.Namespace's no-query GET reuses the shared raw cache instead of a per-requestcreateRepositorySPARQL round-trip. Invalidation updated inClearOntologyandValidatingModelProvider.Token-safe
@typeofmatching. All 28 exact-equality@typeofcomparisons in the client XSLT (View/Object/query/chart blocks, View pager/mode/order/facet handlers) switch totokenize(@typeof, ' '), per RDFa's whitespace-separated list semantics — any legitimately multi-typed resource would have degraded the same way.Also fixed in passing:
UninstallPackageno longer reads a materialized closure when a package URI is a loaded app ontology, and admin ontologies importing each other can no longer fold one closure's artifacts into another on the shared system repository.Test plan
OntologyImportsCharacterizationTestrewritten to pin: eager closure resolution, zero inference in the union, raw document graphs untouched (isomorphism), promotion not leaking into raw graphs,getOntClassrecognition ofrdfs:Class-only terms, import-cycle tolerancehttp-tests/proxy/GET-proxied-ontology-ns.shextended: proxied ontology document contains the authored classes and nordf:type rdfs:Resource; same negative assertion on the DESCRIBE fallbackhttp-testsrun (proxy/,admin/model/, form/constructor suites)typeofin the DOM🤖 Generated with Claude Code