feat: Hippocampus Memory System — Phases 1, 2, 3#35
Open
yhyu13 wants to merge 8 commits into
Open
Conversation
Add neuroscience-inspired episodic memory system for OpenWolf: - src/hippocampus/: types, event-store, index modules - src/templates/hippocampus.json: init template - Wire post-write hook to capture events - Wire pre-read hook to show trauma warnings - docs2/: design docs and plan for hippocampus extension Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add T1_T2_build-init.sh: build integrity + init tests - Add T3_event-store.test.ts: 41 unit tests for event-store CRUD - Add T4_hippocampus.test.ts: 29 unit tests for Hippocampus class - Add T5_T8_runtime.sh: 17 runtime integration tests for hooks - Add TEST_RESULTS.md: full test results log - Fix event-store.ts: correct event ordering in filterEvents - Fix init.ts: properly fill project_root, created_at fields All 98 tests passing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Implementation: - src/hippocampus/cue-index.ts: CueIndex CRUD with batch persistence - src/hippocampus/cue-recall.ts: Recall algorithm with scoring - src/hippocampus/index.ts: Added recall() method, batch index persist - src/hippocampus/types.ts: Added Cue/Recall types - src/cli/recall.ts: openwolf recall CLI command - src/hooks/pre-write.ts: Hippocampus trauma warnings - src/cli/init.ts: Wire cue-index.json creation Test suite (109 tests passing): - T9: Cue index CRUD + batch persist (37 tests) - T10: Recall API + scoring + filters (57 tests) - T11: Recall CLI + output formats (9 tests) - T12: Integration + persistence (6 tests) Known issue (D4): Parent match mode has a prefix lookup bug Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Delete accidentally committed .js files in src/hippocampus/ - Add src/**/*.js to .gitignore to prevent future commits These .js files are TypeScript source duplicates that should only exist as .ts files. Compiled output goes to dist/. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add phase2_hippocampus_usage.md with live demo findings - Change export to export type for type-only exports in hippocampus/index.ts Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add Neocortex long-term memory store (neocortex.json) - Add exponential decay logic (5%/week, trauma never decays) - Add consolidation scoring (intensity + valence + access count + recency) - Wire hippocampus-consolidation cron task (daily at 3 AM) - Add Phase 3 test suite (T13-T16, 37 tests passing) - Add critic review for Phase 3 consolidation implementation New files: - src/hippocampus/consolidation.ts - src/templates/neocortex.json - docs2/phase3/test/ (T13-T16 tests) Modified: - src/hippocampus/index.ts (consolidate methods) - src/cli/init.ts (neocortex initialization) - src/daemon/cron-engine.ts (consolidate_hippocampus action) - src/templates/cron-manifest.json (hippocampus-consolidation task) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add hippocampus memory system section (episodic memory, valence, recall) - Add recall command to commands list - Add hippocampus.json, cue-index.json, neocortex.json to What It Creates - Update Quick Start with local install option: ./scripts/install.sh - Add docs2/critic/5_CRITIC_PLAN.md with plan review findings New: - scripts/install.sh - installs local openwolf globally Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… to hooks - init.ts: copyHookScripts() now copies hippocampus/ module to .wolf/hippocampus/ so hooks can import it (was missing since Phase 2 hippocampus addition) - pre-read/pre-write: use hippocampus.recall() with match_mode:parent to surface related traumas from sibling/parent files, not just exact path matches - post-write: surface past learnings on multi-edit, store files_involved as relative paths for consistent path matching - pre-read/pre-write: convert filePath to relative before getTraumas()/recall() to fix path mismatch bug where stored absolute paths never matched Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Hippocampus Memory System — Phases 1, 2, 3
Summary
Implements a complete neuroscience-inspired episodic/spatial memory system for OpenWolf, tracking file operations across sessions with valence detection, fast recall, and long-term consolidation.
7 commits | 12,221 lines added | 178 deleted
What Is This?
The hippocampus memory system addresses a fundamental gap in OpenWolf's intelligence:
Current OpenWolf (Before Hippocampus)
OpenWolf tracks what exists and what you told it:
anatomy.md — what files contain (static map)
cerebrum.md — what you corrected it to remember (explicit)
buglog.json — bugs you explicitly logged (manual)
memory.md — chronological log (flat, unindexed)
But it has no memory of what happened across sessions in a structured, queryable way.
Why Hippocampus Matters
Implicit Learning Without Explicit Corrections
Cerebrum requires you to explicitly correct Claude. Hippocampus watches silently and learns from actions — file edited 8 times? That's trauma, worth remembering. No explicit correction needed.
Spatial Memory — "Where" vs "What"
A log says "file X was edited." Hippocampus says "file X was edited 8 times by you across 3 sessions, always in src/auth/, the errors were TypeErrors about undefined properties." That's context-aware memory.
Automatic Problem Detection
Files with high trauma scores are signals: "this code is problematic." Claude can use this to prioritize testing, be more careful with edits, or proactively suggest fixes.
Recall with Scoring
Instead of grepping a flat memory.md, openwolf recall /src/ returns ranked results weighted by recency, intensity, and valence. Most relevant events surface first.
Token Savings
When Claude knows "I already fixed this exact bug in this file 3 weeks ago" before starting work, it doesn't re-do the investigation. The cue-index makes this O(1) lookup instead of scanning.
Long-term Memory That Decays Like Real Memory
5%/week decay for low-value events, trauma never decays. Important stuff persists, noise fades. This is how biological memory actually works.
The Analogy
Human Memory Hippocampus
Episodic memory hippocampus.json (who what when where)
Fast indexing (where did I put my keys?) cue-index.json (fast path lookup)
Consolidation during sleep neocortex.json (long-term storage)
Emotional intensity = better recall trauma valence = high intensity = important
Forgetting low-importance details 5%/week decay for neutral events
Bottom line: Without hippocampus, OpenWolf is a reactive tool that learns only when explicitly told. With it, OpenWolf becomes a proactive memory system that watches, indexes, recalls, and consolidates — like a real second brain.
What This Adds
Phase 1 — Hippocampus Core (✅ 98 tests)
src/hippocampus/types.ts— WolfEvent, Valence, ConsolidationStage typessrc/hippocampus/index.ts— Hippocampus class with addEvent(), recall(), getTraumas()src/hippocampus/event-store.ts— hippocampus.json CRUD operationssrc/templates/hippocampus.json— Template foropenwolf initPhase 2 — Recall System (✅ 109 tests)
src/hippocampus/cue-index.ts— Fast lookup index (location_index, tag_index, trauma_index)src/hippocampus/cue-recall.ts— Scoring algorithm (location 55%, recency 20%, valence 15%, intensity 10%)src/cli/recall.ts—openwolf recall <path>CLI commandsrc/templates/cue-index.json— Template for cue-indexPhase 3 — Consolidation (✅ 37 tests)
src/hippocampus/consolidation.ts— Neocortex transfer, decay logic, consolidation scoringsrc/templates/neocortex.json— Long-term memory templatehippocampus-consolidationcron task (daily 3 AM)New Files
New CLI Commands
Test Results
Known Defects (Documented)
Breaking Changes
Backward Compatibility
openwolf initcreates new files alongside existing.wolf/filesTest Plan
Generated by Claude Code