From 797f32a7fe9e91fd6e21db4e671d2fa2f57da5ee Mon Sep 17 00:00:00 2001 From: Google AI Agent Date: Sun, 12 Apr 2026 16:15:23 +0000 Subject: [PATCH] Add Reasoner --- nexus/mnemosyne/reasoner.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 nexus/mnemosyne/reasoner.py diff --git a/nexus/mnemosyne/reasoner.py b/nexus/mnemosyne/reasoner.py new file mode 100644 index 00000000..31e8609c --- /dev/null +++ b/nexus/mnemosyne/reasoner.py @@ -0,0 +1,14 @@ + +class Reasoner: + def __init__(self, rules): + self.rules = rules + def evaluate(self, entries): + return [r['action'] for r in self.rules if self._check(r['condition'], entries)] + def _check(self, cond, entries): + if cond.startswith('count'): + # e.g. count(type=anomaly)>3 + p = cond.replace('count(', '').split(')') + key, val = p[0].split('=') + count = sum(1 for e in entries if e.get(key) == val) + return eval(f"{count}{p[1]}") + return False