Home/Docs/Getting Started/Platform Overview

ContextUnityπŸ”—

The Open, Zero-Trust AI Service Mesh You Actually OwnπŸ”—

Memory Β· Agency Β· Durable Execution Β· Cryptographic Isolation Β· Read-Only Observability

Zero cloud provider lock-in. Zero vendor lock-in. Built for teams shipping real sovereign AI applications.

License: Apache 2.0 Python 3.13+ Status: Early Preview v0.5.x Docs: contextunity.com ACDD Spec-Driven

Documentation Β· Manifesto Β· Roadmap (0.6 β†’ 0.14) Β· Architecture & ADRs Β· Report an Issue


Why ContextUnity?πŸ”—

Most modern "AI agent frameworks" force an uncomfortable choice:

  1. Thin prompt wrappers that fall apart the moment you need durable retries, multi-tenant isolation, real memory beyond naive vector chunks, or an audit trail.
  2. Hosted black-box agent clouds that lock you into one provider, burn tokens on redundant loops, and force you to hand over database credentials and private business data.

ContextUnity is an open-source, modular AI service mesh designed for teams building real AI products they fully own β€” running identically on a single developer laptop (SQLite + Huey + loopback gRPC) and on a production cluster (PostgreSQL + pgvector + Temporal + mTLS/KMS).

Early Preview (v0.5.x): ContextUnity is an active open R&D and application platform already powering multiple real products in development. Contracts and manifests are stabilizing across continuous lockstep iterations (0.6 β†’ 0.14+). Feedback, bug reports, and contributions are welcome on GitHub Issues.


Architecture at a GlanceπŸ”—

ContextUnity separates orchestration, memory, execution, security, and observability into five typed gRPC services speaking a single protocol (ContextUnit), while your application code and database credentials stay strictly inside your own project perimeter.

flowchart LR
    App["Your Application / Project<br/>contextunity.project.yaml<br/>(@federated_tool handlers Β· private DB)"]

    subgraph Mesh["ContextUnity Service Mesh (gRPC Β· ContextUnit Β· Attenuated ContextToken)"]
        Router["ContextRouter<br/>Stateless LangGraph 1.2 DAGs<br/>Model Routing Β· PII Masking"]
        Brain["ContextBrain<br/>5-Module Hybrid Memory<br/>Graph-First Β· Vector Fallback"]
        Worker["ContextWorker<br/>PATH L (Huey) / PATH T (Temporal)<br/>Durable Workflows Β· Sandboxes"]
        Shield["ContextShield<br/>Zero-Trust Citadel<br/>Secrets Β· Attenuation Β· Firewall"]
        Forge["ContextForge<br/>Read-Only Observability<br/>Traces Β· UDB Β· Review Queues"]
    end

    App <-->|"BiDi gRPC Stream<br/>(Intents & Tool Results)"| Router
    Router <--> Brain
    Router <--> Shield
    Router <--> Worker
    Worker <--> Brain
    Worker <--> Shield
    Forge -.->|"Read-Only Queries"| Brain
    Forge -.->|"Read-Only Queries"| Shield
    Forge -.->|"Read-Only Queries"| Worker

Core Services & Workspace PackagesπŸ”—

Every package in this repository lives in a single uv workspace and ships under strict lockstep versioning (v0.X.Y) β€” any packages sharing the same 0.X.* minor version are guaranteed contract-compatible over gRPC and ContextUnit.

ModulePackageRoleKey Capabilities
Core Kernelcontextunity-coreShared Contracts & SDKContextUnit protobufs, ContextToken signing/attenuation, typed L0–L4 boundaries, gRPC clients, manifest models.
CLIcontextunity-cliOperator & Dev Shellcontextunity local up, config bootstrap, diagnostics, memory & manifest commands (same contracts as SDK/MCP).
Django Adaptercontextunity-djangoWeb IntegrationTyped Django client integration and GridViewSpec helpers for host web apps.
ContextRoutercontextunity-routerMind & TransportStateless LangGraph 1.2 compilation from manifests, multi-provider LLM gateway, fallback chains, RouterShadower PII masking.
ContextBraincontextunity-brainFlat Hybrid MemoryBlackboard, BrainCell, CellEdges, BrainSynapse (3D Q-learning), BrainEngram compiled surfaces, and UniversalDebugBus (UDB).
ContextWorkercontextunity-workerDurable ExecutionEngine-neutral workflows running locally (PATH L / Huey) or distributed (PATH T / Temporal) with actors & schedules.
ContextShieldcontextunity-shieldThe CitadelPer-node capability stripping, AI firewall, prompt & secret vault, Ed25519/KMS signing, audit trail, Constitution gates.
ContextForgecontextunity-forgeObservability ConsoleRead-only Django + HTMX + GridViewSpec UI for Graph Journey, UDB cases, Context Lineage, Review Queues, and ForgeLibrarian.

Where does domain business logic live? Always in your own application or extension repository (e.g., Commerce PIM, Knowledge Base, or custom products). ContextUnity provides the cognitive, durable, and security substrate β€” never a monolith that absorbs your business domain.


Core Design PrinciplesπŸ”—

  1. Inversion of Control (Federated Execution): ContextUnity never asks for your application database DSN or credentials. Agents emit typed intents; your application executes @federated_tool handlers inside its own perimeter over authenticated bidirectional gRPC streams (ADR-0001).
  2. Manifest-First (contextunity.project.yaml): Projects declare graphs, model policies, orchestration roles, and allowed toolkits in one strictly validated YAML file β€” zero orchestration boilerplate (ADR-0002).
  3. Graph-First, Vector-Fallback Memory: ContextBrain traverses spatial scope_path, explicit CellEdges, compiled BrainEngrams, and sparse BM25 first, invoking vector search only as a bounded fallback. BrainSynapse tracks 3D Q-values and separates agent faults from infra faults (ADR-0011, ADR-0018).
  4. Zero-Trust Capability Attenuation: No agent holds ambient privileges. ContextRouter strips ContextToken permissions per graph node from the project manifest; gRPC interceptors and PostgreSQL Row-Level Security (RLS) enforce tenant and project isolation fail-closed (ADR-0017).
  5. Pass-by-Reference & Encrypted Offload: Inter-service calls pass lightweight UUID pointers rather than megabytes of raw prompts; large or sensitive artifacts offload under Shield envelope encryption (ADR-0004, ADR-0015).
  6. Graceful Degradation (PATH L ↔ PATH T): Same manifest, same SDK methods, same payloads, same tests β€” from a single laptop to a production cluster (ADR-0016):
LayerLocal Loopback (PATH L)Production Cluster (PATH T)
Memory (ContextBrain)SQLite + optional sqlite-vecPostgreSQL + pgvector + RLS
Execution (ContextWorker)Huey / in-process durable runnerTemporal Server
Service DiscoveryIn-memory / loopbackRedis + gRPC
Security (ContextShield)Local HMAC / dev signerEd25519 / KMS + mTLS + ShieldVault PG

5-Minute QuickstartπŸ”—

Requires Python 3.13+ and uv.

# 1. Clone and install all workspace packages
git clone https://github.com/ContextUnity/contextunity.git
cd contextunity
uv sync --all-packages

# 2. Install local Git quality hooks (pre-commit + pre-push)
./scripts/install-hooks.sh

# 3. Mint local development keys (via mise, or set env vars per .env.example)
mise run mint-hmac
mise run mint-shield

# 4. Boot the full local loopback mesh (Router, Brain, Worker, Shield, Forge)
uv run contextunity local up

Connecting a Project (contextunity.project.yaml)πŸ”—

apiVersion: "contextunity/v1alpha8"
project:
  id: "my-app"
  name: "My Sovereign AI App"

router:
  default_graph: "assistant"
  config:
    models:
      llm:
        default: "openai/gpt-4o-mini"
  graph:
    assistant:
      template: "local"
      nodes:
        - name: "responder"
          type: "agent"
          tools:
            - "federated:InventoryToolkit.lookup_sku"

Your app connects over the SDK, registers @federated_tool handlers over a BiDi stream, and never exposes internal database credentials to the AI mesh.


Platform Roadmap (0.6 β†’ 0.14 & 0.15+)πŸ”—

ContextUnity ships as continuous, dependency-ordered lockstep iterations (0.6 β†’ 0.14+) rather than a single monolithic 1.0 cutoff. Every minor release delivers a compact, verifiable vertical slice across coupled services with zero backward release dependencies.

Near-Term ReleasesπŸ”—

ReleaseFocusWhat Ships
0.6 (Next)Hardened Core, Local Brain & Dev SpineUnified token UUIDs (P-001), secret-safe CLI diagnostics & live BiDi contract (P-101), local CLI provider subscriptions (claude/codex/gemini) & SQL guards (R-103), in-process test harnesses (P-203), Brain Phase-5 receipts, Q-aging & default local embeddings (B-001).
0.7Durable Runtime SpineWorker CAS-versioned WorkflowRunRecord + ADR-0008 recovery provenance + Huey cron (W-001), ShieldVault PostgreSQL + live secret auth + SecurityAudit (S-001), Ed25519/KMS signer (S-002), service-principal trace artifacts (P-002).
0.8SDK, Live UI & Headless LabLightweight contextunity-sdk + umbrella pip install contextunity metapackage (P-205), AG-UI/A2UI protocol alignment (P-204), Headless Lab CLI/lab:// MCP memory kernel (B-101), Forge Graph Journey / UDB / Lineage views (F-001) & ForgeLibrarian (F-101).
0.9Dynamic DAGs, Channels & ACPStateless LangGraph 1.2 inline/durable Task DAGs, type: parallel batch nodes & BlackboardSticker admission (R-201), bidirectional channel connectors + Telegram adapter (R-202), ACP coding-graph adapter (R-203), RouterArchitect with Immune Memory Recall & "verifier" role (R-301).

Subsequent Track (0.10 β†’ 0.14)πŸ”—

  • 0.10 β€” Citadel Effects, Tenancy & Constitution: Paired Shield Effect Authorization & ADR-0015 encrypted offload (S-101), multi-tenant lifecycle & tenant CLI (S-301), WorkerStrongman heavy-job budgets (W-101), Shield Constitution AST gate + non-configurable HarmlessInvariant floor (S-202).
  • 0.11 β€” Sandboxed Execution, Eval Gates & Audit: O(1) KEK shadow-swap rotation & signed _audit (S-201), Shield admin CLI + OTLP audit export (S-102), ephemeral Linux WorkerSandman sandbox (W-102), WorkerTestMan/WorkerAuditor (W-201), autonomous candidate pipelines (W-202).
  • 0.12 β€” Forge HITL, Economics & Governed Memory: Forge Security/Tenant & Worker/TestMan views + Review Queues emitting Brain outcome feedback (F-201), Router token economics reconciliation (R-401), DualGating + first-class no-change states + Memory Linter (B-201), Supervised Lab Mode & HITL policy sync (F-202).
  • 0.13 β€” Adaptive Memory, Backups & Path RLS: Derived ContextRank, durable Procedure auto-recall & default-off epsilon-greedy exploration (B-202), encrypted ContextSnapshot/v1 backup/restore drills (B-301), Engram path-scope PostgreSQL RLS isolation (B-402).
  • 0.14 β€” Portability, Compression & Prod Parity: Production TOON ContextProjection & EngramIndex pinning (R-501), signed ContextSeed universal packages & local-first Registry (B-501), bidirectional SQLite ↔ PostgreSQL migration (B-502), verified multi-owner tenant retirement & legal holds (S-302), and live no-mocks PATH L/PATH T parity & p95 baseline gate (P-110).

Evolutionary Horizon (0.15+)πŸ”—

Long-term research tracks live in docs/plans/backlog/: Teacher–Student RLM & LoRA hot-swapping, wire-level CodecNegotiation (Immutable Envelope / Mutable Payload), Dialectic depth-escalating retrieval & Spreading Activation, inter-agent Peer Representations, ContextStorage CRDT edge sync, WireGuard/Tailscale P2P mesh, and M2M Economy / Temporal Escrow.

πŸ‘‰ Read the full narrative in docs/roadmap.md or inspect all 39 executable milestone specs in docs/milestones/.


Where the Documentation LivesπŸ”—

ResourceLocationWhat You'll Find
Documentation Websitecontextunity.com/docsSearchable guides, Manifesto, service deep dives, and synced architecture docs.
ACDD Spec-Driven Engineacdd.contextunity.comThe open-source spec, code-map, and verification workflow powering this repo.
Architecture & Contractsdocs/architecture/Service boundaries, ContextUnit protocol, L0–L4 type boundaries, security model, local/prod parity.
ADRsdocs/adr/Accepted Architecture Decision Records (ADR-0001 through ADR-0019).
Live Milestones & Backlogdocs/milestones/ Β· docs/plans/backlog/Executable ACDD milestone contracts (0.6 β†’ 0.14) and 0.15+ research specs.
Testing & Quality GatesTESTS.md Β· docs/testing/independent-review.mdTest taxonomy, markers, in-proc vs live suites, and review criteria.
Release & Lockstep Versioningdocs/development/release.mdLockstep v0.X.Y release process across all workspace packages on PyPI.

Contributing & CommunityπŸ”—

We welcome contributors β€” whether you are fixing a bug, improving docs, adding a model/channel adapter, or tackling a milestone in docs/milestones/.

Development Workflow & Quality BarπŸ”—

ContextUnity enforces strict, automated engineering gates so every PR stays clean and verifiable:

  1. Fork & install workspace + hooks:
    uv sync --all-packages
    ./scripts/install-hooks.sh
  2. Run local quality gates before opening a PR:
    # Lint & strict typing (0 errors required)
    uv run ruff check packages/ services/ scripts/ tests/
    uv run basedpyright --level error
    
    # Changed-owner lightweight test suite (same gate as pre-push hook)
    python3 scripts/test_gate.py pre-push
    
    # Regenerate protobuf stubs when editing packages/core/protos/
    uv run python scripts/build_protos.py
  3. Run ACDD architectural linting & keep AI-assisted coding predictable:
    • ContextUnity uses ACDD (.acdd/lint/zones.yaml, .acdd/lint/rules.yaml, and executable inline ```acdd-rule blocks in architecture docs) to enforce module isolation, graph boundaries, AST security guards, and doc-to-code symbol integrity so both human and AI contributors operate against machine-checked contracts rather than implicit conventions:
      # Validate manifests, lint rules, and documentation links/invariants
      acdd validate && acdd docs check && acdd lint --categories arch,docs
    • Before making architectural or cross-module edits, inspect dependencies and invariants via acdd query overview|search|inspect|impact (or the ACDD MCP tools).
  4. Follow repository contracts:
    • All shared JSON/gRPC contracts live in contextunity.core (type-boundaries.md).
    • Never bypass tenant/project isolation or introduce silent except Exception swallows (delivery-readiness.md).
    • Include focused regression tests covering both happy and fail-closed paths (TESTS.md).
    • For AI-assisted contributors, follow AGENTS.md and docs/AGENTS.md for ACDD workflow conventions, verified symbol links, and canonical INV-*: invariants.

Issues, Ideas & SecurityπŸ”—

  • Bugs & Feature Requests: Open a ticket on GitHub Issues.
  • Roadmap & Architecture Discussions: Check docs/milestones/ and docs/adr/ before proposing large structural changes.
  • Security Vulnerabilities: Please report security issues privately via GitHub Security Advisories rather than posting exploit details in public issues.

LicenseπŸ”—

Licensed under the Apache License 2.0 β€” see LICENSE for full terms.