Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

fix(demo): recompute DCAT-US findings against the real deleted context

FABIOTESS77327fec48a8
diff --git a/Makefile b/Makefile
index 5e17141b..610d35d8 100644
--- a/Makefile
+++ b/Makefile
@@ -93,6 +93,8 @@ demo:
demo-verify:
python3 demo/verify.py
cd demo/precomputed && shasum -a 256 -c MANIFEST.sha256
+ python3 demo/dcat_conformance.py
+ python3 -m pytest demo/tests/test_dcat_conformance.py -q
# ─── Cleanup ─────────────────────────────────────────────────────────────────
diff --git a/demo/README.md b/demo/README.md
index f6932ddc..0ad86683 100644
--- a/demo/README.md
+++ b/demo/README.md
@@ -113,16 +113,34 @@ pipeline's contradiction scanner detects provenance-split typing conflicts
disagreement is not that shape: it is a README's conformance claim
contradicted by the artifacts published alongside it. That finding is
established by a validator, not the model, and lives in
-`demo/dcat_conformance.py`.
+`demo/dcat_conformance.py`. `make demo-verify` runs it (and its tests) as
+part of the verify target, so the command a sceptic runs re-derives the
+figures below rather than only checking that committed bytes have not moved.
The script reads only files committed under `demo/corpus/dcat-us/`: the full
GSA/dcat-us `jsonschema/definitions/` and `jsonschema/examples/` tree
(`demo/corpus/dcat-us/jsonschema/`, vendored separately from the seven
-documents the pipeline above reads) and `recovered-shapes.ttl`, the SHACL
-shapes file GSA/dcat-us deleted in pull request 120. It derives a JSON-LD
-context from the RDF terms the JSON Schema's own `_oldDocs` blocks still
-carry, expands every published "good" example with and without that context,
-and validates both expansions against the deleted shapes with pySHACL.
+documents the pipeline above reads), `recovered-shapes.ttl`, and
+`recovered-context.jsonld`. Pull request 120 deleted two files, not one:
+the SHACL shapes and the profile's only published JSON-LD `@context`
+(`context/dcat-us-3.0.jsonld`). Both are recovered here, from the pull
+request's base commit, and vendored unmodified; see
+`demo/corpus/dcat-us/pr-120-record.md` and `MANIFEST.json`.
+
+The script measures two independent things against the same 115 examples and
+the same unmodified `recovered-shapes.ttl`, and reports both rather than
+picking one:
+
+- **A schema-derived reconstruction.** A JSON-LD context built from the RDF
+ terms the JSON Schema's own `_oldDocs` blocks still carry (`declared`, and
+ `observed`, which also relaxes terms the corpus itself publishes as prose
+ rather than IRIs).
+- **The real recovered context**, `recovered-context.jsonld`, injected
+ verbatim (which binds almost nothing against today's examples, because its
+ class bindings are keyed by CURIE and every example's own `@type` is the
+ schema's bare title) and with each example's `@type` mechanically rewritten
+ to the CURIE the schema's own `_oldDocs.rdfClass` already names for it
+ (`typed`, exercising what the real context actually binds).
```bash
python3 demo/dcat_conformance.py
@@ -130,8 +148,20 @@ python3 -m pytest demo/tests/test_dcat_conformance.py
```
It writes `demo/corpus/dcat-us/jsonschema/generated-context.jsonld` (and an
-`.observed.jsonld` variant, lenient on the terms the corpus publishes as
-prose rather than IRIs), `demo/dcat_conformance_measurements.json` (every
-figure this script measures), and, by hand from those measurements,
-`demo/precomputed/findings.json`. No network call and no model call happen
-anywhere in this path.
+`.observed.jsonld` variant), `demo/dcat_conformance_measurements.json` (every
+figure this script measures, both ways), and, by hand from those
+measurements, `demo/precomputed/findings.json`. No network call and no model
+call happen anywhere in this path.
+
+**No single SHACL violation count is defensible as "the" figure.** The
+schema-derived reconstruction's own two variants disagree with each other
+(178 declared vs. 272 observed). The real recovered context, exercised
+against the same shapes, gives a third number again (147), lower than either
+reconstruction because it scopes every property binding strictly to its
+owning class with no cross-class default, unlike the reconstruction. And the
+two recovered files disagree internally about what the `org:` prefix
+expands to (`recovered-context.jsonld` line 18 vs. `recovered-shapes.ttl`),
+which alone moves the real-context count by several more violations if
+corrected. `demo/tests/test_dcat_conformance.py::
+test_shacl_violation_counts_disagree_across_methods` pins the disagreement,
+not a winner.
diff --git a/demo/corpus/dcat-us/MANIFEST.json b/demo/corpus/dcat-us/MANIFEST.json
index b457e342..41533aac 100644
--- a/demo/corpus/dcat-us/MANIFEST.json
+++ b/demo/corpus/dcat-us/MANIFEST.json
@@ -29,6 +29,13 @@
"sha256": "fecdf70f48a46a73ae6280c1f047d84ac185f52dfbcae97816960f759b0a8efb",
"source_url": "https://github.com/GSA/dcat-us/blob/aaa3ff4a/shacl/dcat-us_3.0_shacl_shapes.ttl"
},
+ {
+ "file": "recovered-context.jsonld",
+ "retrieved": "2026-08-25",
+ "sha256": "7d4e498fa5ff7d4f9e2fedd1ac95644960604ef79a3e98fdc618a8d1d57ad51c",
+ "source_url": "https://github.com/GSA/dcat-us/blob/04acd5c25579dd70a86a436b30a33e0784965cc4/context/dcat-us-3.0.jsonld",
+ "note": "pull request 120 (https://github.com/GSA/dcat-us/pull/120, see pr-120-record.md) deleted two files, not one: shacl/dcat-us_3.0_shacl_shapes.ttl (recovered above as recovered-shapes.ttl) and context/dcat-us-3.0.jsonld, the profile's actual, historically published JSON-LD context. This is the second deleted file, recovered from the pull request's base commit 04acd5c25579dd70a86a436b30a33e0784965cc4 the same way, verified byte-identical to a fresh 'git show 04acd5c2...:context/dcat-us-3.0.jsonld'. Read by demo/dcat_conformance.py alongside the schema-derived reconstruction; see demo/README.md for how the two differ."
+ },
{
"file": "pr-120-record.md",
"retrieved": "2026-08-25",
diff --git a/demo/corpus/dcat-us/recovered-context.jsonld b/demo/corpus/dcat-us/recovered-context.jsonld
new file mode 100644
index 00000000..f19c77a7
--- /dev/null
+++ b/demo/corpus/dcat-us/recovered-context.jsonld
@@ -0,0 +1,1317 @@
+{
+ "@context": {
+ "@version": 1.1,
+ "@protected": true,
+ "adms": "http://www.w3.org/ns/adms#",
+ "cnt": "http://www.w3.org/2011/content#",
+ "dash": "http://datashapes.org/dash#",
+ "dcat": "http://www.w3.org/ns/dcat#",
+ "dcatap": "http://data.europa.eu/r5r/",
+ "dcat-us": "http://data.resources.gov/ontology/dcat-us#",
+ "dcat-us-shp": "http://data.resources.gov/shapes/dcat-us#",
+ "dcterms": "http://purl.org/dc/terms/",
+ "dqv": "http://www.w3.org/ns/dqv#",
+ "foaf": "http://xmlns.com/foaf/0.1/",
+ "gsp": "http://www.opengis.net/ont/geosparql#",
+ "locn": "http://www.w3.org/ns/locn#",
+ "odrs": "http://schema.theodi.org/odrs#",
+ "org": "http://www.w3c.org/ns/org#",
+ "owl": "http://www.w3.org/2002/07/owl#",
+ "prov": "http://www.w3.org/ns/prov#",
+ "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
+ "schema": "http://schema.org/",
+ "sh": "http://www.w3.org/ns/shacl#",
+ "skos": "http://www.w3.org/2004/02/skos/core#",
+ "sdmx-attribute": "http://purl.org/linked-data/sdmx/2009/attribute#",
+ "spdx": "http://spdx.org/rdf/terms#",
+ "vcard": "http://www.w3.org/2006/vcard/ns#",
+ "adms:Identifier": {
+ "@id": "adms:Identifier",
+ "@context": {
+ "schemaAgency": "http://www.w3.org/ns/adms#schemaAgency",
+ "creator": {
+ "@id": "dcterms:creator",
+ "@type": "@id"
+ },
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "version": "http://purl.org/dc/terms/version",
+ "notation": "http://www.w3.org/2004/02/skos/core#notation"
+ }
+ },
+ "dcat-us:AccessRestriction": {
+ "@id": "dcat-us:AccessRestriction",
+ "@context": {
+ "restrictionNoteMap": {
+ "@id": "http://data.resources.gov/ontology/dcat-us#restrictionNote",
+ "@container": "@language"
+ },
+ "restrictionNote": "http://data.resources.gov/ontology/dcat-us#restrictionNote",
+ "restrictionStatus": {
+ "@id": "dcat-us:restrictionStatus",
+ "@type": "@id"
+ },
+ "specificRestriction": {
+ "@id": "dcat-us:specificRestriction",
+ "@type": "@id"
+ }
+ }
+ },
+ "dcat-us:CUIRestriction": {
+ "@id": "dcat-us:CUIRestriction",
+ "@context": {
+ "cuiBannerMarking": "http://data.resources.gov/ontology/dcat-us#cuiBannerMarking",
+ "designationIndicator": "http://data.resources.gov/ontology/dcat-us#designationIndicator",
+ "requiredIndicatorPerAuthority": {
+ "@id": "dcat-us:requiredIndicatorPerAuthority",
+ "@type": "http://www.w3.org/2001/XMLSchema#string",
+ "@container": "@set"
+ }
+ }
+ },
+ "dcat-us:GeographicBoundingBox": {
+ "@id": "dcat-us:GeographicBoundingBox",
+ "@context": {
+ "eastBoundingLongitude": {
+ "@id": "dcat-us:eastBoundingLongitude",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+ },
+ "northBoundingLatitude": {
+ "@id": "dcat-us:northBoundingLatitude",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+ },
+ "southBoundingLatitude": {
+ "@id": "dcat-us:southBoundingLatitude",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+ },
+ "westBoundingLongitude": {
+ "@id": "dcat-us:westBoundingLongitude",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+ }
+ }
+ },
+ "dcat-us:LiabilityStatement": {
+ "@id": "dcat-us:LiabilityStatement",
+ "@context": {
+ "labelMap": {
+ "@id": "http://www.w3.org/2000/01/rdf-schema#label",
+ "@container": "@language"
+ },
+ "label": "http://www.w3.org/2000/01/rdf-schema#label"
+ }
+ },
+ "dcat-us:UseRestriction": {
+ "@id": "dcat-us:UseRestriction",
+ "@context": {
+ "restrictionNoteMap": {
+ "@id": "http://data.resources.gov/ontology/dcat-us#restrictionNote",
+ "@container": "@language"
+ },
+ "restrictionNote": "http://data.resources.gov/ontology/dcat-us#restrictionNote",
+ "restrictionStatus": {
+ "@id": "dcat-us:restrictionStatus",
+ "@type": "@id"
+ },
+ "specificRestriction": {
+ "@id": "dcat-us:specificRestriction",
+ "@type": "@id"
+ }
+ }
+ },
+ "dcat:Catalog": {
+ "@id": "dcat:Catalog",
+ "@context": {
+ "catalog": {
+ "@id": "dcat:catalog",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "contactPoint": {
+ "@id": "dcat:contactPoint",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "dataset": {
+ "@id": "dcat:dataset",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "keywordMap": {
+ "@id": "http://www.w3.org/ns/dcat#keyword",
+ "@container": "@language"
+ },
+ "keyword": "http://www.w3.org/ns/dcat#keyword",
+ "record": {
+ "@id": "dcat:record",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "service": {
+ "@id": "dcat:service",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "theme": {
+ "@id": "dcat:theme",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "themeTaxonomy": {
+ "@id": "dcat:themeTaxonomy",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "accessRights": {
+ "@id": "dcterms:accessRights",
+ "@type": "@id"
+ },
+ "conformsTo": {
+ "@id": "dcterms:conformsTo",
+ "@type": "@id"
+ },
+ "creator": {
+ "@id": "dcterms:creator",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "hasPart": {
+ "@id": "dcterms:hasPart",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "language": {
+ "@id": "dcterms:language",
+ "@type": "@id",
+ "@container": "@set",
+ "@context": {
+ "@base": "http://id.loc.gov/vocabulary/iso639-1/"
+ }
+ },
+ "license": {
+ "@id": "dcterms:license",
+ "@type": "@id"
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "publisher": {
+ "@id": "dcterms:publisher",
+ "@type": "@id"
+ },
+ "rights": {
+ "@id": "dcterms:rights",
+ "@type": "@id"
+ },
+ "rightsHolder": {
+ "@id": "dcterms:rightsHolder",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "spatial": {
+ "@id": "dcterms:spatial",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "subject": {
+ "@id": "dcterms:subject",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "temporal": {
+ "@id": "dcterms:temporal",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id"
+ },
+ "homepage": {
+ "@id": "foaf:homepage",
+ "@type": "@id"
+ },
+ "qualifiedAttribution": {
+ "@id": "prov:qualifiedAttribution",
+ "@type": "@id",
+ "@container": "@set"
+ }
+ }
+ },
+ "dcat:CatalogRecord": {
+ "@id": "dcat:CatalogRecord",
+ "@context": {
+ "status": {
+ "@id": "adms:status",
+ "@type": "@id"
+ },
+ "conformsTo": {
+ "@id": "dcterms:conformsTo",
+ "@type": "@id"
+ },
+ "description": {
+ "@id": "dcterms:description",
+ "@container": "@set"
+ },
+ "issued": {
+ "@id": "dcterms:issued",
+ "@container": "@set"
+ },
+ "language": {
+ "@id": "dcterms:language",
+ "@type": "@id",
+ "@container": "@set",
+ "@context": {
+ "@base": "http://id.loc.gov/vocabulary/iso639-1/"
+ }
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "source": {
+ "@id": "dcterms:source",
+ "@type": "@id"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "primaryTopic": {
+ "@id": "foaf:primaryTopic",
+ "@type": "@id"
+ }
+ }
+ },
+ "dcat:DataService": {
+ "@id": "dcat:DataService",
+ "@context": {
+ "contactPoint": {
+ "@id": "dcat:contactPoint",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "endpointDescription": {
+ "@id": "dcat:endpointDescription",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "endpointURL": {
+ "@id": "dcat:endpointURL",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "keywordMap": {
+ "@id": "http://www.w3.org/ns/dcat#keyword",
+ "@container": "@language"
+ },
+ "keyword": "http://www.w3.org/ns/dcat#keyword",
+ "servesDataset": {
+ "@id": "dcat:servesDataset",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "spatialResolutionInMeters": {
+ "@id": "dcat:spatialResolutionInMeters",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal",
+ "@container": "@set"
+ },
+ "temporalResolution": {
+ "@id": "dcat:temporalResolution",
+ "@container": "@set"
+ },
+ "theme": {
+ "@id": "dcat:theme",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "geographicBoundingBox": {
+ "@id": "dcat-us:geographicBoundingBox",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "accessRights": {
+ "@id": "dcterms:accessRights",
+ "@type": "@id"
+ },
+ "conformsTo": {
+ "@id": "dcterms:conformsTo",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "created": {
+ "@id": "dcterms:created"
+ },
+ "creator": {
+ "@id": "dcterms:creator",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "language": {
+ "@id": "dcterms:language",
+ "@type": "@id",
+ "@container": "@set",
+ "@context": {
+ "@base": "http://id.loc.gov/vocabulary/iso639-1/"
+ }
+ },
+ "license": {
+ "@id": "dcterms:license",
+ "@type": "@id"
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "publisher": {
+ "@id": "dcterms:publisher",
+ "@type": "@id"
+ },
+ "rights": {
+ "@id": "dcterms:rights",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "rightsHolder": {
+ "@id": "dcterms:rightsHolder",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "spatial": {
+ "@id": "dcterms:spatial",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "temporal": {
+ "@id": "dcterms:temporal",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id"
+ },
+ "hasQualityMeasurement": {
+ "@id": "dqv:hasQualityMeasurement",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "hasPolicy": {
+ "@id": "odrl:hasPolicy",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "qualifiedAttribution": {
+ "@id": "prov:qualifiedAttribution",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "wasUsedBy": {
+ "@id": "prov:wasUsedBy",
+ "@type": "@id",
+ "@container": "@set"
+ }
+ }
+ },
+ "dcat:Dataset": {
+ "@id": "dcat:Dataset",
+ "@context": {
+ "otherIdentifier": {
+ "@id": "adms:identifier",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "sample": {
+ "@id": "adms:sample",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "status": {
+ "@id": "adms:status",
+ "@type": "@id"
+ },
+ "supportedSchema": {
+ "@id": "adms:supportedSchema",
+ "@type": "@id"
+ },
+ "versionNotes": "http://www.w3.org/ns/adms#versionNotes",
+ "contactPoint": {
+ "@id": "dcat:contactPoint",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "distribution": {
+ "@id": "dcat:distribution",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "first": {
+ "@id": "dcat:first",
+ "@type": "@id"
+ },
+ "hasCurrentVersion": {
+ "@id": "dcat:hasCurrentVersion",
+ "@type": "@id"
+ },
+ "hasVersion": {
+ "@id": "dcat:hasVersion",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "inSeries": {
+ "@id": "dcat:inSeries",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "keywordMap": {
+ "@id": "http://www.w3.org/ns/dcat#keyword",
+ "@container": "@language"
+ },
+ "keyword": "http://www.w3.org/ns/dcat#keyword",
+ "landingPage": {
+ "@id": "dcat:landingPage",
+ "@type": "@id"
+ },
+ "previousVersion": {
+ "@id": "dcat:previousVersion",
+ "@type": "@id"
+ },
+ "qualifiedRelation": {
+ "@id": "dcat:qualifiedRelation",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "spatialResolutionInMeters": {
+ "@id": "dcat:spatialResolutionInMeters",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+ },
+ "temporalResolution": {
+ "@id": "dcat:temporalResolution",
+ "@type": "http://www.w3.org/2001/XMLSchema#duration"
+ },
+ "theme": {
+ "@id": "dcat:theme",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "version": "http://www.w3.org/ns/dcat#version",
+ "describedBy": {
+ "@id": "dcat-us:describedBy",
+ "@type": "@id"
+ },
+ "geographicBoundingBox": {
+ "@id": "dcat-us:geographicBoundingBox",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "liabilityStatement": {
+ "@id": "dcat-us:liabilityStatement",
+ "@type": "@id"
+ },
+ "metadataDistribution": {
+ "@id": "dcat-us:metadataDistribution",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "purposeMap": {
+ "@id": "http://data.resources.gov/ontology/dcat-us#purpose",
+ "@container": "@language"
+ },
+ "purpose": "http://data.resources.gov/ontology/dcat-us#purpose",
+ "accessRights": {
+ "@id": "dcterms:accessRights",
+ "@type": "@id"
+ },
+ "accrualPeriodicity": {
+ "@id": "dcterms:accrualPeriodicity",
+ "@type": "@id",
+ "@context": {
+ "@base": "http://purl.org/cld/freq/"
+ }
+ },
+ "conformsTo": {
+ "@id": "dcterms:conformsTo",
+ "@type": "@id"
+ },
+ "contributor": {
+ "@id": "dcterms:contributor",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "created": {
+ "@id": "dcterms:created"
+ },
+ "creator": {
+ "@id": "dcterms:creator",
+ "@type": "@id"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "hasPart": {
+ "@id": "dcterms:hasPart",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "isReferencedBy": {
+ "@id": "dcterms:isReferencedBy",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "language": {
+ "@id": "dcterms:language",
+ "@type": "@id",
+ "@container": "@set",
+ "@context": {
+ "@base": "http://id.loc.gov/vocabulary/iso639-1/"
+ }
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "provenance": {
+ "@id": "dcterms:provenance",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "publisher": {
+ "@id": "dcterms:publisher",
+ "@type": "@id"
+ },
+ "relation": {
+ "@id": "dcterms:relation",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "replaces": {
+ "@id": "dcterms:replaces",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "rights": {
+ "@id": "dcterms:rights",
+ "@type": "@id"
+ },
+ "rightsHolder": {
+ "@id": "dcterms:rightsHolder",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "source": {
+ "@id": "dcterms:source",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "spatial": {
+ "@id": "dcterms:spatial",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "subject": {
+ "@id": "dcterms:subject",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "temporal": {
+ "@id": "dcterms:temporal",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "hasQualityMeasurement": {
+ "@id": "dqv:hasQualityMeasurement",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "page": {
+ "@id": "foaf:page",
+ "@type": "@id"
+ },
+ "qualifiedAttribution": {
+ "@id": "prov:qualifiedAttribution",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "wasAttributedTo": {
+ "@id": "prov:wasAttributedTo",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "wasGeneratedBy": {
+ "@id": "prov:wasGeneratedBy",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "wasUsedBy": {
+ "@id": "prov:wasUsedBy",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "image": {
+ "@id": "schema:image",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "scopeNoteMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#scopeNote",
+ "@container": "@language"
+ },
+ "scopeNote": "http://www.w3.org/2004/02/skos/core#scopeNote"
+ }
+ },
+ "dcat:DatasetSeries": {
+ "@id": "dcat:DatasetSeries",
+ "@context": {
+ "contactPoint": {
+ "@id": "dcat:contactPoint",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "first": {
+ "@id": "dcat:first",
+ "@type": "@id"
+ },
+ "last": {
+ "@id": "dcat:last",
+ "@type": "@id"
+ },
+ "seriesMember": {
+ "@id": "dcat:seriesMember",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "accrualPeriodicity": {
+ "@id": "dcterms:accrualPeriodicity",
+ "@type": "@id",
+ "@context": {
+ "@base": "http://purl.org/cld/freq/"
+ }
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "publisher": {
+ "@id": "dcterms:publisher",
+ "@type": "@id"
+ },
+ "spatial": {
+ "@id": "dcterms:spatial",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "temporal": {
+ "@id": "dcterms:temporal",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title"
+ }
+ },
+ "dcat:Distribution": {
+ "@id": "dcat:Distribution",
+ "@context": {
+ "representationTechnique": {
+ "@id": "adms:representationTechnique",
+ "@type": "@id"
+ },
+ "status": {
+ "@id": "adms:status",
+ "@type": "@id"
+ },
+ "characterEncoding": {
+ "@id": "cnt:characterEncoding",
+ "@container": "@set"
+ },
+ "accessService": {
+ "@id": "dcat:accessService",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "accessURL": {
+ "@id": "dcat:accessURL",
+ "@type": "@id"
+ },
+ "byteSize": {
+ "@id": "dcat:byteSize",
+ "@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
+ },
+ "compressFormat": {
+ "@id": "dcat:compressFormat",
+ "@type": "@id"
+ },
+ "downloadURL": {
+ "@id": "dcat:downloadURL",
+ "@type": "@id"
+ },
+ "mediaType": {
+ "@id": "dcat:mediaType",
+ "@type": "@id",
+ "@context": {
+ "@base": "https://www.iana.org/assignments/media-types/"
+ }
+ },
+ "packageFormat": {
+ "@id": "dcat:packageFormat",
+ "@type": "@id"
+ },
+ "spatialResolutionInMeters": {
+ "@id": "dcat:spatialResolutionInMeters",
+ "@type": "http://www.w3.org/2001/XMLSchema#decimal"
+ },
+ "temporalResolution": {
+ "@id": "dcat:temporalResolution",
+ "@type": "http://www.w3.org/2001/XMLSchema#duration"
+ },
+ "availability": {
+ "@id": "dcatap:availability",
+ "@type": "@id"
+ },
+ "accessRestriction": {
+ "@id": "dcat-us:accessRestriction",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "cuiRestriction": {
+ "@id": "dcat-us:cuiRestriction",
+ "@type": "@id"
+ },
+ "describedBy": {
+ "@id": "dcat-us:describedBy",
+ "@type": "@id"
+ },
+ "useRestriction": {
+ "@id": "dcat-us:useRestriction",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "accessRights": {
+ "@id": "dcterms:accessRights",
+ "@type": "@id"
+ },
+ "conformsTo": {
+ "@id": "dcterms:conformsTo",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "format": {
+ "@id": "dcterms:format",
+ "@type": "@id"
+ },
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "language": {
+ "@id": "dcterms:language",
+ "@type": "@id",
+ "@container": "@set",
+ "@context": {
+ "@base": "http://id.loc.gov/vocabulary/iso639-1/"
+ }
+ },
+ "license": {
+ "@id": "dcterms:license",
+ "@type": "@id"
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "rights": {
+ "@id": "dcterms:rights",
+ "@type": "@id"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "hasQualityMeasurement": {
+ "@id": "dqv:hasQualityMeasurement",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "page": {
+ "@id": "foaf:page",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "image": {
+ "@id": "schema:image",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "checksum": {
+ "@id": "spdx:checksum",
+ "@type": "@id"
+ }
+ }
+ },
+ "dcat:Relationship": {
+ "@id": "dcat:Relationship",
+ "@context": {
+ "hadRole": {
+ "@id": "dcat:hadRole",
+ "@type": "@id"
+ },
+ "relation": {
+ "@id": "dcterms:relation",
+ "@type": "@id"
+ }
+ }
+ },
+ "dcterms:LicenseDocument": {
+ "@id": "dcterms:LicenseDocument",
+ "@context": {
+ "licenseText": "http://spdx.org/rdf/terms#licenseText"
+ }
+ },
+ "dcterms:Location": {
+ "@id": "dcterms:Location",
+ "@context": {
+ "bbox": {
+ "@id": "dcat:bbox"
+ },
+ "centroid": {
+ "@id": "dcat:centroid"
+ },
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "geometry": {
+ "@id": "locn:geometry"
+ },
+ "inScheme": {
+ "@id": "skos:inScheme",
+ "@type": "@id"
+ },
+ "altLabelMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#altLabel",
+ "@container": "@language"
+ },
+ "altLabel": "http://www.w3.org/2004/02/skos/core#altLabel",
+ "prefLabelMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#prefLabel",
+ "@container": "@language"
+ },
+ "prefLabel": "http://www.w3.org/2004/02/skos/core#prefLabel"
+ }
+ },
+ "dcterms:MediaType": {
+ "@id": "dcterms:MediaType",
+ "@context": {
+ "labelMap": {
+ "@id": "http://www.w3.org/2000/01/rdf-schema#label",
+ "@container": "@language"
+ },
+ "label": "http://www.w3.org/2000/01/rdf-schema#label"
+ }
+ },
+ "dcterms:PeriodOfTime": {
+ "@id": "dcterms:PeriodOfTime",
+ "@context": {
+ "endDate": {
+ "@id": "dcat:endDate"
+ },
+ "startDate": {
+ "@id": "dcat:startDate"
+ }
+ }
+ },
+ "dcterms:ProvenanceStatement": {
+ "@id": "dcterms:ProvenanceStatement",
+ "@context": {
+ "labelMap": {
+ "@id": "http://www.w3.org/2000/01/rdf-schema#label",
+ "@container": "@language"
+ },
+ "label": "http://www.w3.org/2000/01/rdf-schema#label"
+ }
+ },
+ "dcterms:RightsStatement": {
+ "@id": "dcterms:RightsStatement",
+ "@context": {
+ "attributionTextMap": {
+ "@id": "http://schema.theodi.org/odrs#attributionText",
+ "@container": "@language"
+ },
+ "attributionText": "http://schema.theodi.org/odrs#attributionText"
+ }
+ },
+ "dcterms:Standard": {
+ "@id": "dcterms:Standard",
+ "@context": {
+ "created": {
+ "@id": "dcterms:created"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id"
+ },
+ "inScheme": {
+ "@id": "skos:inScheme",
+ "@type": "@id"
+ }
+ }
+ },
+ "dqv:Metric": {
+ "@id": "dqv:Metric",
+ "@context": {
+ "expectedDataType": {
+ "@id": "dqv:expectedDataType",
+ "@type": "@id"
+ },
+ "inDimension": {
+ "@id": "dqv:inDimension",
+ "@type": "@id"
+ }
+ }
+ },
+ "dqv:QualityMeasurement": {
+ "@id": "dqv:QualityMeasurement",
+ "@context": {
+ "isMeasurementOf": {
+ "@id": "dqv:isMeasurementOf",
+ "@type": "@id"
+ },
+ "value": "http://www.w3.org/ns/dqv#value",
+ "unitMeasure": {
+ "@id": "sdmx-attribute:unitMeasure",
+ "@type": "@id"
+ }
+ }
+ },
+ "foaf:Agent": {
+ "@id": "foaf:Agent",
+ "@context": {
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id"
+ },
+ "name": "http://xmlns.com/foaf/0.1/name"
+ }
+ },
+ "foaf:Document": {
+ "@id": "foaf:Document",
+ "@context": {
+ "creators": {
+ "@id": "dc:creator",
+ "@container": "@set"
+ },
+ "publishers": "http://purl.org/dc/elements/1.1/publisher",
+ "mediaType": {
+ "@id": "dcat:mediaType",
+ "@type": "@id",
+ "@container": "@set",
+ "@context": {
+ "@base": "https://www.iana.org/assignments/media-types/"
+ }
+ },
+ "abstractMap": {
+ "@id": "http://purl.org/dc/terms/abstract",
+ "@container": "@language"
+ },
+ "abstract": "http://purl.org/dc/terms/abstract",
+ "bibliographicCitation": "http://purl.org/dc/terms/bibliographicCitation",
+ "conformsTo": {
+ "@id": "dcterms:conformsTo",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "creator": {
+ "@id": "dcterms:creator",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "identifier": {
+ "@id": "dcterms:identifier",
+ "@container": "@set"
+ },
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "publisher": {
+ "@id": "dcterms:publisher",
+ "@type": "@id"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title",
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id"
+ }
+ }
+ },
+ "foaf:Person": {
+ "@id": "foaf:Person",
+ "@context": {
+ "givenName": "http://xmlns.com/foaf/0.1/givenName",
+ "familyName": "http://xmlns.com/foaf/0.1/familyname",
+ "name": "http://xmlns.com/foaf/0.1/name",
+ "memberOf": {
+ "@id": "org:memberOf",
+ "@type": "@id",
+ "@container": "@set"
+ }
+ }
+ },
+ "locn:Address": {
+ "@id": "locn:Address",
+ "@context": {
+ "adminUnitL1": "http://www.w3.org/ns/locn#adminUnitL1",
+ "adminUnitL2": "http://www.w3.org/ns/locn#adminUnitL2",
+ "postCode": "http://www.w3.org/ns/locn#postCode",
+ "postName": "http://www.w3.org/ns/locn#postName",
+ "thoroughfare": "http://www.w3.org/ns/locn#thoroughfare"
+ }
+ },
+ "org:Organization": {
+ "@id": "org:Organization",
+ "@context": {
+ "name": "http://xmlns.com/foaf/0.1/name",
+ "subOrganizationOf": {
+ "@id": "org:subOrganizationOf",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "altLabelMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#altLabel",
+ "@container": "@language"
+ },
+ "altLabel": "http://www.w3.org/2004/02/skos/core#altLabel",
+ "notation": {
+ "@id": "skos:notation",
+ "@container": "@set"
+ },
+ "prefLabelMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#prefLabel",
+ "@container": "@language"
+ },
+ "prefLabel": "http://www.w3.org/2004/02/skos/core#prefLabel"
+ }
+ },
+ "prov:Activity": {
+ "@id": "prov:Activity",
+ "@context": {
+ "category": {
+ "@id": "dcterms:type",
+ "@type": "@id"
+ },
+ "labelMap": {
+ "@id": "http://www.w3.org/2000/01/rdf-schema#label",
+ "@container": "@language"
+ },
+ "label": "http://www.w3.org/2000/01/rdf-schema#label"
+ }
+ },
+ "prov:Attribution": {
+ "@id": "prov:Attribution",
+ "@context": {
+ "hadRole": {
+ "@id": "dcat:hadRole",
+ "@type": "@id"
+ },
+ "agent": {
+ "@id": "prov:agent",
+ "@type": "@id"
+ }
+ }
+ },
+ "skos:Concept": {
+ "@id": "skos:Concept",
+ "@context": {
+ "altLabelMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#altLabel",
+ "@container": "@language"
+ },
+ "altLabel": "http://www.w3.org/2004/02/skos/core#altLabel",
+ "definitionMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#definition",
+ "@container": "@language"
+ },
+ "definition": "http://www.w3.org/2004/02/skos/core#definition",
+ "inScheme": {
+ "@id": "skos:inScheme",
+ "@type": "@id"
+ },
+ "notation": {
+ "@id": "skos:notation",
+ "@container": "@set"
+ },
+ "prefLabelMap": {
+ "@id": "http://www.w3.org/2004/02/skos/core#prefLabel",
+ "@container": "@language"
+ },
+ "prefLabel": "http://www.w3.org/2004/02/skos/core#prefLabel"
+ }
+ },
+ "skos:ConceptScheme": {
+ "@id": "skos:ConceptScheme",
+ "@context": {
+ "version": "http://www.w3.org/ns/dcat#version",
+ "created": {
+ "@id": "dcterms:created"
+ },
+ "descriptionMap": {
+ "@id": "http://purl.org/dc/terms/description",
+ "@container": "@language"
+ },
+ "description": "http://purl.org/dc/terms/description",
+ "issued": {
+ "@id": "dcterms:issued"
+ },
+ "modified": {
+ "@id": "dcterms:modified"
+ },
+ "titleMap": {
+ "@id": "http://purl.org/dc/terms/title",
+ "@container": "@language"
+ },
+ "title": "http://purl.org/dc/terms/title"
+ }
+ },
+ "spdx:Checksum": {
+ "@id": "spdx:Checksum",
+ "@context": {
+ "algorithm": {
+ "@id": "spdx:algorithm",
+ "@type": "@id"
+ },
+ "checksumValue": {
+ "@id": "spdx:checksumValue",
+ "@type": "http://www.w3.org/2001/XMLSchema#hexBinary"
+ }
+ }
+ },
+ "vcard:Address": {
+ "@id": "vcard:Address",
+ "@context": {
+ "country-name": "http://www.w3.org/2006/vcard/ns#country-name",
+ "locality": "http://www.w3.org/2006/vcard/ns#locality",
+ "postal-code": "http://www.w3.org/2006/vcard/ns#postal-code",
+ "region": "http://www.w3.org/2006/vcard/ns#region",
+ "street-address": "http://www.w3.org/2006/vcard/ns#street-address"
+ }
+ },
+ "vcard:Kind": {
+ "@id": "vcard:Kind",
+ "@context": {
+ "address": {
+ "@id": "vcard:address",
+ "@type": "@id",
+ "@container": "@set"
+ },
+ "hasEmail": {
+ "@id": "vcard:hasEmail",
+ "@type": "@id"
+ },
+ "family-name": "http://www.w3.org/2006/vcard/ns#family-name",
+ "fn": "http://www.w3.org/2006/vcard/ns#fn",
+ "given-name": "http://www.w3.org/2006/vcard/ns#given-name",
+ "organization-name": "http://www.w3.org/2006/vcard/ns#organization-name",
+ "tel": {
+ "@id": "vcard:tel",
+ "@type": "@id"
+ },
+ "title": "http://www.w3.org/2006/vcard/ns#title"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/demo/dcat_conformance.py b/demo/dcat_conformance.py
index a1b14f30..dec1f691 100644
--- a/demo/dcat_conformance.py
+++ b/demo/dcat_conformance.py
@@ -4,14 +4,19 @@
DCAT-US 3.0's README describes the profile as an implementation of the W3C
DCAT standard. Its published JSON Schema carries no JSON-LD `@context`, so
none of its own examples expand into DCAT (or any other) RDF vocabulary as
-published. The schema was not always contextless: every bound property still
-carries the RDF term it stood for in an `_oldDocs` block, left behind when
-`shacl/dcat-us_3.0_shacl_shapes.ttl` was deleted in pull request 120 (commit
-99ef81c9, https://github.com/GSA/dcat-us/pull/120). That block is a binding
-the schema already implies; nothing here invents an RDF term the schema does
-not already name.
-
-This script does three things, in order, against files committed under
+published. Pull request 120 (commit 99ef81c9,
+https://github.com/GSA/dcat-us/pull/120) deleted two files, not one:
+`shacl/dcat-us_3.0_shacl_shapes.ttl` and `context/dcat-us-3.0.jsonld`, the
+profile's only published JSON-LD `@context`. The schema's `_oldDocs` blocks
+are what is left of the second: every bound property still carries the RDF
+term it stood for. This script uses both: `_oldDocs` to derive a
+reconstruction, and the real deleted context, recovered separately from the
+pull request's base commit (04acd5c25579dd70a86a436b30a33e0784965cc4) and
+vendored unmodified as `recovered-context.jsonld`, to check the
+reconstruction against what the profile actually published rather than only
+against itself.
+
+This script does the following, against files committed under
`demo/corpus/dcat-us/`, with no network access and no model call:
1. Reads `jsonschema/definitions/*.json` and derives a JSON-LD context from
@@ -20,11 +25,15 @@ This script does three things, in order, against files committed under
its properties binds to. Namespace prefixes are read from the recovered
shapes file's own `@prefix` block (`recovered-shapes.ttl`), so the
context and the shapes cannot disagree about what a prefix expands to.
- 2. Expands every `jsonschema/examples/<Class>/good/*.json` file twice: once
- exactly as published (no context at all) and once with the derived
- context injected, and counts triples, distinct predicates and DCAT
- namespace predicates each way.
- 3. Merges the expanded corpus and runs it, both ways, against
+ 2. Expands every `jsonschema/examples/<Class>/good/*.json` file several
+ ways: exactly as published (no context at all), with the derived
+ context injected, and against `recovered-context.jsonld` (the real
+ context, both verbatim and with each example's bare `@type` rewritten
+ to the CURIE the schema's own `_oldDocs.rdfClass` already names for it,
+ since the real context's class bindings are keyed by CURIE and every
+ example's `@type` is the bare title). Counts triples, distinct
+ predicates and DCAT namespace predicates each way.
+ 3. Merges the expanded corpus and runs it, every way, against
`recovered-shapes.ttl` with pySHACL, counting violations and how many
focus nodes the shapes actually reach.
@@ -51,6 +60,7 @@ CORPUS = ROOT / "demo" / "corpus" / "dcat-us"
DEFINITIONS = CORPUS / "jsonschema" / "definitions"
EXAMPLES = CORPUS / "jsonschema" / "examples"
SHAPES_PATH = CORPUS / "recovered-shapes.ttl"
+REAL_CONTEXT_PATH = CORPUS / "recovered-context.jsonld"
BASE = "https://example.gov/"
DCAT_NS = "http://www.w3.org/ns/dcat#"
SH = rdflib.Namespace("http://www.w3.org/ns/shacl#")
@@ -174,6 +184,32 @@ def load_shapes_namespaces(shapes_path: Path) -> dict[str, str]:
return {prefix: str(ns) for prefix, ns in g.namespaces() if prefix}
+def load_real_context(path: Path) -> dict:
+ """The profile's own, actually published JSON-LD context (recovered-context.jsonld).
+
+ Retrieved verbatim from the base commit of pull request 120
+ (04acd5c25579dd70a86a436b30a33e0784965cc4), the commit immediately before
+ the same pull request that deleted the shapes file also deleted this
+ file. Nothing here derives or reconstructs it; it is read as published.
+ """
+ return json.loads(path.read_text(encoding="utf-8"))
+
+
+def title_to_rdf_class(classes: dict[str, ClassDef]) -> dict[str, str]:
+ """Schema title -> _oldDocs.rdfClass, exactly as load_classes already read it.
+
+ Used only to rewrite a '@type' value from the schema's bare title (what
+ every example actually publishes) to the CURIE the real context's
+ type-scoped bindings are keyed by. This is a reformatting of a class name
+ the schema itself states in _oldDocs.rdfClass, not a new binding: if a
+ title has no rdfClass, or an example's '@type' does not literally equal a
+ title (one case in this corpus: examples say 'Catalog', the schema's own
+ title is 'DCAT-US 3 Catalog'), the value is left as published rather than
+ guessed at.
+ """
+ return {name: cls.rdf_class for name, cls in classes.items() if cls.rdf_class}
+
+
ABSOLUTE_IRI = re.compile(r"^[A-Za-z][A-Za-z0-9+.\-]*:")
@@ -287,8 +323,39 @@ def build_context(
# --------------------------------------------------------------------------
-def expand_file(path: Path, context: dict | None, base: str = BASE) -> tuple[Graph | None, str | None]:
+def _retype(node, mapping: dict[str, str]):
+ """Rewrite every '@type' value found anywhere in node via mapping, in place.
+
+ Used only to exercise the real recovered context (recovered-context.jsonld)
+ against today's examples: that context's class bindings are keyed by the
+ class's full CURIE (e.g. 'skos:Concept', 'dcat:Dataset'), but every good
+ example's own '@type' is the bare schema title ('Concept', 'Dataset').
+ mapping comes straight from each class's own `_oldDocs.rdfClass` (already
+ read by load_classes for an unrelated purpose) -- nothing here invents a
+ binding; it only reformats a class name the schema already states, so the
+ real context's own type-scoped terms have a chance to match.
+ """
+ if isinstance(node, dict):
+ if "@type" in node:
+ t = node["@type"]
+ if isinstance(t, str):
+ node["@type"] = mapping.get(t, t)
+ elif isinstance(t, list):
+ node["@type"] = [mapping.get(x, x) if isinstance(x, str) else x for x in t]
+ for v in node.values():
+ _retype(v, mapping)
+ elif isinstance(node, list):
+ for item in node:
+ _retype(item, mapping)
+ return node
+
+
+def expand_file(
+ path: Path, context: dict | None, base: str = BASE, retype: dict[str, str] | None = None
+) -> tuple[Graph | None, str | None]:
raw = json.loads(path.read_text(encoding="utf-8"))
+ if retype and isinstance(raw, dict):
+ raw = _retype(raw, retype)
if not isinstance(raw, dict):
# A handful of "good" examples are a bare JSON string (a Concept or
# an Identifier used in its string form, e.g. Identifier/good/
@@ -317,13 +384,15 @@ def expand_file(path: Path, context: dict | None, base: str = BASE) -> tuple[Gra
return g, None
-def measure(files: list[Path], context: dict | None, base: str = BASE) -> dict:
+def measure(
+ files: list[Path], context: dict | None, base: str = BASE, retype: dict[str, str] | None = None
+) -> dict:
total = 0
predicates: Counter = Counter()
zero_files: list[str] = []
errors: list[dict] = []
for path in files:
- g, err = expand_file(path, context, base)
+ g, err = expand_file(path, context, base, retype)
if err:
errors.append({"file": path.name, "error": err})
continue
@@ -346,10 +415,12 @@ def measure(files: list[Path], context: dict | None, base: str = BASE) -> dict:
}
-def merge_corpus(files: list[Path], context: dict | None, base: str = BASE) -> Graph:
+def merge_corpus(
+ files: list[Path], context: dict | None, base: str = BASE, retype: dict[str, str] | None = None
+) -> Graph:
merged = Graph()
for path in files:
- g, err = expand_file(path, context, base)
+ g, err = expand_file(path, context, base, retype)
if err:
continue
for triple in g:
@@ -388,6 +459,33 @@ def run_shacl(shapes_path: Path, data: Graph) -> dict:
}
+# --------------------------------------------------------------------------
+# 5. A defect internal to the recovered files themselves, not this script
+# --------------------------------------------------------------------------
+
+
+def check_real_context_org_prefix(real_context: dict, shapes_namespaces: dict) -> dict:
+ """Compare 'org:' as bound in the two recovered files from the same deletion.
+
+ recovered-context.jsonld and recovered-shapes.ttl were both deleted by
+ the same pull request, as part of the same profile release, and both are
+ vendored here unmodified. They disagree about what 'org:' expands to:
+ the context binds it to 'http://www.w3c.org/ns/org#' (an extra 'c'); the
+ shapes file binds it to 'http://www.w3.org/ns/org#', the actual W3C
+ Organization Ontology namespace. This is reported here, not corrected:
+ substituting the shapes file's binding into the context would test a
+ context DCAT-US never actually published. See main()'s
+ 'orgPrefixTypoImpact' for what changes if it were corrected anyway.
+ """
+ real_org = real_context["@context"].get("org")
+ shapes_org = shapes_namespaces.get("org")
+ return {
+ "recoveredContextOrgPrefix": real_org,
+ "recoveredShapesOrgPrefix": shapes_org,
+ "agree": real_org == shapes_org,
+ }
+
+
# --------------------------------------------------------------------------
# main
# --------------------------------------------------------------------------
@@ -425,23 +523,94 @@ def main() -> int:
zero_bound_classes = sorted(c.name for c in classes.values() if not c.properties)
+ # --- The real, historically published context (recovered-context.jsonld) ---
+ # Pull request 120 deleted two files, not one: the shapes file above, and
+ # this JSON-LD @context, the profile's own actual publication, not a
+ # reconstruction. Two measurements, both against the unmodified file:
+ #
+ # - "verbatim": the context injected exactly as retrieved, no rewriting.
+ # Its class bindings are keyed by full CURIE ('skos:Concept',
+ # 'dcat:Dataset', ...); every good example's own '@type' is the bare
+ # schema title ('Concept', 'Dataset'). JSON-LD type-scoped contexts
+ # require an exact term match, so this measurement shows what actually
+ # happens if the file is dropped back in as-is: almost nothing.
+ # - "typed": the same unmodified context, with each example's '@type'
+ # mechanically rewritten from the schema's bare title to the CURIE the
+ # schema's own _oldDocs.rdfClass already records for that title (see
+ # title_to_rdf_class). This is the measurement that exercises what the
+ # real context actually binds, once its own naming convention is met.
+ real_context = load_real_context(REAL_CONTEXT_PATH)
+ retype_map = title_to_rdf_class(classes)
+
+ real_verbatim = measure(good_files, real_context)
+ real_typed = measure(good_files, real_context, retype=retype_map)
+
+ corpus_real_verbatim = merge_corpus(good_files, real_context)
+ corpus_real_typed = merge_corpus(good_files, real_context, retype=retype_map)
+
+ shacl_real_verbatim = run_shacl(SHAPES_PATH, corpus_real_verbatim)
+ shacl_real_typed = run_shacl(SHAPES_PATH, corpus_real_typed)
+
+ # Sanity check pinned by demo/tests/test_dcat_conformance.py: the real
+ # context does bind Concept's and Identifier's properties, contradicting
+ # the schema-residue reading that they are unbound.
+ real_concept_props = sorted(real_context["@context"]["skos:Concept"]["@context"].keys())
+ real_identifier_props = sorted(real_context["@context"]["adms:Identifier"]["@context"].keys())
+
+ # A defect internal to the two recovered files, independent of anything
+ # this script assumes: they disagree about what 'org:' expands to (see
+ # check_real_context_org_prefix). Quantified here, purely diagnostic, not
+ # one of the four canonical measurements above: how many more focus
+ # nodes and violations the shapes-file binding of 'org:' would reach, if
+ # it were substituted into the real context. Not used to adjust any
+ # reported figure; it is evidence for why a single violation count is
+ # not defensible, not a correction to the published files.
+ org_prefix_check = check_real_context_org_prefix(real_context, namespaces)
+ org_typo_fixed_context = json.loads(json.dumps(real_context))
+ org_typo_fixed_context["@context"]["org"] = namespaces.get("org", org_prefix_check["recoveredShapesOrgPrefix"])
+ corpus_org_fixed = merge_corpus(good_files, org_typo_fixed_context, retype=retype_map)
+ shacl_org_fixed = run_shacl(SHAPES_PATH, corpus_org_fixed)
+ org_prefix_impact = {
+ "description": "legacyShapesOverRealContextTypedCorpus, with recovered-context.jsonld's own "
+ "'org:' prefix replaced by recovered-shapes.ttl's, diagnostic only",
+ "violations": shacl_org_fixed["violations"],
+ "focusNodes": shacl_org_fixed["focusNodes"],
+ "violationsDelta": shacl_org_fixed["violations"] - shacl_real_typed["violations"],
+ "focusNodesDelta": shacl_org_fixed["focusNodes"] - shacl_real_typed["focusNodes"],
+ }
+
result = {
"measured": "2026-08-25, this repository, no network, no model call",
"commit": COMMIT_SHA,
+ "realContextBaseCommit": REAL_CONTEXT_COMMIT_SHA,
"classes": len(classes),
"classesWithZeroBoundProperties": zero_bound_classes,
+ "realContextBindsConceptProperties": real_concept_props,
+ "realContextBindsIdentifierProperties": real_identifier_props,
+ "recoveredFilesOrgPrefixCheck": org_prefix_check,
+ "recoveredFilesOrgPrefixTypoImpactDiagnosticOnly": org_prefix_impact,
"lenientTermCount": len(lenient_terms),
"lenientTerms": sorted(lenient_terms),
- "examples": {"asPublished": as_published, "withDeclaredBinding": with_declared, "withObservedBinding": with_observed},
+ "examples": {
+ "asPublished": as_published,
+ "withDeclaredBinding": with_declared,
+ "withObservedBinding": with_observed,
+ "withRealContextVerbatim": real_verbatim,
+ "withRealContextTyped": real_typed,
+ },
"corpusTriples": {
"asPublished": len(corpus_published),
"withDeclaredBinding": len(corpus_declared),
"withObservedBinding": len(corpus_observed),
+ "withRealContextVerbatim": len(corpus_real_verbatim),
+ "withRealContextTyped": len(corpus_real_typed),
},
"shacl": {
"legacyShapesOverPublishedCorpus": shacl_published,
"legacyShapesOverDeclaredBoundCorpus": shacl_declared,
"legacyShapesOverObservedBoundCorpus": shacl_observed,
+ "legacyShapesOverRealContextVerbatimCorpus": shacl_real_verbatim,
+ "legacyShapesOverRealContextTypedCorpus": shacl_real_typed,
},
}
@@ -453,25 +622,41 @@ def main() -> int:
)
print(f"classes {len(classes)} good examples {len(good_files)} lenient terms {len(lenient_terms)}")
- print(f"as published : {as_published['triples']:5} triples {as_published['distinctPredicates']:3} predicates "
+ print(f"as published : {as_published['triples']:5} triples {as_published['distinctPredicates']:3} predicates "
f"{as_published['dcatPredicateTriples']:4} dcat {as_published['zeroTripleFiles']:3} empty "
f"{len(as_published['errors'])} errors")
- print(f"declared binding : {with_declared['triples']:5} triples {with_declared['distinctPredicates']:3} predicates "
+ print(f"declared binding : {with_declared['triples']:5} triples {with_declared['distinctPredicates']:3} predicates "
f"{with_declared['dcatPredicateTriples']:4} dcat {with_declared['zeroTripleFiles']:3} empty "
f"{len(with_declared['errors'])} errors")
- print(f"observed binding : {with_observed['triples']:5} triples {with_observed['distinctPredicates']:3} predicates "
+ print(f"observed binding : {with_observed['triples']:5} triples {with_observed['distinctPredicates']:3} predicates "
f"{with_observed['dcatPredicateTriples']:4} dcat {with_observed['zeroTripleFiles']:3} empty "
f"{len(with_observed['errors'])} errors")
- print(f"shacl over as-published corpus : conforms={shacl_published['conforms']} "
+ print(f"real context verbatim: {real_verbatim['triples']:4} triples {real_verbatim['distinctPredicates']:3} predicates "
+ f"{real_verbatim['dcatPredicateTriples']:4} dcat {real_verbatim['zeroTripleFiles']:3} empty "
+ f"{len(real_verbatim['errors'])} errors")
+ print(f"real context typed : {real_typed['triples']:5} triples {real_typed['distinctPredicates']:3} predicates "
+ f"{real_typed['dcatPredicateTriples']:4} dcat {real_typed['zeroTripleFiles']:3} empty "
+ f"{len(real_typed['errors'])} errors")
+ print(f"shacl over as-published corpus : conforms={shacl_published['conforms']} "
f"violations={shacl_published['violations']} focus_nodes={shacl_published['focusNodes']}")
- print(f"shacl over declared-bound corpus : conforms={shacl_declared['conforms']} "
+ print(f"shacl over declared-bound corpus : conforms={shacl_declared['conforms']} "
f"violations={shacl_declared['violations']} focus_nodes={shacl_declared['focusNodes']}")
- print(f"shacl over observed-bound corpus : conforms={shacl_observed['conforms']} "
+ print(f"shacl over observed-bound corpus : conforms={shacl_observed['conforms']} "
f"violations={shacl_observed['violations']} focus_nodes={shacl_observed['focusNodes']}")
+ print(f"shacl over real-context-verbatim corpus: conforms={shacl_real_verbatim['conforms']} "
+ f"violations={shacl_real_verbatim['violations']} focus_nodes={shacl_real_verbatim['focusNodes']}")
+ print(f"shacl over real-context-typed corpus : conforms={shacl_real_typed['conforms']} "
+ f"violations={shacl_real_typed['violations']} focus_nodes={shacl_real_typed['focusNodes']}")
+ print(f"recovered files disagree on 'org:' -- context: {org_prefix_check['recoveredContextOrgPrefix']} "
+ f"shapes: {org_prefix_check['recoveredShapesOrgPrefix']} agree={org_prefix_check['agree']}")
+ print(f" (diagnostic only) with shapes-file 'org:' substituted: "
+ f"violations={org_prefix_impact['violations']} ({org_prefix_impact['violationsDelta']:+d}) "
+ f"focus_nodes={org_prefix_impact['focusNodes']} ({org_prefix_impact['focusNodesDelta']:+d})")
return 0
COMMIT_SHA = "7a6e803fb94ee9903e7e7405ec4afcc8da13383f"
+REAL_CONTEXT_COMMIT_SHA = "04acd5c25579dd70a86a436b30a33e0784965cc4"
if __name__ == "__main__":
sys.exit(main())
diff --git a/demo/dcat_conformance_measurements.json b/demo/dcat_conformance_measurements.json
index c414ff57..143b9149 100644
--- a/demo/dcat_conformance_measurements.json
+++ b/demo/dcat_conformance_measurements.json
@@ -8,7 +8,9 @@
"corpusTriples": {
"asPublished": 73,
"withDeclaredBinding": 1381,
- "withObservedBinding": 1383
+ "withObservedBinding": 1383,
+ "withRealContextTyped": 997,
+ "withRealContextVerbatim": 73
},
"examples": {
"asPublished": {
@@ -313,6 +315,212 @@
"null_example.json"
],
"zeroTripleFiles": 10
+ },
+ "withRealContextTyped": {
+ "dcatPredicateTriples": 184,
+ "distinctPredicates": 114,
+ "errors": [],
+ "files": 115,
+ "topPredicates": [
+ [
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
+ 230
+ ],
+ [
+ "http://purl.org/dc/terms/title",
+ 82
+ ],
+ [
+ "http://purl.org/dc/terms/description",
+ 57
+ ],
+ [
+ "http://www.w3.org/2004/02/skos/core#prefLabel",
+ 37
+ ],
+ [
+ "http://purl.org/dc/terms/identifier",
+ 31
+ ],
+ [
+ "http://www.w3.org/2004/02/skos/core#inScheme",
+ 29
+ ],
+ [
+ "http://xmlns.com/foaf/0.1/name",
+ 28
+ ],
+ [
+ "http://www.w3.org/2004/02/skos/core#notation",
+ 26
+ ],
+ [
+ "http://www.w3.org/ns/dcat#contactPoint",
+ 26
+ ],
+ [
+ "http://purl.org/dc/terms/publisher",
+ 25
+ ],
+ [
+ "http://www.w3.org/ns/dcat#keyword",
+ 24
+ ],
+ [
+ "http://www.w3.org/2004/02/skos/core#definition",
+ 23
+ ],
+ [
+ "http://purl.org/dc/terms/issued",
+ 15
+ ],
+ [
+ "http://purl.org/dc/terms/type",
+ 13
+ ],
+ [
+ "http://www.w3.org/ns/dcat#downloadURL",
+ 13
+ ],
+ [
+ "http://purl.org/dc/terms/modified",
+ 12
+ ],
+ [
+ "http://www.w3.org/2004/02/skos/core#altLabel",
+ 11
+ ],
+ [
+ "http://www.w3.org/ns/adms#schemaAgency",
+ 11
+ ],
+ [
+ "http://www.w3.org/ns/dcat#mediaType",
+ 11
+ ],
+ [
+ "http://www.w3.org/ns/dcat#startDate",
+ 11
+ ],
+ [
+ "http://www.w3.org/ns/dcat#endDate",
+ 10
+ ],
+ [
+ "http://www.w3.org/ns/dcat#hadRole",
+ 9
+ ],
+ [
+ "http://purl.org/dc/terms/format",
+ 8
+ ],
+ [
+ "http://purl.org/dc/terms/language",
+ 8
+ ],
+ [
+ "http://purl.org/dc/terms/relation",
+ 8
+ ]
+ ],
+ "triples": 1069,
+ "zeroTripleFileNames": [
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_object_example.json",
+ "minimal_string_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json"
+ ],
+ "zeroTripleFiles": 39
+ },
+ "withRealContextVerbatim": {
+ "dcatPredicateTriples": 0,
+ "distinctPredicates": 1,
+ "errors": [],
+ "files": 115,
+ "topPredicates": [
+ [
+ "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
+ 76
+ ]
+ ],
+ "triples": 76,
+ "zeroTripleFileNames": [
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_example.json",
+ "minimal_object_example.json",
+ "minimal_string_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json",
+ "null_example.json"
+ ],
+ "zeroTripleFiles": 39
}
},
"lenientTermCount": 22,
@@ -341,6 +549,36 @@
"unitMeasure"
],
"measured": "2026-08-25, this repository, no network, no model call",
+ "realContextBaseCommit": "04acd5c25579dd70a86a436b30a33e0784965cc4",
+ "realContextBindsConceptProperties": [
+ "altLabel",
+ "altLabelMap",
+ "definition",
+ "definitionMap",
+ "inScheme",
+ "notation",
+ "prefLabel",
+ "prefLabelMap"
+ ],
+ "realContextBindsIdentifierProperties": [
+ "creator",
+ "issued",
+ "notation",
+ "schemaAgency",
+ "version"
+ ],
+ "recoveredFilesOrgPrefixCheck": {
+ "agree": false,
+ "recoveredContextOrgPrefix": "http://www.w3c.org/ns/org#",
+ "recoveredShapesOrgPrefix": "http://www.w3.org/ns/org#"
+ },
+ "recoveredFilesOrgPrefixTypoImpactDiagnosticOnly": {
+ "description": "legacyShapesOverRealContextTypedCorpus, with recovered-context.jsonld's own 'org:' prefix replaced by recovered-shapes.ttl's, diagnostic only",
+ "focusNodes": 194,
+ "focusNodesDelta": 11,
+ "violations": 153,
+ "violationsDelta": 6
+ },
"shacl": {
"legacyShapesOverDeclaredBoundCorpus": {
"bySeverity": {
@@ -428,6 +666,54 @@
"shapeTriples": 4043,
"targetClassCount": 34,
"violations": 0
+ },
+ "legacyShapesOverRealContextTypedCorpus": {
+ "bySeverity": {
+ "Violation": 147
+ },
+ "conforms": false,
+ "dataTriples": 997,
+ "focusNodes": 183,
+ "matchedClassCount": 23,
+ "matchedClasses": [
+ "http://data.resources.gov/ontology/dcat-us#AccessRestriction",
+ "http://data.resources.gov/ontology/dcat-us#UseRestriction",
+ "http://purl.org/dc/terms/Location",
+ "http://purl.org/dc/terms/PeriodOfTime",
+ "http://purl.org/dc/terms/Standard",
+ "http://spdx.org/rdf/terms#Checksum",
+ "http://www.w3.org/2004/02/skos/core#Concept",
+ "http://www.w3.org/2004/02/skos/core#ConceptScheme",
+ "http://www.w3.org/2006/vcard/ns#Kind",
+ "http://www.w3.org/ns/adms#Identifier",
+ "http://www.w3.org/ns/dcat#CatalogRecord",
+ "http://www.w3.org/ns/dcat#DataService",
+ "http://www.w3.org/ns/dcat#Dataset",
+ "http://www.w3.org/ns/dcat#DatasetSeries",
+ "http://www.w3.org/ns/dcat#Distribution",
+ "http://www.w3.org/ns/dcat#Relationship",
+ "http://www.w3.org/ns/dqv#Metric",
+ "http://www.w3.org/ns/dqv#QualityMeasurement",
+ "http://www.w3.org/ns/locn#Address",
+ "http://www.w3.org/ns/prov#Activity",
+ "http://www.w3.org/ns/prov#Attribution",
+ "http://xmlns.com/foaf/0.1/Agent",
+ "http://xmlns.com/foaf/0.1/Document"
+ ],
+ "shapeTriples": 4043,
+ "targetClassCount": 34,
+ "violations": 147
+ },
+ "legacyShapesOverRealContextVerbatimCorpus": {
+ "bySeverity": {},
+ "conforms": true,
+ "dataTriples": 73,
+ "focusNodes": 0,
+ "matchedClassCount": 0,
+ "matchedClasses": [],
+ "shapeTriples": 4043,
+ "targetClassCount": 34,
+ "violations": 0
}
}
}
diff --git a/demo/precomputed/MANIFEST.sha256 b/demo/precomputed/MANIFEST.sha256
index 62f31b4e..5618f870 100644
--- a/demo/precomputed/MANIFEST.sha256
+++ b/demo/precomputed/MANIFEST.sha256
@@ -1,6 +1,6 @@
+087e822944642ba70570428b872025f63ebd9fdee813e8ad6c0b7b741e610d7d bundle.json
198cbb5a2734e83c7347ad739f2bf8d3d038526bb89b3383ee277929bd307c07 compare.json
+220dea33101436310a5cbfcda5c59df528acb4f15761b7a2f729d5d40015c34d findings.json
257d0ca76ab9b3c892cb06c2acc46c97d878be758bba99a2dcd8758f4b32ec44 graph.json
-94aa1ece09b95caa42ebbd2de332a737fdc8331bbbb5ead22279b028b479ec0b bundle.json
9a5257a4d084b733e1d69fd714113402806215a810e79c342c4360799961eb03 corpus.json
-aa03d13e399ec47561223478562de2227e45c3a406d54a2ada193c69dc68699c findings.json
b91d367cc4722fe65a18a49d57b79cea8194673c780579968f644a9f4ef0cada chat.json
diff --git a/demo/precomputed/bundle.json b/demo/precomputed/bundle.json
index 267f238b..06c82ad1 100644
--- a/demo/precomputed/bundle.json
+++ b/demo/precomputed/bundle.json
@@ -213,6 +213,11 @@
"object": "conforming data use the dcat: vocabulary (W3C DCAT 3, section 4)",
"predicate": "requires"
},
+ {
+ "document": "pr-120-record.md",
+ "object": "two files, both status: removed with no renamed successor anywhere in the diff: context/dcat-us-3.0.jsonld (the profile's only published JSON-LD @context) and shacl/dcat-us_3.0_shacl_shapes.ttl (its only SHACL shapes); every other file the pull request touched has status: renamed into a DEPRECATED/ tree, byte-identical",
+ "predicate": "removedWithNoSuccessor"
+ },
{
"document": "jsonschema/examples/Catalog/good/complete_example.json",
"object": "1 triple: rdf:type of a manufactured IRI, no @context present, 0 dcat: predicates",
@@ -247,8 +252,18 @@
},
{
"document": "recovered-shapes.ttl",
- "object": "the same 115 files, with the context demo/dcat_conformance.py derives from _oldDocs, expand to 1510 triples, 123 distinct predicates, 228 dcat: triples, 10 files empty, 0 errors",
- "predicate": "measuredWithBinding"
+ "object": "the same 115 files, with a context demo/dcat_conformance.py derives from the schema's own _oldDocs residue (not the real context), expand to 1510 triples, 123 distinct predicates, 228 dcat: triples, 10 files empty, 0 errors",
+ "predicate": "measuredWithSchemaDerivedBinding"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "object": "the profile's own recovered, historically published context, injected exactly as retrieved with no rewriting: 76 triples, 1 predicate, 0 dcat, 39 empty files, 0 errors, nearly identical to publishing no context at all. Cause, verified directly: every good example's own @type is the bare schema title ('Dataset', 'Concept'), but this context's class bindings are keyed by full CURIE ('dcat:Dataset', 'skos:Concept'); JSON-LD type-scoped contexts require an exact term match, which the bare title never gives",
+ "predicate": "measuredWithRealPublishedContextVerbatim"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "object": "the same 115 files, same unmodified context, with each example's @type mechanically rewritten from the schema's bare title to the CURIE the schema's own _oldDocs.rdfClass already names for that title (no invented binding, only a reformatting the schema itself states): 1069 triples, 114 distinct predicates, 184 dcat: triples, 39 empty files, 0 errors. Lower than the schema-derived reconstruction's 1508/123/228 figures above: the real context scopes every property strictly to its owning class with no cross-class default term, while the reconstruction, built from _oldDocs residue without ever seeing the real context, defines every term as a global default plus per-class overrides only where the schema itself flags an ambiguity",
+ "predicate": "measuredWithRealPublishedContextTyped"
}
],
"id": "conformance-2-corpus-wide-expansion",
@@ -259,68 +274,110 @@
"claims": [
{
"document": "jsonschema/definitions/Concept.json",
- "object": "skos:Concept, in _oldDocs.rdfClass, with prefLabel, definition, inScheme, notation as properties",
+ "object": "skos:Concept, in _oldDocs.rdfClass, with prefLabel, altLabel, definition, inScheme, notation as properties",
"predicate": "declaresRdfClass"
},
{
"document": "jsonschema/definitions/Concept.json",
- "object": "prefLabel, definition, inScheme, notation carry no _oldDocs.uri: zero of Concept's properties have an RDF term",
- "predicate": "bindsNoneOf"
+ "object": "prefLabel, altLabel, definition, inScheme, notation: none carries an _oldDocs.uri in the schema's current definitions, so nothing published today (the schema alone, with no context and no shapes) assigns any of Concept's five properties an RDF term",
+ "predicate": "assignsNoTermTodayTo"
},
{
"document": "jsonschema/definitions/Identifier.json",
- "object": "schemaAgency, creator, issued, version, notation carry no _oldDocs.uri: zero of Identifier's properties have an RDF term",
- "predicate": "bindsNoneOf"
+ "object": "schemaAgency, creator, issued, version, notation: none carries an _oldDocs.uri in the schema's current definitions, so nothing published today assigns any of Identifier's five properties an RDF term",
+ "predicate": "assignsNoTermTodayTo"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "object": "Concept, under the type-scoped context keyed skos:Concept: prefLabel -> skos:prefLabel, altLabel -> skos:altLabel, definition -> skos:definition, inScheme -> skos:inScheme (@id), notation -> skos:notation (@set). The schema's own remaining metadata assigns Concept no term at all; the profile's own deleted context assigned all five, before it was removed by the same pull request that removed the shapes",
+ "predicate": "didBindAllFiveOf"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "object": "Identifier, under the type-scoped context keyed adms:Identifier: schemaAgency -> adms:schemaAgency, creator -> dcterms:creator (@id), issued -> dcterms:issued, version -> dcterms:version, notation -> skos:notation",
+ "predicate": "didBindAllFiveOf"
},
{
"document": "jsonschema/examples/Concept/good/complete_example.json",
- "object": "prefLabel and definition values, present in the data, that no shape or context can reach",
- "predicate": "instantiatesUncheckable"
+ "object": "prefLabel and altLabel values present in the data: unreachable by anything published today (no context, no shapes); once expanded against recovered-context.jsonld with @type rewritten to the CURIE the schema's own _oldDocs.rdfClass already names (demo/dcat_conformance.py, no invented binding), the node becomes a SHACL focus node and the file conforms with 0 violations, while jsonschema/examples/Concept/good/minimal_object.json fires 1 violation under the same recovered context",
+ "predicate": "reachableOnlyUnderRealContext"
},
{
"document": "jsonschema/examples/Identifier/good/complete_example.json",
- "object": "schemaAgency and creator values, present in the data, that no shape or context can reach",
- "predicate": "instantiatesUncheckable"
+ "object": "schemaAgency and creator values present in the data: unreachable by anything published today; once expanded against recovered-context.jsonld with the same mechanical @type rewrite, the node becomes a SHACL focus node and the file fires 1 violation, where as-published it fired none because nothing could be checked",
+ "predicate": "reachableOnlyUnderRealContext"
}
],
- "id": "conformance-3-unbound-heavily-instantiated-classes",
+ "id": "conformance-3-real-context-binds-what-schema-residue-does-not",
"kind": "conformance",
"subject": "dcat-us:Concept,dcat-us:Identifier"
},
+ {
+ "claims": [
+ {
+ "document": "recovered-context.jsonld",
+ "object": "org: to http://www.w3c.org/ns/org# (line 18 of the recovered file)",
+ "predicate": "bindsPrefix"
+ },
+ {
+ "document": "recovered-shapes.ttl",
+ "object": "org: to http://www.w3.org/ns/org#, the W3C Organization Ontology namespace, no 'c' in w3c",
+ "predicate": "bindsPrefix"
+ },
+ {
+ "document": "jsonschema/definitions/Organization.json",
+ "object": "org:Organization, in _oldDocs.rdfClass, matching recovered-shapes.ttl's prefix, not recovered-context.jsonld's",
+ "predicate": "declaresRdfClass"
+ },
+ {
+ "document": "recovered-shapes.ttl",
+ "object": "with recovered-context.jsonld's own org: prefix replaced by recovered-shapes.ttl's (diagnostic only, not applied to any other figure in this file): SHACL violations over the real-context-typed corpus rise from 147 to 153, focus nodes from 183 to 194 (demo/dcat_conformance_measurements.json, recoveredFilesOrgPrefixTypoImpactDiagnosticOnly)",
+ "predicate": "quantifiedImpactOfSubstitutingCorrectPrefix"
+ }
+ ],
+ "id": "conformance-4-recovered-files-disagree-on-org-prefix",
+ "kind": "conformance",
+ "subject": "dcat-us:Organization"
+ },
{
"claims": [
{
"document": "pr-120-record.md",
- "object": "shacl/dcat-us_3.0_shacl_shapes.ttl, at commit aaa3ff4a, in favour of the JSON Schema alone",
+ "object": "shacl/dcat-us_3.0_shacl_shapes.ttl, at commit aaa3ff4a, and context/dcat-us-3.0.jsonld, at commit 04acd5c2, in favour of the JSON Schema alone",
"predicate": "deletes"
},
{
"document": "recovered-shapes.ttl",
- "object": "conforms=true, 0 violations, 0 focus nodes: the shapes select nothing to check against the 115 examples as published",
+ "object": "conforms=true, 0 violations, 0 focus nodes, whether checked against the as-published corpus or against the same corpus expanded with recovered-context.jsonld injected verbatim: the shapes select nothing to check either way",
"predicate": "unchangedFileValidatesAsPublishedCorpusAs"
},
{
"document": "recovered-shapes.ttl",
- "object": "conforms=false, 272 violations, 228 focus nodes, once the schema-implied binding is applied to the same 115 examples",
- "predicate": "sameUnchangedFileValidatesBoundCorpusAs"
+ "object": "conforms=false, 228 focus nodes, but the violation count itself is not stable across the reconstruction's own two variants: 178 violations under the declared binding, 272 under the observed binding (which relaxes 22 terms the corpus publishes as prose rather than IRIs), a spread of 94 from one schema-residue reconstruction alone",
+ "predicate": "validatesSchemaDerivedBoundCorpusAs"
+ },
+ {
+ "document": "recovered-shapes.ttl",
+ "object": "conforms=false, 147 violations, 183 focus nodes, measured against the profile's own recovered context rather than a reconstruction. Lower than either reconstruction figure for a specific, checked reason: the real context has no cross-class default term bindings, and the schema's title for the Catalog class ('DCAT-US 3 Catalog') does not match the bare '@type': 'Catalog' every Catalog example actually publishes, so a literal CURIE rewrite leaves Catalog-typed nodes, and everything nested inside them, outside the real context's reach; the schema-derived reconstruction does not have this gap, because it defines every property term globally regardless of which class's scope activates",
+ "predicate": "validatesRealContextTypedCorpusAs"
},
{
"document": "jsonschema/examples/Dataset/good/complete_example.json",
- "object": "35, once bound (sh:datatype and sh:minCount failures on dcterms/foaf/dcat properties)",
+ "object": "35 under the schema-derived observed binding, 15 under the real recovered context typed",
"predicate": "firesViolations"
},
{
"document": "jsonschema/examples/Catalog/good/complete_example.json",
- "object": "19, once bound",
+ "object": "19 under the schema-derived observed binding; 0 under the real recovered context typed, for the reason given above (the file's own top-level node never becomes a reachable focus node under that context, so nothing nested inside it is checked either)",
"predicate": "firesViolations"
},
{
"document": "jsonschema/examples/Distribution/good/complete_example.json",
- "object": "14, once bound",
+ "object": "14 under the schema-derived observed binding, 5 under the real recovered context typed",
"predicate": "firesViolations"
}
],
- "id": "conformance-4-deleted-shapes-fire-on-bound-examples",
+ "id": "conformance-5-deleted-shapes-fire-on-bound-examples",
"kind": "conformance",
"subject": "dcat-us:pr-120"
}
diff --git a/demo/precomputed/findings.json b/demo/precomputed/findings.json
index d1ba1683..77301428 100644
--- a/demo/precomputed/findings.json
+++ b/demo/precomputed/findings.json
@@ -14,6 +14,11 @@
"predicate": "requires",
"object": "conforming data use the dcat: vocabulary (W3C DCAT 3, section 4)"
},
+ {
+ "document": "pr-120-record.md",
+ "predicate": "removedWithNoSuccessor",
+ "object": "two files, both status: removed with no renamed successor anywhere in the diff: context/dcat-us-3.0.jsonld (the profile's only published JSON-LD @context) and shacl/dcat-us_3.0_shacl_shapes.ttl (its only SHACL shapes); every other file the pull request touched has status: renamed into a DEPRECATED/ tree, byte-identical"
+ },
{
"document": "jsonschema/examples/Catalog/good/complete_example.json",
"predicate": "expandsAsPublishedTo",
@@ -48,77 +53,129 @@
},
{
"document": "recovered-shapes.ttl",
- "predicate": "measuredWithBinding",
- "object": "the same 115 files, with the context demo/dcat_conformance.py derives from _oldDocs, expand to 1510 triples, 123 distinct predicates, 228 dcat: triples, 10 files empty, 0 errors"
+ "predicate": "measuredWithSchemaDerivedBinding",
+ "object": "the same 115 files, with a context demo/dcat_conformance.py derives from the schema's own _oldDocs residue (not the real context), expand to 1510 triples, 123 distinct predicates, 228 dcat: triples, 10 files empty, 0 errors"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "predicate": "measuredWithRealPublishedContextVerbatim",
+ "object": "the profile's own recovered, historically published context, injected exactly as retrieved with no rewriting: 76 triples, 1 predicate, 0 dcat, 39 empty files, 0 errors, nearly identical to publishing no context at all. Cause, verified directly: every good example's own @type is the bare schema title ('Dataset', 'Concept'), but this context's class bindings are keyed by full CURIE ('dcat:Dataset', 'skos:Concept'); JSON-LD type-scoped contexts require an exact term match, which the bare title never gives"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "predicate": "measuredWithRealPublishedContextTyped",
+ "object": "the same 115 files, same unmodified context, with each example's @type mechanically rewritten from the schema's bare title to the CURIE the schema's own _oldDocs.rdfClass already names for that title (no invented binding, only a reformatting the schema itself states): 1069 triples, 114 distinct predicates, 184 dcat: triples, 39 empty files, 0 errors. Lower than the schema-derived reconstruction's 1508/123/228 figures above: the real context scopes every property strictly to its owning class with no cross-class default term, while the reconstruction, built from _oldDocs residue without ever seeing the real context, defines every term as a global default plus per-class overrides only where the schema itself flags an ambiguity"
}
]
},
{
- "id": "conformance-3-unbound-heavily-instantiated-classes",
+ "id": "conformance-3-real-context-binds-what-schema-residue-does-not",
"subject": "dcat-us:Concept,dcat-us:Identifier",
"kind": "conformance",
"claims": [
{
"document": "jsonschema/definitions/Concept.json",
"predicate": "declaresRdfClass",
- "object": "skos:Concept, in _oldDocs.rdfClass, with prefLabel, definition, inScheme, notation as properties"
+ "object": "skos:Concept, in _oldDocs.rdfClass, with prefLabel, altLabel, definition, inScheme, notation as properties"
},
{
"document": "jsonschema/definitions/Concept.json",
- "predicate": "bindsNoneOf",
- "object": "prefLabel, definition, inScheme, notation carry no _oldDocs.uri: zero of Concept's properties have an RDF term"
+ "predicate": "assignsNoTermTodayTo",
+ "object": "prefLabel, altLabel, definition, inScheme, notation: none carries an _oldDocs.uri in the schema's current definitions, so nothing published today (the schema alone, with no context and no shapes) assigns any of Concept's five properties an RDF term"
},
{
"document": "jsonschema/definitions/Identifier.json",
- "predicate": "bindsNoneOf",
- "object": "schemaAgency, creator, issued, version, notation carry no _oldDocs.uri: zero of Identifier's properties have an RDF term"
+ "predicate": "assignsNoTermTodayTo",
+ "object": "schemaAgency, creator, issued, version, notation: none carries an _oldDocs.uri in the schema's current definitions, so nothing published today assigns any of Identifier's five properties an RDF term"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "predicate": "didBindAllFiveOf",
+ "object": "Concept, under the type-scoped context keyed skos:Concept: prefLabel -> skos:prefLabel, altLabel -> skos:altLabel, definition -> skos:definition, inScheme -> skos:inScheme (@id), notation -> skos:notation (@set). The schema's own remaining metadata assigns Concept no term at all; the profile's own deleted context assigned all five, before it was removed by the same pull request that removed the shapes"
+ },
+ {
+ "document": "recovered-context.jsonld",
+ "predicate": "didBindAllFiveOf",
+ "object": "Identifier, under the type-scoped context keyed adms:Identifier: schemaAgency -> adms:schemaAgency, creator -> dcterms:creator (@id), issued -> dcterms:issued, version -> dcterms:version, notation -> skos:notation"
},
{
"document": "jsonschema/examples/Concept/good/complete_example.json",
- "predicate": "instantiatesUncheckable",
- "object": "prefLabel and definition values, present in the data, that no shape or context can reach"
+ "predicate": "reachableOnlyUnderRealContext",
+ "object": "prefLabel and altLabel values present in the data: unreachable by anything published today (no context, no shapes); once expanded against recovered-context.jsonld with @type rewritten to the CURIE the schema's own _oldDocs.rdfClass already names (demo/dcat_conformance.py, no invented binding), the node becomes a SHACL focus node and the file conforms with 0 violations, while jsonschema/examples/Concept/good/minimal_object.json fires 1 violation under the same recovered context"
},
{
"document": "jsonschema/examples/Identifier/good/complete_example.json",
- "predicate": "instantiatesUncheckable",
- "object": "schemaAgency and creator values, present in the data, that no shape or context can reach"
+ "predicate": "reachableOnlyUnderRealContext",
+ "object": "schemaAgency and creator values present in the data: unreachable by anything published today; once expanded against recovered-context.jsonld with the same mechanical @type rewrite, the node becomes a SHACL focus node and the file fires 1 violation, where as-published it fired none because nothing could be checked"
+ }
+ ]
+ },
+ {
+ "id": "conformance-4-recovered-files-disagree-on-org-prefix",
+ "subject": "dcat-us:Organization",
+ "kind": "conformance",
+ "claims": [
+ {
+ "document": "recovered-context.jsonld",
+ "predicate": "bindsPrefix",
+ "object": "org: to http://www.w3c.org/ns/org# (line 18 of the recovered file)"
+ },
+ {
+ "document": "recovered-shapes.ttl",
+ "predicate": "bindsPrefix",
+ "object": "org: to http://www.w3.org/ns/org#, the W3C Organization Ontology namespace, no 'c' in w3c"
+ },
+ {
+ "document": "jsonschema/definitions/Organization.json",
+ "predicate": "declaresRdfClass",
+ "object": "org:Organization, in _oldDocs.rdfClass, matching recovered-shapes.ttl's prefix, not recovered-context.jsonld's"
+ },
+ {
+ "document": "recovered-shapes.ttl",
+ "predicate": "quantifiedImpactOfSubstitutingCorrectPrefix",
+ "object": "with recovered-context.jsonld's own org: prefix replaced by recovered-shapes.ttl's (diagnostic only, not applied to any other figure in this file): SHACL violations over the real-context-typed corpus rise from 147 to 153, focus nodes from 183 to 194 (demo/dcat_conformance_measurements.json, recoveredFilesOrgPrefixTypoImpactDiagnosticOnly)"
}
]
},
{
- "id": "conformance-4-deleted-shapes-fire-on-bound-examples",
+ "id": "conformance-5-deleted-shapes-fire-on-bound-examples",
"subject": "dcat-us:pr-120",
"kind": "conformance",
"claims": [
{
"document": "pr-120-record.md",
"predicate": "deletes",
- "object": "shacl/dcat-us_3.0_shacl_shapes.ttl, at commit aaa3ff4a, in favour of the JSON Schema alone"
+ "object": "shacl/dcat-us_3.0_shacl_shapes.ttl, at commit aaa3ff4a, and context/dcat-us-3.0.jsonld, at commit 04acd5c2, in favour of the JSON Schema alone"
},
{
"document": "recovered-shapes.ttl",
"predicate": "unchangedFileValidatesAsPublishedCorpusAs",
- "object": "conforms=true, 0 violations, 0 focus nodes: the shapes select nothing to check against the 115 examples as published"
+ "object": "conforms=true, 0 violations, 0 focus nodes, whether checked against the as-published corpus or against the same corpus expanded with recovered-context.jsonld injected verbatim: the shapes select nothing to check either way"
+ },
+ {
+ "document": "recovered-shapes.ttl",
+ "predicate": "validatesSchemaDerivedBoundCorpusAs",
+ "object": "conforms=false, 228 focus nodes, but the violation count itself is not stable across the reconstruction's own two variants: 178 violations under the declared binding, 272 under the observed binding (which relaxes 22 terms the corpus publishes as prose rather than IRIs), a spread of 94 from one schema-residue reconstruction alone"
},
{
"document": "recovered-shapes.ttl",
- "predicate": "sameUnchangedFileValidatesBoundCorpusAs",
- "object": "conforms=false, 272 violations, 228 focus nodes, once the schema-implied binding is applied to the same 115 examples"
+ "predicate": "validatesRealContextTypedCorpusAs",
+ "object": "conforms=false, 147 violations, 183 focus nodes, measured against the profile's own recovered context rather than a reconstruction. Lower than either reconstruction figure for a specific, checked reason: the real context has no cross-class default term bindings, and the schema's title for the Catalog class ('DCAT-US 3 Catalog') does not match the bare '@type': 'Catalog' every Catalog example actually publishes, so a literal CURIE rewrite leaves Catalog-typed nodes, and everything nested inside them, outside the real context's reach; the schema-derived reconstruction does not have this gap, because it defines every property term globally regardless of which class's scope activates"
},
{
"document": "jsonschema/examples/Dataset/good/complete_example.json",
"predicate": "firesViolations",
- "object": "35, once bound (sh:datatype and sh:minCount failures on dcterms/foaf/dcat properties)"
+ "object": "35 under the schema-derived observed binding, 15 under the real recovered context typed"
},
{
"document": "jsonschema/examples/Catalog/good/complete_example.json",
"predicate": "firesViolations",
- "object": "19, once bound"
+ "object": "19 under the schema-derived observed binding; 0 under the real recovered context typed, for the reason given above (the file's own top-level node never becomes a reachable focus node under that context, so nothing nested inside it is checked either)"
},
{
"document": "jsonschema/examples/Distribution/good/complete_example.json",
"predicate": "firesViolations",
- "object": "14, once bound"
+ "object": "14 under the schema-derived observed binding, 5 under the real recovered context typed"
}
]
}
diff --git a/demo/tests/test_dcat_conformance.py b/demo/tests/test_dcat_conformance.py
index d7b7965c..8f64059c 100644
--- a/demo/tests/test_dcat_conformance.py
+++ b/demo/tests/test_dcat_conformance.py
@@ -1,24 +1,36 @@
"""Pin the headline figures demo/dcat_conformance.py measures.
-These numbers are recomputed here, from the vendored jsonschema/ tree under
+These numbers are recomputed here, from the vendored jsonschema/ tree and
+the vendored recovered-shapes.ttl / recovered-context.jsonld under
demo/corpus/dcat-us/, not quoted from anywhere else. If GSA/dcat-us changes
its published examples or schema, this test fails rather than letting the
findings in demo/precomputed/findings.json silently drift away from what the
corpus actually measures.
+
+Nothing in this file asserts a single SHACL violation count as though it
+were settled. Three independent, reproducible measurements against the same
+unmodified recovered-shapes.ttl disagree with each other (schema-derived
+declared binding, schema-derived observed binding, and the profile's own
+real recovered context); test_shacl_violation_counts_disagree_across_methods
+pins the disagreement itself, not a winner.
"""
from demo.dcat_conformance import (
CORPUS,
DEFINITIONS,
EXAMPLES,
+ REAL_CONTEXT_PATH,
SHAPES_PATH,
build_context,
+ check_real_context_org_prefix,
load_classes,
+ load_real_context,
load_shapes_namespaces,
measure,
merge_corpus,
run_shacl,
scan_bare_values,
+ title_to_rdf_class,
)
@@ -30,19 +42,36 @@ def test_corpus_is_vendored():
assert DEFINITIONS.is_dir()
assert EXAMPLES.is_dir()
assert SHAPES_PATH.is_file()
+ assert REAL_CONTEXT_PATH.is_file()
assert len(list(DEFINITIONS.glob("*.json"))) == 26
assert len(_good_files()) == 115
assert len(list(EXAMPLES.glob("*/bad/*.json"))) == 76
-def test_two_classes_have_zero_bound_properties():
+def test_two_classes_unbound_in_schema_residue_but_bound_in_real_context():
# skos:Concept and adms:Identifier are the schema's two most frequently
- # instantiated types in the example corpus; the schema names properties
- # for both but assigns none of them an RDF term.
+ # instantiated types in the example corpus. The schema's own remaining
+ # metadata (_oldDocs, what is left after pull request 120 deleted the
+ # context and the shapes) assigns neither class's properties an RDF
+ # term. That is true only of this residue, not of the profile's actual
+ # publication history: see the second half of this test.
classes = load_classes(DEFINITIONS)
assert classes["Concept"].properties == {}
assert classes["Identifier"].properties == {}
+ # The profile's own deleted context -- recovered separately from pull
+ # request 120's base commit, not reconstructed from the schema residue
+ # above -- did bind every one of these properties before it was removed
+ # by the same pull request that removed the shapes. This is the guard
+ # against the original, corrected error: asserting that these classes
+ # carry no RDF term anywhere, rather than only in what the schema alone
+ # still states.
+ real_context = load_real_context(REAL_CONTEXT_PATH)
+ concept_terms = set(real_context["@context"]["skos:Concept"]["@context"].keys())
+ identifier_terms = set(real_context["@context"]["adms:Identifier"]["@context"].keys())
+ assert {"prefLabel", "altLabel", "definition", "inScheme", "notation"} <= concept_terms
+ assert {"schemaAgency", "creator", "issued", "version", "notation"} <= identifier_terms
+
def test_as_published_examples_carry_no_dcat_vocabulary():
files = _good_files()
@@ -70,19 +99,88 @@ def test_binding_the_schema_implies_recovers_dcat_vocabulary():
assert len(result["errors"]) == 0
-def test_deleted_shapes_select_nothing_as_published_but_fire_once_bound():
+def test_real_context_verbatim_binds_almost_nothing_against_todays_examples():
+ # The profile's own recovered context, injected exactly as retrieved,
+ # with no rewriting. Its class bindings are keyed by full CURIE
+ # ('dcat:Dataset', 'skos:Concept'); every good example's own '@type' is
+ # the bare schema title ('Dataset', 'Concept'). JSON-LD type-scoped
+ # contexts require an exact term match, so this is nearly indistinguishable
+ # from publishing no context at all -- a real, measured fact about the
+ # naming drift between the real context and today's examples, not a bug
+ # in this script.
+ real_context = load_real_context(REAL_CONTEXT_PATH)
+ files = _good_files()
+ result = measure(files, real_context)
+ assert result["triples"] == 76
+ assert result["distinctPredicates"] == 1
+ assert result["dcatPredicateTriples"] == 0
+
+
+def test_real_context_typed_recovers_dcat_vocabulary_the_reconstruction_also_finds():
+ # The same unmodified real context, with each example's bare '@type'
+ # mechanically rewritten to the CURIE the schema's own
+ # _oldDocs.rdfClass already names for that title -- a reformatting of a
+ # class name the schema itself states, not an invented binding.
+ classes = load_classes(DEFINITIONS)
+ real_context = load_real_context(REAL_CONTEXT_PATH)
+ retype_map = title_to_rdf_class(classes)
+ files = _good_files()
+ result = measure(files, real_context, retype=retype_map)
+ assert result["triples"] == 1069
+ assert result["distinctPredicates"] == 114
+ assert result["dcatPredicateTriples"] == 184
+ assert len(result["errors"]) == 0
+
+
+def test_shacl_violation_counts_disagree_across_methods():
+ """Three reproducible measurements against the SAME unmodified
+ recovered-shapes.ttl and the SAME 115 examples do not agree on a
+ violation count. This test pins that disagreement, not a winner: it is
+ the guard against a future change collapsing three real, differently
+ computed numbers into one asserted "the" count.
+ """
classes = load_classes(DEFINITIONS)
namespaces = load_shapes_namespaces(SHAPES_PATH)
files = _good_files()
- lenient_terms = scan_bare_values(files, classes)
- context = build_context(classes, namespaces, lenient_terms=lenient_terms)
published = run_shacl(SHAPES_PATH, merge_corpus(files, None))
assert published["conforms"] is True
assert published["violations"] == 0
assert published["focusNodes"] == 0
- bound = run_shacl(SHAPES_PATH, merge_corpus(files, context))
- assert bound["conforms"] is False
- assert bound["focusNodes"] == 228
- assert bound["violations"] == 272
+ declared = build_context(classes, namespaces)
+ lenient_terms = scan_bare_values(files, classes)
+ observed = build_context(classes, namespaces, lenient_terms=lenient_terms)
+ bound_declared = run_shacl(SHAPES_PATH, merge_corpus(files, declared))
+ bound_observed = run_shacl(SHAPES_PATH, merge_corpus(files, observed))
+ assert bound_declared["conforms"] is False
+ assert bound_declared["focusNodes"] == 228
+ assert bound_declared["violations"] == 178
+ assert bound_observed["conforms"] is False
+ assert bound_observed["focusNodes"] == 228
+ assert bound_observed["violations"] == 272
+
+ real_context = load_real_context(REAL_CONTEXT_PATH)
+ retype_map = title_to_rdf_class(classes)
+ bound_real_typed = run_shacl(SHAPES_PATH, merge_corpus(files, real_context, retype=retype_map))
+ assert bound_real_typed["conforms"] is False
+ assert bound_real_typed["focusNodes"] == 183
+ assert bound_real_typed["violations"] == 147
+
+ # The point of this test: three legitimate, reproducible methods, same
+ # inputs, three different violation counts. None should be published as
+ # THE count.
+ counts = {bound_declared["violations"], bound_observed["violations"], bound_real_typed["violations"]}
+ assert len(counts) == 3
+
+
+def test_recovered_files_disagree_on_org_prefix():
+ # A defect internal to the two recovered files themselves, both deleted
+ # by the same pull request as part of the same profile release: they
+ # disagree about what 'org:' expands to.
+ namespaces = load_shapes_namespaces(SHAPES_PATH)
+ real_context = load_real_context(REAL_CONTEXT_PATH)
+ check = check_real_context_org_prefix(real_context, namespaces)
+ assert check["recoveredContextOrgPrefix"] == "http://www.w3c.org/ns/org#"
+ assert check["recoveredShapesOrgPrefix"] == "http://www.w3.org/ns/org#"
+ assert check["agree"] is False
diff --git a/demo/verify.py b/demo/verify.py
index 9cfb784b..dbeb9bd3 100644
--- a/demo/verify.py
+++ b/demo/verify.py
@@ -274,7 +274,15 @@ def main() -> int:
print(f"\n{BOLD}{'PASS' if not failures else str(failures) + ' CHECK(S) FAILED'}{OFF}"
f" {DIM}{conform}/{len(graphs)} graphs conform, "
- f"{len(contradictions)} contradictions across documents{OFF}\n")
+ f"{len(contradictions)} contradictions across documents{OFF}")
+ print(f"{DIM}CHECK 6 only re-derives disjointness contradictions in the pipeline ontology "
+ f"above; it is not wired to this script's exit code, and finds none here by "
+ f"construction (see docs/superpowers/plans/2026-08-24-studio-public-port.md, "
+ f"'PIVOT, 25 August 2026'). The findings this demonstration actually reports live "
+ f"in demo/precomputed/findings.json, computed independently by "
+ f"demo/dcat_conformance.py and re-derived every time 'make demo-verify' runs -- "
+ f"see its own output above, or run 'python3 -m pytest demo/tests/"
+ f"test_dcat_conformance.py' directly.{OFF}\n")
return failures