kglab ontology audit

The self-checking version of the tunnel knowledge graph. The tunnel-ontology-visualizer tab draws the KG; this tab makes the same graph queryable, provenance-carrying and machine-validated. A small kglab pipeline lifts the visualizer's D3 data into RDF, merges it with the previously unused ontology file not_yet_used/tunnel-ontology-visualizer.ttl.txt, reconciles the two by label, enforces an edge-provenance discipline with SHACL, materialises OWL-RL inference, and answers plan questions as SPARQL → pandas DataFrames. Everything below is the actual output of one pipeline run, embedded at build time.

1 · LiftD3 nodes/links → RDF, each edge a first-class assertion with edge-type, confidence, source
2 · Reconcilematch D3 nodes to ontology individuals by label; corroborated edges score 0.9, D3-only 0.6
3 · ValidateSHACL shapes enforce the provenance rule — raw lift fails, repaired graph passes
4 · InferOWL-RL closure lands everything in the Digital Construction Ontology upper classes
5 · QuerySPARQL → DataFrame: census, weak edges, dependency chains, corroboration
6 · Measurekglab → NetworkX: betweenness picks out the graph's brokers

1–2 · Lift & reconcile

Reconciliation is done in SPARQL-adjacent fashion: a D3 node and an ontology individual sharing an rdfs:label get owl:sameAs; an edge present in both representations is marked corroborated. Confidence is therefore not decoration — it records cross-representation agreement.

3 · SHACL validation: fail first, then conform

Two shapes (see shapes.ttl): every edge assertion needs an edge-type, a confidence in [0,1] and a source; plan-critical edges (dependsOn, precedes) additionally need a use statement and an update trigger — the contingent-edge discipline from the portfolio AGENTS.md.

Run 1 — raw lift:


  

Run 2 — after the repair pass added use statements and update triggers to plan-critical edges:

This is the point of the spike: an undocumented dependency is now a validation error, not a hope that reviewers notice.

4 · OWL-RL closure

Census by upper-ontology class — answerable only because inference materialised the rdfs:subClassOf bridge from the lifted D3 groups into the Digital Construction Ontology:

5 · SPARQL → DataFrame

Weak plan-critical edges (confidence < 0.7)

Dependencies asserted only by the D3 demo and never corroborated by the curated ontology — the first candidates for review:

Transitive dependency chain

Everything SegmentInstallation depends on, via the property path st:dependsOn+ (one line of SPARQL; no hand-rolled BFS):

Corroboration summary

6 · Graph measure

The merged graph projected into NetworkX; betweenness centrality names the brokers everything routes through:

Reproduce

From the repo root: pip install kglab then python3 apps/kglab-ontology-audit/pipeline/kglab_spike.py. The script regenerates results.json, solway_merged.ttl and this page. Environment of the embedded run: .

Foray: FORAY-KGLAB-ONTOLOGY-AUDIT · sources: apps/tunnel-ontology-visualizer/src/App.tsx (D3 layer), not_yet_used/tunnel-ontology-visualizer.ttl.txt (ontology layer) · results embedded at build time by pipeline/kglab_spike.py.