# nerdsane/temper architecture

> Architecture diagram of the GitHub repository nerdsane/temper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nerdsane/temper
- Repository: https://github.com/nerdsane/temper

## Overview

1. **Repository shape**
This is a Rust-first monorepo for the Temper kernel plus supporting SDKs, UI, reference apps, and generated WASM modules. The center of gravity is the `crates/temper-*` workspace; everything else is either app content (`os-apps`, `reference-apps`), developer tooling (`scripts`, `.claude`, `docs`), or client-side surfaces (`packages/temper-sdk-ts`, `ui/observe`).

2. **Core product boundary**
Temper is a verified runtime for agent-built systems. The key boundary is between:
- **specification**: what the system is allowed to do
- **runtime**: what actually executes
- **governance**: what requires human approval
- **observation**: what was done and why  
The README’s “Specs → Verify → Deploy” flow is the architectural spine.

3. **Specification and type system**
`crates/temper-spec` is the front door for domain definitions. It parses I/O Automata specs (`*.ioa.toml`) plus CSDL schemas (`*.csdl.xml`) and compiles them into an internal state-machine model. This is the canonical source for behavior, entity types, transitions, and cross-invariants, and it drives both verification and runtime generation.

4. **Verification pipeline**
`crates/temper-verify` enforces the contract before deployment through a four-stage cascade: symbolic checks, model checking, deterministic simulation testing, and property-based testing. This is where specs are proven sane, reachable, and robust against randomized or fault-injected execution. The result gates what can be deployed to the live system.

5. **Execution runtime**
`crates/temper-runtime` is the generic actor/runtime layer: actors, mailboxes, persistence hooks, scheduling, supervision, and system/tenant isolation. `crates/temper-jit` sits beside it to build and hot-swap transition tables, so the runtime can keep running while the compiled behavior changes. This is the “live machine” that executes verified transitions.

6. **Server/kernel layer**
`crates/temper-server` is the main HTTP kernel. It exposes the API surface, OData endpoints, routing, request context, entity dispatch, idempotency, and trigger handling. It also owns most of the platform-specific application logic: entity actors, state management, projection/query paths, webhook delivery, secrets, blob handling, and workflow tracing.

7. **Data access and storage backends**
The server is storage-abstracted through backend crates:
- `crates/temper-store-postgres` for the canonical Postgres platform store
- `crates/temper-store-turso` for Turso/libSQL
- `crates/temper-store-redis` for distributed mailbox/cache concerns
- `crates/temper-store-sim` for deterministic in-memory simulation  
This makes “live storage,” “simulation,” and “test” variants interchangeable at the platform boundary. Postgres appears to be the primary production persistence path.

8. **Authorization and governance**
`crates/temper-authz` implements Cedar-based policy evaluation. The server uses this to decide whether an action is allowed for a given principal/resource/context. Denied requests become pending decisions, and the CLI’s `temper decide` flow turns human approvals into hot-loaded policy updates. That means governance is not external paperwork; it is part of the runtime control plane.

9. **WASM integration boundary**
`crates/temper-wasm` and `crates/temper-wasm-sdk` define the sandbox for untrusted or user-authored integration logic. WASM modules run with host functions, telemetry, streaming support, and bounded resource budgets. The server’s state-dispatch and trigger subsystems invoke these modules inline or as background work, which is how app-specific behavior is plugged into the verified core without giving it direct access to the kernel.

10. **Query and API shape**
`crates/temper-odata` handles OData path/query parsing, `$filter`, `$select`, and related read semantics. It is the typed query boundary exposed to clients and SDKs. `crates/temper-sdk` and `packages/temper-sdk-ts` are thin client facades over that HTTP/OData surface, while the server enforces authz and projection rules underneath.

11. **Observability and evolution**
`crates/temper-observe` and the server’s `observe/*` modules provide tracing, metrics, wide events, and trajectory capture. `crates/temper-evolution` stores and analyzes evolution records and feedback loops. This makes runtime behavior auditable and also feeds the platform’s self-improvement workflows, especially in the directed-evolution app and related OS apps.

12. **Operator and integration surfaces**
`crates/temper-cli` is the main operator entrypoint for serving, verifying, deciding, initializing, installing, and bridging MCP. `crates/temper-mcp` exposes a stdio bridge for agent clients. `ui/observe` is the human-facing observability console. `crates/temper-platform` and the `os-apps/*` directories contain higher-level packaged applications built on the kernel, showing how the platform composes into full products.

13. **End-to-end flow to draw**
A useful architecture diagram should show: spec authoring and app packages feed verification; verification gates deploy into the runtime; runtime executes transitions and WASM triggers; the server exposes typed OData/HTTP APIs; authz sits in front of mutation and sensitive reads; storage persists state/events/projections; observe captures traces and evolution records; CLI/MCP/SDKs are the external entrypoints.

14. **Important structural constraint**
The repo is intentionally split so that behavioral truth lives in specs, execution lives in runtime/server, and policy lives in Cedar—not in ad hoc application code. That separation is the main architectural boundary, and most crates exist to preserve it while still allowing hot reload, simulation, and agent-driven extension.

Main entry points: [`crates/temper-server`](https://github.com/nerdsane/temper/tree/main/crates/temper-server) (Server), [`crates/temper-spec`](https://github.com/nerdsane/temper/tree/main/crates/temper-spec) (Spec), [`crates/temper-cli`](https://github.com/nerdsane/temper/tree/main/crates/temper-cli) (CLI), [`crates/temper-wasm`](https://github.com/nerdsane/temper/tree/main/crates/temper-wasm) (WASM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_core["Core kernel"]
  node_temper_spec["Spec"]
  node_temper_verify{{"Verify<br/>verification pipeline"}}
  node_temper_runtime["Runtime"]
  node_temper_jit["JIT<br/>hot swap tables"]
  node_temper_server["Server<br/>HTTP kernel"]
  node_temper_odata["OData<br/>query boundary"]
  node_temper_wasm["WASM<br/>sandbox engine"]
  node_temper_wasm_sdk["WASM SDK<br/>guest SDK"]
  node_temper_observe(("Observe<br/>telemetry core"))
  node_temper_evolution["Evolution<br/>feedback store"]
end

subgraph group_grp_data["Storage & policy"]
  node_temper_authz{{"Authz<br/>Cedar policy engine"}}
  node_store_postgres[("Postgres store<br/>canonical backend")]
  node_store_turso[("Turso store<br/>libSQL backend")]
  node_store_redis[("Redis store<br/>cache/mailbox backend")]
  node_store_sim[("Sim store<br/>deterministic backend")]
end

subgraph group_grp_clients["Clients & UX"]
  node_temper_cli["CLI<br/>operator entrypoint"]
  node_temper_mcp["MCP<br/>stdio bridge"]
  node_sdk_rust["Rust SDK<br/>client facade"]
  node_sdk_ts["TS SDK<br/>client facade"]
  node_ui_observe["Observe UI<br/>web console"]
end

subgraph group_grp_apps["Apps & examples"]
  node_os_apps["OS apps<br/>packaged apps"]
  node_reference_apps["Reference apps<br/>sample systems"]
end

subgraph group_grp_tooling["Tooling & modules"]
  node_wasm_modules["WASM modules<br/>app modules"]
end

node_temper_spec -->|"compile+prove"| node_temper_verify
node_temper_verify -->|"gate deploy"| node_temper_runtime
node_temper_spec -->|"model input"| node_temper_server
node_temper_spec -->|"compile tables"| node_temper_jit
node_temper_jit -->|"swap behavior"| node_temper_runtime
node_temper_runtime -->|"execute actors"| node_temper_server
node_temper_server -->|"serve reads"| node_temper_odata
node_temper_server -->|"authorize actions"| node_temper_authz
node_temper_server -->|"dispatch triggers"| node_temper_wasm
node_temper_wasm -->|"guest host api"| node_temper_wasm_sdk
node_temper_server -->|"persist live state"| node_store_postgres
node_temper_server -->|"alt backend"| node_store_turso
node_temper_server -->|"mailboxes/cache"| node_store_redis
node_temper_server -->|"simulate"| node_store_sim
node_temper_server -->|"emit traces"| node_temper_observe
node_temper_server -->|"record feedback"| node_temper_evolution
node_temper_cli -->|"run verify"| node_temper_verify
node_temper_cli -->|"serve kernel"| node_temper_server
node_temper_cli -->|"decide"| node_temper_authz
node_temper_cli -->|"bridge agents"| node_temper_mcp
node_sdk_rust -->|"http client"| node_temper_server
node_sdk_ts -->|"api client"| node_temper_server
node_ui_observe -->|"inspect system"| node_temper_server
node_os_apps -->|"define apps"| node_temper_spec
node_os_apps -->|"ship modules"| node_temper_wasm
node_reference_apps -->|"demonstrate"| node_temper_spec
node_reference_apps -->|"exercise kernel"| node_temper_server
node_wasm_modules -->|"execute in sandbox"| node_temper_wasm
node_temper_observe -->|"visualize"| node_ui_observe
node_temper_evolution -->|"drive loops"| node_os_apps

click node_temper_spec "https://github.com/nerdsane/temper/tree/main/crates/temper-spec"
click node_temper_verify "https://github.com/nerdsane/temper/tree/main/crates/temper-verify"
click node_temper_runtime "https://github.com/nerdsane/temper/tree/main/crates/temper-runtime"
click node_temper_jit "https://github.com/nerdsane/temper/tree/main/crates/temper-jit"
click node_temper_server "https://github.com/nerdsane/temper/tree/main/crates/temper-server"
click node_temper_odata "https://github.com/nerdsane/temper/tree/main/crates/temper-odata"
click node_temper_wasm "https://github.com/nerdsane/temper/tree/main/crates/temper-wasm"
click node_temper_wasm_sdk "https://github.com/nerdsane/temper/tree/main/crates/temper-wasm-sdk"
click node_temper_authz "https://github.com/nerdsane/temper/tree/main/crates/temper-authz"
click node_store_postgres "https://github.com/nerdsane/temper/tree/main/crates/temper-store-postgres"
click node_store_turso "https://github.com/nerdsane/temper/tree/main/crates/temper-store-turso"
click node_store_redis "https://github.com/nerdsane/temper/tree/main/crates/temper-store-redis"
click node_store_sim "https://github.com/nerdsane/temper/tree/main/crates/temper-store-sim"
click node_temper_observe "https://github.com/nerdsane/temper/tree/main/crates/temper-observe"
click node_temper_evolution "https://github.com/nerdsane/temper/tree/main/crates/temper-evolution"
click node_temper_cli "https://github.com/nerdsane/temper/tree/main/crates/temper-cli"
click node_temper_mcp "https://github.com/nerdsane/temper/tree/main/crates/temper-mcp"
click node_sdk_rust "https://github.com/nerdsane/temper/tree/main/crates/temper-sdk"
click node_sdk_ts "https://github.com/nerdsane/temper/tree/main/packages/temper-sdk-ts"
click node_ui_observe "https://github.com/nerdsane/temper/tree/main/ui/observe"
click node_os_apps "https://github.com/nerdsane/temper/tree/main/os-apps"
click node_reference_apps "https://github.com/nerdsane/temper/tree/main/reference-apps"
click node_wasm_modules "https://github.com/nerdsane/temper/tree/main/wasm-modules"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_temper_spec,node_temper_verify,node_temper_runtime,node_temper_jit,node_temper_server,node_temper_odata,node_temper_wasm,node_temper_wasm_sdk,node_temper_observe,node_temper_evolution toneBlue
class node_temper_authz,node_store_postgres,node_store_turso,node_store_redis,node_store_sim toneAmber
class node_temper_cli,node_temper_mcp,node_sdk_rust,node_sdk_ts,node_ui_observe toneMint
class node_os_apps,node_reference_apps toneRose
class node_wasm_modules toneIndigo
```

## Components

### Core kernel

Spec, verification, runtime, server, and extensibility boundary.

- [Spec](https://github.com/nerdsane/temper/tree/main/crates/temper-spec): spec compiler · Parses IOA and CSDL into the canonical automaton/model used as behavioral truth. · `crates/temper-spec`
- [Verify](https://github.com/nerdsane/temper/tree/main/crates/temper-verify): verification pipeline · Runs symbolic checks, model checking, simulation, and property-based tests before deployment. · `crates/temper-verify`
- [Runtime](https://github.com/nerdsane/temper/tree/main/crates/temper-runtime): actor runtime · Generic actor system with mailboxes, persistence hooks, scheduling, and supervision. · `crates/temper-runtime`
- [JIT](https://github.com/nerdsane/temper/tree/main/crates/temper-jit): hot swap tables · Builds and swaps compiled transition tables while the runtime stays live. · `crates/temper-jit`
- [Server](https://github.com/nerdsane/temper/tree/main/crates/temper-server): HTTP kernel · Main API kernel for routing, entity dispatch, state management, triggers, projections, blobs, and workflow execution. · `crates/temper-server`
- [OData](https://github.com/nerdsane/temper/tree/main/crates/temper-odata): query boundary · Parses typed read paths and query semantics such as filter and select. · `crates/temper-odata`
- [WASM](https://github.com/nerdsane/temper/tree/main/crates/temper-wasm): sandbox engine · Runs untrusted integration logic with host functions, telemetry, streaming, and bounded resources. · `crates/temper-wasm`
- [WASM SDK](https://github.com/nerdsane/temper/tree/main/crates/temper-wasm-sdk): guest SDK · Host-facing SDK for WASM modules to access context, streaming, and host APIs. · `crates/temper-wasm-sdk`
- [Observe](https://github.com/nerdsane/temper/tree/main/crates/temper-observe): telemetry core · Tracing, metrics, wide events, trajectory capture, and observability storage helpers. · `crates/temper-observe`
- [Evolution](https://github.com/nerdsane/temper/tree/main/crates/temper-evolution): feedback store · Stores and analyzes evolution records, insights, and feedback loops. · `crates/temper-evolution`

### Storage & policy

Persistence backends and authorization/governance.

- [Authz](https://github.com/nerdsane/temper/tree/main/crates/temper-authz): Cedar policy engine · Evaluates authorization and supports governance decisions and policy generation. · `crates/temper-authz`
- [Postgres store](https://github.com/nerdsane/temper/tree/main/crates/temper-store-postgres): canonical backend · Primary production persistence path for platform state, events, projections, and metadata. · `crates/temper-store-postgres`
- [Turso store](https://github.com/nerdsane/temper/tree/main/crates/temper-store-turso): libSQL backend · Alternative storage backend for platform persistence and query paths. · `crates/temper-store-turso`
- [Redis store](https://github.com/nerdsane/temper/tree/main/crates/temper-store-redis): cache/mailbox backend · Distributed mailbox and cache support for runtime coordination. · `crates/temper-store-redis`
- [Sim store](https://github.com/nerdsane/temper/tree/main/crates/temper-store-sim): deterministic backend · In-memory simulation backend for deterministic testing and verification flows. · `crates/temper-store-sim`

### Clients & UX

Operator, SDK, and human-facing surfaces.

- [CLI](https://github.com/nerdsane/temper/tree/main/crates/temper-cli): operator entrypoint · Serves, verifies, decides, initializes, installs, and bridges MCP for operators. · `crates/temper-cli`
- [MCP](https://github.com/nerdsane/temper/tree/main/crates/temper-mcp): stdio bridge · Agent-facing stdio bridge into the Temper runtime and control plane. · `crates/temper-mcp`
- [Rust SDK](https://github.com/nerdsane/temper/tree/main/crates/temper-sdk): client facade · Rust client for Temper HTTP and OData surfaces. · `crates/temper-sdk`
- [TS SDK](https://github.com/nerdsane/temper/tree/main/packages/temper-sdk-ts): client facade · TypeScript client for the Temper API surface. · `packages/temper-sdk-ts`
- [Observe UI](https://github.com/nerdsane/temper/tree/main/ui/observe): web console · Human-facing observability and governance console. · `ui/observe`

### Apps & examples

Packaged Temper apps and reference systems built on the kernel.

- [OS apps](https://github.com/nerdsane/temper/tree/main/os-apps): packaged apps · Temper-native application packages built on the kernel and specs. · `os-apps`
- [Reference apps](https://github.com/nerdsane/temper/tree/main/reference-apps): sample systems · Example applications demonstrating Temper patterns and integrations. · `reference-apps`

### Tooling & modules

Build, integration, and standalone WASM/module artifacts.

- [WASM modules](https://github.com/nerdsane/temper/tree/main/wasm-modules): app modules · Standalone compiled WASM artifacts used by apps and experiments. · `wasm-modules`

## Connections

- Spec → Verify: compile+prove · Specs are parsed and verified before deployment.
- Verify → Runtime: gate deploy · Verified behavior is allowed into the live runtime.
- Spec → Server: model input · The server consumes canonical spec/model definitions.
- Spec → JIT: compile tables · Specs drive transition-table generation for hot swapping.
- JIT → Runtime: swap behavior · Compiled behavior is loaded without stopping the runtime.
- Runtime → Server: execute actors · The server hosts entity actors and runtime-driven workflows.
- Server → OData: serve reads · Read/query semantics are exposed through OData paths.
- Server → Authz: authorize actions · Sensitive reads and mutations are policy-checked.
- Server → WASM: dispatch triggers · State transitions and triggers invoke WASM modules.
- WASM → WASM SDK: guest host api · Modules depend on the sandbox SDK for host interaction.
- Server → Postgres store: persist live state · Primary persistence path for production data.
- Server → Turso store: alt backend · Secondary storage backend for compatible deployments.
- Server → Redis store: mailboxes/cache · Redis supports distributed coordination concerns.
- Server → Sim store: simulate · Deterministic simulation uses the in-memory backend.
- Server → Observe: emit traces · Runtime activity is captured for observability.
- Server → Evolution: record feedback · Evolution data and insights are materialized from runtime activity.
- CLI → Verify: run verify · Operators can invoke verification from the CLI.
- CLI → Server: serve kernel · CLI boots and manages the kernel process.
- CLI → Authz: decide · Human decisions update governance state and policies.
- CLI → MCP: bridge agents · CLI exposes an MCP bridge for agent clients.
- Rust SDK → Server: http client · Rust SDK consumes the server API surface.
- TS SDK → Server: api client · TypeScript SDK targets the same HTTP/OData surface.
- Observe UI → Server: inspect system · The web console reads from the platform API and observability feeds.
- OS apps → Spec: define apps · Packaged applications contribute their own specs and policies.
- OS apps → WASM: ship modules · OS apps include app-specific WASM modules.
- Reference apps → Spec: demonstrate · Reference systems provide example specs and patterns.
- Reference apps → Server: exercise kernel · Reference apps run through the server/runtime stack.
- WASM modules → WASM: execute in sandbox · Standalone modules are loaded by the WASM engine.
- Observe → Observe UI: visualize · Observability data is presented in the UI console.
- Evolution → OS apps: drive loops · Evolution records inform higher-level OS app workflows.
