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: Edit /workspaces/claude-code-flow/docs/memory-fixes-summary.md

rUv16b606541639
diff --git a/.claude/checkpoints/1754404164.json b/.claude/checkpoints/1754404164.json
new file mode 100644
index 0000000000..5d1aef0588
--- /dev/null
+++ b/.claude/checkpoints/1754404164.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250805-142923", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/memory.js", "timestamp": "2025-08-05T14:29:24Z", "type": "pre-edit", "original_branch": "alpha-86"}
diff --git a/.claude/checkpoints/1754404165.json b/.claude/checkpoints/1754404165.json
new file mode 100644
index 0000000000..ef5ba71a67
--- /dev/null
+++ b/.claude/checkpoints/1754404165.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250805-142925", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/memory.js", "timestamp": "2025-08-05T14:29:25Z", "type": "post-edit", "branch": "alpha-86", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 2912 +++++++++++++----------------- .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1754404152.json | 1 + .claude/checkpoints/1754404154.json | 1 + memory/memory-store.json | 6 + src/cli/simple-commands/memory.js | 3 +- 7 files changed, 1290 insertions(+), 1641 deletions(-) "}
diff --git a/docs/memory-fixes-summary.md b/docs/memory-fixes-summary.md
new file mode 100644
index 0000000000..55b53222e9
--- /dev/null
+++ b/docs/memory-fixes-summary.md
@@ -0,0 +1,141 @@
+# Memory System Fixes Summary
+
+This document summarizes the fixes implemented for GitHub issue #589.
+
+## Issues Fixed
+
+### 1. CLI Namespace Flag Not Working
+
+**Problem**: The `--namespace` option in CLI memory commands didn't work correctly (always stored in default namespace).
+
+**Root Cause**: The namespace was being extracted from `subArgs` instead of the `flags` parameter passed by Commander.js.
+
+**Fix Implemented**:
+- Modified `memoryCommand` function to extract namespace from `flags` parameter
+- Updated all subfunctions to accept and use the namespace parameter
+- Fixed parameter extraction logic in `queryMemory`, `exportMemory`, and `clearMemory`
+
+**Files Modified**:
+- `/src/cli/simple-commands/memory.js`
+
+**Testing Results**:
+```bash
+# Store in custom namespace - WORKING βœ“
+npx claude-flow memory store testkey1 "test value 1" --namespace custom-ns
+
+# Query specific namespace - WORKING βœ“
+npx claude-flow memory query test --namespace custom-ns
+
+# Export specific namespace - WORKING βœ“
+npx claude-flow memory export test.json --namespace custom-ns
+
+# Clear specific namespace - WORKING βœ“
+npx claude-flow memory clear --namespace custom-ns
+```
+
+### 2. Database Fragmentation
+
+**Problem**: Multiple .db files scattered across different directories causing fragmentation and inconsistent memory storage.
+
+**Identified Database Files**:
+- `./.swarm/memory.db` (85MB)
+- `./.hive-mind/memory.db` (24KB)
+- `./.hive-mind/hive.db` (508KB)
+- `./.ruv-swarm/swarm.db` (0KB)
+- `./data/hive-mind.db` (148KB)
+- And several others in subdirectories
+
+**Solution Implemented**:
+
+1. **Memory Consolidation Utility** (`/src/cli/simple-commands/memory-consolidation.js`):
+ - Scans for all memory storage locations (JSON and SQLite)
+ - Creates automatic backups before consolidation
+ - Merges all stores into a unified SQLite database
+ - Optimizes with indices for better performance
+ - Maintains backward compatibility
+
+2. **Unified Memory Manager** (`/src/memory/unified-memory-manager.js`):
+ - Single interface for all memory operations
+ - Automatic detection of unified vs legacy stores
+ - Seamless fallback to JSON if SQLite unavailable
+ - Support for import/export operations
+
+3. **New CLI Command** (`memory-consolidate`):
+ ```bash
+ # Scan for all memory stores
+ npx claude-flow memory-consolidate scan
+
+ # Create consolidation plan
+ npx claude-flow memory-consolidate plan
+
+ # Execute consolidation (requires sqlite3 package)
+ npx claude-flow memory-consolidate execute --force
+
+ # Generate report
+ npx claude-flow memory-consolidate report
+ ```
+
+## Benefits
+
+1. **Namespace Support**: Properly isolate memory by namespace for better organization
+2. **Performance**: SQLite with indices provides faster queries than JSON scanning
+3. **Single Source of Truth**: All memory data in one location
+4. **Easier Backup**: Single database file to backup/restore
+5. **Reduced Fragmentation**: No more scattered .db files
+6. **Backward Compatibility**: Falls back to JSON if SQLite unavailable
+
+## Migration Path
+
+For users wanting to consolidate their fragmented databases:
+
+1. Install SQLite dependencies (optional but recommended):
+ ```bash
+ npm install sqlite3 sqlite
+ ```
+
+2. Run consolidation:
+ ```bash
+ npx claude-flow memory-consolidate scan
+ npx claude-flow memory-consolidate plan
+ npx claude-flow memory-consolidate execute --force
+ ```
+
+3. The unified database will be created at:
+ `./.claude-flow/memory/unified-memory.db`
+
+## Technical Details
+
+### Unified Database Schema
+```sql
+CREATE TABLE memory_entries (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ key TEXT NOT NULL,
+ value TEXT NOT NULL,
+ namespace TEXT NOT NULL DEFAULT 'default',
+ timestamp INTEGER NOT NULL,
+ source TEXT,
+ UNIQUE(key, namespace)
+);
+
+-- Performance indices
+CREATE INDEX idx_namespace ON memory_entries(namespace);
+CREATE INDEX idx_timestamp ON memory_entries(timestamp);
+CREATE INDEX idx_key ON memory_entries(key);
+CREATE INDEX idx_key_value ON memory_entries(key, value);
+CREATE INDEX idx_namespace_timestamp ON memory_entries(namespace, timestamp);
+```
+
+### Compatibility
+
+- The system automatically detects if a unified database exists
+- Falls back to JSON storage if SQLite modules unavailable
+- All existing memory commands work with both storage types
+- Import/export functionality preserved
+
+## Future Improvements
+
+1. Automatic migration on first run after update
+2. Memory quota management per namespace
+3. Memory compression for large values
+4. Cross-project memory sharing capabilities
+5. Memory versioning and history tracking
\ No newline at end of file