Compare commits

...

2 Commits

Author SHA1 Message Date
fec98e9499 Add Symbolic Reasoner 2026-04-12 16:14:50 +00:00
2240143df7 Enhance MemoryOptimizer with temporal decay 2026-04-12 16:14:49 +00:00
2 changed files with 41 additions and 6 deletions

View File

@@ -1,13 +1,22 @@
class MemoryOptimizer {
constructor(options = {}) {
this.threshold = options.threshold || 0.8;
this.decayRate = options.decayRate || 0.05;
this.threshold = options.threshold || 0.3;
this.decayRate = options.decayRate || 0.01;
this.lastRun = Date.now();
}
optimize(memory) {
console.log('Optimizing memory...');
// Heuristic-based pruning
return memory.filter(m => m.strength > this.threshold);
optimize(memories) {
const now = Date.now();
const elapsed = (now - this.lastRun) / 1000;
this.lastRun = now;
console.log(`Optimizing ${memories.length} memories...`);
return memories.map(m => {
// Temporal decay: strength drops over time unless reinforced
const decay = m.importance * this.decayRate * elapsed;
return { ...m, strength: Math.max(0, m.strength - decay) };
}).filter(m => m.strength > this.threshold || m.locked);
}
}
export default MemoryOptimizer;

View File

@@ -0,0 +1,26 @@
"""Symbolic Reasoner — Rule-based event triggering for the Mnemosyne archive."""
import json
class Reasoner:
def __init__(self, rules_path):
with open(rules_path) as f:
self.rules = json.load(f)
def evaluate(self, archive_entries):
triggers = []
for rule in self.rules:
if self._check_condition(rule['condition'], archive_entries):
triggers.append(rule['action'])
return triggers
def _check_condition(self, condition, entries):
# Simple symbolic checks: e.g., "count(type=error) > 5"
if condition.startswith("count"):
parts = condition.split(" ")
key, val = parts[0][6:-1].split("=")
op = parts[1]
threshold = int(parts[2])
count = sum(1 for e in entries if e.get(key) == val)
if op == ">": return count > threshold
return False