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 edit:

rUvc798898aa82e
diff --git a/v3/@claude-flow/memory/src/agentdb-backend.ts b/v3/@claude-flow/memory/src/agentdb-backend.ts
index 7da9c0100c..ba1007f2da 100644
--- a/v3/@claude-flow/memory/src/agentdb-backend.ts
+++ b/v3/@claude-flow/memory/src/agentdb-backend.ts
@@ -919,18 +919,37 @@ export class AgentDBBackend extends EventEmitter implements IMemoryBackend {
}
/**
- * Convert numeric ID back to string (placeholder)
+ * Convert numeric ID back to string using O(1) reverse lookup
+ * PERFORMANCE FIX: Uses pre-built reverse map instead of O(n) linear scan
*/
private numericIdToString(numericId: number): string {
- // In practice, maintain a bidirectional map
- for (const [id, entry] of this.entries) {
- if (this.stringIdToNumeric(id) === numericId) {
- return id;
- }
+ // Use O(1) reverse lookup map
+ const stringId = this.numericToStringIdMap.get(numericId);
+ if (stringId) {
+ return stringId;
}
+ // Fallback for unmapped IDs
return String(numericId);
}
+ /**
+ * Register string ID in reverse lookup map
+ * Called when storing entries to maintain bidirectional mapping
+ */
+ private registerIdMapping(stringId: string): void {
+ const numericId = this.stringIdToNumeric(stringId);
+ this.numericToStringIdMap.set(numericId, stringId);
+ }
+
+ /**
+ * Unregister string ID from reverse lookup map
+ * Called when deleting entries
+ */
+ private unregisterIdMapping(stringId: string): void {
+ const numericId = this.stringIdToNumeric(stringId);
+ this.numericToStringIdMap.delete(numericId);
+ }
+
/**
* Cosine similarity
*/