Cenosis Docs
v4.0 · ABI major 4 · NPCB v17

Cenosis Documentation

Cenosis is a Rust behavior engine for always-live, socially believable NPCs. It integrates into Unity, Unreal, or any web engine via a stable C ABI or WebAssembly — and never blocks your game thread.

Quick Start

Three commands to get a running build:

PowerShell
# 1. Build native DLL (Unity / Unreal)
.\build-ffi.ps1

# 2. Build WASM + JS glue (browser)
.\build-wasm.ps1

# 3. Run the test suite
.\test.ps1 unit

Generated bindings are committed at npc-ffi/bindings/NpcEngineV40.{cs,hpp,ts} — copy the appropriate file into your host project and you're type-safe against the frozen ABI.

What Cenosis gives you

The central value proposition is simple: every NPC in the world is always doing something believable, whether or not the player is watching.

  • Persistent social world — NPCs evolve relationships, beliefs, memories, moods, and reputations independently of player interaction.
  • Scalable simulation — 20-NPC village to 10,080-agent city, with deterministic and reproducible behavior at every scale.
  • LLM-powered narrative — dialog, reflection, and wake summaries driven by cloud LLMs with hard budget governance.
  • Clean host integration — non-blocking C ABI and WASM surface; all FFI is catch_unwind-wrapped.
  • Extension API — replace any core decision in Rust or from C#/C++/JS without recompiling the engine.

What Cenosis is NOT

Out of scope by design — the host engine handles these:

  • Pathfinding / navmesh
  • Animation — the engine emits structured action descriptors
  • Voice synthesis / ASR
  • Combat or destructive mutation
  • Procedural terrain, quest, or world generation
  • Rendering

Workspace Crate Map

The workspace is 18 crates. npc-common is the leaf — everything depends on it. npc-ffi is the only outward-facing surface — the only thing host code links against.

CrateLayerPurpose
npc-commonLeafShared types — AgentId, WorldTime, Need, TimelineEvent, EngineError, the 7 *Policy traits. Everything depends on this.
npc-storagePersistenceSQLite projections, WAL writer thread, HNSW vector index, NPCB v17 bundle format.
npc-worldWorld stateWorld, WorldClock, location graph, SmartObject + Affordance definitions.
npc-socialSocial graphRelationshipGraph (6 asymmetric dims), BeliefStore (theory-of-mind), gossip/rumor propagation.
npc-agentAgent modelAgent, Persona, Mood, Schedule, needs map with decay rates, custom needs registry.
npc-runtimeThe spineFS/SS/Macro tier map, AgentRuntime::tick, SceneManager, tier transitions, reflection, wake summary.
npc-planningDecisionUtilitySelector (utility AI), GoalSelector, relationship-intent bias.
npc-cognitionLLMPromptBuilder, ConstraintEngine, local ONNX SLM, identity drift.
npc-budgetGovernancePer-agent/session/hour caps, priority queue, prompt→response cache, circuit breaker.
npc-directorDramaStoryletEngine, tension pacing, storylines, factions, life/economic event pulses.
npc-cloudLLM clientrig-core 0.18 native (Anthropic, Synthetic.new) / fetch on WASM.
npc-moddingWorldPacksPack loading, validation, DependencyResolver, NamespaceRegistry, URL pack install.
npc-editorAuthoringPackEditor — editable in-memory WorldPack, live validation, lossless save.
npc-extendExtension APIExtension trait, 7 policy + 4 service seams, ConformanceVerifier, DeepExtension.
npc-ffiOnly outwardcdylib (C ABI) + wasm-bindgen. 65+ exported symbols.
npc-replayReproRPRO repro bundle capture + CLI replay with divergence localization.
npc-codegenBindings genC# / C++ / TypeScript host bindings from the frozen ABI surface.
npc-testsAcceptanceSynthetic towns, deterministic replay, scale benchmarks, ABI/API stability gates.

Technology Stack

LayerTechnology
LanguageRust 1.95 (Edition 2024, resolver 3)
PersistenceSQLite (rusqlite bundled) + okaywal WAL + HNSW vector index
Cloud LLMrig-core 0.18 → Anthropic / Synthetic.new (native); fetch (WASM)
Local inferenceONNX Runtime (ort 2.0) for embeddings + tactical SLM
Asynctokio (cloud path only); game-facing FFI is synchronous and non-blocking
Concurrencycrossbeam-channel (ingress), rayon (parallel social compute), parking_lot / dashmap
WASM storagesqlite-wasm-rs + OPFS VFS (sahpool) inside Web Worker
Buildcargo-zigbuild for cross-platform native; wasm-pack for browser
Editor GUITauri 2 desktop shell (detached workspace)