@prefix : <https://ontology.inferal.com/modules/advertising-delivery-state/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix mod: <https://w3id.org/mod#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix pubacc: <https://ontology.inferal.com/modules/publication-access/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rng: <https://ontology.inferal.com/modules/range/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vann: <http://purl.org/vocab/vann/> .

:
    a owl:Ontology, pubacc:PublicationManagedOntology ;
    dcterms:accessRights pubacc:PublicAccess ;
    owl:imports
        rng: ,
        <http://www.w3.org/2004/02/skos/core> ,
        <http://www.w3.org/ns/prov> ;
    dcterms:title "Advertising Delivery State Ontology" ;
    dcterms:description "Terms separating what an advertiser intends an entity to do from whether it is actually delivering, the reasons it is not, and whether the entity still exists." ;
    dcterms:license <https://creativecommons.org/licenses/by/4.0/> ;
    dcterms:source rng: , <http://www.w3.org/2004/02/skos/core> , <http://www.w3.org/ns/prov> ;
    vann:preferredNamespacePrefix "adel" ;
    vann:preferredNamespaceUri "https://ontology.inferal.com/modules/advertising-delivery-state/" ;
    mod:status "draft" ;
    rdfs:comment "Status is four independent questions wearing one word: what does the advertiser want, is the entity delivering, why not, and does it still exist. One provider answers all four with a single twelve-value enumeration whose members mix an advertiser's intent with a policy verdict, an unpaid invoice, a paused ancestor, and a deleted record. Because the answers are collapsed, the most common operational question in advertising, why is this ad not running, cannot be asked at all. This module separates the four and reifies the reason, so a hold names its kind and the resource it originated from. That last part is what makes an inherited pause traceable to the ancestor responsible rather than leaving an operator to walk the hierarchy by hand." ;
    owl:versionInfo "0.1.0" .


# --- Delivery state ----------------------------------------------------------

:DeliveryState
    a rdfs:Class ;
    rdfs:subClassOf prov:Entity ;
    rdfs:label "delivery state" ;
    rdfs:comment "The observed delivery situation of one advertising entity: what the advertiser intends, whether it is serving, the holds preventing it, and its lifecycle standing." ;
    dcterms:description "Reified so the four independent answers stay separate and can carry provenance. A state is an observation about an entity at a point in time, not a property of the entity, which is why it can disagree with a later one without contradiction." .

:DeliveryIntent
    a rdfs:Class ;
    rdfs:subClassOf skos:Concept ;
    rdfs:label "delivery intent" ;
    rdfs:comment "What the advertiser wants the entity to do: run, or not run. Intent is a setting, and it is independent of whether delivery actually occurs." ;
    dcterms:description "Deliberately narrow. Archival and deletion are not intents: they describe whether the entity still exists, and folding them in means a query for everything the advertiser switched off silently returns records that are gone." .

:ServingState
    a rdfs:Class ;
    rdfs:subClassOf skos:Concept ;
    rdfs:label "serving state" ;
    rdfs:comment "Whether the entity is actually being delivered, independent of what the advertiser intends." ;
    dcterms:description "Intending to run and not serving is the normal case in advertising operations, not an anomaly. A model with one status field cannot express it, which is why an entity under review, out of budget, or beneath a paused ancestor all report as though the advertiser had switched them off." .

:ServingHold
    a rdfs:Class ;
    rdfs:label "serving hold" ;
    rdfs:comment "A first-class reason an entity is not serving despite the advertiser intending it to, naming the kind of hold and the resource it originated from." ;
    dcterms:description "Reified because the reason determines who can act. A policy rejection is the advertiser's to appeal, an unpaid invoice is the account owner's to settle, an exhausted budget is a configuration change, and a paused ancestor is somebody else's entity entirely. Providers expose these as untyped string arrays or fold them into a status enumeration, so none of that is decidable today." .

:HoldKind
    a rdfs:Class ;
    rdfs:subClassOf skos:Concept ;
    rdfs:label "hold kind" ;
    rdfs:comment "The category of a serving hold, such as a policy review outcome, a billing problem, an exhausted allowance, or an ancestor that is paused." ;
    dcterms:description "A concept class rather than a fixed enumeration, because providers surface hold reasons at different granularities and profiles need to extend the scheme without minting parallel classes." .

:LifecycleState
    a rdfs:Class ;
    rdfs:subClassOf skos:Concept ;
    rdfs:label "lifecycle state" ;
    rdfs:comment "Whether the entity is live, archived out of the working set, or deleted." ;
    dcterms:description "Separate from delivery intent because it answers a different question. An archived entity is not one the advertiser paused; it is one removed from view whose historical metrics remain valid and must still be readable." .


# --- Object properties -------------------------------------------------------

:stateOf
    a rdf:Property ;
    rdfs:label "state of" ;
    rdfs:comment "The advertising entity this delivery state describes." ;
    rdfs:domain :DeliveryState ;
    rdfs:range rdfs:Resource .

:intendedDelivery
    a rdf:Property ;
    rdfs:label "has intended delivery" ;
    rdfs:comment "What the advertiser wants the entity to do." ;
    rdfs:domain :DeliveryState ;
    rdfs:range :DeliveryIntent .

:observedServing
    a rdf:Property ;
    rdfs:label "has observed serving" ;
    rdfs:comment "Whether the entity is actually delivering." ;
    rdfs:domain :DeliveryState ;
    rdfs:range :ServingState .

:heldBy
    a rdf:Property ;
    rdfs:label "held by" ;
    rdfs:comment "A hold preventing delivery. A state may carry several, and an entity intending to run with no holds should be serving." ;
    rdfs:domain :DeliveryState ;
    rdfs:range :ServingHold .

:lifecycleStanding
    a rdf:Property ;
    rdfs:label "has lifecycle standing" ;
    rdfs:comment "Whether the entity is live, archived, or deleted." ;
    rdfs:domain :DeliveryState ;
    rdfs:range :LifecycleState .

:holdKind
    a rdf:Property ;
    rdfs:label "has hold kind" ;
    rdfs:comment "The category of the hold, which determines who can act on it." ;
    rdfs:domain :ServingHold ;
    rdfs:range :HoldKind .

:originatingResource
    a rdf:Property ;
    rdfs:label "originating resource" ;
    rdfs:comment "The resource the hold came from. For an inherited hold this is the ancestor that is paused; for a hold arising from the entity itself it is that entity." ;
    dcterms:description "Naming the origin is what makes an inherited pause traceable. A provider enumeration whose value means the parent campaign is paused says an ancestor is responsible but never which one, leaving an operator to walk a four-tier hierarchy by hand." ;
    rdfs:domain :ServingHold ;
    rdfs:range rdfs:Resource .

:effectiveDuring
    a rdf:Property ;
    rdfs:label "effective during" ;
    rdfs:comment "The interval a delivery state was observed to hold over. Open above when the state is current." ;
    rdfs:domain :DeliveryState ;
    rdfs:range rng:Range .


# --- Delivery intent scheme --------------------------------------------------

:DeliveryIntentScheme
    a skos:ConceptScheme ;
    rdfs:label "delivery intent scheme" ;
    rdfs:comment "Controlled vocabulary of what an advertiser intends an entity to do." ;
    skos:prefLabel "Delivery intents" .

:intendToRun
    a :DeliveryIntent, skos:Concept ;
    skos:inScheme :DeliveryIntentScheme ;
    rdfs:label "intend to run" ;
    rdfs:comment "The advertiser wants the entity to deliver." ;
    skos:definition "Delivery is switched on by the advertiser, whatever the platform then does." .

:intendToHold
    a :DeliveryIntent, skos:Concept ;
    skos:inScheme :DeliveryIntentScheme ;
    rdfs:label "intend to hold" ;
    rdfs:comment "The advertiser has switched delivery off." ;
    skos:definition "Delivery is switched off by the advertiser, distinct from being prevented by the platform." .


# --- Serving state scheme ----------------------------------------------------

:ServingStateScheme
    a skos:ConceptScheme ;
    rdfs:label "serving state scheme" ;
    rdfs:comment "Controlled vocabulary of observed delivery." ;
    skos:prefLabel "Serving states" .

:serving
    a :ServingState, skos:Concept ;
    skos:inScheme :ServingStateScheme ;
    rdfs:label "serving" ;
    rdfs:comment "The entity is being delivered." ;
    skos:definition "Delivery is occurring at the time of observation." .

:notServing
    a :ServingState, skos:Concept ;
    skos:inScheme :ServingStateScheme ;
    rdfs:label "not serving" ;
    rdfs:comment "The entity is not being delivered, for reasons its holds record." ;
    skos:definition "Delivery is not occurring at the time of observation." .


# --- Hold kind scheme --------------------------------------------------------

:HoldKindScheme
    a skos:ConceptScheme ;
    rdfs:label "hold kind scheme" ;
    rdfs:comment "Controlled vocabulary of reasons delivery is prevented." ;
    skos:prefLabel "Hold kinds" .

:policyReviewHold
    a :HoldKind, skos:Concept ;
    skos:inScheme :HoldKindScheme ;
    rdfs:label "policy review" ;
    rdfs:comment "Delivery is prevented pending or following a platform policy decision. The advertiser's remedy is to amend the entity or appeal." ;
    skos:definition "A hold arising from platform review of the entity's content or targeting." .

:billingHold
    a :HoldKind, skos:Concept ;
    skos:inScheme :HoldKindScheme ;
    rdfs:label "billing" ;
    rdfs:comment "Delivery is prevented by the account's payment standing. The remedy lies with whoever owns the account, not with the entity." ;
    skos:definition "A hold arising from payment method or outstanding balance." .

:allowanceExhaustedHold
    a :HoldKind, skos:Concept ;
    skos:inScheme :HoldKindScheme ;
    rdfs:label "allowance exhausted" ;
    rdfs:comment "Delivery is prevented because the governing budget or spend cap is spent. The remedy is a configuration change." ;
    skos:definition "A hold arising from an exhausted spending allowance." .

:outsideScheduleHold
    a :HoldKind, skos:Concept ;
    skos:inScheme :HoldKindScheme ;
    rdfs:label "outside schedule" ;
    rdfs:comment "Delivery is prevented because the current time falls outside the entity's flight or dayparting. Nothing is wrong." ;
    skos:definition "A hold arising from the entity's schedule rather than from a fault." .

:ancestorHeldHold
    a :HoldKind, skos:Concept ;
    skos:inScheme :HoldKindScheme ;
    rdfs:label "ancestor held" ;
    rdfs:comment "Delivery is prevented by an ancestor that is itself not delivering. The originating resource names which ancestor, which is the part provider enumerations omit." ;
    skos:definition "An inherited hold, whose remedy lies on a different entity." .

:processingHold
    a :HoldKind, skos:Concept ;
    skos:inScheme :HoldKindScheme ;
    rdfs:label "processing" ;
    rdfs:comment "Delivery is prevented while the platform finishes work on a recent change. Transient and requiring no action." ;
    skos:definition "A hold arising from in-flight platform processing." .


# --- Lifecycle state scheme --------------------------------------------------

:LifecycleStateScheme
    a skos:ConceptScheme ;
    rdfs:label "lifecycle state scheme" ;
    rdfs:comment "Controlled vocabulary of whether an entity still exists." ;
    skos:prefLabel "Lifecycle states" .

:liveEntity
    a :LifecycleState, skos:Concept ;
    skos:inScheme :LifecycleStateScheme ;
    rdfs:label "live" ;
    rdfs:comment "The entity exists in the advertiser's working set." ;
    skos:definition "Present and editable." .

:archivedEntity
    a :LifecycleState, skos:Concept ;
    skos:inScheme :LifecycleStateScheme ;
    rdfs:label "archived" ;
    rdfs:comment "The entity is removed from the working set but retained. Its historical metrics remain valid and readable." ;
    skos:definition "Retained out of view, with history intact." .

:removedEntity
    a :LifecycleState, skos:Concept ;
    skos:inScheme :LifecycleStateScheme ;
    rdfs:label "removed" ;
    rdfs:comment "The entity no longer exists. Historical metrics may survive it, and a query joining to the entity will not resolve." ;
    skos:definition "Gone from the platform, though its measurements may persist." .
