Codemine (QB) commited on
Commit Β·
ba60fcd
1
Parent(s): 289eae9
fix(openclaw_hook): ingest error path, checkpoint config re-apply, tonic gate (#215)
Browse files- openclaw_hook.py +19 -2
openclaw_hook.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
# ---- Changelog ----
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
# [2026-04-20] Codemine (BLK-NG-193) β Wire SimpleVectorDB persistence into save/load
|
| 3 |
# What: _vector_db_path added; __init__ loads sidecar if exists; save() writes it.
|
| 4 |
# Why: vector_db was recreated empty on every restart β recall() returned
|
|
@@ -136,6 +144,7 @@ class NeuroGraphMemory:
|
|
| 136 |
len(self.graph.nodes),
|
| 137 |
len(self.graph.synapses),
|
| 138 |
)
|
|
|
|
| 139 |
except Exception as exc:
|
| 140 |
logger.warning("Failed to restore checkpoint: %s", exc)
|
| 141 |
|
|
@@ -191,7 +200,8 @@ class NeuroGraphMemory:
|
|
| 191 |
except ImportError:
|
| 192 |
logger.info("Tonic engine not available β ouroboros-only mode")
|
| 193 |
except Exception as exc:
|
| 194 |
-
logger.
|
|
|
|
| 195 |
except Exception as exc:
|
| 196 |
logger.info("The Tonic not available: %s", exc)
|
| 197 |
|
|
@@ -232,7 +242,11 @@ class NeuroGraphMemory:
|
|
| 232 |
# Acquire graph lock β waits for Tonic engine to finish its current
|
| 233 |
# token before mutating graph state (RLock so re-entrant calls are safe).
|
| 234 |
with self.graph._concurrent_lock:
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
# Run SNN learning step
|
| 238 |
step_result = self.graph.step()
|
|
@@ -254,6 +268,9 @@ class NeuroGraphMemory:
|
|
| 254 |
if self._message_count % self.auto_save_interval == 0:
|
| 255 |
self.save()
|
| 256 |
|
|
|
|
|
|
|
|
|
|
| 257 |
return {
|
| 258 |
"status": "ingested",
|
| 259 |
"nodes_created": len(result.nodes_created),
|
|
|
|
| 1 |
# ---- Changelog ----
|
| 2 |
+
# [2026-04-26] Codemine (BLK-FC-215) β Three targeted bug fixes
|
| 3 |
+
# What: (A) on_message() wraps ingestor.ingest() in try/except; result=None on failure; return dict gated.
|
| 4 |
+
# (B) graph.config.update(snn_config) re-applied after restore() so checkpoint cannot overwrite code defaults.
|
| 5 |
+
# (C) Unexpected TonicEngine init Exception escalated to logger.warning; _tonic_thread cleared to None.
|
| 6 |
+
# Why: (A) Unbound NameError on result.nodes_created if ingest throws inside the concurrent lock.
|
| 7 |
+
# (B) Pre-tuning config values bleed in from checkpoint on every container restart.
|
| 8 |
+
# (C) Unexpected engine failures were silently swallowed at info level, leaving half-configured tonic state.
|
| 9 |
+
# How: Targeted edits only. Intentional scope differences (no CES, no River, no BrainSwitcher) preserved.
|
| 10 |
# [2026-04-20] Codemine (BLK-NG-193) β Wire SimpleVectorDB persistence into save/load
|
| 11 |
# What: _vector_db_path added; __init__ loads sidecar if exists; save() writes it.
|
| 12 |
# Why: vector_db was recreated empty on every restart β recall() returned
|
|
|
|
| 144 |
len(self.graph.nodes),
|
| 145 |
len(self.graph.synapses),
|
| 146 |
)
|
| 147 |
+
self.graph.config.update(snn_config)
|
| 148 |
except Exception as exc:
|
| 149 |
logger.warning("Failed to restore checkpoint: %s", exc)
|
| 150 |
|
|
|
|
| 200 |
except ImportError:
|
| 201 |
logger.info("Tonic engine not available β ouroboros-only mode")
|
| 202 |
except Exception as exc:
|
| 203 |
+
logger.warning("Tonic engine init error: %s β ouroboros-only mode", exc)
|
| 204 |
+
self._tonic_thread = None
|
| 205 |
except Exception as exc:
|
| 206 |
logger.info("The Tonic not available: %s", exc)
|
| 207 |
|
|
|
|
| 242 |
# Acquire graph lock β waits for Tonic engine to finish its current
|
| 243 |
# token before mutating graph state (RLock so re-entrant calls are safe).
|
| 244 |
with self.graph._concurrent_lock:
|
| 245 |
+
try:
|
| 246 |
+
result = self.ingestor.ingest(text, source_type=source_type)
|
| 247 |
+
except Exception as exc:
|
| 248 |
+
logger.warning("Ingest error: %s", exc)
|
| 249 |
+
result = None
|
| 250 |
|
| 251 |
# Run SNN learning step
|
| 252 |
step_result = self.graph.step()
|
|
|
|
| 268 |
if self._message_count % self.auto_save_interval == 0:
|
| 269 |
self.save()
|
| 270 |
|
| 271 |
+
if result is None:
|
| 272 |
+
return {"status": "error", "reason": "ingest_failed", "message_count": self._message_count}
|
| 273 |
+
|
| 274 |
return {
|
| 275 |
"status": "ingested",
|
| 276 |
"nodes_created": len(result.nodes_created),
|