Back to Ruflo

V3 Architecture Decision Records (ADRs)

v3/implementation/adrs/README.md

3.6.3027.5 KB
Original Source

V3 Architecture Decision Records (ADRs)

This directory contains all Architecture Decision Records for Claude-Flow v3.

Status:BETA READY (22 ADRs Complete) Version: 3.0.0-alpha.84 Last Updated: 2026-01-13

ADR Index

Core Architecture (ADR-001 to ADR-010)

ADRTitleStatusFile
ADR-001Adopt agentic-flow as Core Foundation✅ ImplementedADR-001-AGENT-IMPLEMENTATION.md
ADR-002Implement Domain-Driven Design Structure✅ ImplementedADR-002-DDD-STRUCTURE.md
ADR-003Single Coordination Engine✅ ImplementedADR-003-CONSOLIDATION-COMPLETE.md
ADR-004Plugin-Based Architecture✅ ImplementedADR-004-PLUGIN-ARCHITECTURE.md
ADR-005MCP-First API Design✅ ImplementedADR-005-implementation-summary.md
ADR-006Unified Memory Service✅ ImplementedADR-006-UNIFIED-MEMORY.md
ADR-007Event Sourcing for State Changes✅ ImplementedADR-007-EVENT-SOURCING.md
ADR-008Vitest Over Jest✅ ImplementedADR-008-VITEST.md
ADR-009Hybrid Memory Backend as Default✅ ImplementedADR-009-IMPLEMENTATION.md
ADR-010Remove Deno Support✅ ImplementedADR-010-NODE-ONLY.md

Providers & Security (ADR-011 to ADR-017)

ADRTitleStatusFile
ADR-011LLM Provider System✅ ImplementedADR-011-llm-provider-system.md
ADR-012MCP Security Features✅ ImplementedADR-012-mcp-security-features.md
ADR-013Core Security Module✅ ImplementedADR-013-core-security-module.md
ADR-014Workers System✅ ImplementedADR-014-workers-system.md
ADR-015Unified Plugin System✅ ImplementedADR-015-unified-plugin-system.md
ADR-016Collaborative Issue Claims✅ ImplementedADR-016-collaborative-issue-claims.md
ADR-017RuVector Integration✅ ImplementedADR-017-ruvector-integration.md

Advanced Features (ADR-018 to ADR-025)

ADRTitleStatusFile
ADR-018Claude Code Integration✅ ImplementedADR-018-claude-code-integration.md
ADR-019Headless Runtime Package✅ ImplementedADR-019-headless-runtime-package.md
ADR-020Headless Worker Integration✅ ImplementedADR-020-headless-worker-integration.md
ADR-021Transfer Hook IPFS Pattern Sharing✅ ImplementedADR-021-transfer-hook-ipfs-pattern-sharing.md
ADR-022AIDefence Integration✅ ImplementedADR-022-aidefence-integration.md
ADR-023ONNX Hyperbolic Embeddings Init✅ ImplementedADR-023-onnx-hyperbolic-embeddings-init.md
ADR-024Embeddings MCP Tools✅ ImplementedADR-024-embeddings-mcp-tools.md
ADR-025Auto-Update System✅ ImplementedADR-025-auto-update-system.md

Neural & Integration (ADR-026 to ADR-031)

ADRTitleStatusFile
ADR-026Agent Booster Model Routing✅ ImplementedADR-026-agent-booster-model-routing.md
ADR-027RuVector PostgreSQL Integration✅ ImplementedADR-027-ruvector-postgresql-integration.md
ADR-028Neural Attention Mechanisms✅ ImplementedADR-028-neural-attention-mechanisms.md
ADR-029GNN Integration✅ ImplementedADR-029-gnn-integration.md
ADR-030Agentic QE Integration✅ ImplementedADR-030-agentic-qe-integration.md
ADR-031Prime Radiant Integration✅ ImplementedADR-031-prime-radiant-integration.md

Packaging & Branding (ADR-042 to ADR-048)

ADRTitleStatusFile
ADR-046Dual Umbrella: claude-flow + rufloAcceptedADR-046-ruflo-rebrand.md
ADR-047Fast Mode IntegrationProposedADR-047-fast-mode-integration.md
ADR-048Auto Memory IntegrationAcceptedADR-048-auto-memory-integration.md

RuVector WASM Plugin Architecture (ADR-032 to ADR-041)

ADRTitleCategoryStatusFile
ADR-032Healthcare Clinical Decision SupportPracticalProposedADR-032-healthcare-clinical-plugin.md
ADR-033Financial Risk AnalysisPracticalProposedADR-033-financial-risk-plugin.md
ADR-034Legal Contract AnalysisPracticalProposedADR-034-legal-contract-plugin.md
ADR-035Advanced Code IntelligenceAdvancedProposedADR-035-code-intelligence-plugin.md
ADR-036Test IntelligenceAdvancedProposedADR-036-test-intelligence-plugin.md
ADR-037Performance OptimizationAdvancedProposedADR-037-performance-optimization-plugin.md
ADR-038Multi-Agent Neural CoordinationCutting-EdgeProposedADR-038-multi-agent-coordination-plugin.md
ADR-039Cognitive KernelCutting-EdgeProposedADR-039-cognitive-kernel-plugin.md
ADR-040Quantum-Inspired OptimizationExotic SOTAProposedADR-040-quantum-inspired-plugin.md
ADR-041Hyperbolic ReasoningExotic SOTAProposedADR-041-hyperbolic-reasoning-plugin.md

Implementation Progress

Last Updated: 2026-01-13 (Beta Ready Audit) Status:READY FOR 3.0.0-beta.1

ComponentStatusDetails
DDD Modules✅ 100%16 packages, 419 TS files
CLI Commands✅ 100%28 commands, 140+ subcommands
MCP Tools✅ 100%119 tools (exceeds V2)
Hooks System✅ 100%20 CLI + 60 MCP hook tools
Test Coverage✅ 85%+85+ test files (ADR-008)
Service Integration✅ Completeagentic-flow@alpha integration
RuVector Integration✅ CompleteQ-Learning, AST, Diff, Coverage (ADR-017)
Performance Benchmarks✅ CompleteFull benchmark suite
Auto-Update System✅ CompleteRate-limited startup checks (ADR-025)
Production Hardening✅ CompleteReal metrics, labeled examples, fallback warnings

Overall V3 Implementation: 100% Complete

Beta Readiness Checklist

CategoryStatus
Real ONNX embeddings
Real performance metrics
Real security scanning
Fallback warnings
Auto-update system
Claims MCP tools
Production hardening
Windows validated

Quick Summary

Core Decisions

  1. ADR-001: Build on agentic-flow@alpha instead of duplicating (eliminates 10,000+ lines)
  2. ADR-002: Domain-Driven Design with bounded contexts for clean architecture
  3. ADR-003: Single UnifiedSwarmCoordinator as canonical coordination engine
  4. ADR-004: Microkernel with plugins for optional features (HiveMind, Neural, etc.)
  5. ADR-005: MCP tools as primary API, CLI as thin wrapper

Technical Decisions

  1. ADR-006: Single MemoryService with SQLite, AgentDB, or Hybrid backends
  2. ADR-007: Event sourcing for audit trail and state reconstruction
  3. ADR-008: Vitest for 10x faster testing with native ESM
  4. ADR-009: Hybrid backend (SQLite + AgentDB) as default for best performance
  5. ADR-010: Node.js 20+ only, removing Deno complexity

Additional Files

Performance Targets (from ADRs)

MetricTargetADR Reference
Code reduction<5,000 lines vs 15,000+ADR-001
HNSW search150x-12,500x fasterADR-009
Flash Attention2.49x-7.47x speedupADR-001
Test execution<5s (10x improvement)ADR-008
Startup time<500msADR-004
Query latency<100msADR-006

Security Improvements

All ADRs consider security:

  • CVE-1: Command injection prevention (ADR-005 input validation)
  • CVE-2: Path traversal prevention (ADR-006 memory sandboxing)
  • CVE-3: Credential generation (secure random with rejection sampling)

Last Updated: 2026-01-13 Project: Claude-Flow V3 Version: 3.0.0-alpha.84 (Beta Ready)

Recent Updates (2026-01-13)

Release: @claude-flow/[email protected] (Beta Ready)

All Audit Issues Resolved:

FixBeforeAfter
Profile metricsHardcoded 23%, 145MBReal: process.memoryUsage(), process.cpuUsage()
CVE dataUnmarked fake dataLabeled as examples with warnings
Demo mode warningsSilent fallback⚠ DEMO MODE / OFFLINE MODE warnings

Auto-Update System (ADR-025):

bash
npx claude-flow update check      # Check for updates
npx claude-flow update all        # Update all packages
npx claude-flow update history    # View update history
npx claude-flow update rollback   # Rollback last update

Previous Updates (2026-01-07)

Release: @claude-flow/[email protected] (Latest)

Doctor Command Enhancements:

  • Claude Code CLI Check: Verifies @anthropic-ai/claude-code installation
  • Auto-Install: --install flag to auto-install missing Claude Code CLI
  • Fixed Package Paths: Corrected dist/src/ paths for proper npm resolution
bash
# Check system health including Claude Code CLI
npx claude-flow@v3alpha doctor

# Auto-install Claude Code CLI if missing
npx claude-flow@v3alpha doctor --install

# Check only Claude Code CLI
npx claude-flow@v3alpha doctor -c claude

Package Resolution Fix: Fixed Windows module resolution issue where @claude-flow/cli exports pointed to wrong paths (dist/index.jsdist/src/index.js).

Release: @claude-flow/[email protected]

  • Hive-Mind CLI: All MCP tools now exposed via CLI subcommands:
    • hive-mind join <agent-id> - Join agent to hive
    • hive-mind leave <agent-id> - Remove agent from hive
    • hive-mind consensus - Manage consensus proposals and voting
    • hive-mind broadcast -m <msg> - Broadcast messages to workers
    • hive-mind memory - Access shared memory (get/set/delete/list)
  • Bug Fix: Fixed positional argument parsing for subcommands in CLI parser
  • File Persistence: All MCP tools use file-based persistence in .claude-flow/ directories
  • ADR-014: Node.js Worker Daemon - cross-platform TypeScript daemon replaces shell helpers
  • CLI: daemon command with start/stop/status/trigger/enable subcommands
  • Session Integration: Auto-start daemon on SessionStart, auto-stop on SessionEnd

CLI MCP Tool Coverage

CategoryToolsCLI Status
Agentspawn, terminate, status, list, pool, health, update✅ Complete
Hive-Mindinit, spawn, status, task, join, leave, consensus, broadcast, memory, optimize-memory, shutdown✅ Complete
Taskcreate, status, list, complete, cancel✅ Complete
Sessionsave, restore, list, delete, export✅ Complete
Configget, set, list, reset, export, import✅ Complete
Memorystore, retrieve, list, delete, search✅ Complete
Workflowcreate, execute, list, status, delete✅ Complete

Install

bash
npx @claude-flow/cli@v3alpha --help

Release: @claude-flow/[email protected] (2026-01-07)

New V3 Advanced CLI Commands

All commands include subcommand help and "Created with ❤️ by ruv.io" branding.

CommandDescriptionSubcommands
neuralNeural pattern training, MoE, Flash Attentiontrain, status, patterns, predict, optimize
securitySecurity scanning, CVE detection, threat modelingscan, cve, threats, audit, secrets
performancePerformance profiling, benchmarking, optimizationbenchmark, profile, metrics, optimize, bottleneck
providersAI provider management, models, configurationslist, configure, test, models, usage
pluginsPlugin management, installation, lifecyclelist, install, uninstall, toggle, info, create
deploymentDeployment management, environments, rollbacksdeploy, status, rollback, history, environments, logs
claimsClaims-based authorization, access controllist, check, grant, revoke, roles, policies
embeddingsVector embeddings, semantic searchgenerate, search, compare, collections, index, providers
doctorSystem diagnosticsNode version, config, daemon, memory, API keys, MCP, disk
completionsShell completionsbash, zsh, fish, powershell

P0 Features Completed (alpha.12)

Smart Error Suggestions: Typo detection with Levenshtein distance

bash
$ claude-flow swram
[ERROR] Unknown command: swram
  Did you mean one of these?
  - swarm
  - neural
  - start

$ claude-flow memroy
[ERROR] Unknown command: memroy
  Did you mean "memory"?

Doctor Command: System health diagnostics

bash
$ claude-flow doctor
Claude Flow Doctor
──────────────────────────────────────────────────
✓ Node.js Version: v22.21.1 (>= 20 required)
✓ npm Version: v10.9.4
✓ Git: v2.52.0
✓ Git Repository: In a git repository
⚠ Config File: No config file (using defaults)
⚠ Daemon Status: Not running
⚠ Memory Database: Not initialized
⚠ API Keys: No API keys found
⚠ MCP Servers: No MCP config found
✓ Disk Space: 73G available
✓ TypeScript: v5.9.3
──────────────────────────────────────────────────
Summary: 6 passed, 5 warnings

Shell Completions: Tab completion for all shells

bash
# Install bash completions
claude-flow completions bash > ~/.bash_completion.d/claude-flow

# Install zsh completions
claude-flow completions zsh > ~/.zfunc/_claude-flow

# Install fish completions
claude-flow completions fish > ~/.config/fish/completions/claude-flow.fish

# Install PowerShell completions
claude-flow completions powershell >> $PROFILE

CLI Roadmap

Priority Recommendations

PriorityRecommendationStatusDescription
🔴 P0Add doctor command✅ DoneSystem diagnostics, dependency checks, config validation
🔴 P0Add completions command✅ DoneShell completions for bash, zsh, fish, powershell
🔴 P0Add smart error suggestions✅ DoneLevenshtein distance for typo corrections
🟡 P1Resolve provider config overlapPendingUnify provider configs across embeddings/providers commands
🟡 P1Add unified logs commandPendingCentralized log viewing across daemon, agents, swarms
🟢 P2Add upgrade commandPendingSelf-update CLI to latest version
🟢 P2Add interactive shell/REPL modePendingclaude-flow shell for interactive command execution

Implementation Plan

P0 - Critical (Next Release)

bash
# Doctor command - diagnose system health
claude-flow doctor              # Full system check
claude-flow doctor --fix        # Auto-fix issues where possible
claude-flow doctor --component mcp  # Check specific component

# Shell completions
claude-flow completions bash > ~/.bash_completion.d/claude-flow
claude-flow completions zsh > ~/.zfunc/_claude-flow
claude-flow completions fish > ~/.config/fish/completions/claude-flow.fish

P1 - High Priority

bash
# Unified logs command
claude-flow logs                # All logs
claude-flow logs --follow       # Tail logs
claude-flow logs --component daemon
claude-flow logs --level error

P2 - Nice to Have

bash
# Self-update
claude-flow upgrade             # Upgrade to latest
claude-flow upgrade --check     # Check for updates
claude-flow upgrade --version 3.1.0

# Interactive shell
claude-flow shell               # Enter REPL
> swarm init mesh
> agent spawn coder
> memory search "patterns"

agentic-flow vs claude-flow Feature Comparison

Feature Matrix

Featureagentic-flowclaude-flowIntegration Value
Core Agent System
Specialized Agents66+15 (hierarchical)🟡
Agent Spawning-
Agent Pool/Scaling-
Orchestration
Swarm Coordination-
Hive-Mind Consensus-
Federation Hub🔴 High
Ephemeral Agents🔴 High
Transport
HTTP/SSE-
QUIC (UDP)🔴 High
WebSocket-
AI Providers
Multi-Provider-
Model Optimization🔴 High
Provider Fallback🔴 High
Cost Tracking🟡 Medium
Proxy Server🟡 Medium
Memory/Learning
ReasoningBank (WASM)🔴 High
Embeddings CLI-
HNSW Indexing-
Memory Persistence-
DevOps
Doctor Command-
Shell Completions-
Smart Errors-
Background Workers-
Worker Dispatch🟡 Medium
Security
Security Scanning-
CVE Detection-
Claims/RBAC-
Advanced
Neural Patterns-
Self-Learning Hooks-
Deployment Mgmt-
Plugin System-

High-Value Integration Opportunities

🔴 Tier 1: Highest Impact (Unique to agentic-flow)

1. QUIC Transport (50-70% faster)

bash
# Integration target:
claude-flow transport quic --port 4433
claude-flow swarm start --transport quic  # 50-70% faster agent comms

2. Federation Hub (Ephemeral Agents)

bash
# Integration target:
claude-flow federation start --port 9443
claude-flow federation spawn --tenant acme --lifetime 600

Value: Agents die but memories persist → learning across agent generations

3. Model Optimization (85% cost savings)

bash
# Integration target:
claude-flow agent spawn -t coder --optimize --priority cost
claude-flow providers optimize --task "Build API" --budget 0.01

4. Provider Fallback (Enterprise resilience)

bash
# Integration target:
claude-flow providers fallback configure --primary anthropic --fallback openrouter,onnx

5. ReasoningBank (WASM Learning Memory)

bash
# Integration target:
claude-flow reasoningbank store "pattern" --reasoning "..."
claude-flow reasoningbank search "authentication patterns"

Value: 10-100x faster reasoning pattern storage vs JSON

🟡 Tier 2: Medium Impact

FeatureDescriptionComplexity
Proxy ServerUse any model with Claude Code via local proxy🟡 Medium
Worker DispatchMore granular worker control🟢 Low
Embeddings ManagementBetter model management🟢 Low

Integration Roadmap

Phase 1: Quick Wins (1 week) → 9.3 → 9.5

FeatureEffortImpactSource
Model Optimization flags🟢 Low🔴 HighNew command
Provider fallback config🟢 Low🔴 HighNew subcommand
Embeddings download/benchmark🟢 Low🟡 MedEnhance existing
bash
# After Phase 1:
claude-flow agent spawn -t coder --optimize --priority cost
claude-flow providers fallback configure --primary anthropic --fallback openrouter,onnx
claude-flow embeddings download all-MiniLM-L6-v2

Phase 2: Core Integration (2-3 weeks) → 9.5 → 9.7

FeatureEffortImpactSource
Federation Hub🟡 Med🔴 HighPort from agentic-flow
Ephemeral agents🟡 Med🔴 HighPart of federation
Proxy server🟡 Med🟡 MedPort from agentic-flow
Worker dispatch triggers🟢 Low🟡 MedEnhance daemon
bash
# After Phase 2:
claude-flow federation start --port 9443
claude-flow federation spawn --lifetime 300 --task "Quick analysis"
claude-flow proxy start --provider openrouter
claude-flow daemon dispatch security-audit

Phase 3: Advanced (4-6 weeks) → 9.7 → 9.9

FeatureEffortImpactSource
QUIC Transport🔴 High🔴 HighPort QUIC module
ReasoningBank (WASM)🔴 High🔴 HighPort + WASM build
66 Agent configs🟡 Med🟡 MedCopy + adapt
bash
# After Phase 3:
claude-flow swarm start --transport quic  # 50-70% faster
claude-flow reasoningbank store "pattern" --reasoning "..."
claude-flow agent spawn -t security-analyst  # One of 66 types

Option A: Dependency Approach (Fastest)

json
// claude-flow/package.json
{
  "dependencies": {
    "agentic-flow": "^2.0.3"
  }
}

Option B: Port Code (More Control)

bash
# Copy specific modules:
- agentic-flow/src/transport/quic.ts → claude-flow/src/transport/
- agentic-flow/src/federation/ → claude-flow/src/federation/
- agentic-flow/src/reasoningbank/ → claude-flow/src/reasoningbank/

Option C: Unified Package (Long-term)

bash
@claude-flow/core      # Shared primitives
@claude-flow/cli       # CLI (current)
@claude-flow/agents    # From agentic-flow's 66 agents
@claude-flow/transport # QUIC + HTTP + WebSocket

ruvector Integration Analysis

Package Overview

PackageVersionDescription
ruvector0.1.95Main CLI + unified interface
@ruvector/core0.1.30Rust-native vector DB (52K+ inserts/sec)
@ruvector/attention0.1.4Flash Attention mechanisms
@ruvector/sona0.1.5Self-Optimizing Neural Architecture (LoRA, EWC++)
@ruvector/gnn0.1.22Graph Neural Networks

Feature Overlap Analysis

claude-flow ALREADY HAS (via @claude-flow/embeddings):

Featureclaude-flowruvectorStatus
ONNX Embeddings✅ agentic-flow (~3ms)✅ @ruvector/coreEquivalent
Local Embeddings✅ all-MiniLM-L6-v2✅ all-MiniLM-L6-v2Equivalent
HNSW Indexing✅ @claude-flow/memory✅ @ruvector/coreEquivalent
Persistent Cache✅ SQLite + LRU✅ Memory cacheEquivalent
Hyperbolic Embeddings✅ Poincaré ballclaude-flow ahead
Document Chunking✅ 4 strategiesclaude-flow ahead
Normalization✅ L2, L1, min-max, z-scoreclaude-flow ahead
Neural Substrate✅ Drift, memory physicsclaude-flow ahead

Unique ruvector Features (Integration Candidates)

🔴 Tier 1: High Value (claude-flow lacks these)

Featureruvector SourceIntegration TargetValue
Q-Learning Agent Routerhooks_routehooks route --task80%+ accuracy, learns patterns
AST Analysishooks_ast_analyzeanalyze --astSymbol extraction, complexity
Diff Classificationhooks_diff_analyzeanalyze --diff --riskChange risk scoring
Coverage Routinghooks_coverage_routehooks route --coverage-awareTest-aware agent selection

🟡 Tier 2: Medium Value

Featureruvector SourceIntegration Target
Co-edit PredictionGit history analysispredict --coedits
Security Patternshooks_security_scansecurity scan --patterns

🟢 Tier 3: Nice to Have

Featureruvector SourceUse Case
MinCut Boundarieshooks_graph_mincutCode organization
Louvain Communitieshooks_graph_clusterModule detection
GNN Layers@ruvector/gnnGraph analysis

Note: Flash Attention, SONA Learning, HNSW, and ONNX embeddings are already in claude-flow via agentic-flow.

MCP Tools from ruvector (Unique Only)

bash
# Add ruvector MCP server (for unique features)
claude mcp add ruvector-mcp -- npx ruvector mcp-server

Unique Tools Worth Integrating:

  • hooks_route, hooks_route_enhanced — Q-Learning agent routing (80%+ accuracy) ✅
  • hooks_ast_analyze, hooks_ast_complexity — Code structure analysis ✅
  • hooks_diff_analyze, hooks_diff_classify — Change classification ✅
  • hooks_coverage_route, hooks_coverage_suggest — Test-aware routing ✅
  • hooks_graph_mincut, hooks_graph_cluster — Code boundaries ✅

Already in claude-flow (skip):

  • hooks_rag_context — Use @claude-flow/memory instead
  • hooks_attention_info — Use @claude-flow/neural instead
  • Embeddings tools — Use @claude-flow/embeddings instead

Integration Approach

Recommended: Option A - Add as Optional Dependency (for unique features only)

json
// @claude-flow/cli/package.json
{
  "optionalDependencies": {
    "ruvector": "^0.1.95"
  }
}

CLI Wrappers (unique ruvector features):

bash
# Q-Learning agent routing (unique to ruvector)
claude-flow route "task" --q-learning          # Uses hooks_route

# AST analysis (unique to ruvector)
claude-flow analyze ast src/                   # Uses hooks_ast_analyze

# Diff classification (unique to ruvector)
claude-flow analyze diff --risk                # Uses hooks_diff_analyze

# Coverage-aware routing (unique to ruvector)
claude-flow route "task" --coverage-aware      # Uses hooks_coverage_route

Already in claude-flow (DO NOT import from ruvector):

bash
claude-flow embeddings generate --local        # Uses @claude-flow/embeddings (ONNX)
claude-flow memory search --semantic "query"   # Uses @claude-flow/memory (HNSW)

ruvector Integration Roadmap

Phase 1: Q-Learning Router (1-2 days)

  • Add ruvector as optional dependency
  • Implement hooks route --q-learning wrapper
  • Add info --ruvector command for capability detection

Phase 2: Code Intelligence (1 week)

  • Integrate AST analysis commands (analyze ast)
  • Implement diff classification (analyze diff --risk)
  • Add coverage-aware routing (route --coverage-aware)

Phase 3: Graph Analysis (2 weeks)

  • Implement MinCut boundaries (analyze --boundaries)
  • Add Louvain community detection (analyze --modules)
  • Integrate GNN layers for dependency graphs

Note: SONA, Flash Attention, HNSW already in claude-flow - no need to import.