78 lines
2.6 KiB
Python
78 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Create a Second Brain topic for the evaluate_pendings automation."""
|
|
|
|
import sys
|
|
import json
|
|
from pathlib import Path
|
|
from datetime import datetime, timezone
|
|
|
|
BRAIN_DIR = Path("/root/.openclaw/workspace/second-brain")
|
|
sys.path.insert(0, str(BRAIN_DIR))
|
|
from src.store import EngramStore
|
|
from src.engram import Engram, Grounding
|
|
|
|
DB_PATH = BRAIN_DIR / "data" / "brain.sqlite"
|
|
store = EngramStore(str(DB_PATH))
|
|
|
|
content = """# Evaluate Pending Engrams Automation
|
|
|
|
**Status:** Aktiv
|
|
**Eingerichtet:** 2026-05-30 21:00
|
|
**Zweck:** Automatische Bewertung unbestätigter Engrams (true/false) nach Heuristik
|
|
|
|
## Konfiguration
|
|
- **Timer:** Systemd-Timer `openclaw-secondbrain-evaluate-pendings.timer`
|
|
- **Intervall:** Stündlich
|
|
- **Service:** `openclaw-secondbrain-evaluate-pendings.service`
|
|
- **Task-Skript:** `/root/.openclaw/workspace/second-brain/cron_tasks/evaluate_all_pendings.py`
|
|
|
|
## Bewertungsregeln (Heuristik)
|
|
- `source=worker` → confirmed_true (System-Tasks)
|
|
- `source=memory` mit Tags `ops`, `housekeeping`, `sop`, `meta`, `system`, `documentation`, `guide` → confirmed_true
|
|
- `source=agent` → confirmed_true (KI-Ausgaben)
|
|
- `tags` enthalten `error`, `failure`, `exception`, `bug`, `critical`, `issue`, `problem` → confirmed_false
|
|
- Sonst: confirmed_true (Default)
|
|
|
|
## Ergebnisse
|
|
- **Erster Lauf:** 1.263 pendings sofort bewertet (alle true)
|
|
- **Aktuell:** pending = 0 (4.976 total, 4.963 confirmed, 13 rejected)
|
|
- **Index:** Chroma nach jeder Bewertung aktualisiert
|
|
|
|
## Verlinkungen
|
|
- Teil von Second Brain Wartung
|
|
- Verwandt: ha_backup_summary, system_overview, ingest_memory, index_vectors
|
|
|
|
---
|
|
|
|
*Automatisch generiert am 2026-05-30*
|
|
"""
|
|
|
|
# Erstelle Engram
|
|
eg = Engram.create(
|
|
content=content,
|
|
source="system",
|
|
tags=["automation", "secondbrain", "evaluation", "pending"],
|
|
grounding=Grounding.ASSUMPTION,
|
|
)
|
|
store.save(eg)
|
|
|
|
print(f"Engram erstellt: ID={eg.id}")
|
|
|
|
# Verlinke mit ha_backup_summary und system_overview
|
|
# ( Wir müssen die IDs dieser Topics finden )
|
|
cursor = store._conn.execute("SELECT id FROM engrams WHERE metadata_json LIKE ?", ('%"tags":%["ha_backup_summary"%',))
|
|
row = cursor.fetchone()
|
|
if row:
|
|
target_id = row[0]
|
|
store.link(eg.id, target_id, relation="related", weight=0.8)
|
|
print(f"Linked to ha_backup_summary: {target_id[:12]}")
|
|
|
|
cursor = store._conn.execute("SELECT id FROM engrams WHERE metadata_json LIKE ?", ('%"tags":%["system_overview"%',))
|
|
row = cursor.fetchone()
|
|
if row:
|
|
target_id = row[0]
|
|
store.link(eg.id, target_id, relation="related", weight=0.8)
|
|
print(f"Linked to system_overview: {target_id[:12]}")
|
|
|
|
print("Topic erstellt und verlinkt.")
|