@prefix ae: <https://ontology.inferal.com/modules/artifact-evolution/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix prof: <http://www.w3.org/ns/dx/prof/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix role: <http://www.w3.org/ns/dx/prof/role/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

ae:OntologyEvolutionProfile
    a prof:Profile ;
    dcterms:title "Ontology Evolution Profile"@en ;
    dcterms:description "OWL ontology evolution constraints and change kinds layered on the semantic-artifact and governed-artifact profiles."@en ;
    rdfs:label "ontology evolution profile"@en ;
    rdfs:comment "A governed-artifact evolution profile for published ontologies and other semantic artifacts whose public terms, axioms, validation contracts, mappings, and human definitions require stable review."@en ;
    prof:isProfileOf ae:, ae:SemanticArtifactProfile ;
    prof:hasResource
        <https://ontology.inferal.com/modules/artifact-evolution/profiles/ontology-evolution#constraints> ,
        <https://ontology.inferal.com/modules/artifact-evolution/profiles/ontology-evolution#semantic-constraints> ,
        <https://ontology.inferal.com/modules/artifact-evolution/profiles/ontology-evolution#governed-constraints> .

<https://ontology.inferal.com/modules/artifact-evolution/profiles/ontology-evolution#constraints>
    a prof:ResourceDescriptor ;
    rdfs:label "ontology evolution constraints descriptor"@en ;
    rdfs:comment "Describes the SHACL artifact for the ontology evolution profile."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/artifact-evolution/versions/0.1.0/profiles/ontology-evolution.ttl> ;
    prof:hasRole role:constraints, role:validation ;
    dcterms:conformsTo <http://www.w3.org/ns/shacl#> ;
    dcterms:format <https://www.iana.org/assignments/media-types/text/turtle> .

<https://ontology.inferal.com/modules/artifact-evolution/profiles/ontology-evolution#semantic-constraints>
    a prof:ResourceDescriptor ;
    rdfs:label "inherited semantic artifact constraints descriptor"@en ;
    rdfs:comment "Makes semantic-artifact constraints an explicit component of ontology evolution conformance."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/artifact-evolution/versions/0.1.0/profiles/semantic-artifact.ttl> ;
    prof:hasRole role:constraints, role:validation ;
    dcterms:conformsTo <http://www.w3.org/ns/shacl#> ;
    dcterms:format <https://www.iana.org/assignments/media-types/text/turtle> .

<https://ontology.inferal.com/modules/artifact-evolution/profiles/ontology-evolution#governed-constraints>
    a prof:ResourceDescriptor ;
    rdfs:label "inherited governed artifact constraints descriptor"@en ;
    rdfs:comment "Makes governed lifecycle constraints an explicit component of ontology evolution conformance."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/artifact-evolution/versions/0.1.0/profiles/governed-artifact.ttl> ;
    prof:hasRole role:constraints, role:validation ;
    dcterms:conformsTo <http://www.w3.org/ns/shacl#> ;
    dcterms:format <https://www.iana.org/assignments/media-types/text/turtle> .

ae:OntologyChangeKinds
    a skos:ConceptScheme ;
    rdfs:label "ontology change kinds"@en ;
    rdfs:comment "Ontology-specific change kinds for public terms and RDF, RDFS, or OWL axioms; broader semantic-artifact changes are supplied by the parent profile."@en ;
    skos:prefLabel "ontology change kinds"@en .

ae:PublicTermAddition
    a ae:ChangeKind ;
    rdfs:label "public term addition"@en ;
    rdfs:comment "Addition of a new public ontology class, property, individual, shape, rule-like term, or controlled concept."@en ;
    skos:broader ae:Addition ;
    skos:inScheme ae:OntologyChangeKinds ;
    skos:prefLabel "public term addition"@en .

ae:PublicTermDeprecation
    a ae:ChangeKind ;
    rdfs:label "public term deprecation"@en ;
    rdfs:comment "Deprecation of an adopted public term while retaining its stable IRI and historical meaning."@en ;
    skos:broader ae:Deprecation ;
    skos:inScheme ae:OntologyChangeKinds ;
    skos:prefLabel "public term deprecation"@en .

ae:PublicTermReplacement
    a ae:ChangeKind ;
    rdfs:label "public term replacement"@en ;
    rdfs:comment "Replacement of a public term by another term with explicit migration or mapping semantics rather than silent IRI reuse."@en ;
    skos:broader ae:Replacement ;
    skos:inScheme ae:OntologyChangeKinds ;
    skos:prefLabel "public term replacement"@en .

ae:AxiomAddition
    a ae:ChangeKind ;
    rdfs:label "axiom addition"@en ;
    rdfs:comment "Addition of an RDF, RDFS, or OWL statement that changes the semantic artifact's asserted or entailed contract."@en ;
    skos:broader ae:Addition ;
    skos:inScheme ae:OntologyChangeKinds ;
    skos:prefLabel "axiom addition"@en .

ae:AxiomRemoval
    a ae:ChangeKind ;
    rdfs:label "axiom removal"@en ;
    rdfs:comment "Removal of an RDF, RDFS, or OWL statement from the semantic artifact's asserted contract."@en ;
    skos:broader ae:Removal ;
    skos:inScheme ae:OntologyChangeKinds ;
    skos:prefLabel "axiom removal"@en .

ae:AxiomModification
    a ae:ChangeKind ;
    rdfs:label "axiom modification"@en ;
    rdfs:comment "Replacement or coordinated revision of one or more RDF, RDFS, or OWL statements."@en ;
    skos:broader ae:Modification ;
    skos:inScheme ae:OntologyChangeKinds ;
    skos:prefLabel "axiom modification"@en .

ae:OntologyArtifactShape
    a sh:NodeShape ;
    rdfs:label "ontology artifact shape"@en ;
    rdfs:comment "Requires semantic artifacts in this profile to be identified as OWL ontologies."@en ;
    sh:targetClass ae:GovernedArtifact ;
    sh:property [ sh:path rdf:type ; sh:hasValue owl:Ontology ] .

ae:OntologyProposalProfileShape
    a sh:NodeShape ;
    rdfs:label "ontology proposal profile shape"@en ;
    rdfs:comment "Requires ontology proposals to identify the ontology profile; structured confidence and impact are inherited from the semantic-artifact profile."@en ;
    sh:targetClass ae:ChangeProposal ;
    sh:property [ sh:path dcterms:conformsTo ; sh:hasValue ae:OntologyEvolutionProfile ] .

ae:OntologyOperationProfileShape
    a sh:NodeShape ;
    rdfs:label "ontology operation profile shape"@en ;
    rdfs:comment "Requires ontology operations to use ontology-specific, inherited semantic, or narrower extension change kinds and exact statement targets for axiom-level changes."@en ;
    sh:targetClass ae:ChangeOperation ;
    sh:sparql [
        sh:message "An ontology change operation must use an ontology-specific, inherited semantic, or narrower extension change kind."@en ;
        sh:select """
            PREFIX ae: <https://ontology.inferal.com/modules/artifact-evolution/>
            PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
            SELECT $this ?kind WHERE {
                $this ae:hasChangeKind ?kind .
                FILTER NOT EXISTS {
                    ?kind skos:broader* ?recognizedKind .
                    ?recognizedKind skos:inScheme ?scheme .
                    FILTER(?scheme IN (ae:OntologyChangeKinds, ae:SemanticChangeKinds))
                }
            }
        """ ;
    ] ;
    sh:sparql [
        sh:message "Axiom additions, removals, and modifications must identify at least one exact statement target."@en ;
        sh:select """
            PREFIX ae: <https://ontology.inferal.com/modules/artifact-evolution/>
            PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
            SELECT $this WHERE {
                $this ae:hasChangeKind ?kind .
                ?kind skos:broader* ?axiomKind .
                FILTER(?axiomKind IN (ae:AxiomAddition, ae:AxiomRemoval, ae:AxiomModification))
                FILTER NOT EXISTS { $this ae:affectsStatementTarget ?target . }
            }
        """ ;
    ] .

ae:OntologyRealizedChangeProfileShape
    a sh:NodeShape ;
    rdfs:label "ontology realized change profile shape"@en ;
    rdfs:comment "Requires observed ontology changes to use ontology-specific, inherited semantic, or narrower extension change kinds and exact statement targets for axiom-level changes."@en ;
    sh:targetClass ae:RealizedChange ;
    sh:sparql [
        sh:message "A realized ontology change must use an ontology-specific, inherited semantic, or narrower extension change kind."@en ;
        sh:select """
            PREFIX ae: <https://ontology.inferal.com/modules/artifact-evolution/>
            PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
            SELECT $this ?kind WHERE {
                $this ae:hasChangeKind ?kind .
                FILTER NOT EXISTS {
                    ?kind skos:broader* ?recognizedKind .
                    ?recognizedKind skos:inScheme ?scheme .
                    FILTER(?scheme IN (ae:OntologyChangeKinds, ae:SemanticChangeKinds))
                }
            }
        """ ;
    ] ;
    sh:sparql [
        sh:message "Realized axiom additions, removals, and modifications must identify at least one exact statement target."@en ;
        sh:select """
            PREFIX ae: <https://ontology.inferal.com/modules/artifact-evolution/>
            PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
            SELECT $this WHERE {
                $this ae:hasChangeKind ?kind .
                ?kind skos:broader* ?axiomKind .
                FILTER(?axiomKind IN (ae:AxiomAddition, ae:AxiomRemoval, ae:AxiomModification))
                FILTER NOT EXISTS { $this ae:affectsStatementTarget ?target . }
            }
        """ ;
    ] .

ae:AcceptedOntologyDecisionShape
    a sh:NodeShape ;
    rdfs:label "accepted ontology decision shape"@en ;
    rdfs:comment "Requires accepted ontology decisions to include a rationale and an impact assessment on the decided proposal."@en ;
    sh:targetClass ae:ChangeDecision ;
    sh:sparql [
        sh:message "An accepted ontology decision must have a rationale and its proposal must have an impact assessment."@en ;
        sh:select """
            PREFIX ae: <https://ontology.inferal.com/modules/artifact-evolution/>
            PREFIX dcterms: <http://purl.org/dc/terms/>
            SELECT $this ?proposal WHERE {
                $this ae:hasDecisionOutcome ae:Accepted ; ae:decidesProposal ?proposal .
                FILTER(
                    NOT EXISTS { $this dcterms:description ?rationale . } ||
                    NOT EXISTS { ?proposal ae:hasImpactAssessment ?assessment . }
                )
            }
        """ ;
    ] .
