@prefix gedrm: <https://specs.kivanura.org/gedrm#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://specs.kivanura.org/gedrm/0.1/shacl> a owl:Ontology ;
  dcterms:title "GEDRM 0.1 — SHACL Core Conformance Shapes" ;
  dcterms:identifier "GEDRM-0.1-SHACL" ;
  dcterms:description "Sparse SHACL companion constraints for the normative GEDRM 0.1 semantic model." ;
  owl:versionInfo "0.1" ;
  dcterms:issued "2026-09-08"^^xsd:date ;
  rdfs:seeAlso <https://specs.kivanura.org/spec/gedrm/0.1/gedrm-0.1.ttl> ,
               <https://specs.kivanura.org/spec/gedrm/0.1/gedrm-0.1.context.jsonld> ,
               <https://specs.kivanura.org/spec/gedrm/0.1/gedrm-0.1.concept-registry.yaml> ;
  gedrm:normativeSemanticAuthority "gedrm-specification.md" ;
  gedrm:precedenceRule "The human-readable GEDRM 0.1 specification is the normative semantic authority. These SHACL shapes encode only sparse practical conformance constraints and MUST NOT introduce incompatible semantics." .

#################################################################
# Core authority constraints
#################################################################

gedrm:SystemOfRecordShape a sh:NodeShape ;
  sh:targetClass gedrm:SystemOfRecord ;
  sh:name "System of Record core conformance" ;
  sh:description "A System of Record must record authoritative state for at least one governed scope." ;
  sh:property [
    sh:path gedrm:recordsAuthoritativeStateFor ;
    sh:minCount 1 ;
    sh:message "A System of Record MUST record authoritative state for at least one defined scope." ;
  ] .

gedrm:AuthoritativeSourceShape a sh:NodeShape ;
  sh:targetClass gedrm:AuthoritativeSource ;
  sh:name "Authoritative Source core conformance" ;
  sh:description "An Authoritative Source must be authoritative for at least one governed scope." ;
  sh:property [
    sh:path gedrm:isAuthoritativeSourceFor ;
    sh:minCount 1 ;
    sh:message "An Authoritative Source MUST be authoritative for at least one defined scope." ;
  ] .

#################################################################
# Data Product and governed-construct constraints
#################################################################

gedrm:DataProductShape a sh:NodeShape ;
  sh:targetClass gedrm:DataProduct ;
  sh:name "Data Product core conformance" ;
  sh:description "A Data Product requires accountable ownership. GEDRM core does not require exactly one owner." ;
  sh:property [
    sh:path gedrm:hasAccountableOwner ;
    sh:minCount 1 ;
    sh:message "A Data Product MUST have at least one accountable owner." ;
  ] .

gedrm:DataContractShape a sh:NodeShape ;
  sh:targetClass gedrm:DataContract ;
  sh:name "Data Contract core conformance" ;
  sh:description "A Data Contract must define at least one governed interaction, product, or output commitment." ;
  sh:property [
    sh:path gedrm:definesCommitmentFor ;
    sh:minCount 1 ;
    sh:message "A Data Contract MUST define a commitment for at least one governed boundary." ;
  ] .

gedrm:DataControlShape a sh:NodeShape ;
  sh:targetClass gedrm:DataControl ;
  sh:name "Data Control core conformance" ;
  sh:description "A Data Control requires accountable control ownership. Evidence production remains optional at definition level." ;
  sh:property [
    sh:path gedrm:hasControlOwner ;
    sh:minCount 1 ;
    sh:class gedrm:ControlOwner ;
    sh:message "A Data Control MUST have at least one Control Owner." ;
  ] .

#################################################################
# Control Evidence constraints
#################################################################

gedrm:ControlEvidenceShape a sh:NodeShape ;
  sh:targetClass gedrm:ControlEvidence ;
  sh:name "Control Evidence core conformance" ;
  sh:description "Control Evidence must identify exactly one Data Control. Where an execution relationship is supplied, it must identify a Control Execution." ;
  sh:property [
    sh:path gedrm:evidenceForControl ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:class gedrm:DataControl ;
    sh:message "Control Evidence MUST identify exactly one Data Control that it substantiates." ;
  ] ;
  sh:property [
    sh:path gedrm:evidenceForExecution ;
    sh:maxCount 1 ;
    sh:class gedrm:ControlExecution ;
    sh:message "When evidence-for-execution is present, it MUST identify no more than one Control Execution." ;
  ] ;
  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:message "Where a Control Execution explicitly produces this Control Evidence, the evidence MUST identify that execution using evidence-for-execution." ;
    sh:prefixes gedrm:GEDRMShaclPrefixes ;
    sh:select """
      SELECT $this
      WHERE {
        ?execution a gedrm:ControlExecution ;
                   gedrm:producesEvidence $this .
        FILTER NOT EXISTS { $this gedrm:evidenceForExecution ?execution . }
      }
    """ ;
  ] .

#################################################################
# Representation and provenance constraints
#################################################################

gedrm:GoldenRecordShape a sh:NodeShape ;
  sh:targetClass gedrm:GoldenRecord ;
  sh:name "Golden Record core conformance" ;
  sh:description "A Golden Record represents exactly one governed entity identity." ;
  sh:property [
    sh:path gedrm:represents ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
    sh:message "A Golden Record MUST represent exactly one governed entity identity." ;
  ] .

gedrm:DerivedDataShape a sh:NodeShape ;
  sh:targetClass gedrm:DerivedData ;
  sh:name "Derived Data core conformance" ;
  sh:description "Derived Data requires at least one derivation input." ;
  sh:property [
    sh:path gedrm:derivedFrom ;
    sh:minCount 1 ;
    sh:class gedrm:DataObject ;
    sh:message "Data classified as Derived Data MUST have at least one derived-from relationship." ;
  ] .

#################################################################
# Privacy-role constraints
#################################################################

gedrm:DataProcessorShape a sh:NodeShape ;
  sh:targetClass gedrm:DataProcessor ;
  sh:name "Data Processor role conformance" ;
  sh:description "Within a Data Processor role context, processing is inherently on behalf of at least one Controller or Processing Activity context." ;
  sh:property [
    sh:path gedrm:processesOnBehalfOf ;
    sh:minCount 1 ;
    sh:message "A Data Processor role MUST have at least one processes-on-behalf-of relationship within its role context." ;
  ] .

gedrm:ProcessingActivityShape a sh:NodeShape ;
  sh:targetClass gedrm:ProcessingActivity ;
  sh:name "Processing Activity privacy-context conformance" ;
  sh:description "When a Processing Activity processes Personal Data and Controller semantics are applicable, it requires one or more Data Controllers. Legal applicability cannot be inferred mechanically by GEDRM core." ;
  sh:property [
    sh:path gedrm:hasDataProcessor ;
    sh:class gedrm:DataProcessor ;
    sh:message "Each has-data-processor value MUST be a Data Processor." ;
  ] ;
  sh:property [
    sh:path gedrm:hasDataController ;
    sh:class gedrm:DataController ;
    sh:message "Each has-data-controller value MUST be a Data Controller." ;
  ] ;
  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:severity sh:Warning ;
    sh:message "This Processing Activity processes Personal Data but has no Data Controller assignment. Confirm whether Controller semantics are applicable under the governing privacy law/profile." ;
    sh:prefixes gedrm:GEDRMShaclPrefixes ;
    sh:select """
      SELECT $this
      WHERE {
        $this gedrm:processesPersonalData ?data .
        FILTER NOT EXISTS { $this gedrm:hasDataController ?controller . }
      }
    """ ;
  ] .

#################################################################
# Classification facet value constraints
# These constrain property values without making dimensions disjoint.
#################################################################

gedrm:DataObjectClassificationShape a sh:NodeShape ;
  sh:targetClass gedrm:DataObject ;
  sh:name "Data Object classification facet conformance" ;
  sh:description "Classification facets are orthogonal; this shape validates value kinds only and intentionally imposes no cross-dimension disjointness." ;
  sh:property [
    sh:path gedrm:hasBusinessSemanticClassification ;
    sh:class gedrm:BusinessSemanticClassification ;
    sh:message "Business/semantic classifications MUST use a Business Semantic Classification concept." ;
  ] ;
  sh:property [
    sh:path gedrm:hasProvenanceClassification ;
    sh:class gedrm:ProvenanceClassification ;
    sh:message "Provenance classifications MUST use a Provenance Classification concept." ;
  ] ;
  sh:property [
    sh:path gedrm:hasProcessingGovernanceState ;
    sh:class gedrm:ProcessingGovernanceState ;
    sh:message "Processing/governance state values MUST use a Processing Governance State concept." ;
  ] ;
  sh:property [
    sh:path gedrm:hasLegalSensitivityClassification ;
    sh:class gedrm:LegalSensitivityClassification ;
    sh:message "Legal/sensitivity classifications MUST use a Legal Sensitivity Classification concept." ;
  ] .

#################################################################
# Traceability value constraints
#################################################################

gedrm:RequirementTraceabilityShape a sh:NodeShape ;
  sh:targetSubjectsOf gedrm:derivedFromRequirement ;
  sh:targetSubjectsOf gedrm:satisfiesRequirement ;
  sh:name "Requirement Reference traceability conformance" ;
  sh:description "GEDRM 0.1 keeps requirements external; traceability relations must point to Requirement Reference resources." ;
  sh:property [
    sh:path gedrm:derivedFromRequirement ;
    sh:class gedrm:RequirementReference ;
    sh:message "derived-from-requirement MUST point to a Requirement Reference." ;
  ] ;
  sh:property [
    sh:path gedrm:satisfiesRequirement ;
    sh:class gedrm:RequirementReference ;
    sh:message "satisfies-requirement MUST point to a Requirement Reference." ;
  ] .

#################################################################
# Prefix declarations for SHACL-SPARQL constraints
#################################################################

gedrm:GEDRMShaclPrefixes a owl:Ontology ;
  sh:declare [
    sh:prefix "gedrm" ;
    sh:namespace "https://specs.kivanura.org/gedrm#"^^xsd:anyURI ;
  ] .
