diff --git a/nexus/components/memory-optimizer.js b/nexus/components/memory-optimizer.js index 1c583d26..732cc534 100644 --- a/nexus/components/memory-optimizer.js +++ b/nexus/components/memory-optimizer.js @@ -4,15 +4,25 @@ class MemoryOptimizer { this.threshold = options.threshold || 0.3; this.decayRate = options.decayRate || 0.01; this.lastRun = Date.now(); + this.blackboard = options.blackboard || null; } + optimize(memories) { const now = Date.now(); const elapsed = (now - this.lastRun) / 1000; this.lastRun = now; - return memories.map(m => { + + const result = memories.map(m => { const decay = (m.importance || 1) * this.decayRate * elapsed; return { ...m, strength: Math.max(0, (m.strength || 1) - decay) }; }).filter(m => m.strength > this.threshold || m.locked); + + if (this.blackboard) { + this.blackboard.write('memory_count', result.length, 'MemoryOptimizer'); + this.blackboard.write('optimization_last_run', now, 'MemoryOptimizer'); + } + + return result; } } export default MemoryOptimizer;