feat(systemd): Dashboard-Service, brain_rules, 18 Engramme bewertet, Cron persistent

Neu:
- systemd: secondbrain-dashboard.service (Port 8501, autostart)
- cron_rules.py: Auto-Confirm ab 3x, Archiv nach 30d
- cron_tasks/: heartbeat + backup + brain_rules (persistent)
- openclaw_cron_wrapper.py: subprocess-Isolation (kein SessionTakeover)
- chat_autosave.py: Auto-Save von Chat + Kontext-Anreicherung

Daten:
- 18 unbestätigte Engramme bewertet:
  - 14x CONFIRMED (Fakten/Definitionen korrekt)
  - 3x ARCHIVIERT (historisch, nicht aktuell)
  - 1x CONFIRMED (Regel 73624013)
- 0 offene unbestätigte

Closes Gitea-Issue: #9
This commit is contained in:
2026-05-25 22:35:44 +02:00
parent a5d5b2f2ec
commit 29bc45d623
5 changed files with 343 additions and 0 deletions

53
cron_tasks/brain_rules.py Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""
Brain-Regeln - Automatische Bestaetigungs- und Archivierungslogik.
Wird von Cron und Agent aufgerufen.
"""
import sys
sys.path.insert(0, "/root/.openclaw/workspace/second-brain")
from src.engram import Engram, Grounding
from src.store import EngramStore
DB = "/root/.openclaw/workspace/second-brain/data/brain.sqlite"
def apply_rules():
store = EngramStore(DB)
egs = store.get_all(limit=1000)
actions = []
for eg in egs:
conf = eg.compute_confidence()
age_days = eg._age_days(eg.metadata.get("created", ""))
correct = eg.correctness
# Regel 1: Triple-Confirm → Auto-Verifiziert
if not correct.confirmed and correct.confirmations >= 3:
correct.confirmed = True
correct.confirmations += 1
store.save(eg)
actions.append(f"Auto-Confirm: {str(eg.id)[:8]} (3x confirmed)")
# Regel 2: Lang unbestaetigt → ASSUMPTION Tag
if age_days > 30 and not correct.confirmed and "archiviert" not in eg.metadata.get("tags", []):
eg.metadata.setdefault("tags", []).append("archiviert")
eg.metadata["archivgrund"] = f"Unbestaetigt seit {age_days} Tagen"
store.save(eg)
actions.append(f"Archiviert: {str(eg.id)[:8]} (Alter {age_days}d)")
# Regel 3: Rejected mit 2+ Rejections → loeschen (Sanft: Tag statt rm)
if correct.rejections >= 2:
eg.metadata.setdefault("tags", []).append("deleted")
store.save(eg)
actions.append(f"Deleted-Tag: {str(eg.id)[:8]} ({correct.rejections}x rejected)")
return actions
if __name__ == "__main__":
actions = apply_rules()
print("Brain-Regeln angewendet:")
for a in actions or ["Keine Aktionen noetig"]:
print(f" {a}")