From 80a47a184bb1f7f573243ecdfbaabba3d055a831 Mon Sep 17 00:00:00 2001 From: Toni Nowak Date: Mon, 22 Jun 2026 14:20:46 +0200 Subject: [PATCH] fix(storage): neuron_state record-id mismatch broke activation persistence add_neuron writes the activation-state record as neuron_state:state_, but get_neuron_state, update_neuron_state and the delete path addressed neuron_state: without the state_ prefix. So every get_neuron_state missed and returned None, every update/merge was a silent no-op, and the batch helpers (which delegate to these) cascaded empty. recall -> reinforce read empty states and wrote nothing back, so access_frequency / last_activated / activation_level stayed at 0 and the whole activation -> decay -> tiering -> consolidation loop was dormant. Three reader call sites now address neuron_state:state_, matching the writer. Re-scoped from #16 to the neuron_state fix only, dropping the unrelated deployment-specific changes that PR also carried. Co-authored-by: Robert Sigmundsson <230784065+RobertSigmundsson@users.noreply.github.com> --- src/surreal_memory/storage/surrealdb/store.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/surreal_memory/storage/surrealdb/store.py b/src/surreal_memory/storage/surrealdb/store.py index d92dea8c..4473e7fd 100755 --- a/src/surreal_memory/storage/surrealdb/store.py +++ b/src/surreal_memory/storage/surrealdb/store.py @@ -589,8 +589,8 @@ async def delete_neuron(self, neuron_id: str) -> bool: brain_id=brain_id, nid=sid, ) - # Delete state - await self._query(f"DELETE neuron_state:{sid}") + # Delete state (record id is state_, matching the writer in add_neuron) + await self._query(f"DELETE neuron_state:state_{sid}") try: await conn.delete(f"neuron:{sid}") @@ -616,7 +616,7 @@ async def get_neuron_state(self, neuron_id: str) -> NeuronState | None: conn = self._ensure_conn() sid = _to_surreal_id(neuron_id) try: - result = await conn.select(f"neuron_state:{sid}") + result = await conn.select(f"neuron_state:state_{sid}") if result: return _row_to_neuron_state(result[0] if isinstance(result, list) else result) except Exception: @@ -640,7 +640,7 @@ async def update_neuron_state(self, state: NeuronState) -> None: if state.refractory_until: update_data["refractory_until"] = state.refractory_until - await conn.merge(f"neuron_state:{sid}", update_data) + await conn.merge(f"neuron_state:state_{sid}", update_data) # ================================================================ # Synapse Operations