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

rUveb70b8c2e7f5
diff --git a/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts b/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts
index 2fa18628f8..315a4f64dc 100644
--- a/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts
+++ b/v3/@claude-flow/cli/src/ruvector/q-learning-router.ts
@@ -158,8 +158,37 @@ const ROUTE_NAMES = [
'documenter',
];
+/**
+ * Task feature keywords for state representation
+ */
+const FEATURE_KEYWORDS = [
+ // Code-related
+ 'implement', 'code', 'write', 'create', 'build', 'develop',
+ // Testing-related
+ 'test', 'spec', 'coverage', 'unit', 'integration', 'e2e',
+ // Review-related
+ 'review', 'check', 'audit', 'analyze', 'inspect',
+ // Architecture-related
+ 'architect', 'design', 'structure', 'pattern', 'system',
+ // Research-related
+ 'research', 'investigate', 'explore', 'find', 'search',
+ // Optimization-related
+ 'optimize', 'performance', 'speed', 'memory', 'improve',
+ // Debug-related
+ 'debug', 'fix', 'bug', 'error', 'issue', 'problem',
+ // Documentation-related
+ 'document', 'docs', 'readme', 'comment', 'explain',
+];
+
/**
* Q-Learning Router for intelligent task routing
+ *
+ * Optimized with:
+ * - LRU cache for repeated task patterns
+ * - Feature hashing for efficient state space
+ * - Exponential epsilon decay
+ * - Prioritized experience replay
+ * - Model persistence
*/
export class QLearningRouter {
private config: QLearningRouterConfig;
@@ -171,6 +200,20 @@ export class QLearningRouter {
private ruvectorEngine: unknown = null;
private useNative = false;
+ // Experience replay buffer (circular buffer)
+ private replayBuffer: Experience[] = [];
+ private replayBufferIdx = 0;
+ private totalExperiences = 0;
+
+ // LRU cache for route decisions
+ private routeCache: Map<string, CacheEntry> = new Map();
+ private cacheOrder: string[] = [];
+ private cacheHits = 0;
+ private cacheMisses = 0;
+
+ // Feature hash cache for state representation
+ private featureHashCache: Map<string, Float32Array> = new Map();
+
constructor(config: Partial<QLearningRouterConfig> = {}) {
this.config = { ...DEFAULT_CONFIG, ...config };
this.epsilon = this.config.explorationInitial;