feat: add proactive cron tasks and systemd timers\n\n- 10 proactive tasks: ingest with self-healing & link suggestions, daily summary, health check, archive stale, tag normalizer, predictive links, auto assign review, import context buffer\n- systemd timers for scheduling (02:00/14:00 slots, 30min intervals, weekly)\n- all tasks tested and working\n\nRefs: #1
This commit is contained in:
41
cron_tasks/index_vectors_fix.py
Normal file
41
cron_tasks/index_vectors_fix.py
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Force index all missing Engrams into Chroma."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
BRAIN_DIR = Path("/root/.openclaw/workspace/second-brain")
|
||||
sys.path.insert(0, str(BRAIN_DIR))
|
||||
from src.store import EngramStore
|
||||
from src.chroma_store import ChromaStore
|
||||
|
||||
DB_PATH = BRAIN_DIR / "data" / "brain.sqlite"
|
||||
CHROMA_DIR = BRAIN_DIR / "data" / "chroma"
|
||||
|
||||
store = EngramStore(str(DB_PATH))
|
||||
chroma = ChromaStore(str(CHROMA_DIR))
|
||||
|
||||
# Get all DB IDs
|
||||
db_ids = [row[0] for row in store._conn.execute("SELECT id FROM engrams").fetchall()]
|
||||
existing = set(chroma.collection.get(include=[])["ids"])
|
||||
missing = [eid for eid in db_ids if eid not in existing]
|
||||
|
||||
print(f"DB: {len(db_ids)} IDs, Chroma: {len(existing)} IDs, Missing: {len(missing)}")
|
||||
|
||||
indexed = 0
|
||||
errors = []
|
||||
for eid in missing:
|
||||
try:
|
||||
eg = store.get(eid)
|
||||
if eg is None:
|
||||
errors.append(f"{eid}: not found")
|
||||
continue
|
||||
chroma.add(eg)
|
||||
indexed += 1
|
||||
except Exception as e:
|
||||
errors.append(f"{eid}: {e}")
|
||||
|
||||
print(f"Indexed: {indexed}, Errors: {len(errors)}")
|
||||
if errors:
|
||||
for err in errors[:10]:
|
||||
print(f" {err}")
|
||||
Reference in New Issue
Block a user