# ConceptKernel Base Instance Shapes Ontology
# Version: v3.5
# Date: 2026-03-25
# Purpose: OWL classes for base instance shapes — InstanceManifest, SealedInstance, LedgerEntry
# Source: SPEC.CKP.v3.5.alpha-3.md Section 4.1

@prefix : <https://conceptkernel.org/ontology/v3.5/> .
@prefix ckp: <https://conceptkernel.org/ontology/v3.5/> .
@prefix bfo: <http://purl.obolibrary.org/obo/BFO_> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix prov: <http://www.w3.org/ns/prov#> .

<https://conceptkernel.org/ontology/v3.5/base-instances> a owl:Ontology ;
    dc:title "ConceptKernel Base Instance Shapes Ontology" ;
    dc:description "OWL classes defining the base instance shapes for InstanceManifest, SealedInstance, and LedgerEntry" ;
    dcterms:created "2026-03-25"^^xsd:date ;
    owl:versionInfo "v3.5" ;
    rdfs:comment "Defines the canonical instance structures from SPEC.CKP.v3.5.alpha-3 Section 4.1" ;
    owl:imports <http://purl.obolibrary.org/obo/bfo.owl> ,
                <https://conceptkernel.org/ontology/v3.5/> .

#################################################################
#    InstanceManifest — base class for all instances
#################################################################

ckp:InstanceManifest a owl:Class ;
    rdfs:subClassOf bfo:0000031 ;  # bfo:GenericallyDependentContinuant (information entity)
    rdfs:label "Instance Manifest"@en ;
    rdfs:comment "The base shape for all CKP instances. An immutable information entity produced by a kernel action. Every instance directory contains a manifest.json conforming to this shape."@en ;
    dc:description "Stored at storage/instances/i-{identifier}/manifest.json" .

### InstanceManifest Properties

ckp:instance_id a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range xsd:string ;
    rdfs:label "instance ID"@en ;
    rdfs:comment "Unique identifier for the instance, format: i-{slug}-{epoch}"@en .

ckp:kernel_class a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range xsd:string ;
    rdfs:label "kernel class"@en ;
    rdfs:comment "The class name of the kernel that produced this instance (e.g., LOCAL.ClaudeCode)"@en .

ckp:kernel_id a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range xsd:string ;
    rdfs:label "kernel ID"@en ;
    rdfs:comment "The unique identifier (GUID) of the kernel that produced this instance"@en .

ckp:created_at a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range xsd:dateTime ;
    rdfs:label "created at"@en ;
    rdfs:comment "ISO 8601 timestamp of instance creation"@en .

### Provenance linkage (PROV-O aligned)

ckp:instanceWasGeneratedBy a owl:ObjectProperty , owl:FunctionalProperty ;
    rdfs:subPropertyOf prov:wasGeneratedBy ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range prov:Activity ;
    rdfs:label "was generated by"@en ;
    rdfs:comment "The action/activity that generated this instance (prov:wasGeneratedBy)"@en .

ckp:instanceWasAttributedTo a owl:ObjectProperty , owl:FunctionalProperty ;
    rdfs:subPropertyOf prov:wasAttributedTo ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range prov:Agent ;
    rdfs:label "was attributed to"@en ;
    rdfs:comment "The kernel/agent responsible for this instance (prov:wasAttributedTo)"@en .

ckp:instanceGeneratedAtTime a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:subPropertyOf prov:generatedAtTime ;
    rdfs:domain ckp:InstanceManifest ;
    rdfs:range xsd:dateTime ;
    rdfs:label "generated at time"@en ;
    rdfs:comment "Timestamp when this instance was generated (prov:generatedAtTime)"@en .

#################################################################
#    SealedInstance — finalized instance with data and refs
#################################################################

ckp:SealedInstance a owl:Class ;
    rdfs:subClassOf ckp:InstanceManifest ;
    rdfs:label "Sealed Instance"@en ;
    rdfs:comment "A finalized, immutable instance that has been sealed with data, tool reference, and CK reference. Once sealed, the instance and its contents cannot be modified."@en ;
    dc:description "Sealed instances contain data.json, and link back to tool/ and CK loop references" .

### SealedInstance Properties

ckp:data a owl:DatatypeProperty ;
    rdfs:domain ckp:SealedInstance ;
    rdfs:range xsd:string ;
    rdfs:label "data"@en ;
    rdfs:comment "JSON-serialized output data of the sealed instance (stored as data.json). Required — every SealedInstance must contain data."@en .

ckp:tool_ref a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:SealedInstance ;
    rdfs:range xsd:string ;
    rdfs:label "tool reference"@en ;
    rdfs:comment "Reference to the tool loop (processor) that produced this instance, e.g., tool/processor.py"@en .

ckp:ck_ref a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:SealedInstance ;
    rdfs:range xsd:string ;
    rdfs:label "CK reference"@en ;
    rdfs:comment "Reference to the CK loop (conceptkernel.yaml) identity at the time this instance was sealed"@en .

#################################################################
#    LedgerEntry — append-only action log
#################################################################

ckp:LedgerEntry a owl:Class ;
    rdfs:subClassOf bfo:0000031 ;  # bfo:GenericallyDependentContinuant (information entity)
    rdfs:label "Ledger Entry"@en ;
    rdfs:comment "An append-only log entry recording a state transition or action event. Stored in storage/ledger/ as JSONL files, one entry per line."@en ;
    dc:description "Stored at storage/ledger/actions-{date}.jsonl" .

### LedgerEntry Properties

ckp:ledgerTimestamp a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:LedgerEntry ;
    rdfs:range xsd:dateTime ;
    rdfs:label "timestamp"@en ;
    rdfs:comment "ISO 8601 timestamp of when this ledger event occurred"@en .

ckp:ledgerEvent a owl:DatatypeProperty , owl:FunctionalProperty ;
    rdfs:domain ckp:LedgerEntry ;
    rdfs:range xsd:string ;
    rdfs:label "event"@en ;
    rdfs:comment "The event type or action name recorded in this ledger entry (e.g., spawn, seal, context)"@en .

ckp:ledgerBefore a owl:DatatypeProperty ;
    rdfs:domain ckp:LedgerEntry ;
    rdfs:range xsd:string ;
    rdfs:label "before"@en ;
    rdfs:comment "JSON-serialized state before the event (for state transitions)"@en .

ckp:ledgerAfter a owl:DatatypeProperty ;
    rdfs:domain ckp:LedgerEntry ;
    rdfs:range xsd:string ;
    rdfs:label "after"@en ;
    rdfs:comment "JSON-serialized state after the event (for state transitions)"@en .

#################################################################
# End of ConceptKernel Base Instance Shapes Ontology
#################################################################
