@prefix convo: <https://ontology.inferal.com/modules/conversation/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix loc: <https://ontology.inferal.com/modules/localization/> .
@prefix ord: <https://ontology.inferal.com/modules/ordering/> .
@prefix prof: <http://www.w3.org/ns/dx/prof/> .
@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#> .

convo:PositionAwareProfile
    a prof:Profile ;
    prof:isProfileOf convo: ;
    prof:hasResource
        <https://ontology.inferal.com/modules/conversation/profiles/position-aware#constraints> ,
        <https://ontology.inferal.com/modules/conversation/profiles/position-aware#transcript-validation> ,
        <https://ontology.inferal.com/modules/conversation/profiles/position-aware#localization-validation> ,
        <https://ontology.inferal.com/modules/conversation/profiles/position-aware#ordering-validation> ,
        <https://ontology.inferal.com/modules/conversation/profiles/position-aware#range-validation> ,
        <https://ontology.inferal.com/modules/conversation/profiles/position-aware#confidence-validation> .

<https://ontology.inferal.com/modules/conversation/profiles/position-aware#constraints>
    a prof:ResourceDescriptor ;
    rdfs:label "Position-Aware conversation constraints descriptor"@en ;
    rdfs:comment "Describes the conversation-specific SHACL artifact for frame-aware view membership."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/conversation/profiles/position-aware.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/conversation/profiles/position-aware#transcript-validation>
    a prof:ResourceDescriptor ;
    rdfs:label "Position-Aware Transcript validation descriptor"@en ;
    rdfs:comment "Declares that Position-Aware conformance includes the Conversation Transcript constraints for ordered views and memberships."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/conversation/profiles/transcript.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/conversation/profiles/position-aware#localization-validation>
    a prof:ResourceDescriptor ;
    rdfs:label "Position-Aware Localization validation descriptor"@en ;
    rdfs:comment "Declares that Position-Aware conformance also applies the Inferal Localization SHACL artifact."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/localization/shapes.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/conversation/profiles/position-aware#ordering-validation>
    a prof:ResourceDescriptor ;
    rdfs:label "Position-Aware Ordering validation descriptor"@en ;
    rdfs:comment "Declares the Ordering SHACL artifact used when conversation position frames provide comparison contexts."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/ordering/shapes.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/conversation/profiles/position-aware#range-validation>
    a prof:ResourceDescriptor ;
    rdfs:label "Position-Aware Range validation descriptor"@en ;
    rdfs:comment "Declares the Range SHACL artifact applied when a localization uses an ordered uncertainty interval."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/range/shapes.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/conversation/profiles/position-aware#confidence-validation>
    a prof:ResourceDescriptor ;
    rdfs:label "Position-Aware Confidence validation descriptor"@en ;
    rdfs:comment "Declares the Confidence SHACL artifact applied when a source assesses a localization claim."@en ;
    prof:hasArtifact <https://ontology.inferal.com/modules/confidence/shapes.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> .

convo:ContributionSequenceFrameShape
    a sh:NodeShape ;
    rdfs:label "contribution sequence frame shape"@en ;
    rdfs:comment "Requires a conversation sequence frame in Position-Aware data to identify exactly one ordering context."@en ;
    sh:targetClass convo:ContributionSequenceFrame ;
    sh:property [ sh:path loc:orderedBy ; sh:class ord:Ordering ; sh:minCount 1 ; sh:maxCount 1 ] .

convo:PositionAwareMembershipShape
    a sh:NodeShape ;
    rdfs:label "position-aware membership shape"@en ;
    rdfs:comment "Requires the membership locus to use the frame declared by its ordered view."@en ;
    sh:targetClass convo:OrderedMembership ;
    sh:sparql [
        sh:message "The membership locus must be in the position frame of its ordered view."@en ;
        sh:select """
            PREFIX convo: <https://ontology.inferal.com/modules/conversation/>
            PREFIX loc: <https://ontology.inferal.com/modules/localization/>
            SELECT $this ?locus ?expectedFrame WHERE {
                $this (convo:orderedMembershipOf|^convo:hasOrderedMembership) ?view ;
                      convo:membershipLocus ?locus .
                ?view convo:hasPositionFrame ?expectedFrame .
                FILTER NOT EXISTS { ?locus loc:inFrame ?expectedFrame . }
            }
        """ ;
    ] .

convo:GenerationLocusShape
    a sh:NodeShape ;
    rdfs:label "generation locus shape"@en ;
    rdfs:comment "Validates that any stable contribution-generation position is represented by a Localization locus."@en ;
    sh:targetSubjectsOf convo:hasGenerationLocus ;
    sh:property [ sh:path convo:hasGenerationLocus ; sh:class loc:Locus ] .
