From 24023279abd30a9f90db211564c9f3fcb22784eb Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 12:05:58 -0500 Subject: [PATCH] fix: update references to openclaw-true-recall-blocks, add upgrade docs, add backfill script --- README.md | 107 ++++++++++++++++++++++++++++++++++++- install.sh | 29 ++++++++++ scripts/backfill_memory.py | 67 +++++++++++++++++++++++ session.md | 4 +- 4 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 scripts/backfill_memory.py diff --git a/README.md b/README.md index bdd56cc..9a4d889 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ true-recall-base (REQUIRED) │ ├── Curator extracts gems → gems_tr │ └── Plugin injects gems into prompts │ - └──▶ true-recall-blocks (ADDON) + └──▶ openclaw-true-recall-blocks (ADDON) ├── Topic clustering → topic_blocks_tr └── Contextual block retrieval @@ -654,3 +654,108 @@ curl -s "http://10.0.0.40:6333/collections/memories_tr/points/scroll" \ --- **Prerequisite for:** TrueRecall Gems, TrueRecall Blocks + + +--- + +## Upgrading from Older Versions + +This section covers full upgrades from older TrueRecall Base installations to the current version. + +### Version History + +| Version | Key Changes | +|---------|-------------| +| **v1.0** | Initial release - basic watcher | +| **v1.1** | Session detection improvements | +| **v1.2** | Priority-based session detection, lock file validation, backfill script | +| **v1.3** | Offset persistence (resumes from last position), fixes duplicate processing | +| **v1.4** | Current version - Memory backfill fix (Qdrant ids field), improved error handling | + +### Upgrade Paths + +#### From v1.0/v1.1/v1.2 → v1.4 (Current) + +If you have an older installation, follow these steps: + +```bash +# Step 1: Backup existing configuration +cp /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py.bak.$(date +%Y%m%d) + +cp /root/.openclaw/workspace/skills/qdrant-memory/scripts/config.json /root/.openclaw/workspace/skills/qdrant-memory/scripts/config.json.bak.$(date +%Y%m%d) +``` + +```bash +# Step 2: Stop the watcher +pkill -f realtime_qdrant_watcher +# Verify stopped +ps aux | grep realtime_qdrant_watcher +``` + +```bash +# Step 3: Download latest files (choose one source) + +# Option A: From GitLab (recommended) +curl -o /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py https://gitlab.com/mdkrush/openclaw-true-recall-base/-/raw/master/watcher/realtime_qdrant_watcher.py + +# Option B: From Gitea +curl -o /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py http://10.0.0.61:3000/SpeedyFoxAi/openclaw-true-recall-base/raw/branch/master/watcher/realtime_qdrant_watcher.py + +# Option C: From local clone (if you cloned the repo) +cp /path/to/openclaw-true-recall-base/watcher/realtime_qdrant_watcher.py /root/.openclaw/workspace/skills/qdrant-memory/scripts/ +``` + +```bash +# Step 4: Start the watcher +python3 /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py --daemon +``` + +```bash +# Step 5: Verify installation +ps aux | grep realtime_qdrant_watcher +curl -s "http://10.0.0.40:6333/collections/memories_tr/points/scroll" -H "Content-Type: application/json" -d '{"limit": 3}' | jq '.result.points[0].payload.timestamp' +``` + +### Upgrading with Git (If You Cloned the Repository) + +```bash +# Navigate to your clone +cd /path/to/openclaw-true-recall-base +git pull origin master + +# Stop current watcher +pkill -f realtime_qdrant_watcher + +# Copy updated files to OpenClaw +cp watcher/realtime_qdrant_watcher.py /root/.openclaw/workspace/skills/qdrant-memory/scripts/ +cp scripts/backfill_memory.py /root/.openclaw/workspace/skills/qdrant-memory/scripts/ + +# Restart the watcher +python3 /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py --daemon + +# Verify +ps aux | grep realtime_qdrant_watcher +``` + +### Backfilling Historical Memories (Optional) + +```bash +python3 /root/.openclaw/workspace/skills/qdrant-memory/scripts/backfill_memory.py +``` + +### Verifying Your Upgrade + +```bash +# 1. Check watcher is running +ps aux | grep realtime_qdrant_watcher + +# 2. Verify source is "true-recall-base" +curl -s "http://10.0.0.40:6333/collections/memories_tr/points/scroll" -H "Content-Type: application/json" -d '{"limit": 1}' | jq '.result.points[0].payload.source' + +# 3. Check date coverage +curl -s "http://10.0.0.40:6333/collections/memories_tr/points/scroll" -H "Content-Type: application/json" -d '{"limit": 10000}' | jq '[.result.points[].payload.date] | unique | sort' +``` + +Expected output: +- Source: `"true-recall-base"` +- Dates: Array from oldest to newest memory diff --git a/install.sh b/install.sh index 1db02f9..158b1ba 100644 --- a/install.sh +++ b/install.sh @@ -96,3 +96,32 @@ echo " curl -s http://$QDRANT_IP/collections/memories_tr | jq '.result.points_c echo "" echo "View logs:" echo " sudo journalctl -u mem-qdrant-watcher -f" + + +echo "" +echo "==========================================" +echo "UPGRADING FROM OLDER VERSION" +echo "==========================================" +echo "" +echo "If you already have TrueRecall Base installed:" +echo "" +echo "1. Stop the watcher:" +echo " pkill -f realtime_qdrant_watcher" +echo "" +echo "2. Backup current files:" +echo " cp /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py \" +echo " /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py.bak" +echo "" +echo "3. Copy updated files:" +echo " cp watcher/realtime_qdrant_watcher.py \" +echo " /root/.openclaw/workspace/skills/qdrant-memory/scripts/" +echo " cp scripts/backfill_memory.py \" +echo " /root/.openclaw/workspace/skills/qdrant-memory/scripts/" +echo "" +echo "4. Restart watcher:" +echo " python3 /root/.openclaw/workspace/skills/qdrant-memory/scripts/realtime_qdrant_watcher.py --daemon" +echo "" +echo "5. Verify:" +echo " ps aux | grep realtime_qdrant_watcher" +echo "" +echo "For full upgrade instructions, see README.md" diff --git a/scripts/backfill_memory.py b/scripts/backfill_memory.py new file mode 100644 index 0000000..3a3a88b --- /dev/null +++ b/scripts/backfill_memory.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +"""Backfill memory files to Qdrant memories_tr collection.""" + +import os +import json +from datetime import datetime + +QDRANT_URL = "http://10.0.0.40:6333" +MEMORY_DIR = "/root/.openclaw/workspace/memory" + +def get_memory_files(): + """Get all memory files sorted by date.""" + files = [] + for f in os.listdir(MEMORY_DIR): + if f.startswith("2026-") and f.endswith(".md"): + date = f.replace(".md", "") + files.append((date, f)) + return sorted(files, key=lambda x: x[0]) + +def backfill_file(date, filename): + """Backfill a single memory file to Qdrant.""" + filepath = os.path.join(MEMORY_DIR, filename) + with open(filepath, 'r') as f: + content = f.read() + + # Truncate if too long for payload + payload = { + "content": content[:50000], # Limit size + "date": date, + "source": "memory_file", + "curated": False, + "role": "system", + "user_id": "rob" + } + + # Add to Qdrant + import requests + point_id = hash(f"memory_{date}") % 10000000000 + resp = requests.post( + f"{QDRANT_URL}/collections/memories_tr/points", + json={ + "points": [{ + "id": point_id, + "payload": payload + }], + "ids": [point_id] + } + ) + return resp.status_code == 200 + +def main(): + files = get_memory_files() + print(f"Found {len(files)} memory files to backfill") + + count = 0 + for date, filename in files: + print(f"Backfilling {filename}...", end=" ") + if backfill_file(date, filename): + print("✓") + count += 1 + else: + print("✗") + + print(f"\nBackfilled {count}/{len(files)} files") + +if __name__ == "__main__": + main() diff --git a/session.md b/session.md index a71682e..b82a8bc 100644 --- a/session.md +++ b/session.md @@ -19,7 +19,7 @@ true-recall-base (REQUIRED FOUNDATION) │ ├── Curator extracts atomic gems │ └── Plugin injects gems as context │ - └──▶ true-recall-blocks (OPTIONAL ADDON) + └──▶ openclaw-true-recall-blocks (OPTIONAL ADDON) ├── Topic clustering └── Block-based retrieval ``` @@ -82,4 +82,4 @@ curl -s http://10.0.0.40:6333/collections/memories_tr | jq '.result.points_count --- -*Next: Install true-recall-gems OR true-recall-blocks (not both)* +*Next: Install true-recall-gems OR openclaw-true-recall-blocks (not both)*