Skip to content

Commit 2a3e9e1

Browse files
authored
feat(routines): validate semantic RDF with SHACL Core (#76)
Add a governed, offline SHACL Core gate for the RDF projections of the synthetic routine semantic fixtures. Pin pySHACL 0.31.0, normalize deterministic diagnostics, and preserve the non-production validation boundary.
1 parent 2726314 commit 2a3e9e1

7 files changed

Lines changed: 1435 additions & 26 deletions

File tree

SCHEMA.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ software-signal, derived-signal, aggregate, derivation, and policy terms used by
229229
the governed fixtures. It has no imports. Its SHA-256 is part of the pin record;
230230
changing the Turtle bytes requires updating that hash in the same change.
231231

232+
`routines/ontology/shacl/open-control-routine-shapes.ttl` is the governed SHACL
233+
Core graph for the two synthetic semantic fixtures. Shape identifiers use
234+
`urn:open-control-library:shacl:routine:`; every OCL term in the graph MUST be
235+
declared by `ocl-vocabulary.ttl`. The graph defines no SPARQL constraints,
236+
SHACL-AF rules, or SHACL-JS. Validation performs no imports or inference.
237+
232238
#### Routine semantic profiles (`cxf-library/routine-semantic-profile/v1`)
233239

234240
A semantic profile has a stable JSON-LD `@id`, type
@@ -304,12 +310,20 @@ added to a registry, coverage claim, source inventory, book, or production
304310
catalog destination.
305311

306312
`tools/lint/routine_semantics.py` checks the closed pin record, recomputes the
307-
local-vocabulary hash, parses the Turtle from local bytes, applies the same
308-
six-resource in-memory schema registry, rejects unsafe JSON-LD constructs before
309-
RDFLib parsing, and validates semantic and derivation cross-document rules. Its
310-
two fixtures under `tools/lint/tests/fixtures/routine_semantics/` are synthetic.
311-
Their point references are syntax examples and are not resolved against
312-
production dictionaries or routine interfaces.
313+
local-vocabulary hash, parses local Turtle bytes, applies the same six-resource
314+
in-memory schema registry, and rejects unsafe JSON-LD constructs before RDFLib
315+
parsing. It passes each fixture's parsed graph independently to pySHACL 0.31.0
316+
with imports, inference, advanced features, JavaScript, and in-place mutation
317+
disabled. SHACL reports are normalized into sorted diagnostics; Python retains
318+
the uniqueness, member, unit-policy, and cross-document checks.
319+
320+
The SHACL graph checks the RDF projection's expected local classes and
321+
predicates, nested node/cardinality/datatype/class structure, and closed current
322+
entities. It does not duplicate every JSON Schema lexical rule or the Python
323+
checks above. The two fixtures under
324+
`tools/lint/tests/fixtures/routine_semantics/` are synthetic. Their point
325+
references are syntax examples and are not resolved against production
326+
dictionaries or routine interfaces.
313327

314328
No external ontology is vendored or fetched. Brick, S223, and QUDT CURIE checks
315329
therefore prove closed syntax and selected S223 class and aspect policy, not that

routines/README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ routine inventories:
2121
- `ontology/ontology-pins.json` fixes the Brick 1.4.4, ASHRAE 223
2222
1.0.0-ppr.2.1 compatibility, QUDT 3.1.4, and local OCL identities.
2323
`ontology/ocl-vocabulary.ttl` is the hashed Library-owned vocabulary for
24-
software and derivation concepts.
24+
software and derivation concepts. `ontology/shacl/` contains the SHACL Core
25+
graph used against the synthetic fixtures' RDF projections.
2526

2627
`g36/coverage.json` references the scope manifest, remains `planned`, and makes
2728
no implementation or completeness claims.
@@ -54,7 +55,7 @@ python3 tools/lint/g36_source.py --check \
5455
Run the remaining catalog gates from the repository root:
5556

5657
`requirements-routine-schemas.txt` pins `jsonschema==4.26.0`,
57-
`referencing==0.37.0`, and `rdflib==7.1.4`.
58+
`pyshacl==0.31.0`, `referencing==0.37.0`, and `rdflib==7.1.4`.
5859

5960
```sh
6061
python3 -m venv /tmp/cxf-routine-schemas
@@ -82,14 +83,16 @@ specializations, generated deployments, or executable CXF.
8283

8384
The semantic and derivation schemas are exercised only by synthetic fixtures
8485
under `tools/lint/tests/fixtures/routine_semantics/`. Validation is local and
85-
network-free. It checks closed syntax, local OCL terms, connector semantic-role,
86-
mapping-status and topology obligations, selected S223 class and aspect policy,
87-
member references, the shared ontology-pin authority, and the
88-
profile-to-derivation relationship. Connector dataflow does not reclassify an
89-
S223 property as observable or actuatable. The topology strings are authoring
90-
requirements, not building-instance certification. Validation does not certify
91-
external ontology term existence, resolve fixture point references against
92-
production dictionaries, compare a profile to a production interface, or
93-
validate a building instance. Production semantic profiles, derivation
94-
manifests, point migrations, SHACL certification, and routine classes remain
95-
deferred.
86+
network-free. JSON Schema and Python checks own closed JSON syntax, policy,
87+
uniqueness, references, and the profile-to-derivation relationship. The SHACL
88+
Core graph validates each RDF projection independently: expected local classes
89+
and predicates, nested node/cardinality/datatype/class structure, and closed
90+
current entities. It does not mirror every JSON lexical or cross-document rule.
91+
92+
Connector dataflow does not reclassify an S223 property as observable or
93+
actuatable. Topology strings are authoring requirements, not building-instance
94+
certification. Validation does not certify external ontology term existence,
95+
resolve fixture point references against production dictionaries, compare a
96+
profile to a production interface, or validate a building instance. Production
97+
semantic profiles, derivation manifests, point migrations, building-instance
98+
SHACL certification, and routine classes remain deferred.

0 commit comments

Comments
 (0)