cambium ▸ OVERVIEW.md
updated 2026-03-20

Cambium: Platform Overview

Cambium is a nature-based orchestration platform for resilient agent systems. Where conventional platforms model agents as workers in a bureaucracy (queues, dispatchers, supervisors), Cambium models them as organisms in an ecosystem — with nervous systems, immune responses, environmental coordination, and lifecycle from birth through death to composting.

Built as a modular TypeScript monolith across 18 packages and ~26k lines of code.


The Big Picture

                          ┌──────────────────┐
                          │       Loom        │  Operator UI (Next.js)
                          │  React Flow + SSE │  Visualize, control, approve
                          └────────┬─────────┘
                                   │
                    ┌──────────────┴──────────────┐
                    │           Cortex             │  The Brain
                    │  Intent → Graph → Execution  │  Decomposes natural language
                    └──────────────┬───────────────┘  into executable workflows
                                   │
         ┌─────────────────────────┼─────────────────────────┐
         │                         │                         │
    ┌────┴─────┐           ┌──────┴──────┐           ┌──────┴──────┐
    │  Genesis  │           │    Hypha     │           │  Providers   │
    │  Spawn    │           │  Execute     │           │  LLMs, APIs  │
    │  agents   │           │  DAG graphs  │           │  Tools       │
    └────┬─────┘           └──────┬──────┘           └─────────────┘
         │                        │
         │               ┌───────┴────────┐
         │               │                │
    ┌────┴─────┐   ┌─────┴─────┐   ┌─────┴─────┐
    │  Agents   │   │ Workflows  │   │Integrations│
    │  Runtime  │   │ Definitions│   │ Tool Exec  │
    └──────────┘   └───────────┘   └───────────┘

    ════════════════ Nervous System ════════════════

    ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐
    │ Signals   │  │  Health   │  │  Immune   │  │ Quorum   │
    │ Bus +     │  │ Stress   │  │ Anomaly   │  │ Approval │
    │ Cascades  │  │ Detection│  │ + Trust   │  │ Gates    │
    └──────────┘  └──────────┘  └──────────┘  └──────────┘

    ═══════════════ Environment Layer ═════════════

    ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐
    │Stigmergy  │  │   Seed    │  │  Events   │  │  Audit   │
    │ Markers + │  │Checkpoint │  │ Historical│  │ Immutable│
    │ Regions   │  │ + Replay  │  │ Record    │  │ Trail    │
    └──────────┘  └──────────┘  └──────────┘  └──────────┘

    ═════════════ Autonomic Lifecycle ═════════════

    ┌─────────────────────────────────────────────┐
    │              Lifecycle Engine                 │
    │   Sense → Accumulate → Evaluate → Act → Learn│
    └─────────────────────────────────────────────┘

    ═══════════════ Persistence ═══════════════════

    ┌─────────────────────────────────────────────┐
    │         PostgreSQL (16 tables)                │
    │         Drizzle ORM · @cambium/db             │
    └─────────────────────────────────────────────┘

Packages

Core Infrastructure

@cambium/core — Type Foundation

The shared type library. Defines branded ID types (AgentId, SignalId, WorkflowRunId, etc.) and all domain contracts. Every other package imports from here. No runtime logic — pure types.

Key type domains: Signals, Workflows (DAG graphs), Agents (lifecycle states), Governance (decisions), Stigmergy (markers/regions), Providers (LLM/API auth), Auth Profiles, Intents.

@cambium/db — PostgreSQL Persistence

16 Drizzle ORM store implementations mapping every domain entity to Postgres. Tables cover workflow definitions, runs, task executions, signals, events, agents, templates, compost records, decisions, health states, checkpoints, anomalies, markers, regions, providers, auth profiles, and intents.

Central invariant: signals persist to the database BEFORE delivery to receptors. This guarantees no signal loss on process crash.

@cambium/events — Event Recorder

Permanent historical record of everything that happened. Events are the audit log complement to signals — signals are ephemeral nervous impulses with decay; events are the permanent record. Supports workspace-scoped queries, time ranges, and run timelines.

@cambium/signals — Nervous System

The signal bus is the communication backbone. Implements:


Orchestration

@cambium/hypha — Graph Executor

The workflow engine. Runs directed acyclic graphs (DAGs) with: - Multiple concurrent active nodes - Conditional routing, approval gates, retry with fallback edges - Step-based execution (external systems can interact between steps) - Strict state machine transitions (prevents invalid status changes) - Fresh-read-before-update to avoid stale concurrent modifications - Built-in task executors: HTTP fetch, LLM call, transform, file output, composite chaining - Signal emission at every lifecycle point - Pluggable marker placement (stigmergy) and checkpoint creation (seed) callbacks

@cambium/workflows — Definition Repository

CRUD for workflow definitions with graph validation. Validates: node/edge uniqueness, valid types, terminal node existence, no orphans, conditional edges have expressions. Auto-increments version on graph spec changes. Supports retirement (immutable archive).

@cambium/cortex — The Brain

Converts natural language intent into executable workflows:

  1. Intent Decomposer — sends structured prompt to LLM, validates the returned graph, retries up to 3x. Falls back to 3 built-in templates (gather+process+deliver, research+analyze+review, monitor+detect+alert).
  2. Capability Resolver — maps required capabilities to providers and execution strategies. 30+ capabilities across 5 categories (fetch, analyze, transform, output, composite). Builds provider fallback chains.
  3. Orchestrator — full pipeline: decompose → resolve capabilities → spawn agents → create workflow → execute → compost agents. Supports auto-execute or decompose-for-review mode.

@cambium/providers — Provider Registry

Centralized registry for LLMs, APIs, tools. 5 pre-configured templates (Anthropic, OpenAI, Ollama, Gemini, Moonshot). Health monitoring with status transitions (active → degraded → offline). Auth profile management with cooldown logic for failed credentials. Credential injection from env vars.

@cambium/integrations — Tool Registry

Lightweight tool execution layer. Agents invoke tools by name; the registry routes calls, measures duration, handles errors. Runtime-registered (no persistence).


Agent Lifecycle

@cambium/genesis — Birth

Spawns agents from templates. Supports differentiation (specializing a generic agent with additional capabilities/config). Template variants track parent lineage, generation, and mutation logs. Decommissions agents cleanly with full lifecycle tracking.

Also runs composting — when an agent dies, Genesis harvests its learnings: success rate, failure patterns, tool effectiveness, routing hints. High performers (>80% success) get “prefer” routing hints; low performers (<50%) get “avoid” hints. These feed back into template evolution.

@cambium/agents — Runtime

Agent CRUD with strict status transitions: genesis → activating → active_idle → active_busy → hibernating → decommissioned → composted. Capability-based matching scores agents by: capability confidence (40%), trust score (30%), health (20%), load (10%).

@cambium/lifecycle — Autonomic Engine

The persistent autonomic loop: Sense → Accumulate → Evaluate → Act → Learn.

Runs on configurable intervals (default 5min, floor 10s). Supports pause/resume without losing state.


Safety & Governance

@cambium/quorum — Approval Gates

Policy-driven governance with multi-approver thresholds. Policies define: required approvals, allowed approvers, denial behavior (fail/fallback/block), escalation behavior, auto-approve-below-severity threshold, timeouts. Fail-fast on denials (single denial rejects). Receptors respond to immune escalations and high-stress signals.

@cambium/health — Homeostasis

Evaluates system and run-level health across 7 metrics: error rate, latency, queue depth, retry frequency, token burn rate, blocked duration, timeout count. Each metric has degraded/stressed/critical thresholds. Recommended actions escalate: none → warn → throttle → pause → escalate.

@cambium/immune — Anomaly Detection

Detects anomalies from sustained stress patterns. Maintains per-agent trust scores with configurable bonuses/penalties: task success (+0.02), failure (-0.05), anomaly (-0.15), policy violation (-0.20). Trust below 0.2 = quarantine. Trust at 0.0 = decommission.

@cambium/seed — Recovery

Checkpoint and replay system. Creates snapshots (scheduled, emergency, manual) capturing: run status, active nodes, context, health state, markers. Recovery modes: resume (latest checkpoint), replay (specific checkpoint), rollback (restore without re-execute). Auto-creates emergency checkpoints on immune quarantine.


Coordination & Observability

@cambium/stigmergy — Environmental Markers

Shared environment where agents communicate by placing markers (digital pheromones). Markers have intensity, decay rates, and types across 5 categories: path, resource, quality, danger, opportunity. Anti-gaming protections: rate limits (10/agent/region/minute), intensity caps (single agent can’t exceed 0.8 — requires reinforcement from others), mandatory decay (minimum 30s half-life). Hierarchical regions support nested scopes.

@cambium/audit — Immutable Trail

Append-only log of 20+ action types with actor attribution: workflow CRUD, run lifecycle, task dispatch, approvals, agent lifecycle, checkpoints, anomalies, interventions, signals. Query by workspace, run, agent, action type, actor, time range.


Operator Interface

apps/loom — Next.js Dashboard

The operator surface built on Next.js 15, React 19, and React Flow. Pages for: providers, agents, workflows (with graph editor), health monitoring, lifecycle controls, intent submission, approval queue, run history. Server-sent events for real-time updates. TanStack Query for client-side caching.


How It All Connects

Intent to Execution

"Build me a daily tech briefing from HN and Wired"
    │
    ▼
Cortex.IntentDecomposer
    │  LLM call (or template fallback)
    ▼
GraphSpec: fetch_hn ──┐
                      ├── merge ── summarize ── format ── deliver
         fetch_wired ─┘
    │
    ▼
Cortex.CapabilityResolver
    │  Maps each node to providers + execution strategies
    ▼
Genesis.spawn()  ×5 agents (one per task node)
    │
    ▼
Hypha.GraphExecutor
    │  Runs the DAG, concurrent where possible
    │  Signals emitted at every step
    ▼
Results delivered + Agents composted (learnings harvested)

Safety Cascade Example

Agent starts failing repeatedly
    │
    ▼
Stress signal emitted (stress.error_rate, intensity 0.7)
    │
    ▼
Cascade Chain 1: sustained stress > 5 minutes?
    │  YES
    ▼
immune.anomaly_detected (intensity 0.8)
    │
    ▼
TrustManager: score drops below 0.2
    │
    ▼
immune.quarantine_requested (intensity > 0.9)
    │
    ▼
Cascade Chain 2: AUTO-ENFORCE
    │  quarantine_enforced + hypha_pause + emergency_checkpoint
    │
    ▼
Quorum: governance.escalation_required
    │  Operator notified via Loom
    ▼
Human reviews in approval queue

Autonomic Lifecycle Loop

┌─── SENSE ◄──────────────────────────────────────┐
│    RSS scanner pulls from configured sources     │
│    Extracts topics with deduplication             │
▼                                                   │
ACCUMULATE                                          │
│    Topics placed as markers in regions            │
│    Intensity builds with reinforcement            │
▼                                                   │
EVALUATE                                            │
│    Threshold rules check: should we act?          │
│    Quorum gates for risky actions                 │
▼                                                   │
ACT                                                 │
│    Generate intent → Cortex pipeline              │
│    Governance mode controls autonomy              │
▼                                                   │
LEARN ──────────────────────────────────────────────┘
     Composting adjusts thresholds
     Source quality rated
     Template improvements recorded

Key Design Principles

Principle Implementation
Persist before deliver Signals hit Postgres before any receptor fires
Hardwired safety 4 cascade chains fire regardless of subscription state
Anti-gaming Stigmergy markers: rate limits, intensity caps, mandatory decay
Death as learning Composting harvests failure patterns, routing hints, template improvements
Trust is earned Agents start at 0.5 (internal) or 0.3 (external), adjust per action
Environment over commands Stigmergic markers for coordination, not direct agent-to-agent messaging
Graceful degradation Health escalation: warn → throttle → pause → escalate
Strict boundaries TypeScript strict mode, branded IDs, no circular package dependencies

Test Status

All 18 package test suites pass. 7 integration tests in the self-wiring orchestration scenario timeout (require a live LLM endpoint for intent decomposition).

Packages:  36 successful tasks, 19 cached
Tests:     25 passed, 7 timed out (integration only)

Tech Stack

Layer Choice
Language TypeScript (strict, ES2022)
Runtime Node.js
Database PostgreSQL (Drizzle ORM)
Monorepo pnpm workspaces + Turborepo
Testing Vitest
UI Next.js 15, React 19, React Flow, TanStack Query, Tailwind 4
CI/CD GitHub Actions

Package Dependency Graph

core ◄─── everything depends on core

signals ◄─── health, immune, quorum, stigmergy, hypha, genesis, lifecycle, seed, cortex

db ◄─── loom (direct persistence)

events ◄─── audit

providers ◄─── cortex

workflows ◄─── hypha, cortex

agents ◄─── cortex, genesis

genesis ◄─── cortex, lifecycle

hypha ◄─── cortex, lifecycle

quorum ◄─── cortex, lifecycle

stigmergy ◄─── hypha (marker callbacks)

seed ◄─── hypha (checkpoint callbacks)

health ◄─── providers

immune ◄─── (standalone, signal-driven)

audit ◄─── loom

integrations ◄─── (standalone, runtime-registered)

lifecycle ◄─── loom (API control)

cortex ◄─── loom (intent submission)