The canonical operational environment for Canonical Knowledge Structures.
π Live demo β β explore the CKS ecosystem graph directly in your browser, no server required.
CKS Runtime is the canonical execution environment for Canonical Knowledge Structures (CKS).
Where CKS Core defines the semantics of knowledge, CKS Runtime defines its operational lifecycle.
Runtime provides the infrastructure required to execute, manage, version, persist and expose Canonical Knowledge Structures without becoming a semantic authority itself. Now fully async with PostgreSQL support.
CKS Runtime is part of a family of interoperable projects built on the Canonical Knowledge Structure.
| Project | Description | Repository |
|---|---|---|
| cks-core | Canonical semantic engine β the single source of canonical truth. | Deus-corp/cks-core |
| cks-runtime | Operational environment β sessions, transactions, persistence. | Deus-corp/cks-runtime |
| cks-mcp | MCP server β exposes CKS to LLMs and autonomous agents. | Deus-corp/cks-mcp |
| cks-studio | Visual workspace β explore, monitor, and manage graphs. | Deus-corp/cks-studio |
| cks-website | Documentation & demo site. | Deus-corp/cks-website |
π Full documentation, case studies, and an interactive demo are available at the CKS Documentation Site.
Canonical knowledge is immutable.
Operational state is not.
Applications need to:
- create sessions
- execute transactions
- maintain history
- persist state
- expose APIs
- coordinate diagnostics
These responsibilities belong to Runtime rather than CKS Core.
Canonical Knowledge Structure
β
βΌ
CKS Runtime
β
ββββββββββββΌβββββββββββ
βΌ βΌ βΌ
Session Versioning Storage
Runtime manages operational behaviour.
CKS Core defines semantic behaviour.
CKS Runtime is founded on four architectural principles.
Semantic meaning permanently belongs to CKS Core.
Runtime never redefines knowledge.
Validation.
Evolution.
Serialization.
Diagnostics.
These services originate from CKS Core.
Runtime coordinates their execution.
Sessions.
Transactions.
Persistence.
Version History.
These are Runtime responsibilities.
The Runtime Standard specifies observable operational behaviour rather than implementation techniques.
The CKS ecosystem is organized into four architectural layers.
Applications
β
βΌ
Adapters
β
βΌ
CKS Runtime
β
βΌ
Public CKS Core API
β
βΌ
CKS Core
Responsibilities are strictly separated.
| Layer | Responsibility |
|---|---|
| CKS Core | Semantic authority |
| CKS Runtime | Operational orchestration |
| Adapters | Protocol exposure |
| Applications | Business logic |
The current Reference Runtime provides:
- Runtime Sessions
- Transaction Management
- Version History
- Storage Abstraction
- Runtime Diagnostics
- Explainability Coordination
- Canonical Runtime API
- Reference Runtime Architecture
- Runtime Conformance Model
- CKS Core Integration (via
CksCoreAdapter) - Execution Engine β canonical operations (Validate, Serialize, Explain, Evolve, Diff) via
CoreBridge - Operation Dispatcher β registry-based operation resolution
- Event System β lifecycle events published via
EventBus - Time-Travel Operations β
ListVersionsOperation,RevertVersionOperation - Structural Diff β compact change computation between versions
- Threeβway merge of knowledge structures via
cks-core'smerge()function - Query Subgraph β kβhop neighbourhood extraction with type filters and budget/ranking, delegated to cks-core's query_subgraph()
- Persistent Storage β SQLite-backed storage via
SQLiteStorage, surviving server restarts. Configurable throughRuntimeConfig.storage_path. - Indexed & Vectorized Embeddings β
search_embeddingsuses NumPy matrix operations for ~10Γ faster similarity search, with a database index for multi-session scalability. - PostgreSQL Storage Backend β production-grade, async connection pooling, JSONB payloads, outbox with
SELECT ... FOR UPDATE SKIP LOCKED, and pgvector-powered semantic search with HNSW index. - Shared Patch Codec β consistent serialization/deserialization of structural operators across SQLite and Postgres backends.
- Session Garbage Collector β background task that automatically archives stale closed sessions, keeping storage compact in long-running deployments. Configurable retention window and sweep interval.
- Local embeddings via fastembed β offline, token-free semantic search with
FastEmbedEmbeddingClient(pip install cks-runtime[fastembed]). - Gossip Replication (ADR-008) β peer-to-peer session exchange: replica identity, HMAC-signed envelopes, replay protection, peer discovery (
PeerDiscovery,HTTPPeerDiscovery), weighted peer selection with backoff (PeerScheduler), and a background anti-entropy service (GossipService). HTTP transport viaaiohttp(pip install cks-runtime[gossip]). - CRDT Adapter (ADR-013) β conflict-free replicated storage layer beneath gossip: a grow-only set with a content-addressed Merkle prefix tree, an MV-Register with causal ordering and automatic fork detection, and quarantine validation (
cks.validate()+ Merkle-identity checks) wired into every incoming merge. PublishesCRDTForkDetectedevents and detects duplicate replica IDs to block silent divergence. - Autonomous Sweepers β seven background, detection-only sweepers that escalate findings into the persistent outbox rather than acting unilaterally:
ContradictionSweeper,InferenceStalenessSweeper(ADR-009),ProvenanceStalenessSweeper(ADR-010),TemporalStalenessSweeper(ADR-011),GraphFreshnessSweeper,GraphAutoUpdateSweeper, andGraphHealthSweeper. Shared observability viaSweeperStatusMixin/list_agent_statuses(), and remote start/stop control through persisted overrides (ADR-015). - Agent Infrastructure β liveness tracking (
cks_agent_liveness) and stop signalling (ADR-016) for external standalone agent processes (Critic, Enrichment, Fork Resolution, Pipeline);AgentStepStarted/AgentStepCompletedevents for pipeline observability. - Graph Registry β
register_graph/get_graph/list_graphspersist named session references, the storage foundation forcks-mcp's Memory Agent. - Backup & Disaster Recovery (ADR-012) β
export_storage()/import_storage()across every backend for full data dumps and clear/merge restores. - Persistent Outbox β task-type filtering, dead-letter queue (
dead_letter_outbox_task,list_dead_letter_tasks), and batch peek/drain by type, so multiple workers can share one outbox table without stealing each other's tasks.
CKS Runtime is designed to be:
- deterministic
- implementation-independent
- transport-independent
- storage-independent
- session-oriented
- transaction-oriented
- semantically neutral
CKS Runtime depends upon CKS Core.
CKS Runtime never replaces CKS Core.
CKS Core
defines semantics
β
βΌ
CKS Runtime
orchestrates semantics
manages operational lifecycle
Runtime communicates exclusively through the public CKS Core API.
From PyPI:
pip install cks-runtimeOr from source:
git clone https://github.com/Deus-corp/cks-runtime.git
cd cks-runtime
pip install -e .from cks_runtime import Runtime
from cks_runtime_plugins.cks_core import CksCoreAdapter
from cks_runtime.operations.operation_types import (
ValidateOperation,
EvolveOperation,
ListVersionsOperation,
RevertVersionOperation,
)
# Create Runtime with real CKS Core
runtime = Runtime(core=CksCoreAdapter())
# Create a session and validate a knowledge structure
session = runtime.create_session({"example": True})
tx = runtime.begin_transaction(session)
tx.add_operation(ValidateOperation("v1", knowledge_structure=session.knowledge_structure))
version = runtime.commit_transaction(tx)
# Evolve the structure
tx2 = runtime.begin_transaction(session)
tx2.add_operation(EvolveOperation("evolve", knowledge_structure=session.knowledge_structure, evolution=[]))
version2 = runtime.commit_transaction(tx2)
# List versions
versions = runtime.executor.execute(ListVersionsOperation(), session)
print(versions.payload)
# Revert to the first version
tx3 = runtime.begin_transaction(session)
tx3.add_operation(RevertVersionOperation("revert", target_version_id=version.version_id))
runtime.commit_transaction(tx3)CKS Runtime supports pluggable storage backends through a unified async interface (AsyncRuntimeStorage):
| Backend | Type | Status | Notes |
|---|---|---|---|
| InMemoryStorage | Sync | β Stable | For testing and ephemeral sessions |
| SQLiteStorage | Sync | β Stable | Persistent, singleβwriter, WAL mode |
| PostgresStorage | Async | β Stable | Productionβgrade, connection pooling, JSONB, outbox, pgvector embeddings with HNSW index |
Sync backends (InMemoryStorage, SQLiteStorage) are automatically adapted to the async interface via SyncStorageAdapter (using asyncio.to_thread), so existing code works unchanged. Use await Runtime.create(...) for full async startup, or plain Runtime(...) for lightweight testing without persistence.
π CKS Documentation β architecture guides, case studies, and API reference across all CKS projects.
The Runtime Standard consists of the following normative specifications.
| Specification | Purpose |
|---|---|
| SPEC-001 | Runtime Overview |
| SPEC-002 | Session Model |
| SPEC-003 | Runtime API |
| SPEC-004 | Diagnostics |
| SPEC-005 | Transactions |
| SPEC-006 | Storage |
| SPEC-007 | Version History |
| SPEC-008 | Runtime Conformance |
Supporting documents include:
- Runtime Charter
- Architectural Analyses
- Architecture Decision Records
- Reference Architecture
Current implementation status:
| Component | Status |
|---|---|
| Runtime Architecture | β Complete |
| Session Model | β Complete |
| Transaction Model | β Complete |
| Version History | β Complete |
| Diagnostics | β Complete |
| Storage Abstraction | β Complete |
| Async Runtime | β Complete |
| PostgreSQL Backend | β Complete |
| Session Garbage Collector | β Complete |
| Core Integration (CoreBridge) | β Complete |
| Execution Engine (Operations + Dispatcher) | β Complete |
| Event System | β Complete |
| Time-Travel Operations | β Complete |
| Structural Diff | β Complete |
| Query Subgraph | β Complete |
| Persistent Storage (SQLite) | β Complete |
| Gossip Replication (ADR-008) | β Complete β peer discovery, anti-entropy, duplicate replica ID detection |
| CRDT Adapter (ADR-013) | β Complete β G-Set + Merkle tree, MV-Register, fork detection, quarantine |
| Autonomous Sweepers (7) | β Complete β contradiction, inference/provenance/temporal staleness, graph freshness/auto-update/health |
| Sweeper Control (ADR-015) | β Complete |
| Agent Liveness & Control (ADR-016) | β Complete |
| Graph Registry | β Complete |
| Backup & Disaster Recovery (ADR-012) | β Complete |
| Outbox: task-type filter, DLQ | β Complete |
| Test Suite | β 734 tests passing (+69 requiring optional backends: Postgres, gossip) |
The current implementation serves as the reference implementation of the CKS Runtime Standard (SPEC-001 β¦ SPEC-008).
Future work focuses on Runtime Platform 2.0: dependency resolution and
parallel execution in the Execution Engine, distributed transactions and
leader election, and a unified observability platform. See ROADMAP.md
for the full breakdown.
CKS Runtime aims to become the canonical operational foundation shared by every CKS-compatible implementation.
Future adapter standardsβincluding MCP, CLI, HTTP and othersβwill rely on Runtime rather than communicating directly with CKS Core.
This preserves a single semantic authority while allowing unlimited operational implementations.
MIT