# Hermes Memory Auto-Consolidation **Deployed:** July 9, 2026 **Schedule:** Every 10 min (Hermes cron, no_agent mode) **Scripts:** `/root/.hermes/scripts/hermes-consolidate.sh` + `hermes-consolidate.py` ## Architecture ``` Every 10 min: 1. Dump MEMORY.md entries to JSON 2. Upload to S3 (backup-before-prune guarantee — aborts if S3 fails) 3. Run pruner (pattern prune + size safety valve) 4. Prune fact store (entries older than 7 days, never-retrieved, trust < 0.5) 5. Keep local pre-prune copy in ~/.hermes/memories/.consolidate-backups/ (48h retention) ``` ## Safety Guarantees - **Backup-before-prune:** S3 upload is a hard gate; prune never runs without it - **Never writes empty file:** pruner aborts if kept set would be empty - **Atomic write:** `os.replace()` on temp file — no partial-write risk - **Protected entries:** regex PROTECT prevents identity, rules, credentials, and key infrastructure facts from EVER being pruned (pattern or size valve) - **Idempotent:** if already under target, backs up and exits without modifying ## PROTECT List (entries never pruned) As of Jul 9 2026: includes "Core:", "STANDING PRACTICE", "app1-bu", "netcup|admin-ai.itpropartner", "Ops portal", "Recovery manual", "Ollama", "RS 4000", "Migration target", plus all credential/identity/formatting rules. ## Restore Procedure ```bash # From S3: source /opt/awscli-venv/bin/activate aws s3 cp s3://hermes-vps-backups/live/memories/memory-backup.json /tmp/mem.json \ --endpoint-url https://s3.us-east-1.wasabisys.com # Rebuild MEMORY.md: python3 -c " import json d = json.load(open('/tmp/mem.json')) open('/root/.hermes/memories/MEMORY.md','w').write(('\n§\n'.join(d['entries'])) + '\n') print('restored', d['entry_count'], 'entries') " ``` ## Known Caveat The size safety valve drops oldest-appended entries when pattern-pruning alone doesn't reach 7,000 chars. This can remove useful entries at the top of the file if they don't match a PROTECT pattern. All data preserved in S3.