Multi-Agent Coordination System
Enable indefinite multi-agent coordination between Claude Code instances using file-based message passing, Orbit project management, and RAG++ trajectory memory—without requiring persistent context or human intermediation.
Full Public Reader
Multi-Agent Coordination System
Phase Zero: Project Control Layer
Version: 1.1.0
Created: 2025-12-28
Last Updated: 2025-12-28
Status: PROVISIONAL → IMPLEMENTED
---
I. Project Charter (PROVISIONAL)
I.1 Purpose
Enable indefinite multi-agent coordination between Claude Code instances using file-based message passing, Orbit project management, and RAG++ trajectory memory—without requiring persistent context or human intermediation.
Falsifiable Success Criteria:
1. Two Claude instances can exchange 10+ messages via file edits without human copy-paste
2. An agent resuming from context loss can reconstruct state within 3 tool calls
3. Cross-session decision continuity is maintained via ChainLink trajectories
4. Agent accomplishments are automatically logged to Orbit database
I.2 Non-Goals
- Real-time synchronous communication (we use async file polling)
- Shared memory or IPC between instances (files are the only channel)
- Automatic task scheduling (human orchestrates which agent runs when)
- Replacing human judgment on architectural decisions
I.3 Direction Constraints
Future evolution must remain compatible with:
- CLAUDE.md governance principles (anticipation over prediction)
- Existing Orbit database schema
- RAG++ ChainLink and Ring structures
- File-based message protocol (no external services required)
---
II. System Glossary
| Term | Definition | Layer | Stability |
|---|---|---|---|
| Agent | A Claude Code instance with its own context window | Runtime | Stable |
| AgentLevel | Higher (Application) or Lower (Infrastructure) designation | Conceptual | Stable |
| AgentState | Current status, pending tasks, blockers for an agent | Conceptual | Stable |
| Message | A structured communication from one agent to another | Conceptual | Stable |
| INBOX | Section of agent state file for receiving messages | Interface | Stable |
| OUTBOX | Section of agent state file for sending messages | Interface | Stable |
| EventBus | The file-based message passing mechanism | Architectural | Stable |
| DecisionNode | A ChainLink representing an agent decision | Architectural | Provisional |
| DecisionRing | A DualRing tracking decision trajectory | Architectural | Provisional |
| Orbit | Project management database (Supabase) | Infrastructure | Stable |
| Accomplishment | Completed work unit logged to Orbit | Conceptual | Stable |
| Blocker | Dependency preventing progress | Conceptual | Stable |
---
III. Assumptions & Invariants Ledger
III.1 Assumptions
| ID | Assumption | Breaks If False | Detection |
|---|---|---|---|
| A-001 | File system is accessible to both agents | Message passing fails | File read errors |
| A-002 | Claude hooks can detect file modifications | Auto-notification fails | Hook doesn't trigger |
| A-003 | Supabase MCP is available | Orbit sync fails | MCP connection error |
| A-004 | Agents are run sequentially (not truly parallel) | Race conditions | Conflicting file edits |
| A-005 | Context window is ~200K tokens | May need summarization | Token limit errors |
III.2 Invariants
| ID | Invariant | Rationale | Canary |
|---|---|---|---|
| INV-001 | Agent state files are the source of truth | Enables context reconstruction | State mismatch with codebase |
| INV-002 | OUTBOX messages are append-only | Preserves audit trail | Messages disappear |
| INV-003 | Decisions reference prior decisions | Enables trajectory tracing | Orphaned decisions |
| INV-004 | Each agent owns exactly one state file | Prevents write conflicts | Multiple writers detected |
| INV-005 | Accomplishments map to Orbit records | Enables project tracking | Unsynced accomplishments |
---
IV. Architecture
IV.1 System Stack
┌─────────────────────────────────────────────────────────────────────────────┐
│ USER ORCHESTRATION │
│ Human switches between Claude windows, providing "continue" prompts │
└─────────────────────────────────────────────────────────────────────────────┘
│
┌───────────────────────┴───────────────────────┐
▼ ▼
┌─────────────────────────────────┐ ┌─────────────────────────────────┐
│ HIGHER-LEVEL AGENT │ │ LOWER-LEVEL AGENT │
│ (Application/Data) │ │ (Core Infrastructure) │
│ │ │ │
│ Domain: │ │ Domain: │
│ • Phrases, Dashboard │ │ • cc-core-rs, LIM-RPS │
│ • CC-Collection, Training │ │ • CC-MCS, Equilibrium │
│ • User-facing features │ │ • Low-level APIs │
│ │ │ │
│ Owns: HIGHER_LEVEL.md │ │ Owns: LOWER_LEVEL.md │
│ Reads: LOWER_LEVEL.md OUTBOX │ │ Reads: HIGHER_LEVEL.md OUTBOX │
└─────────────────────────────────┘ └─────────────────────────────────┘
│ │
└───────────────────────┬───────────────────────┘
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ FILE-BASED EVENT BUS │
│ │
│ .governance/agents/HIGHER_LEVEL.md ←→ .governance/agents/LOWER_LEVEL.md │
│ │
│ Protocol: │
│ 1. Agent A writes to own OUTBOX section │
│ 2. Agent B reads other's OUTBOX on next prompt │
│ 3. Agent B copies message to own INBOX (acknowledgment) │
│ 4. Agent B processes and responds via own OUTBOX │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ ORBIT DATABASE │
│ │
│ Tables: │
│ • projects: Agent domains as projects │
│ • planned_actions: Current TODO items │
│ • accomplishments: Completed work │
│ • blockers: Cross-agent dependencies │
│ • claude_sessions: Session tracking │
│ │
│ Sync: Agent state → Orbit on significant events │
└─────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ RAG++ DECISION MEMORY │
│ │
│ Structures: │
│ • DecisionNode (extends ChainLink) │
│ • DecisionRing (DualRing<DecisionNode>) │
│ • Cross-session trajectory via ChainLinkEstimator │
│ │
│ Storage: .governance/trajectory/decisions.jsonl │
└─────────────────────────────────────────────────────────────────────────────┘IV.2 Message Protocol
┌─────────────────────────────────────────────────────────────────────────────┐
│ MESSAGE FORMAT │
└─────────────────────────────────────────────────────────────────────────────┘
### [TIMESTAMP] TYPE: Subject
**From**: Agent Level
**To**: Agent Level
**Priority**: Low | Medium | High | Critical
**Status**: PENDING | ACKNOWLEDGED | PROCESSED | BLOCKED
**Body**:
<content>
**References**: [Prior message IDs or decision IDs]
---IV.3 Message Types (LinkType Mapping)
| Message Type | RAG++ LinkType | Description |
|---|---|---|
| REQUEST | Question | Asking other agent to do something |
| RESPONSE | Answer | Responding to a request |
| INFO | Elaboration | Sharing information, no action needed |
| BLOCKER | Error | Reporting a blocking issue |
| RESOLUTION | Solution | Resolving a blocker |
| CONFIRM | Continuation | Acknowledging receipt/completion |
| CONTEXT | Meta | Sharing context for future reference |
---
V. Data Structures
V.1 DecisionNode (extends ChainLink)
/// A decision made by an agent, extending ChainLink for trajectory tracking.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DecisionNode {
// === ChainLink base fields ===
/// Position in decision trajectory
pub coordinate: TrajectoryCoordinate5D,
/// Semantic embedding of the decision description
pub embedding: Vec<f32>,
/// Type of decision (maps to LinkType)
pub decision_type: DecisionType,
/// Influence weight (0-1)
pub influence: f32,
// === Agent-specific fields ===
/// Unique decision ID
pub id: String,
/// Which agent made this decision
pub agent: AgentLevel,
/// Timestamp (ISO 8601)
pub timestamp: String,
/// Human-readable description
pub description: String,
/// Related file paths affected
pub files_affected: Vec<String>,
/// References to prior decisions
pub references: Vec<String>,
/// Rationale for the decision
pub rationale: String,
/// Confidence level (Low/Medium/High)
pub confidence: Confidence,
/// Whether this decision is reversible
pub reversible: bool,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum AgentLevel {
Higher,
Lower,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum DecisionType {
/// Implementing a feature or fix
Implementation,
/// Designing architecture or API
Design,
/// Requesting action from other agent
Request,
/// Responding to a request
Response,
/// Reporting a blocker
Blocker,
/// Resolving a blocker
Resolution,
/// Sharing context or information
Context,
/// Confirming completion
Confirmation,
/// Investigating or researching
Investigation,
/// Deferring a decision
Deferral,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum Confidence {
Low,
Medium,
High,
}V.2 DecisionRing (DualRing specialization)
/// A ring of decisions with dual traversal (temporal and influence).
pub type DecisionRing = DualRing<DecisionNode>;
/// Build a decision ring from a sequence of decisions.
pub fn build_decision_ring(decisions: Vec<DecisionNode>) -> DecisionRing {
let influences: Vec<f32> = decisions.iter().map(|d| d.influence).collect();
build_dual_ring(decisions, &influences)
}
/// Query related decisions using ChainLinkEstimator.
pub fn find_related_decisions(
current: &DecisionNode,
ring: &DecisionRing,
estimator: &ChainLinkEstimator,
k: usize,
) -> Vec<(&DecisionNode, f32)> {
// Convert DecisionNode to ChainLink for estimation
let current_link = current.to_chain_link();
let mut scored: Vec<_> = ring.iter_temporal()
.filter(|d| d.id != current.id)
.map(|d| {
let link = d.to_chain_link();
let score = estimator.estimate(¤t_link, &link);
(d, score)
})
.collect();
scored.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap());
scored.truncate(k);
scored
}V.3 Agent State File Schema
# {Level}-Level Agent Status
## Domain: {Domain Description}
### Last Updated: {ISO Timestamp}
---
## CURRENT STATE: {State}
### Completed Work
{List of completed items with status}
### Active Work
{Current focus and progress}
---
## IMPLEMENTATION PLAN
{Phased plan with checkboxes}
---
## INTER-AGENT COMMUNICATION
### INBOX (From {Other} Agent):
{Messages received - append only}
### OUTBOX (To {Other} Agent):
{Messages sent - append only}
### Waiting For:
{List of pending items from other agent}
---
## NEXT STEPS
{Numbered list with status emojis}
---
## BLOCKED BY
{List of blockers}
---
## BLOCKING
{What this agent's work blocks}---
VI. Implementation Plan
Phase 1: Foundation (COMPLETE)
| Step | Description | Owner | Status |
|---|---|---|---|
| 1.1 | Create `.governance/systems/MULTI_AGENT_COORDINATION.md` | Higher | ✅ |
| 1.2 | Define DecisionNode schema | Higher | ✅ |
| 1.3 | Create trajectory storage directory | Higher | ✅ |
| 1.4 | Initialize decisions.jsonl | Higher | ✅ |
Phase 2: Event Bus Enhancement (COMPLETE)
| Step | Description | Owner | Status |
|---|---|---|---|
| 2.1 | Add message ID generation (`message_utils.py`) | Higher | ✅ |
| 2.2 | Implement message acknowledgment protocol | Higher | ✅ |
| 2.3 | Add REFERENCES section to messages | Higher | ✅ |
Phase 3: Orbit Integration (FUTURE)
| Step | Description | Owner | Status |
|---|---|---|---|
| 3.1 | Map agent domains to Orbit projects | Higher | ⏳ |
| 3.2 | Sync planned_actions with TODO lists | Both | ⏳ |
| 3.3 | Log accomplishments on task completion | Both | ⏳ |
| 3.4 | Create blockers for cross-agent dependencies | Both | ⏳ |
Phase 4: RAG++ Decision Memory (FUTURE)
| Step | Description | Owner | Status |
|---|---|---|---|
| 4.1 | Implement DecisionNode serialization | Lower | ⏳ |
| 4.2 | Create decision embedding generation | Lower | ⏳ |
| 4.3 | Build DecisionRing from history | Lower | ⏳ |
| 4.4 | Implement find_related_decisions | Lower | ⏳ |
Phase 5: Claude Hooks (COMPLETE)
| Step | Description | Owner | Status |
|---|---|---|---|
| 5.1 | Create `message_utils.py` - ID generation, message classes | Higher | ✅ |
| 5.2 | Create `inter_agent_hook.py` - file change detection | Higher | ✅ |
| 5.3 | Create `context_reconstruction.py` - context recovery | Higher | ✅ |
| 5.4 | Test utilities end-to-end | Higher | ✅ |
---
VII. Claude Hooks Design
VII.1 Hook Configuration
# .claude/hooks.yaml (proposed)
hooks:
# Log all prompts to Orbit
prompt-submit:
- name: "orbit-log"
command: |
python3 -c "
import json, sys, os
from datetime import datetime
# Log prompt to local file (Orbit sync later)
log_entry = {
'timestamp': datetime.utcnow().isoformat(),
'type': 'prompt',
'agent': os.environ.get('AGENT_LEVEL', 'unknown'),
}
log_path = '.governance/trajectory/prompt_log.jsonl'
with open(log_path, 'a') as f:
f.write(json.dumps(log_entry) + '\\n')
print(f'[Logged] {log_entry[\"timestamp\"][:19]}')
"
# Detect agent state file modifications
post-tool-call:
- name: "agent-message-detect"
matcher:
tool: Edit
path_pattern: ".governance/agents/*.md"
command: |
echo "[Agent Message] File modified: $TOOL_PATH"
# Could trigger notification to other agent's terminalVII.2 Hook-Based Message Flow
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Agent A │ │ File System │ │ Agent B │
│ (Higher) │ │ │ │ (Lower) │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
│ Edit HIGHER_LEVEL.md │ │
│ (add to OUTBOX) │ │
│──────────────────────>│ │
│ │ │
│ [Hook: file-edit] │ │
│<──────────────────────│ │
│ "Message pending" │ │
│ │ │
│ │ Read HIGHER_LEVEL.md │
│ │<──────────────────────│
│ │ │
│ │ Edit LOWER_LEVEL.md │
│ │ (copy to INBOX, │
│ │ add to OUTBOX) │
│ │<──────────────────────│
│ │ │
│ Read LOWER_LEVEL.md │ │
│<──────────────────────│ │
│ │ │---
VIII. Context Reconstruction Protocol
When an agent resumes after context loss:
VIII.1 Reconstruction Steps
1. Read own state file (`.governance/agents/{LEVEL}_LEVEL.md`)
- Current state, completed work, active work
- Pending TODO items
- Blockers
2. Read other agent's OUTBOX
- Check for unprocessed messages
- Copy new messages to own INBOX
3. Read decision trajectory (`.governance/trajectory/decisions.jsonl`)
- Last N decisions for context
- Use ChainLinkEstimator to find related decisions
4. Query Orbit (if available)
- Project status, recent accomplishments
- Active blockers
5. Resume execution
- Start from first pending TODO item
- Reference reconstructed context
VIII.2 Reconstruction Anchor Format
CONTINUATION ANCHOR
-------------------
Agent: {Higher | Lower}
Phase: {Current phase}
Last Completed: {Most recent completed item}
Next Active: {Next pending item}
Confidence: {Low | Medium | High}
Open Uncertainties: {List}
Blocked By: {List or "None"}
Unprocessed Messages: {Count from other agent's OUTBOX}
Related Decisions: {IDs of similar past decisions}---
IX. Validation Criteria
IX.1 Message Exchange Validation
- [ ] Agent A can write to OUTBOX without errors
- [ ] Agent B can read Agent A's OUTBOX
- [ ] Message IDs are unique and traceable
- [ ] References to prior messages are valid
IX.2 Context Reconstruction Validation
- [ ] Agent can determine current state from files alone
- [ ] Agent can identify unprocessed messages
- [ ] Agent can resume from correct TODO item
- [ ] Decision trajectory provides relevant context
IX.3 Orbit Sync Validation
- [ ] Accomplishments appear in Orbit database
- [ ] Blockers are created for cross-agent dependencies
- [ ] Planned actions match TODO lists
IX.4 Decision Memory Validation
- [ ] Decisions are serialized to JSONL
- [ ] Embeddings are generated consistently
- [ ] Related decisions are retrievable
- [ ] DecisionRing maintains dual ordering
---
X. File Locations
| File | Purpose |
|---|---|
| `.governance/agents/HIGHER_LEVEL.md` | Higher agent state & messages |
| `.governance/agents/LOWER_LEVEL.md` | Lower agent state & messages |
| `.governance/systems/MULTI_AGENT_COORDINATION.md` | This document |
| `.governance/trajectory/decisions.jsonl` | Decision history |
| `.governance/trajectory/id_counter.json` | Message/Decision ID counters |
| `.governance/trajectory/inter_agent_events.jsonl` | Inter-agent event log |
| `.governance/hooks/message_utils.py` | Message ID generation, Decision logging |
| `.governance/hooks/inter_agent_hook.py` | File change detection, notifications |
| `.governance/hooks/context_reconstruction.py` | Context recovery utility |
| `.governance/notifications/pending_*.json` | Pending notification markers |
| `.governance/hooks/decision_estimator.py` | 4-component relationship estimation |
| `.governance/trajectory/estimator_state.json` | Estimator weights and history |
---
XI. Appendix: RAG++ Structure Reference
XI.1 Ring<T>
// Circular topology with O(1) neighbor access
let ring = Ring::new(vec![decision_1, decision_2, decision_3]);
ring.ring_distance(0, 2); // Shortest path: 1
ring.neighbors(0, 1); // Adjacent decisions
ring.iter_from(1); // Iterate starting from decision_2XI.2 DualRing<T>
// Dual traversal: temporal (RCP) and influence (IRCP)
let dual = DualRing::new(nodes);
// Temporal order (chronological)
dual.iter_temporal();
// Influence order (most impactful first)
dual.iter_by_influence();
dual.top_influential(3);
// Cross-ring analysis
dual.influence_temporal_spread(); // How spread out is influence?XI.3 ChainLink & ChainLinkEstimator
// 4-component relationship strength
let estimator = ChainLinkEstimator::default();
let strength = estimator.estimate(&link_a, &link_b);
// Components:
// - Baseline (0.20): semantic similarity
// - Relationship (0.30): coordinate + attention
// - Type-based (0.20): compatibility matrix
// - Context-weighted (0.30): temporal proximityXI.4 LinkType Compatibility Matrix
| From To | Continuation | Elaboration | Question | Answer | Error | Solution |
|---|---|---|---|---|---|---|
| Continuation | 0.8 | 0.9 | 0.5 | 0.5 | 0.5 | 0.5 |
| Elaboration | 0.9 | 0.8 | 0.5 | 0.5 | 0.5 | 0.5 |
| Question | 0.5 | 0.5 | 0.8 | 0.9 | 0.5 | 0.5 |
| Answer | 0.5 | 0.5 | 0.9 | 0.8 | 0.5 | 0.7 |
| Error | 0.5 | 0.5 | 0.5 | 0.5 | 0.8 | 0.9 |
| Solution | 0.5 | 0.5 | 0.5 | 0.7 | 0.9 | 0.8 |
---
XII. Revision History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2025-12-28 | Initial draft |
| 1.1.0 | 2025-12-28 | Implemented hooks utilities (Phase 1, 2, 5 complete) |
| 1.2.0 | 2025-12-28 | Added 4-component DecisionEstimator from cc-tpo legacy |
---
This document governs all future multi-agent coordination work. Changes require multi-signal convergence per CLAUDE.md governance principles.
Promotion Decision
Attach run IDs, datasets, metrics, and reproduction commands.
Source Anchor
Comp-Core/.governance/systems/MULTI_AGENT_COORDINATION.md
Detected Structure
Method · Evaluation · References · Figures · Code Anchors · Architecture