#!/usr/bin/env python3 """Confirm all Engrams that originated from context-buffer topic-*.md files.""" import sys import json from pathlib import Path BRAIN_DIR = Path("/root/.openclaw/workspace/second-brain") sys.path.insert(0, str(BRAIN_DIR)) from src.store import EngramStore DB_PATH = BRAIN_DIR / "data" / "brain.sqlite" store = EngramStore(str(DB_PATH)) # Finde alle Engrams, deren filepath "topic-" enthält cursor = store._conn.execute( "SELECT id, metadata_json FROM engrams WHERE metadata_json LIKE ?", ('%"filepath": "%topic-%',) ) rows = cursor.fetchall() print(f"Gefundene Context-Buffer Topics: {len(rows)}") confirmed = 0 for eid, meta_json in rows: try: meta = json.loads(meta_json) filepath = meta.get("filepath", "") if "topic-" not in filepath: continue eg = store.get(eid) if eg is None: continue eg.correctness.confirmed = True eg.correctness.verdict = "confirmed_true" store.save(eg) confirmed += 1 except Exception as e: print(f"Fehler bei {eid}: {e}") print(f"Bestätigte Topics: {confirmed}")