Skip to content

feat: add consolidation script (Phase 2) — sleep replay via Hermes cron - #21

Merged
ardhaecosystem merged 2 commits into
mainfrom
feat/consolidation-scheduler
Jul 14, 2026
Merged

feat: add consolidation script (Phase 2) — sleep replay via Hermes cron#21
ardhaecosystem merged 2 commits into
mainfrom
feat/consolidation-scheduler

Conversation

@ardhaecosystem

Copy link
Copy Markdown
Owner

Summary

Phase 2: the consolidation scheduler — the brain's "sleep replay" cycle. The Hippocampus coordinator already had run_consolidation() and extract_schemas() from Phase 1, but nothing called them. Now there's an entry point.

What Changed

New: scripts/consolidate.py

A standalone script that connects to FalkorDB directly and runs the offline hippocampus batch:

  1. Drain online contradictions — contradictions detected during episode ingestion (Phase 1)
  2. Offline contradiction detection — cross-episode contradictions over the full graph
  3. Hebbian strengthening — co-occurring entity groups
  4. Schema extraction (--schemas flag) — neocortical slow learning
  5. Pruning candidates (--prune flag) — entities below forgetting curve threshold (report only, does not delete)

Prints a JSON summary to stdout. Exit 0 on success, 1 on error.

Design decision: standalone script, not a daemon

No internal scheduler thread, no second event loop, no daemon. Hermes cron's no-agent mode runs the script on a schedule — that's the "what triggers background work" mechanism. The consolidation_interval_hours config value (default: 6.0) is a recommendation for the cron cadence.

# Via Hermes cron (recommended)
hermes cron create "every 6h" "python /path/to/synapse/scripts/consolidate.py" --no-agent

# Manual
python scripts/consolidate.py --schemas --prune

Skipped: plugin CLI registration (hermes synapse consolidate). Requires plugin directory setup — standalone script works now without it. Add when the plugin directory structure is formalized.

Updated: docs/hippocampus.md

Replaced the "future feature" placeholder with actual usage instructions (cron setup + manual commands + what-it-does table).

Updated: README.md

  • Feature checklist: consolidation now ✅ (was ⏳ pending)
  • How It Works diagram: "Background (sleep)" now references scripts/consolidate.py (was "Phase 2")
  • Project structure: added scripts/consolidate.py
  • Roadmap: moved consolidation to Done, removed from In Progress

Test Results

  • 118 passed in 0.61s (was 113, +5 new tests)
  • ruff check src/ tests/ scripts/ — all checks passed

New tests (test_consolidate.py)

  • _age_days with valid timestamp, empty string, invalid timestamp
  • Script --help exits 0
  • Script exits 1 with JSON error when FalkorDB unavailable

@ardhaecosystem
ardhaecosystem merged commit fdf49af into main Jul 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant