Early Preview (v0.6.0) · Open Source · Report issues on GitHub →

ContextUnity

An open R&D and service-mesh platform for building your own AI applications without cloud provider dependencies or vendor lock-in. Powering multiple products in active development with stateless LangGraph orchestration, durable Temporal execution, hybrid memory, and zero-trust security.

Actively developed in the open — built for teams and enthusiasts who want to experiment, self-host, and run real multi-agent systems on their own hardware.

git clone https://github.com/ContextUnity/contextunity.git && cd contextunity
uv sync --all-packages
uv run contextunity local init && uv run contextunity local up
git clone https://github.com/ContextUnity/contextunity.git && cd contextunity
cp .env.example .env
./scripts/cu-docker.sh start
Why ContextUnity

Ad-hoc agent glue vs a governed service mesh

Most agent stacks tangle prompts, secrets, memory queries, and retries inside a single process. ContextUnity separates orchestration, memory, execution, security, and observability behind one typed contract.

Ad-Hoc Agent Scripts

Where prototypes break in production

  • Hardcoded prompts & keys — credentials and system prompts leak across every tool call.
  • Ephemeral state — in-process loops vanish on crash or worker restart.
  • Vector-only RAG — flat similarity search misses multi-hop structural dependencies.
  • No operator visibility — zero audit trail, replay, or human review queue for failed verdicts.
ContextUnity Service Mesh

Typed contracts & isolated boundaries

  • Manifest-driven DAGs — declarative YAML workflows compiled into stateless LangGraph 1.2 graphs.
  • Local-to-Temporal parity — develop on PATH L, deploy unchanged to PATH T Temporal workers.
  • Graph-first hybrid memory — CellEdges traversal + BrainSynapse Q-learning + pgvector fallback.
  • Fail-closed zero trust — attenuated per-node tokens and read-only ContextForge inspection.
Orchestration & Durability

Stateless Router, Durable Worker

ContextRouter compiles project manifests into stateless LangGraph 1.2 DAGs, while ContextWorker guarantees execution across local and Temporal backends.

ManifestYAML + Schema
RouterLangGraph 1.2
EnvelopeContextUnit
WorkerPATH L / PATH T
OutcomeFinalVerdict

Every service communicates over typed gRPC contracts (L1 / L2 / L3 type boundaries →).

Progressive Adoption · ADR-0016

One codebase from laptop loopback to Temporal

  1. Start the local loopback mesh Run contextunity local up with SQLite and PATH L in-process workers — zero Docker required.
  2. Declare graphs in contextunity.project.yaml Bind models, memory scopes, and per-node ContextShield permissions declaratively.
  3. Invoke federated tools & typed SDK Expose domain logic from your own apps as @federated_tool handlers called by Router over bidirectional gRPC streams — zero DB credentials ever leave your app.
  4. Switch to production runtime Point config at PostgreSQL, Redis, pgvector, and PATH T Temporal workers without changing node or tool code.
apiVersion: "contextunity/v1alpha10"
project:
  id: "support-triage"
router:
  graph:
    triage:
      template: "yaml:agent_loop"
      shield_scopes: ["shield:secrets:read"]
      memory_scope: "project:support"
  config:
    policy:
      models:
        llm:
          default: "${CU_DEFAULT_MODEL}"
      worker:
        path: "temporal"  # PATH T in prod, PATH L locally
from contextunity.core.sdk import ContextUnityClient

async with ContextUnityClient.from_env() as client:
    verdict = await client.run_workflow(
        "contextunity.project.yaml",
        unit={"ticket_id": "CU-402", "tenant_id": "acme"},
    )
    print(verdict.status, verdict.observations)
ContextBrain · ADR-0011

Five memory modules. Graph-first, vector-fallback.

ContextBrain resolves relational structure before falling back to semantic embeddings, and uses Q-learning feedback from final verdicts to rank useful recall paths.

Module 1 & 2

Blackboard & BrainCell

Blackboard coordinates active run state and handoffs; BrainCell stores canonical, versioned knowledge units with provenance, tenant isolation, and TTL policies.

Module 3

CellEdges (Graph-First Recall)

Explicit causal, dependency, and hierarchy edges are traversed first for exact multi-hop context without drowning the prompt in noisy nearest-neighbor chunks.

Module 4

BrainSynapse (Q-Learning)

Reinforcement updates from FinalVerdict outcome observations adjust edge weights over time so high-signal paths rise and stale paths prune.

Module 5

BrainEngram (Vector Fallback)

pgvector semantic index activates only when graph traversal falls below coverage threshold, backed by background consolidation workflows.

Recall Flow1. Blackboard → 2. CellEdges (graph) → 3. BrainSynapse (Q-rank) → 4. BrainEngram (pgvector fallback) → 5. Verdict Q-update
Security & Observability

Zero-trust enforcement & read-only visibility

ContextShield enforces fail-closed authorization and attenuated node tokens on every call, while ContextForge gives operators full trace visibility without mutating runtime state.

DimensionContextShield (Zero-Trust Gate)ContextForge (Observability Console)
Primary RoleToken attenuation, prompt secrecy, tenant & tool policy enforcementRead-only trace inspection, review queues, and Lab mode experiments
Security PostureFail-closed gRPC interceptors; shield:secrets:write / shield:secrets:readZero mutation privileges over Router or Worker control planes
Core Abstractions4 actors · 4 orthogonal boundaries · per-node attenuated tokensForgeLibrarian diagnostics · Django + GridViewSpec + HTMX
Failure ModeExplicit denial with structured audit event; never leaks raw credentialsSurfaces FinalVerdict outcome observations & drift alerts
Live Documentation

Service specs, boundaries & ADRs

Synchronized directly from the core repository. Inspect any service contract or architectural decision record.

contextunity-router

Stateless LangGraph 1.2 Orchestrator

Compiles YAML manifests into runnable DAGs, enforces per-node capability stripping, and streams BiDi tool calls.

EntrygRPC + Manifest
Runtime GuaranteesL1 / L2 / L3
- Stateless DAG execution per ContextUnit request
- Per-node attenuated tokens minted via ContextShield
- Federated @federated_tool invocation over gRPC BiDi streams
- Strict type boundaries via contextunity.core.types
contextunity-brain

5-Module Hybrid Memory Engine

Graph-first traversal across CellEdges with BrainSynapse Q-learning and pgvector Engram fallback.

ADRADR-0011
Memory Modules5 Layers
1. Blackboard    — run-scoped working memory
2. BrainCell     — canonical versioned knowledge entities
3. CellEdges     — explicit relational graph traversal
4. BrainSynapse  — Q-learning recall weight updates
5. BrainEngram   — pgvector semantic fallback & consolidation
contextunity-worker

Durable Execution Engine

Runs identical workflow definitions on local PATH L runners or Temporal PATH T clusters.

ADRADR-0016
Execution ModesPATH L / PATH T
- PATH L: Fast local async runner for laptop & CI
- PATH T: Temporal Server durable timers, heartbeats & replay
- CAS-versioned WorkflowRunRecord & 5-actor registry
contextunity-shield

Zero-Trust Security Boundary

Holds canonical prompts and secrets, attenuates node scopes, and writes structured security audit records.

PostureFail-Closed
Authorization Boundaries4 Actors
- Bootstrap writes require shield:secrets:write
- Prompt reads require shield:secrets:read + project/node/tenant checks
- ContextShadower PII protection & SecurityAuditRecord trail
contextunity-forge

Read-Only Observability Console

Inspects runs, graph lineage, review queues, and Lab mode experiments without mutating production planes.

StackDjango + HTMX
Operator SurfacesRead-Only
- Trace & Graph Journey inspection
- Review Queues emitting Brain ReportOutcomeObservation
- ForgeLibrarian continuous architecture & docs diagnostics
Platform Roadmap · Near-Term & Direction

Iterative lockstep releases & architectural horizon

Every workspace package releases synchronously under lockstep versioning (v0.X.Y) so cross-service contracts remain guaranteed compatible. Below are the next four iterations — inspect the Full Roadmap (0.6 → 0.14) → or browse live ACDD milestones on GitHub →

v0.6 · Next

Hardened Core & Local Brain

Unified token UUIDs, secret-safe CLI diagnostics, local CLI provider subscriptions, in-proc test harnesses, and Brain Q-aging with local embeddings.

v0.7

Durable Runtime Spine

Worker CAS run records with recovery provenance and Huey cron, ShieldVault PostgreSQL + Ed25519/KMS signer, and service-principal trace artifacts.

v0.8

SDK, Live UI & Headless Lab

Lightweight contextunity-sdk + pip install contextunity metapackage, AG-UI/A2UI transport, Headless Lab kernel, and Forge Lineage + Librarian.

v0.9

Dynamic DAGs, Channels & ACP

LangGraph 1.2 inline/durable Task DAGs, parallel batch nodes, Telegram channel connectors, ACP coding adapter, and RouterArchitect immune planning.

Next Track · 0.10 – 0.14
Citadel Effect Auth, Multi-Tenancy & ConstitutionLinux Sandboxes, TestMan Gates & OTLP AuditForge HITL Review Queues & Governed MemoryAdaptive ContextRank, Backups & Path-Scope RLSTOON Compression, ContextSeed & SQLite ↔ Postgres
0.15+ Horizon
Teacher–Student RLM & LoRA Hot-SwappingWire CodecNegotiation & Dialectic MemoryContextStorage CRDT Sync & P2P MeshM2M Economy & Temporal Escrow

Build your own sovereign AI applications

Apache 2.0 open-source R&D platform with zero cloud or vendor lock-in — already powering multiple products in active development.