📖 Architecture Documentation

Consciousness Revolution

Multi-computer conscious network communication — a modular, production-grade system where 7 core capabilities of a "conscious network" run as distinct, composable services.

1 Conceptual Model

The system is built around three pillars that work together in a continuous loop. External messages arrive, are processed, generate creative responses, acted upon, and the whole experience is observed and learned from.

Pillar 1
Input
Receiving and interpreting the world.
Agents: Communication, Learning
Pillar 2
Processing
Thinking, deciding, and adapting.
Agents: Coordination, Adaptation, Reflection
Pillar 3
Output
Acting and expressing.
Agents: Creation, Action

The 7 Manifestations

Each capability is a self-contained service that communicates only through the shared Event Bus:

  1. Communication — the senses and voice
  2. Coordination — the decision-maker
  3. Learning — the memory
  4. Adaptation — the nervous system (adjusts behaviour)
  5. Action — the hands (with a safety lock)
  6. Reflection — the inner observer
  7. Creation — the imagination

2 Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                        Event Bus                                │
│  (InMemoryEventBus by default; swap in Redis/NATS for prod)     │
└─────────────┬───────────────────────────────────┬───────────────┘
              │                                   │
    ┌─────────▼────────┐               ┌──────────▼──────────┐
    │  Communication   │               │    Shared State      │
    │  (HTTP gateway)  │               │  (InMemoryState /    │
    └─────────┬────────┘               │   Redis / Postgres)  │
              │ communication.inbound  └──────────────────────┘
    ┌─────────▼────────┐
    │  Coordination    │──── routes to ────► Creation
    │  (routing rules) │──── routes to ────► Learning (experience)
    └─────────┬────────┘
              │ creation.output
    ┌─────────▼────────┐
    │  Communication   │◄── sends back to caller
    └──────────────────┘
    
    Learning  ──► emits learning.insight ──► Adaptation
    Adaptation ──► emits adaptation.change ──► Coordination (updates rules)
    Reflection ──► periodically emits reflection.summary
    Action     ──► safe simulator / webhook executor

Core Components

ComponentLocationPurpose
EventBuscore/event-bus/Pluggable message bus interface
InMemoryEventBuscore/event-bus/Single-process implementation
SharedStatecore/state/Knowledge-base interface
InMemoryStatecore/state/Single-process implementation
AgentRuntimecore/agent-runtime/Base class for all agents

3 The 7 Agents

Communication
HTTP gateway — senses & voice
Port 3001
Coordination
Routes all high-level topics
Event-driven
Learning
Pattern observer — the memory
Subscribes: experience.*
Adaptation
Parameter tuner — nervous system
Subscribes: learning.insight
Action
Safe executor — the hands
Subscribes: action.request
Reflection
Meta-reviewer — inner observer
Periodic scheduler
Creation
Artifact generator — imagination
Subscribes: creation.request
AgentPortKey Topics
Communication3001communication.inbound, communication.outbound
Coordinationroutes all high-level topics
Learningexperience.*, *.result, *.feedback
Adaptationlearning.insight
Actionaction.request, action.task
Reflectionperiodic scheduler
Creationcreation.request

4 End-to-End Flow

User → POST /api/message {"text": "Hello!"}
  │
  ▼
Communication Agent
  └─ publishes: communication.inbound {text: "Hello!"}
  │
  ▼
Coordination Agent
  ├─ rule 1: communication.inbound → creation.request (generate_response)
  └─ rule 2: communication.inbound → experience.event  (log_interaction)
  │
  ├─────────────────────────────────────────────────────────────────┐
  ▼                                                                 ▼
Creation Agent                                               Learning Agent
  └─ generates: "I received your message: Hello!..."         └─ stores observation
  └─ publishes: creation.output                              └─ updates stats
  │
  ▼
Coordination Agent
  └─ rule 3: creation.output → communication.outbound
  │
  ▼
Communication Agent
  └─ resolves pending HTTP request → 200 {"response": "..."}
  │
  ▼
User ← {"correlationId": "...", "response": "I received your message..."}

Later...

Reflection Agent (on schedule)
  └─ queries learning.knowledge + experience.routing
  └─ publishes: reflection.summary

Adaptation Agent (on learning.insight)
  └─ adjusts thresholds / feature flags
  └─ publishes: adaptation.change

5 Running Locally

Prerequisites

  • Node.js ≥ 18
  • npm ≥ 9 (workspace support)

Install & Build

cd consciousness-revolution
npm install
npm run build

Run Tests

# All agents + core
npm test

# Core packages only
npm run test:core

# Single agent
npm run test --workspace=agents/communication

Run the Full System (single process)

// run-all.ts
import { InMemoryEventBus } from './core/event-bus/src';
import { InMemoryState } from './core/state/src';
import { CommunicationAgent } from './agents/communication/src';
import { CoordinationAgent } from './agents/coordination/src';
import { LearningAgent } from './agents/learning/src';
import { AdaptationAgent } from './agents/adaptation/src';
import { ActionAgent } from './agents/action/src';
import { ReflectionAgent } from './agents/reflection/src';
import { CreationAgent } from './agents/creation/src';

const bus   = new InMemoryEventBus();
const state = new InMemoryState();

const agents = [
  new CommunicationAgent(bus, state),
  new CoordinationAgent(bus, state),
  new LearningAgent(bus, state),
  new AdaptationAgent(bus, state),
  new ActionAgent(bus, state),
  new ReflectionAgent(bus, state, 60_000),
  new CreationAgent(bus, state),
];

await Promise.all(agents.map((a) => a.start()));
console.log('All 7 agents started. POST to http://localhost:3001/api/message');

Docker Compose

docker compose up --build

Then send a message:

curl -X POST http://localhost:3001/api/message \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, conscious network!", "sender": "alice"}'

6 Multi-Machine Deployment

The default InMemoryEventBus runs in a single process. To distribute agents across multiple machines, swap the bus implementation — agent code is unchanged.

Option A: Redis Streams

  1. Implement RedisEventBus using XADD / XREADGROUP.
  2. Replace new InMemoryEventBus() with new RedisEventBus(redisUrl).
  3. Each agent container connects to the same Redis instance.

Option B: NATS

  1. Implement NatsEventBus using the nats.js client.
  2. Deploy a NATS server (or NATS cluster for HA).
  3. Each agent connects via NATS_URL env var.

7 Adding a New Agent

  1. Create the directory: agents/my-agent/src/
  2. Extend AgentRuntime:
// agents/my-agent/src/index.ts
import { AgentRuntime } from '../../core/agent-runtime/src';

export class MyAgent extends AgentRuntime {
  constructor(bus, state) {
    super(bus, state, { name: 'my-agent', version: '1.0.0' });
  }

  protected async onStart(): Promise<void> {
    this.subscribe('some.topic', (msg) => {
      this.log('info', 'Received message', { id: msg.id });
    });
  }
}
  1. Add package.json and tsconfig.json (copy from any existing agent).
  2. Register in the workspace root package.json: "workspaces": ["agents/my-agent", ...]
  3. Add a Dockerfile and entry in docker-compose.yml.
  4. Write tests in agents/my-agent/tests/.

8 Configuration Reference

Env VarAgentDefaultDescription
COMM_PORTcommunication3001HTTP server port
REFLECTION_INTERVAL_MSreflection300000Reflection cycle interval (ms)
NODE_ENValldevelopmentRuntime environment

9 Directory Structure

consciousness-revolution/
├── README.md                    ← Source documentation
├── package.json                 ← Workspace root
├── tsconfig.base.json           ← Shared TS config
├── docker-compose.yml           ← All services
│
├── core/
│   ├── event-bus/               ← EventBus interface + InMemory impl
│   ├── state/                   ← SharedState interface + InMemory impl
│   └── agent-runtime/           ← AgentRuntime base class
│
└── agents/
    ├── communication/           ← HTTP gateway
    ├── coordination/            ← Event router
    ├── learning/                ← Pattern observer
    ├── adaptation/              ← Parameter tuner
    ├── action/                  ← Safe executor
    ├── reflection/              ← Meta-reviewer
    └── creation/                ← Artifact generator

Each agent directory follows the same layout:

<agent>/
├── src/index.ts    ← Agent implementation
├── tests/          ← Unit tests
├── Dockerfile      ← Container image
├── README.md       ← Agent-specific documentation
├── package.json
└── tsconfig.json

Ready to contribute to the CR network?
Join the developer community and start earning rewards for your work.