# Meshpocalypse Core Ontology
# Version: 3.0
# Description: Core OWL ontology for the Meshpocalypse RDF Semantic Graph Layer
# License: MIT

@prefix mesh: <https://meshpocalypse.dev/ontology#> .
@prefix meshc: <https://meshpocalypse.dev/context/v1> .
@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#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix schema: <https://schema.org/> .
@prefix did: <https://w3id.org/did/v1> .

# Ontology metadata
<https://meshpocalypse.dev/ontology> a owl:Ontology ;
    rdfs:label "Meshpocalypse Core Ontology"@en ;
    rdfs:comment "Core ontology for the Meshpocalypse RDF Semantic Graph Layer"@en ;
    owl:versionInfo "3.0" ;
    owl:versionIRI <https://meshpocalypse.dev/ontology/v3.0> ;
    rdfs:seeAlso <https://github.com/one137th/Meshpocalypse> ;
    schema:author "Meshpocalypse Contributors" ;
    schema:license <https://opensource.org/licenses/MIT> .

# ============================================================
# Core Classes
# ============================================================

mesh:Agent a owl:Class ;
    rdfs:label "Agent"@en ;
    rdfs:comment "An AI agent participating in the mesh"@en ;
    rdfs:subClassOf prov:Agent ;
    owl:disjointWith mesh:Task, mesh:Message .

mesh:RouterAgent a owl:Class ;
    rdfs:label "Router Agent"@en ;
    rdfs:comment "An agent specialized in routing decisions"@en ;
    rdfs:subClassOf mesh:Agent .

mesh:AnalysisAgent a owl:Class ;
    rdfs:label "Analysis Agent"@en ;
    rdfs:comment "An agent specialized in analysis tasks"@en ;
    rdfs:subClassOf mesh:Agent .

mesh:CodeReviewAgent a owl:Class ;
    rdfs:label "Code Review Agent"@en ;
    rdfs:comment "An agent specialized in code review"@en ;
    rdfs:subClassOf mesh:AnalysisAgent .

mesh:ResearchAgent a owl:Class ;
    rdfs:label "Research Agent"@en ;
    rdfs:comment "An agent specialized in research tasks"@en ;
    rdfs:subClassOf mesh:Agent .

mesh:CoordinatorAgent a owl:Class ;
    rdfs:label "Coordinator Agent"@en ;
    rdfs:comment "An agent that coordinates task decomposition and assignment"@en ;
    rdfs:subClassOf mesh:Agent .

mesh:VerifierAgent a owl:Class ;
    rdfs:label "Verifier Agent"@en ;
    rdfs:comment "An agent that verifies task completion and runs tests"@en ;
    rdfs:subClassOf mesh:Agent .

mesh:Capability a owl:Class ;
    rdfs:label "Capability"@en ;
    rdfs:comment "A capability that an agent can possess"@en .

mesh:StaticAnalysis a owl:Class ;
    rdfs:label "Static Analysis"@en ;
    rdfs:comment "Capability to perform static code analysis"@en ;
    rdfs:subClassOf mesh:Capability .

mesh:WebSearch a owl:Class ;
    rdfs:label "Web Search"@en ;
    rdfs:comment "Capability to search the web"@en ;
    rdfs:subClassOf mesh:Capability .

mesh:CodeReview a owl:Class ;
    rdfs:label "Code Review"@en ;
    rdfs:comment "Capability to review code"@en ;
    rdfs:subClassOf mesh:StaticAnalysis .

mesh:Simulation a owl:Class ;
    rdfs:label "Simulation"@en ;
    rdfs:comment "Capability to run simulations"@en ;
    rdfs:subClassOf mesh:Capability .

mesh:TypeScriptDev a owl:Class ;
    rdfs:label "TypeScript Development"@en ;
    rdfs:comment "Capability to develop TypeScript code"@en ;
    rdfs:subClassOf mesh:Capability .

mesh:RustDev a owl:Class ;
    rdfs:label "Rust Development"@en ;
    rdfs:comment "Capability to develop Rust code"@en ;
    rdfs:subClassOf mesh:Capability .

mesh:Task a owl:Class ;
    rdfs:label "Task"@en ;
    rdfs:comment "A task to be executed by an agent"@en ;
    rdfs:subClassOf prov:Activity .

mesh:ResearchTask a owl:Class ;
    rdfs:label "Research Task"@en ;
    rdfs:comment "A research-oriented task"@en ;
    rdfs:subClassOf mesh:Task .

mesh:AnalysisTask a owl:Class ;
    rdfs:label "Analysis Task"@en ;
    rdfs:comment "An analysis-oriented task"@en ;
    rdfs:subClassOf mesh:Task .

mesh:BugFixTask a owl:Class ;
    rdfs:label "Bug Fix Task"@en ;
    rdfs:comment "A bug fix task"@en ;
    rdfs:subClassOf mesh:Task .

mesh:Message a owl:Class ;
    rdfs:label "Message"@en ;
    rdfs:comment "A message exchanged between agents"@en .

mesh:RoutingRequest a owl:Class ;
    rdfs:label "Routing Request"@en ;
    rdfs:comment "A request for agent routing"@en ;
    rdfs:subClassOf mesh:Message .

mesh:TaskResult a owl:Class ;
    rdfs:label "Task Result"@en ;
    rdfs:comment "The result of a task execution"@en ;
    rdfs:subClassOf mesh:Message .

mesh:ProvenanceRecord a owl:Class ;
    rdfs:label "Provenance Record"@en ;
    rdfs:comment "A record of agent activity for provenance"@en ;
    rdfs:subClassOf mesh:Message, prov:Activity .

mesh:MeshNode a owl:Class ;
    rdfs:label "Mesh Node"@en ;
    rdfs:comment "An infrastructure node in the mesh"@en .

mesh:PromotionRequest a owl:Class ;
    rdfs:label "Promotion Request"@en ;
    rdfs:comment "A request for trust level promotion"@en .

# ============================================================
# Object Properties
# ============================================================

mesh:hasCapability a owl:ObjectProperty ;
    rdfs:label "has capability"@en ;
    rdfs:comment "Links an agent to its capabilities"@en ;
    rdfs:domain mesh:Agent ;
    rdfs:range mesh:Capability .

mesh:assignedTo a owl:ObjectProperty ;
    rdfs:label "assigned to"@en ;
    rdfs:comment "Links a task to the agent assigned to it"@en ;
    rdfs:domain mesh:Task ;
    rdfs:range mesh:Agent .

mesh:dependsOn a owl:ObjectProperty, owl:TransitiveProperty ;
    rdfs:label "depends on"@en ;
    rdfs:comment "Links a task to its dependencies"@en ;
    rdfs:domain mesh:Task ;
    rdfs:range mesh:Task .

mesh:sender a owl:ObjectProperty ;
    rdfs:label "sender"@en ;
    rdfs:comment "The agent that sent a message"@en ;
    rdfs:domain mesh:Message ;
    rdfs:range mesh:Agent .

mesh:receiver a owl:ObjectProperty ;
    rdfs:label "receiver"@en ;
    rdfs:comment "The agent that receives a message"@en ;
    rdfs:domain mesh:Message ;
    rdfs:range mesh:Agent .

mesh:requiresInput a owl:ObjectProperty ;
    rdfs:label "requires input"@en ;
    rdfs:comment "The input required by a capability"@en ;
    rdfs:domain mesh:Capability .

mesh:producesOutput a owl:ObjectProperty ;
    rdfs:label "produces output"@en ;
    rdfs:comment "The output produced by a capability"@en ;
    rdfs:domain mesh:Capability .

# ============================================================
# Datatype Properties
# ============================================================

mesh:status a owl:DatatypeProperty ;
    rdfs:label "status"@en ;
    rdfs:comment "The status of an agent or task"@en ;
    rdfs:range xsd:string .

mesh:trustLevel a owl:DatatypeProperty ;
    rdfs:label "trust level"@en ;
    rdfs:comment "The trust level of an agent (0-4)"@en ;
    rdfs:range xsd:integer .

mesh:did a owl:DatatypeProperty ;
    rdfs:label "DID"@en ;
    rdfs:comment "The Decentralized Identifier of an agent"@en ;
    rdfs:range xsd:anyURI .

mesh:priority a owl:DatatypeProperty ;
    rdfs:label "priority"@en ;
    rdfs:comment "The priority of a task (1-10)"@en ;
    rdfs:range xsd:integer .

mesh:timestamp a owl:DatatypeProperty ;
    rdfs:label "timestamp"@en ;
    rdfs:comment "The timestamp of a message or event"@en ;
    rdfs:range xsd:dateTime .

mesh:payload a owl:DatatypeProperty ;
    rdfs:label "payload"@en ;
    rdfs:comment "The payload of a message"@en ;
    rdfs:range xsd:string .

mesh:region a owl:DatatypeProperty ;
    rdfs:label "region"@en ;
    rdfs:comment "The region of a mesh node"@en ;
    rdfs:range xsd:string .

mesh:endpoint a owl:DatatypeProperty ;
    rdfs:label "endpoint"@en ;
    rdfs:comment "The endpoint URL of a mesh node"@en ;
    rdfs:range xsd:anyURI .

mesh:publicKey a owl:DatatypeProperty ;
    rdfs:label "public key"@en ;
    rdfs:comment "The public key of a mesh node"@en ;
    rdfs:range xsd:string .

mesh:protocols a owl:DatatypeProperty ;
    rdfs:label "protocols"@en ;
    rdfs:comment "Supported protocols"@en ;
    rdfs:range xsd:string .

mesh:actionType a owl:DatatypeProperty ;
    rdfs:label "action type"@en ;
    rdfs:comment "The type of action in a provenance record"@en ;
    rdfs:range xsd:string .

mesh:queryHash a owl:DatatypeProperty ;
    rdfs:label "query hash"@en ;
    rdfs:comment "The hash of a SPARQL query"@en ;
    rdfs:range xsd:string .

mesh:previousRecordHash a owl:DatatypeProperty ;
    rdfs:label "previous record hash"@en ;
    rdfs:comment "The hash of the previous provenance record"@en ;
    rdfs:range xsd:string .

mesh:currentRecordHash a owl:DatatypeProperty ;
    rdfs:label "current record hash"@en ;
    rdfs:comment "The hash of the current provenance record"@en ;
    rdfs:range xsd:string .

mesh:specRef a owl:DatatypeProperty ;
    rdfs:label "specification reference"@en ;
    rdfs:comment "Reference to a specification document"@en ;
    rdfs:range xsd:string .

mesh:description a owl:DatatypeProperty ;
    rdfs:label "description"@en ;
    rdfs:comment "A description of a task or entity"@en ;
    rdfs:range xsd:string .

mesh:phase a owl:DatatypeProperty ;
    rdfs:label "phase"@en ;
    rdfs:comment "The implementation phase"@en ;
    rdfs:range xsd:integer .

mesh:requiredCapability a owl:ObjectProperty ;
    rdfs:label "required capability"@en ;
    rdfs:comment "The capability required to execute a task"@en ;
    rdfs:domain mesh:Task ;
    rdfs:range mesh:Capability .

mesh:startedAt a owl:DatatypeProperty ;
    rdfs:label "started at"@en ;
    rdfs:comment "When a task was started"@en ;
    rdfs:range xsd:dateTime .

mesh:completedAt a owl:DatatypeProperty ;
    rdfs:label "completed at"@en ;
    rdfs:comment "When a task was completed"@en ;
    rdfs:range xsd:dateTime .

mesh:verified a owl:DatatypeProperty ;
    rdfs:label "verified"@en ;
    rdfs:comment "Whether a task has been verified"@en ;
    rdfs:range xsd:boolean .

mesh:trustLevelUpdatedAt a owl:DatatypeProperty ;
    rdfs:label "trust level updated at"@en ;
    rdfs:comment "When the trust level was last updated"@en ;
    rdfs:range xsd:dateTime .

mesh:fromLevel a owl:DatatypeProperty ;
    rdfs:label "from level"@en ;
    rdfs:comment "The previous trust level"@en ;
    rdfs:range xsd:integer .

mesh:toLevel a owl:DatatypeProperty ;
    rdfs:label "to level"@en ;
    rdfs:comment "The new trust level"@en ;
    rdfs:range xsd:integer .

mesh:promotedAt a owl:DatatypeProperty ;
    rdfs:label "promoted at"@en ;
    rdfs:comment "When the promotion occurred"@en ;
    rdfs:range xsd:dateTime .

mesh:reason a owl:DatatypeProperty ;
    rdfs:label "reason"@en ;
    rdfs:comment "The reason for a promotion or demotion"@en ;
    rdfs:range xsd:string .

mesh:sparqlEndpoint a owl:DatatypeProperty ;
    rdfs:label "SPARQL endpoint"@en ;
    rdfs:comment "The SPARQL endpoint URL of a mesh node"@en ;
    rdfs:range xsd:anyURI .

mesh:lastSeen a owl:DatatypeProperty ;
    rdfs:label "last seen"@en ;
    rdfs:comment "When the mesh node was last seen"@en ;
    rdfs:range xsd:dateTime .

# ============================================================
# Circuit Breaker State Properties (v1.3.0, Issue #115)
# ============================================================

mesh:circuitState a owl:DatatypeProperty ;
    rdfs:label "circuit state"@en ;
    rdfs:comment "Current circuit breaker state: CLOSED, OPEN, or HALF_OPEN"@en ;
    rdfs:domain mesh:Agent ;
    rdfs:range xsd:string .

mesh:lastCircuitChange a owl:DatatypeProperty ;
    rdfs:label "last circuit change"@en ;
    rdfs:comment "Timestamp of last circuit breaker state change"@en ;
    rdfs:domain mesh:Agent ;
    rdfs:range xsd:dateTime .

# ============================================================
# PROV-O Extensions for AI Agents
# ============================================================

mesh:SparqlQueryAction a owl:Class ;
    rdfs:label "SPARQL Query Action"@en ;
    rdfs:comment "A SPARQL query action"@en ;
    rdfs:subClassOf prov:Activity .

mesh:SparqlUpdateAction a owl:Class ;
    rdfs:label "SPARQL Update Action"@en ;
    rdfs:comment "A SPARQL update action"@en ;
    rdfs:subClassOf prov:Activity .

mesh:ToolInvocation a owl:Class ;
    rdfs:label "Tool Invocation"@en ;
    rdfs:comment "Invocation of a tool by an agent"@en ;
    rdfs:subClassOf prov:Activity .

mesh:PromptExecution a owl:Class ;
    rdfs:label "Prompt Execution"@en ;
    rdfs:comment "Execution of a prompt by an agent"@en ;
    rdfs:subClassOf prov:Activity .

mesh:ModelInvocation a owl:Class ;
    rdfs:label "Model Invocation"@en ;
    rdfs:comment "Invocation of an LLM model"@en ;
    rdfs:subClassOf prov:Activity .

mesh:toolName a owl:DatatypeProperty ;
    rdfs:label "tool name"@en ;
    rdfs:comment "The name of the invoked tool"@en ;
    rdfs:domain mesh:ToolInvocation ;
    rdfs:range xsd:string .

mesh:modelId a owl:DatatypeProperty ;
    rdfs:label "model ID"@en ;
    rdfs:comment "The ID of the invoked model"@en ;
    rdfs:domain mesh:ModelInvocation ;
    rdfs:range xsd:string .

mesh:tokenCount a owl:DatatypeProperty ;
    rdfs:label "token count"@en ;
    rdfs:comment "The number of tokens used"@en ;
    rdfs:domain mesh:ModelInvocation ;
    rdfs:range xsd:integer .

# ============================================================
# MCP Tool Ontology
# ============================================================

mesh:Tool a owl:Class ;
    rdfs:label "Tool"@en ;
    rdfs:comment "An MCP tool"@en .

mesh:toolEndpoint a owl:DatatypeProperty ;
    rdfs:label "tool endpoint"@en ;
    rdfs:comment "The endpoint for the tool"@en ;
    rdfs:domain mesh:Tool ;
    rdfs:range xsd:anyURI .

mesh:requiredTrustLevel a owl:DatatypeProperty ;
    rdfs:label "required trust level"@en ;
    rdfs:comment "The minimum trust level required to use the tool"@en ;
    rdfs:domain mesh:Tool ;
    rdfs:range xsd:integer .

# ============================================================
# Capability Inheritance Axioms
# ============================================================

# CodeReviewAgent inherits from AnalysisAgent
mesh:CodeReviewAgent rdfs:subClassOf mesh:AnalysisAgent .

# AnalysisAgent has StaticAnalysis capability
[] a owl:Restriction ;
    owl:onProperty mesh:hasCapability ;
    owl:someValuesFrom mesh:StaticAnalysis ;
    rdfs:subClassOf mesh:AnalysisAgent .

# CodeReview inherits from StaticAnalysis
mesh:CodeReview rdfs:subClassOf mesh:StaticAnalysis .

# ============================================================
# TokenBudget — Tenant-scoped token cost governance (v1.2.0)
# Design: Perplexity ontology, supersedes earlier GROK proposal
# mesh:remainingTokens is NOT stored — computed via SPARQL BIND
# ============================================================

mesh:Tenant a owl:Class ;
    rdfs:label "Tenant"@en ;
    rdfs:comment "An organisation or account that owns resources and token budgets in the mesh."@en .

mesh:Member a owl:Class ;
    rdfs:label "Member"@en ;
    rdfs:comment "A human user belonging to a tenant."@en .

mesh:memberOf a owl:ObjectProperty ;
    rdfs:label "member of"@en ;
    rdfs:comment "Associates a member (user) with the tenant they belong to."@en ;
    rdfs:domain mesh:Member ;
    rdfs:range mesh:Tenant .

mesh:TokenBudget a owl:Class ;
    rdfs:label "Token Budget"@en ;
    rdfs:comment "Policy object defining token limits for a tenant, optionally scoped to specific members, agents, or tasks. Subclass of prov:Entity for PROV-O integration."@en ;
    rdfs:subClassOf prov:Entity .

# Budget scope relations (tenant required; member/agent/task optional)

mesh:budgetOwner a owl:ObjectProperty ;
    rdfs:label "budget owner"@en ;
    rdfs:comment "The tenant that owns this token budget policy (required)."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range mesh:Tenant .

mesh:budgetMember a owl:ObjectProperty ;
    rdfs:label "budget member"@en ;
    rdfs:comment "Optional: constrains this budget to a specific member (user) within the owning tenant."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range mesh:Member .

mesh:budgetAgent a owl:ObjectProperty ;
    rdfs:label "budget agent"@en ;
    rdfs:comment "Optional: constrains this budget to a specific agent within the owning tenant."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range mesh:Agent .

mesh:budgetTask a owl:ObjectProperty ;
    rdfs:label "budget task"@en ;
    rdfs:comment "Optional: constrains this budget to a specific task or task type."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range mesh:Task .

# Limit fields

mesh:maxTokens a owl:DatatypeProperty ;
    rdfs:label "max tokens"@en ;
    rdfs:comment "Hard limit on tokens allowed in the defined budget window."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range xsd:integer .

mesh:softLimitTokens a owl:DatatypeProperty ;
    rdfs:label "soft limit tokens"@en ;
    rdfs:comment "Warning threshold; must be <= maxTokens. Replaces hardcoded 80% thresholds."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range xsd:integer .

mesh:spentTokens a owl:DatatypeProperty ;
    rdfs:label "spent tokens"@en ;
    rdfs:comment "Cached snapshot of tokens spent in this window; updated on each mesh:chargedTo invocation. mesh:remainingTokens is computed via SPARQL BIND(?maxTokens - ?spentTokens AS ?remaining) — not a stored property."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range xsd:integer .

mesh:limitType a owl:DatatypeProperty ;
    rdfs:label "limit type"@en ;
    rdfs:comment "Semantic purpose of this budget: 'cost' for financial control, 'safety' for guardrails, 'mixed' for both."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range xsd:string .

# Billing period / window

mesh:windowStart a owl:DatatypeProperty ;
    rdfs:label "window start"@en ;
    rdfs:comment "Start timestamp of this budget window (e.g. beginning of billing period)."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range xsd:dateTime .

mesh:windowEnd a owl:DatatypeProperty ;
    rdfs:label "window end"@en ;
    rdfs:comment "End timestamp of this budget window (e.g. end of billing period)."@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range xsd:dateTime .

# Link ModelInvocation → TokenBudget

mesh:chargedTo a owl:ObjectProperty ;
    rdfs:label "charged to"@en ;
    rdfs:comment "The token budget that this model invocation is charged against."@en ;
    rdfs:domain mesh:ModelInvocation ;
    rdfs:range mesh:TokenBudget .

# ============================================================
# Model Cost Tiers (Wave 3B — Issue #128)
# ============================================================

mesh:ModelTier a owl:Class ;
    rdfs:label "Model Tier"@en ;
    rdfs:comment "Cost tier for an agent's LLM backend."@en .

mesh:ECONOMY a mesh:ModelTier ;
    rdfs:label "Economy"@en ;
    rdfs:comment "Low-cost models (e.g. Haiku, Gemini Flash, Llama)."@en .

mesh:STANDARD a mesh:ModelTier ;
    rdfs:label "Standard"@en ;
    rdfs:comment "Standard-cost models (e.g. Sonnet, GPT-4o-mini)."@en .

mesh:PREMIUM a mesh:ModelTier ;
    rdfs:label "Premium"@en ;
    rdfs:comment "Premium models (e.g. Opus, GPT-4, o1)."@en .

mesh:modelTier a owl:ObjectProperty ;
    rdfs:label "model tier"@en ;
    rdfs:domain mesh:Agent ;
    rdfs:range mesh:ModelTier ;
    rdfs:comment "The cost tier of this agent's LLM backend."@en .

mesh:costPerKToken a owl:DatatypeProperty ;
    rdfs:label "cost per kToken"@en ;
    rdfs:domain mesh:Agent ;
    rdfs:range xsd:decimal ;
    rdfs:comment "Approximate cost in USD per 1000 tokens for this agent."@en .

# ============================================================
# Capability Auction Protocol (ADR-009)
# ============================================================

mesh:TaskBid a owl:Class ;
    rdfs:label "Task Bid"@en ;
    rdfs:comment "A bid submitted by an agent in response to a task auction." ;
    owl:disjointWith mesh:Agent, mesh:Task .

mesh:bidScore a owl:DatatypeProperty ;
    rdfs:label "bid score"@en ;
    rdfs:domain mesh:TaskBid ;
    rdfs:range xsd:decimal ;
    rdfs:comment "Computed Jaccard match score for this bid (0.0–1.0)." .

mesh:bidWindowMs a owl:DatatypeProperty ;
    rdfs:label "bid window ms"@en ;
    rdfs:domain mesh:TaskBid ;
    rdfs:range xsd:integer ;
    rdfs:comment "Auction collection window in milliseconds." .

mesh:taskId a owl:DatatypeProperty ;
    rdfs:label "task id"@en ;
    rdfs:domain mesh:TaskBid ;
    rdfs:range xsd:string ;
    rdfs:comment "The unique identifier of the auctioned task." .

mesh:biddingAgent a owl:ObjectProperty ;
    rdfs:label "bidding agent"@en ;
    rdfs:domain mesh:TaskBid ;
    rdfs:range mesh:Agent ;
    rdfs:comment "The agent that submitted this bid." .

mesh:bidStatus a owl:DatatypeProperty ;
    rdfs:label "bid status"@en ;
    rdfs:domain mesh:TaskBid ;
    rdfs:range xsd:string ;
    rdfs:comment "Lifecycle state of the bid: PENDING, WON, LOST, TOMBSTONED." .

mesh:agentLoad a owl:DatatypeProperty ;
    rdfs:label "agent load"@en ;
    rdfs:domain mesh:TaskBid ;
    rdfs:range xsd:decimal ;
    rdfs:comment "Agent load at time of bidding (0.0–1.0). Lower is better." .

# =====================================================
# Budget Delegation — Hierarchical sub-budget allocation (v1.3.0, Issue #127)
# Orchestrators allocate child budgets from a parent TokenBudget.
# Full PROV-O provenance: prov:wasDerivedFrom + prov:Activity per allocation.
# ============================================================

mesh:allocates a owl:ObjectProperty ;
    rdfs:label "allocates"@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range  mesh:TokenBudget ;
    rdfs:comment "Links a parent TokenBudget to a child sub-budget it allocated." .

mesh:allocationId a owl:DatatypeProperty ;
    rdfs:label "allocation id"@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range  xsd:string ;
    rdfs:comment "Unique identifier for this allocation event (UUID v4)." .

mesh:allocatedAt a owl:DatatypeProperty ;
    rdfs:label "allocated at"@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range  xsd:dateTime ;
    rdfs:comment "Timestamp when this sub-budget was allocated from its parent." .

mesh:allocatedBy a owl:ObjectProperty ;
    rdfs:label "allocated by"@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range  mesh:Agent ;
    rdfs:comment "The orchestrator agent that performed this sub-budget allocation." .

mesh:parentBudget a owl:ObjectProperty ;
    rdfs:label "parent budget"@en ;
    rdfs:domain mesh:TokenBudget ;
    rdfs:range  mesh:TokenBudget ;
    rdfs:comment "Inverse of mesh:allocates — points from a child sub-budget to its parent budget." .

mesh:BudgetAllocationActivity a owl:Class ;
    rdfs:label "Budget Allocation Activity"@en ;
    rdfs:comment "A PROV-O Activity recording the allocation of a child sub-budget from a parent. Linked via prov:wasDerivedFrom on the child budget." ;
    rdfs:subClassOf prov:Activity .



# ============================================================
# ATF Review Flow (Wave 4B — Issue #129)
# ============================================================

mesh:TrustReviewRequired
    a owl:Class ;
    rdfs:subClassOf mesh:ATFEvent ;
    rdfs:label "Trust Review Required"@en ;
    rdfs:comment "Marks an agent as suspended pending trust review." .

mesh:suspendedAt
    a owl:DatatypeProperty ;
    rdfs:label "suspended at"@en ;
    rdfs:domain mesh:TrustReviewRequired ;
    rdfs:range xsd:dateTime ;
    rdfs:comment "The timestamp at which the agent was suspended for review." .

mesh:reviewReason
    a owl:DatatypeProperty ;
    rdfs:label "review reason"@en ;
    rdfs:domain mesh:TrustReviewRequired ;
    rdfs:range xsd:string ;
    rdfs:comment "Human-readable reason for the suspension and review requirement." .

mesh:reviewedBy
    a owl:ObjectProperty ;
    rdfs:label "reviewed by"@en ;
    rdfs:domain mesh:TrustReviewRequired ;
    rdfs:range mesh:Agent ;
    rdfs:comment "The guardian agent or human reviewer who resolved this review." .

mesh:reviewOutcome
    a owl:DatatypeProperty ;
    rdfs:label "review outcome"@en ;
    rdfs:domain mesh:TrustReviewRequired ;
    rdfs:range xsd:string ;
    rdfs:comment "Outcome of the review: mesh:Reinstated or mesh:PermanentlyDemoted." .

mesh:reviewTtlSeconds
    a owl:DatatypeProperty ;
    rdfs:label "review TTL seconds"@en ;
    rdfs:domain mesh:TrustReviewRequired ;
    rdfs:range xsd:integer ;
    rdfs:comment "Auto-demotes if no review occurs within this window (seconds)." .


# ============================================================
# Hierarchical Capability Taxonomy (Issue #154)
# ============================================================

# ── Top-level capability domains ────────────────────────────

mesh:NLP a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Natural Language Processing"@en ;
    rdfs:comment "Capabilities related to understanding and generating human language."@en .

mesh:Mathematics a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Mathematics & Reasoning"@en ;
    rdfs:comment "Capabilities for mathematical computation and logical reasoning."@en .

mesh:CodeEngineering a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Code & Engineering"@en ;
    rdfs:comment "Capabilities for software development and engineering tasks."@en .

mesh:DataAnalysis a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Data Analysis"@en ;
    rdfs:comment "Capabilities for analysing and interpreting structured and unstructured data."@en .

mesh:Search a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Search & Retrieval"@en ;
    rdfs:comment "Capabilities for finding, ranking, and retrieving information."@en .

mesh:Compliance a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Compliance & Governance"@en ;
    rdfs:comment "Capabilities for policy enforcement, auditing, and regulatory compliance."@en .

mesh:Embedding a owl:Class ;
    rdfs:subClassOf mesh:Capability ;
    rdfs:label "Embedding & Vectorisation"@en ;
    rdfs:comment "Capabilities for converting content into vector representations."@en .

# ── NLP sub-capabilities ─────────────────────────────────────

mesh:ExtractiveSummarisation a owl:Class ;
    rdfs:subClassOf mesh:NLP ;
    rdfs:label "Extractive Summarisation"@en ;
    rdfs:comment "Summarise text by selecting key sentences verbatim from the source."@en .

mesh:AbstractiveSummarisation a owl:Class ;
    rdfs:subClassOf mesh:NLP ;
    rdfs:label "Abstractive Summarisation"@en ;
    rdfs:comment "Summarise text by paraphrasing and generating novel sentences."@en .

mesh:SentimentAnalysis a owl:Class ;
    rdfs:subClassOf mesh:NLP ;
    rdfs:label "Sentiment Analysis"@en ;
    rdfs:comment "Identify and classify emotional tone in text."@en .

mesh:Translation a owl:Class ;
    rdfs:subClassOf mesh:NLP ;
    rdfs:label "Translation"@en ;
    rdfs:comment "Translate text between natural languages."@en .

# ── Mathematics & Reasoning sub-capabilities ─────────────────

mesh:SymbolicReasoning a owl:Class ;
    rdfs:subClassOf mesh:Mathematics ;
    rdfs:label "Symbolic Reasoning"@en ;
    rdfs:comment "Formal logic and symbolic manipulation."@en .

mesh:NumericalComputation a owl:Class ;
    rdfs:subClassOf mesh:Mathematics ;
    rdfs:label "Numerical Computation"@en ;
    rdfs:comment "Floating-point arithmetic and numerical analysis."@en .

mesh:ProbabilisticInference a owl:Class ;
    rdfs:subClassOf mesh:Mathematics ;
    rdfs:label "Probabilistic Inference"@en ;
    rdfs:comment "Bayesian reasoning and probabilistic modelling."@en .

mesh:OptimisationSolving a owl:Class ;
    rdfs:subClassOf mesh:Mathematics ;
    rdfs:label "Optimisation Solving"@en ;
    rdfs:comment "Solving linear, non-linear, and combinatorial optimisation problems."@en .

# ── Code & Engineering sub-capabilities ──────────────────────

mesh:CodeGeneration a owl:Class ;
    rdfs:subClassOf mesh:CodeEngineering ;
    rdfs:label "Code Generation"@en ;
    rdfs:comment "Generate source code from natural-language or formal specifications."@en .

mesh:CodeRefactoring a owl:Class ;
    rdfs:subClassOf mesh:CodeEngineering ;
    rdfs:label "Code Refactoring"@en ;
    rdfs:comment "Restructure existing code without changing its external behaviour."@en .

mesh:TestGeneration a owl:Class ;
    rdfs:subClassOf mesh:CodeEngineering ;
    rdfs:label "Test Generation"@en ;
    rdfs:comment "Automatically produce unit, integration, or property-based tests."@en .

mesh:SecurityAudit a owl:Class ;
    rdfs:subClassOf mesh:CodeEngineering ;
    rdfs:label "Security Audit"@en ;
    rdfs:comment "Identify security vulnerabilities and code quality issues."@en .

# ── Data Analysis sub-capabilities ───────────────────────────

mesh:AnomalyDetection a owl:Class ;
    rdfs:subClassOf mesh:DataAnalysis ;
    rdfs:label "Anomaly Detection"@en ;
    rdfs:comment "Identify outliers or unusual patterns in datasets."@en .

mesh:DataVisualisation a owl:Class ;
    rdfs:subClassOf mesh:DataAnalysis ;
    rdfs:label "Data Visualisation"@en ;
    rdfs:comment "Render data into charts, graphs, and interactive dashboards."@en .

mesh:TimeSeriesAnalysis a owl:Class ;
    rdfs:subClassOf mesh:DataAnalysis ;
    rdfs:label "Time Series Analysis"@en ;
    rdfs:comment "Analyse and forecast sequential time-indexed data."@en .

mesh:ClassificationLabelling a owl:Class ;
    rdfs:subClassOf mesh:DataAnalysis ;
    rdfs:label "Classification & Labelling"@en ;
    rdfs:comment "Assign categories or labels to data points."@en .

# ── Search & Retrieval sub-capabilities ──────────────────────

mesh:SemanticSearch a owl:Class ;
    rdfs:subClassOf mesh:Search ;
    rdfs:label "Semantic Search"@en ;
    rdfs:comment "Retrieve documents based on meaning rather than exact keywords."@en .

mesh:HybridRetrieval a owl:Class ;
    rdfs:subClassOf mesh:Search ;
    rdfs:label "Hybrid Retrieval"@en ;
    rdfs:comment "Combine dense vector search with sparse keyword retrieval."@en .

mesh:KnowledgeGraphQuery a owl:Class ;
    rdfs:subClassOf mesh:Search ;
    rdfs:label "Knowledge Graph Query"@en ;
    rdfs:comment "Query structured knowledge graphs via SPARQL or Cypher."@en .

# ── Compliance & Governance sub-capabilities ─────────────────

mesh:PIIRedaction a owl:Class ;
    rdfs:subClassOf mesh:Compliance ;
    rdfs:label "PII Redaction"@en ;
    rdfs:comment "Detect and redact personally identifiable information."@en .

mesh:PolicyEnforcement a owl:Class ;
    rdfs:subClassOf mesh:Compliance ;
    rdfs:label "Policy Enforcement"@en ;
    rdfs:comment "Apply and audit governance policies across agent actions."@en .

mesh:AuditLogging a owl:Class ;
    rdfs:subClassOf mesh:Compliance ;
    rdfs:label "Audit Logging"@en ;
    rdfs:comment "Produce tamper-evident audit trails of agent activities."@en .

# ── Embedding & Vectorisation sub-capabilities ───────────────

mesh:DenseEmbedding a owl:Class ;
    rdfs:subClassOf mesh:Embedding ;
    rdfs:label "Dense Embedding"@en ;
    rdfs:comment "Produce fixed-size dense vector representations of text or media."@en .

mesh:SparseEmbedding a owl:Class ;
    rdfs:subClassOf mesh:Embedding ;
    rdfs:label "Sparse Embedding"@en ;
    rdfs:comment "Produce high-dimensional sparse vector representations (e.g. BM25, SPLADE)."@en .

mesh:MultiModalEmbedding a owl:Class ;
    rdfs:subClassOf mesh:Embedding ;
    rdfs:label "Multi-Modal Embedding"@en ;
    rdfs:comment "Embed text, images, and audio into a shared vector space."@en .

# ============================================================
# ModelCapability class and properties (Issue #121)
# ============================================================

mesh:ModelCapability a owl:Class ;
    rdfs:label "Model Capability"@en ;
    rdfs:comment "Describes the performance and cost characteristics of an LLM or AI model available to an agent. Enables SPARQL-driven model selection and budget-aware downgrade paths."@en .

mesh:hasModelCapability a owl:ObjectProperty ;
    rdfs:label "has model capability"@en ;
    rdfs:comment "Associates an agent with one or more model capability profiles it can use."@en ;
    rdfs:domain mesh:Agent ;
    rdfs:range mesh:ModelCapability .

mesh:costPerToken a owl:DatatypeProperty ;
    rdfs:label "cost per token"@en ;
    rdfs:comment "Cost in USD per output token for this model (e.g. 0.000015 for GPT-4o)."@en ;
    rdfs:domain mesh:ModelCapability ;
    rdfs:range xsd:decimal .

mesh:contextWindow a owl:DatatypeProperty ;
    rdfs:label "context window"@en ;
    rdfs:comment "Maximum number of tokens the model can process in a single context (input + output)."@en ;
    rdfs:domain mesh:ModelCapability ;
    rdfs:range xsd:integer .

mesh:qualityScore a owl:DatatypeProperty ;
    rdfs:label "quality score"@en ;
    rdfs:comment "Normalised quality rating for the model in [0.0, 1.0]. Higher values indicate better output quality."@en ;
    rdfs:domain mesh:ModelCapability ;
    rdfs:range xsd:decimal .

mesh:modelProvider a owl:DatatypeProperty ;
    rdfs:label "model provider"@en ;
    rdfs:comment "The organisation or service that provides this model (e.g. 'openai', 'anthropic', 'google')."@en ;
    rdfs:domain mesh:ModelCapability ;
    rdfs:range xsd:string .

mesh:modelId a owl:DatatypeProperty ;
    rdfs:label "model ID"@en ;
    rdfs:comment "Provider-specific model identifier (e.g. 'gpt-4o', 'claude-3-5-sonnet-20241022')."@en ;
    rdfs:domain mesh:ModelCapability ;
    rdfs:range xsd:string .
