Grand Diomande Research · Full HTML Reader

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.

Agents That Account for Themselves research note experiment writeup candidate score 44 .md

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

TermDefinitionLayerStability
AgentA Claude Code instance with its own context windowRuntimeStable
AgentLevelHigher (Application) or Lower (Infrastructure) designationConceptualStable
AgentStateCurrent status, pending tasks, blockers for an agentConceptualStable
MessageA structured communication from one agent to anotherConceptualStable
INBOXSection of agent state file for receiving messagesInterfaceStable
OUTBOXSection of agent state file for sending messagesInterfaceStable
EventBusThe file-based message passing mechanismArchitecturalStable
DecisionNodeA ChainLink representing an agent decisionArchitecturalProvisional
DecisionRingA DualRing tracking decision trajectoryArchitecturalProvisional
OrbitProject management database (Supabase)InfrastructureStable
AccomplishmentCompleted work unit logged to OrbitConceptualStable
BlockerDependency preventing progressConceptualStable

---

III. Assumptions & Invariants Ledger

III.1 Assumptions

IDAssumptionBreaks If FalseDetection
A-001File system is accessible to both agentsMessage passing failsFile read errors
A-002Claude hooks can detect file modificationsAuto-notification failsHook doesn't trigger
A-003Supabase MCP is availableOrbit sync failsMCP connection error
A-004Agents are run sequentially (not truly parallel)Race conditionsConflicting file edits
A-005Context window is ~200K tokensMay need summarizationToken limit errors

III.2 Invariants

IDInvariantRationaleCanary
INV-001Agent state files are the source of truthEnables context reconstructionState mismatch with codebase
INV-002OUTBOX messages are append-onlyPreserves audit trailMessages disappear
INV-003Decisions reference prior decisionsEnables trajectory tracingOrphaned decisions
INV-004Each agent owns exactly one state filePrevents write conflictsMultiple writers detected
INV-005Accomplishments map to Orbit recordsEnables project trackingUnsynced 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 TypeRAG++ LinkTypeDescription
REQUESTQuestionAsking other agent to do something
RESPONSEAnswerResponding to a request
INFOElaborationSharing information, no action needed
BLOCKERErrorReporting a blocking issue
RESOLUTIONSolutionResolving a blocker
CONFIRMContinuationAcknowledging receipt/completion
CONTEXTMetaSharing context for future reference

---

V. Data Structures

V.1 DecisionNode (extends ChainLink)

rust
/// 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)

rust
/// 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(&current_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

markdown
# {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)

StepDescriptionOwnerStatus
1.1Create `.governance/systems/MULTI_AGENT_COORDINATION.md`Higher
1.2Define DecisionNode schemaHigher
1.3Create trajectory storage directoryHigher
1.4Initialize decisions.jsonlHigher

Phase 2: Event Bus Enhancement (COMPLETE)

StepDescriptionOwnerStatus
2.1Add message ID generation (`message_utils.py`)Higher
2.2Implement message acknowledgment protocolHigher
2.3Add REFERENCES section to messagesHigher

Phase 3: Orbit Integration (FUTURE)

StepDescriptionOwnerStatus
3.1Map agent domains to Orbit projectsHigher
3.2Sync planned_actions with TODO listsBoth
3.3Log accomplishments on task completionBoth
3.4Create blockers for cross-agent dependenciesBoth

Phase 4: RAG++ Decision Memory (FUTURE)

StepDescriptionOwnerStatus
4.1Implement DecisionNode serializationLower
4.2Create decision embedding generationLower
4.3Build DecisionRing from historyLower
4.4Implement find_related_decisionsLower

Phase 5: Claude Hooks (COMPLETE)

StepDescriptionOwnerStatus
5.1Create `message_utils.py` - ID generation, message classesHigher
5.2Create `inter_agent_hook.py` - file change detectionHigher
5.3Create `context_reconstruction.py` - context recoveryHigher
5.4Test utilities end-to-endHigher

---

VII. Claude Hooks Design

VII.1 Hook Configuration

yaml
# .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 terminal

VII.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

FilePurpose
`.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>

rust
// 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_2

XI.2 DualRing<T>

rust
// 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

rust
// 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 proximity

XI.4 LinkType Compatibility Matrix

From ToContinuationElaborationQuestionAnswerErrorSolution
Continuation0.80.90.50.50.50.5
Elaboration0.90.80.50.50.50.5
Question0.50.50.80.90.50.5
Answer0.50.50.90.80.50.7
Error0.50.50.50.50.80.9
Solution0.50.50.50.70.90.8

---

XII. Revision History

VersionDateChanges
1.0.02025-12-28Initial draft
1.1.02025-12-28Implemented hooks utilities (Phase 1, 2, 5 complete)
1.2.02025-12-28Added 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