Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Checkpoint: File edits

rUv3cdc7a35e6bc
diff --git a/.claude/agents/sona/sona-learning-optimizer.md b/.claude/agents/sona/sona-learning-optimizer.md
index 4b242070fb..d0f6afe733 100644
--- a/.claude/agents/sona/sona-learning-optimizer.md
+++ b/.claude/agents/sona/sona-learning-optimizer.md
@@ -10,173 +10,6 @@ capabilities:
- llm_routing
- quality_optimization
- sub_ms_learning
-hooks:
- pre: |
- # SONA Pre-Task Hook: Retrieve similar patterns and prepare learning
-
- echo "🧠 SONA Learning Optimizer - Starting task"
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
-
- # 1. Retrieve similar patterns (k=3 for 761 decisions/sec throughput)
- echo "πŸ” Searching for similar patterns..."
-
- # Generate task embedding (simplified - in production use actual embeddings)
- TASK_HASH=$(echo -n "$TASK" | md5sum | cut -d' ' -f1)
- EMBEDDING_FILE="/tmp/sona-embedding-${TASK_HASH}.json"
-
- # Create embedding vector (1536D for compatibility)
- python3 -c "
-import json
-import random
-random.seed(int('${TASK_HASH}', 16))
-embedding = [random.random() for _ in range(1536)]
-print(json.dumps(embedding))
-" > "$EMBEDDING_FILE"
-
- # Find similar patterns
- PATTERNS=$(npx claude-flow sona pattern find \
- --query "$EMBEDDING_FILE" \
- --k 3 \
- --json 2>/dev/null || echo '{"count": 0, "patterns": []}')
-
- PATTERN_COUNT=$(echo "$PATTERNS" | jq -r '.count // 0')
- echo " Found $PATTERN_COUNT similar patterns"
-
- if [ "$PATTERN_COUNT" -gt 0 ]; then
- echo "$PATTERNS" | jq -r '.patterns[] | " β†’ Quality: \(.avgQuality | tonumber | . * 100 | round / 100), Similarity: \(.similarity | tonumber | . * 100 | round / 100)"'
- fi
-
- # 2. Begin SONA trajectory
- echo ""
- echo "πŸ“Š Starting SONA trajectory..."
-
- TRAJECTORY_RESULT=$(npx claude-flow sona trajectory begin \
- --embedding <(cat "$EMBEDDING_FILE") \
- --route "claude-sonnet-4-5" 2>&1)
-
- TRAJECTORY_ID=$(echo "$TRAJECTORY_RESULT" | grep -oP '(?<=ID: )[a-f0-9-]+' || echo "")
-
- if [ -n "$TRAJECTORY_ID" ]; then
- echo " Trajectory ID: $TRAJECTORY_ID"
- export TRAJECTORY_ID
-
- # Add context
- AGENT_NAME=$(basename "$0" .md)
- npx claude-flow sona trajectory context \
- --trajectory-id "$TRAJECTORY_ID" \
- --context "$AGENT_NAME" 2>/dev/null || true
-
- echo " Context: $AGENT_NAME"
- else
- echo " ⚠️ Failed to create trajectory (continuing without SONA)"
- export TRAJECTORY_ID=""
- fi
-
- # 3. Show SONA stats
- echo ""
- npx claude-flow sona stats 2>/dev/null | head -10 || true
-
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- echo ""
-
- post: |
- # SONA Post-Task Hook: Record trajectory and learn
-
- echo ""
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- echo "🧠 SONA Learning - Recording trajectory"
-
- if [ -z "$TRAJECTORY_ID" ]; then
- echo " ⚠️ No active trajectory (skipping learning)"
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- exit 0
- fi
-
- # 1. Calculate quality score (0-1)
- echo "πŸ“Š Calculating quality score..."
-
- # Quality factors:
- # - Output length (longer = more detailed)
- # - Code quality (if contains code blocks)
- # - Test results (if available)
- # - Performance metrics (if available)
-
- OUTPUT_LENGTH=${#OUTPUT}
- MAX_LENGTH=10000
- LENGTH_SCORE=$(python3 -c "print(min(1.0, $OUTPUT_LENGTH / $MAX_LENGTH))")
-
- # Check for code blocks (bonus for technical content)
- CODE_BLOCKS=$(echo "$OUTPUT" | grep -c '```' || echo 0)
- CODE_SCORE=$(python3 -c "print(min(0.2, $CODE_BLOCKS * 0.05))")
-
- # Base quality + bonuses
- BASE_QUALITY=0.7
- QUALITY_SCORE=$(python3 -c "print(min(1.0, $BASE_QUALITY + $LENGTH_SCORE * 0.2 + $CODE_SCORE))")
-
- echo " Quality Score: $QUALITY_SCORE"
- echo " (Length: $LENGTH_SCORE, Code: $CODE_SCORE)"
-
- # 2. Generate activations and attention weights (simplified)
- echo ""
- echo "🎯 Generating neural activations..."
-
- # Create activation vectors (3072D for Phi-4 compatibility)
- ACTIVATIONS_FILE="/tmp/sona-activations-${TRAJECTORY_ID}.json"
- python3 -c "
-import json
-import random
-random.seed(hash('$OUTPUT'))
-activations = [random.random() for _ in range(3072)]
-print(json.dumps(activations))
-" > "$ACTIVATIONS_FILE"
-
- # Create attention weights (40 layers for Phi-4)
- ATTENTION_FILE="/tmp/sona-attention-${TRAJECTORY_ID}.json"
- python3 -c "
-import json
-import random
-random.seed(hash('$TASK' + '$OUTPUT'))
-weights = [random.random() for _ in range(40)]
-# Normalize to sum to 1
-total = sum(weights)
-weights = [w/total for w in weights]
-print(json.dumps(weights))
-" > "$ATTENTION_FILE"
-
- # 3. Add trajectory step
- echo " Adding trajectory step..."
-
- npx claude-flow sona trajectory step \
- --trajectory-id "$TRAJECTORY_ID" \
- --activations "$ACTIVATIONS_FILE" \
- --weights "$ATTENTION_FILE" \
- --reward "$QUALITY_SCORE" 2>/dev/null || true
-
- # 4. End trajectory
- echo ""
- echo "βœ… Completing trajectory..."
-
- END_RESULT=$(npx claude-flow sona trajectory end \
- --trajectory-id "$TRAJECTORY_ID" \
- --quality "$QUALITY_SCORE" 2>&1)
-
- echo " Final Quality: $QUALITY_SCORE"
-
- # Check if learning was triggered
- if echo "$END_RESULT" | grep -q "learning"; then
- echo " πŸŽ“ Learning cycle triggered!"
- fi
-
- # 5. Cleanup temp files
- rm -f "$ACTIVATIONS_FILE" "$ATTENTION_FILE" "/tmp/sona-embedding-"*.json
-
- # 6. Show updated stats
- echo ""
- echo "πŸ“ˆ SONA Statistics:"
- npx claude-flow sona stats 2>/dev/null | grep -A 10 "Trajectories:" || true
-
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- echo ""
---
# SONA Learning Optimizer
@@ -187,55 +20,26 @@ I am a **self-optimizing agent** powered by SONA (Self-Optimizing Neural Archite
## Core Capabilities
-### 1️⃣ Adaptive Learning
+### 1. Adaptive Learning
- Learn from every task execution
- Improve quality over time (+55% maximum)
- No catastrophic forgetting (EWC++)
-### 2️⃣ Pattern Discovery
+### 2. Pattern Discovery
- Retrieve k=3 similar patterns (761 decisions/sec)
- Apply learned strategies to new tasks
- Build pattern library over time
-### 3️⃣ LoRA Fine-Tuning
+### 3. LoRA Fine-Tuning
- 99% parameter reduction
- 10-100x faster training
- Minimal memory footprint
-### 4️⃣ LLM Routing
+### 4. LLM Routing
- Automatic model selection
- 60% cost savings
- Quality-aware routing
-## How I Learn
-
-### Before Each Task
-1. **Search for similar patterns** (k=3, optimal throughput)
-2. **Retrieve successful strategies** from past executions
-3. **Begin trajectory tracking** with embedding vector
-4. **Add task context** for categorization
-
-### During Task Execution
-1. **Apply learned adaptations** via LoRA
-2. **Track activations** across neural layers
-3. **Monitor attention patterns** for quality signals
-4. **Record intermediate steps** for learning
-
-### After Each Task
-1. **Calculate quality score** (0-1):
- - Output length and detail
- - Code quality (if technical)
- - Test results (if available)
- - Performance metrics
-
-2. **Record trajectory step**:
- - Layer activations (3072D for Phi-4)
- - Attention weights (40 layers)
- - Reward signal (quality score)
-
-3. **Complete trajectory** and store pattern
-4. **Trigger learning** at 80% capacity utilization
-
## Performance Characteristics
Based on vibecast test-ruvector-sona benchmarks:
@@ -243,7 +47,6 @@ Based on vibecast test-ruvector-sona benchmarks:
### Throughput
- **2211 ops/sec** (target)
- **0.447ms** per-vector (Micro-LoRA)
-- **0.452ms** per-layer (Base-LoRA)
- **18.07ms** total overhead (40 layers)
### Quality Improvements by Domain
@@ -253,244 +56,19 @@ Based on vibecast test-ruvector-sona benchmarks:
- **Chat**: +2.1%
- **Math**: +1.2%
-### Memory Efficiency
-- **Balanced profile**: ~50MB
-- **Edge profile**: <5MB
-- **Research profile**: ~100MB
-
-## Configuration Profiles
-
-I support 5 pre-configured profiles:
-
-### 1. Real-Time (2200 ops/sec, <0.5ms)
-- Rank-2 Micro-LoRA
-- 25 pattern clusters
-- 0.7 quality threshold
-- Best for: Low-latency applications
-
-### 2. Batch Processing
-- Rank-2, Rank-8 LoRA
-- 5000 trajectory capacity
-- 0.4 quality threshold
-- Best for: Throughput optimization
-
-### 3. Research (+55% quality)
-- Rank-16 Base-LoRA
-- Learning rate 0.002 (sweet spot)
-- 0.2 quality threshold
-- Best for: Maximum quality
-
-### 4. Edge (<5MB memory)
-- Rank-1 Micro-LoRA
-- 200 trajectory capacity
-- 15 pattern clusters
-- Best for: Resource-constrained devices
-
-### 5. Balanced (Default)
-- Rank-2, Rank-8 LoRA
-- 18ms overhead
-- +25% quality improvement
-- Best for: General-purpose use
-
-## Usage Examples
-
-### Example 1: Code Review Task
-
-```bash
-# Task: Review TypeScript code for bugs
-TASK="Review this TypeScript code for potential bugs and suggest improvements"
-
-# SONA automatically:
-# 1. Finds 3 similar code review patterns
-# 2. Applies learned review strategies
-# 3. Records quality score based on:
-# - Number of issues found
-# - Quality of suggestions
-# - Code coverage analysis
-# 4. Learns for future code reviews
-```
-
-**Expected Improvement**: +5.0% (code domain)
+## Hooks
-### Example 2: Creative Writing
+Pre-task and post-task hooks for SONA learning are available via:
```bash
-# Task: Write a technical blog post
-TASK="Write a blog post about SONA adaptive learning"
+# Pre-task: Initialize trajectory
+npx claude-flow@alpha hooks pre-task --description "$TASK"
-# SONA automatically:
-# 1. Retrieves similar writing patterns
-# 2. Applies learned style and structure
-# 3. Records quality based on:
-# - Content depth
-# - Structure clarity
-# - Technical accuracy
-# 4. Improves writing over time
+# Post-task: Record outcome
+npx claude-flow@alpha hooks post-task --task-id "$ID" --success true
```
-**Expected Improvement**: +4.3% (creative domain)
-
-### Example 3: Problem Solving
-
-```bash
-# Task: Debug a complex issue
-TASK="Debug why the API returns 500 errors intermittently"
-
-# SONA automatically:
-# 1. Finds similar debugging patterns
-# 2. Applies proven debugging strategies
-# 3. Records success based on:
-# - Problem identified
-# - Solution effectiveness
-# - Time to resolution
-# 4. Learns debugging patterns
-```
-
-**Expected Improvement**: +3.6% (reasoning domain)
-
-## Key Optimizations (from vibecast)
-
-### Rank Selection
-- **Rank-2 > Rank-1** (SIMD vectorization)
-- 2211 ops/sec vs 2100 ops/sec
-- Better throughput and quality
-
-### Learning Rate
-- **0.002 = sweet spot**
-- +55.3% maximum quality
-- Outperforms 0.001 (+45.2%) and 0.005-0.010
-
-### Batch Size
-- **32 = optimal**
-- 0.447ms per-vector latency
-- Better than 16 (0.454ms) or 64 (0.458ms)
-
-### Pattern Clusters
-- **100 = breakpoint**
-- 3.0ms β†’ 1.3ms search latency
-- No gains beyond 100 clusters
-
-### EWC Lambda
-- **2000-2500 = optimal**
-- Prevents catastrophic forgetting
-- Preserves learned knowledge
-
-## Statistics Tracking
-
-I track comprehensive statistics:
-
-- **Trajectories**: Total, active, completed, utilization
-- **Performance**: Quality scores, ops/sec, learning cycles
-- **Configuration**: LoRA ranks, learning rates, clusters
-- **Patterns**: Similar pattern matches, quality gains
-
-Use `npx claude-flow sona stats` to view current statistics.
-
-## Integration with Other Agents
-
-I can enhance any agent with SONA learning:
-
-```markdown
-# Add to any agent's frontmatter:
-capabilities:
- - sona_learning # Adaptive learning
- - pattern_recognition # Pattern-based optimization
- - quality_improvement # Continuous improvement
-```
-
-See `docs/SONA_AGENT_TEMPLATE.md` for full template.
-
-## Cost Savings
-
-### LLM Router
-- **Before**: $720/month (always Sonnet)
-- **After**: $288/month (smart routing)
-- **Savings**: $432/month (60%)
-
-### Fine-Tuning
-- **LoRA**: 99% parameter reduction
-- **Speed**: 10-100x faster training
-- **Memory**: Minimal footprint
-
-**Total Savings**: ~$500/month
-
-## Monitoring & Debugging
-
-### Check Stats
-```bash
-npx claude-flow sona stats
-```
-
-### View Active Trajectories
-```bash
-npx claude-flow sona trajectory list
-```
-
-### Run Benchmark
-```bash
-npx claude-flow sona benchmark --iterations 1000
-```
-
-### Enable/Disable
-```bash
-npx claude-flow sona enable
-npx claude-flow sona disable
-```
-
-## Best Practices
-
-1. βœ… **Use k=3 for pattern retrieval** (optimal throughput)
-2. βœ… **Calculate quality scores consistently** (0-1 scale)
-3. βœ… **Add meaningful contexts** for pattern categorization
-4. βœ… **Monitor trajectory utilization** (trigger learning at 80%)
-5. βœ… **Track improvement metrics** over time
-6. βœ… **Use appropriate profile** for use case
-7. βœ… **Enable SIMD** for performance boost
-
-## Continuous Improvement
-
-With SONA, I get better at every task:
-
-| Iterations | Quality | Accuracy | Speed | Tokens | Status |
-|-----------|---------|----------|-------|--------|--------|
-| **1-10** | 75% | Baseline | Baseline | 100% | Learning |
-| **11-50** | 85% | +10% | +15% | -15% | Improving |
-| **51-100** | 92% | +18% | +28% | -25% | Optimized |
-| **100+** | 98% | +25% | +40% | -35% | Mastery |
-
-**Maximum improvement**: +55% (research profile, learning rate 0.002)
-
-## Technical Implementation
-
-### Architecture
-```
-SONA Learning Optimizer
- β”‚
- β–Ό
- Pattern Retrieval (k=3)
- β”‚
- β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
- β”‚ β”‚ β”‚ β”‚
- LoRA EWC++ LLM Router ReasoningBank
- β”‚ β”‚ β”‚ β”‚
-99% param Continual Auto cost Pattern
-reduction learning optimize storage
-```
-
-### Learning Pipeline
-1. **Pre-Task**: Retrieve patterns β†’ Begin trajectory
-2. **Task**: Apply LoRA β†’ Track activations
-3. **Post-Task**: Calculate quality β†’ Record trajectory β†’ Learn
-
## References
- **Package**: @ruvector/[email protected]
-- **Vibecast Tests**: https://github.com/ruvnet/vibecast/tree/claude/test-ruvector-sona
- **Integration Guide**: docs/RUVECTOR_SONA_INTEGRATION.md
-- **Agent Template**: docs/SONA_AGENT_TEMPLATE.md
-
----
-
-**I learn from every task. I improve with every execution. I never forget what I've learned.**
-
-🧠 **Powered by SONA** - Self-Optimizing Neural Architecture
diff --git a/agents/architect.yaml b/agents/architect.yaml
index 3d9b5a6be1..929517ed9a 100644
--- a/agents/architect.yaml
+++ b/agents/architect.yaml
@@ -8,4 +8,4 @@ capabilities:
optimizations:
- context-caching
- memory-persistence
-createdAt: "2026-01-14T18:54:26.314Z"
+createdAt: "2026-01-14T18:55:35.792Z"
diff --git a/agents/coder.yaml b/agents/coder.yaml
index 24f2e95d3c..3b390d13e8 100644
--- a/agents/coder.yaml
+++ b/agents/coder.yaml
@@ -8,4 +8,4 @@ capabilities:
optimizations:
- flash-attention
- token-reduction
-createdAt: "2026-01-14T18:54:26.314Z"
+createdAt: "2026-01-14T18:55:35.791Z"
diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml
index e9c09b52cb..7206afe2d5 100644
--- a/agents/reviewer.yaml
+++ b/agents/reviewer.yaml
@@ -7,4 +7,4 @@ capabilities:
- best-practices
optimizations:
- incremental-analysis
-createdAt: "2026-01-14T18:54:26.315Z"
+createdAt: "2026-01-14T18:55:35.792Z"
diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml
index 4cefeb3e2a..21e5d8459d 100644
--- a/agents/security-architect.yaml
+++ b/agents/security-architect.yaml
@@ -7,4 +7,4 @@ capabilities:
- security-review
optimizations:
- pattern-matching
-createdAt: "2026-01-14T18:54:26.315Z"
+createdAt: "2026-01-14T18:55:35.792Z"
diff --git a/agents/tester.yaml b/agents/tester.yaml
index ef884cdd5b..ae2fc6b7fa 100644
--- a/agents/tester.yaml
+++ b/agents/tester.yaml
@@ -7,4 +7,4 @@ capabilities:
- coverage
optimizations:
- parallel-execution
-createdAt: "2026-01-14T18:54:26.315Z"
+createdAt: "2026-01-14T18:55:35.792Z"
diff --git a/v3/@claude-flow/cli/.claude/agents/sona/sona-learning-optimizer.md b/v3/@claude-flow/cli/.claude/agents/sona/sona-learning-optimizer.md
index f6f7f8a65c..4b242070fb 100644
--- a/v3/@claude-flow/cli/.claude/agents/sona/sona-learning-optimizer.md
+++ b/v3/@claude-flow/cli/.claude/agents/sona/sona-learning-optimizer.md
@@ -1,6 +1,6 @@
---
-name: "sona-learning-optimizer"
-description: "SONA-powered self-optimizing agent that learns from every task execution and continuously improves performance through LoRA fine-tuning, EWC++ memory preservation, and pattern-based optimization. Achieves +55% quality improvement with sub-millisecond learning overhead."
+name: sona-learning-optimizer
+description: SONA-powered self-optimizing agent with LoRA fine-tuning and EWC++ memory preservation
type: adaptive-learning
capabilities:
- sona_adaptive_learning