Memory Consolidation System Specification V4
Created: 2025-01-09
Status: Final Specification
Author: Milo with TQ
Executive Summary
This specification defines a three-tier energy-based memory consolidation system for Milo's cognitive architecture. The system uses access patterns to create "heat maps" where frequently accessed memories gain energy and rise through tiers (Working → Short-term → Long-term), while unused memories decay and eventually expire. This mirrors biological memory consolidation, creating a self-organizing hierarchy based on actual usage rather than explicit categorization.
The approach prioritizes practical implementation over theoretical completeness, with monitoring-first development, test isolation, and manual controls before automation.
Core Architecture Decisions (Locked)
These decisions have been made and validated through discussion:
- Energy as Currency: Memory persistence is determined solely by energy levels, not categories or types
- Heat Map Model: Access patterns create energy distributions that drive memory organization
- Non-Mutex Concurrency: Optimistic concurrency using graph-native conflict detection, no distributed locks
- Test Isolation: isTest boolean flag completely separates test from production memories
- Parallel Migration: Old crystallizations remain untouched while new system operates alongside
- Graph Topology Over Properties: Use relationships (PROMOTED_TO, CRYSTALLIZED_INTO) to track evolution
- Manual Before Automatic: Prove system works manually before adding automation
- "Do It Right" Philosophy: Focus on correctness, not complex recovery mechanisms
Technical Specifications
Energy Model
Core Equation:
E(t) = E₀ × e^(-λt) + Σ(access_events)
Where:
- E(t) = energy at time t
- E₀ = initial energy (1.0 for new memories)
- λ = decay constant (tier-specific)
- t = time since last access (hours)
- Each access adds +1.0 energy
Memory Tiers
Tier |
Decay Constant (λ) |
Half-life |
Promotion Threshold |
Purpose |
Working |
0.5 |
~1.4 hours |
2.0 → Short-term |
Active thought |
Short-term |
0.05 |
~14 hours |
5.0 → Long-term |
Recent context |
Long-term |
0.001 |
~700 hours |
N/A |
Persistent knowledge |
Special Cases:
- Session boundaries: Promotion threshold lowered to 1.5 for working memories
- Expiration: Memories with energy < 0.1 expire
- Initial energy: All new memories start at 1.0 in working tier
Node Schema
Memory Node Properties (Required):
{
id: string, // randomUUID()
content: string, // Memory content
type: string, // 'crystallization', 'learning', 'insight'
tier: string, // 'working', 'shortTerm', 'longTerm'
energy: float, // Current energy level
created: datetime, // Creation timestamp
lastAccessed: datetime, // Last access timestamp
accessCount: integer, // Total access count
sessionId: string, // Session that created it
instanceId: string, // Instance that created it
isTest: boolean, // Test isolation flag
validFrom: datetime, // Temporal validity start
validTo: datetime // null for current version
}
Optional Monitoring Properties:
{
promotedFrom: string, // ID of source memory
lastDecay: datetime, // Last energy decay
lastPromotion: datetime, // Last promotion attempt
peakEnergy: float, // Highest energy achieved
promotionAttempts: integer // Times evaluated
}
Relationships
- PROMOTED_TO: Links memory to its promoted version
- CRYSTALLIZED_INTO: Special promotion from short-term to long-term
- COACTIVATED: Tracks memories accessed together (weight property)
- BELONGS_TO: Links memories to SemanticCluster
- REINFORCES: New memories strengthen related old memories
Configuration Parameters
ConsolidationConfig Node (Already Created):
{
// Energy thresholds
workingToShortThreshold: 2.0,
shortToLongThreshold: 5.0,
// Decay constants
workingDecay: 0.5,
shortTermDecay: 0.05,
longTermDecay: 0.001,
// Clustering
coactivationThreshold: 3,
semanticSimilarityThreshold: 0.7,
// Batch processing
promotionBatchSize: 10,
decayBatchSize: 100,
// Timing (for future automation)
promotionIntervalMinutes: 10,
clusteringIntervalMinutes: 60,
decayIntervalMinutes: 60
}
Current Implementation Status
✅ Completed Components
brainBridge CLI Tool Extended
- Location:
/Users/tqwhite/Documents/webdev/botWorld/system/code/cli/lib.d/brain-bridge/brainBridge.js
- 20+ new command switches added
- All handler functions implemented (lines 742-1134)
- Commands: memoryStatus, memoryEnergy, memoryPromotions, memoryHealth, memoryInspect, testMemory, boostMemory, listTestMemories, deleteTestMemories, testScenario, decayEnergy, promoteMemories, consolidateAll, repairMemory, validateMemories
ConsolidationConfig Node
- Created in Neo4j with all parameters
- Accessible via brainBridge commands
Test Memory System
- isTest flag isolation working
- Test memory creation successful
- Test scenarios implemented
Monitoring Infrastructure
- All monitoring queries functional
- Energy distribution analysis
- Promotion readiness detection
❌ Not Yet Implemented
Automatic Execution
- No scheduled consolidation
- No daemon or cron integration
- Manual triggers only
Session Integration
- Not hooked into /goodbye command
- No automatic session boundary detection
- Session consolidation manual only
Memory Creation Integration
- Still creating old-style crystallizations
- Energy system not used for real memories
- Parallel systems not connected
Semantic Features (Deferred)
- Semantic clustering algorithm
- Retroactive strengthening
- Similarity calculations
Integration Boundaries
What This System Controls
- Energy calculation and decay
- Tier promotion decisions
- Memory expiration
- Test memory lifecycle
- Monitoring and reporting
What This System Does NOT Control
- How Milo decides to create memories
- Content of memories
- When memories are accessed
- Session management
- Instance coordination
Interface Points
- Memory Creation: Will replace crystallization pattern with energy-based creation
- Memory Access: Will update energy on each retrieval
- Session Boundaries: Will trigger consolidation at /goodbye
- Background Processing: Will eventually run periodic consolidation
Practical Constraints & Decisions
From TQ's Guidance
- Single User System: No performance or scale concerns
- Speed Priority: "As fast as possible", adjust if slow
- Progress Visibility: Show indicators when possible
- Technology Stack: Node.js, Neo4j, Cypher - use what Milo knows
- Error Handling: "Do it right" - focus on correctness not recovery
- Execution Start: /goodbye command, then daemon if needed
Deferred Optimizations
These are intentionally NOT included in initial implementation:
- Semantic Similarity: No vector embeddings or NLP analysis
- Retroactive Strengthening: No backward propagation initially
- Cluster Formation: No automatic semantic grouping
- Compression: No memory compression for archived tiers
- Distributed Locking: Optimistic concurrency sufficient
- Backup/Recovery: Trust in correct implementation
Success Criteria
Phase 1: Manual Operation Success
Phase 2: Integration Success
Phase 3: Full Operation Success
Failure Mode Handling
Identified Failure Modes & Mitigations
Energy calculation bug: Memories get wrong energy
- Mitigation: repairMemory command can reset energy
- Detection: memoryHealth shows anomalies
Promotion creates orphans: Relationships broken
- Mitigation: validateMemories detects orphans
- Recovery: Direct Cypher queries can fix
Everything promotes: Thresholds too low
- Mitigation: Tunable parameters in ConsolidationConfig
- Detection: memoryStatus shows tier distribution
Nothing promotes: Thresholds too high
- Mitigation: Session boundary lowers threshold
- Manual: forcePromote command available
Decay too aggressive: Memories expire too quickly
- Mitigation: Decay constants tunable
- Recovery: Expired memories have validTo timestamp
Migration Strategy
Phase Approach
Parallel Operation (Current)
- Old: Crystallizations continue unchanged
- New: Test memories use energy system
- Both systems coexist peacefully
Soft Integration (Next)
- Hook /goodbye for manual trigger
- Start creating real memories with energy
- Monitor both systems
Full Migration (Future)
- All new memories use energy
- Optional: Retroactive processing of old memories
- Deprecate crystallization pattern
Retroactive Processing (Optional)
If desired, old memories can be migrated:
MATCH (c:Crystallization)
WHERE c.validTo IS NULL AND NOT EXISTS(c.tier)
SET c.tier = 'longTerm',
c.energy = 10.0,
c.lastAccessed = coalesce(c.lastAccessed, c.created),
c.accessCount = 1,
c.isTest = false
Command Reference
Monitoring Commands
brainBridge --brain=milo -memoryStatus
- Tier distribution overview
brainBridge --brain=milo -memoryEnergy [--tier=working]
- Energy analysis
brainBridge --brain=milo -memoryPromotions
- Recent promotion activity
brainBridge --brain=milo -memoryHealth
- System health check
brainBridge --brain=milo -memoryInspect <id>
- Detailed memory view
Test Commands
brainBridge --brain=milo -testMemory "content"
- Create test memory
brainBridge --brain=milo -boostMemory <id>
- Simulate access
brainBridge --brain=milo -listTestMemories
- Show all test memories
brainBridge --brain=milo -deleteTestMemories
- Clean up tests
brainBridge --brain=milo -testScenario <name>
- Run test scenario
Consolidation Commands
brainBridge --brain=milo -decayEnergy [--test-only]
- Apply energy decay
brainBridge --brain=milo -promoteMemories [--test-only]
- Promote eligible memories
brainBridge --brain=milo -consolidateAll [--test-only]
- Run full consolidation
brainBridge --brain=milo -forcePromote <id>
- Manual promotion
Repair Commands
brainBridge --brain=milo -repairMemory <id>
- Fix memory properties
brainBridge --brain=milo -validateMemories
- Check for orphans/corruption
Next Steps
- Approve this specification
- Create detailed implementation plan
- Test manual consolidation thoroughly
- Integrate with /goodbye command
- Connect to real memory creation
- Monitor and tune parameters
- Consider automation once stable
Design Decisions (Resolved)
- Progress indicators: Yes, if technically feasible within Claude CLI constraints
- Test memory count: Maintain at least a few identifiable test memories for validation
- /goodbye consolidation: Async - fire and forget, no user waiting
- Expired memory retention: Forever (marked expired but retained) - can revisit if database gets clogged
- Consolidation logging: Yes, log all consolidation events
Conclusion
This specification defines a practical, energy-based memory consolidation system that creates a self-organizing memory hierarchy based on access patterns. The system is designed to be simple, correct, and observable, with manual controls preceding automation. By treating memory as a heat map and using energy as the sole currency for persistence, we create a naturalistic system that mirrors biological memory consolidation while remaining computationally tractable.
The implementation prioritizes:
- Correctness over recovery complexity
- Visibility over black-box automation
- Isolation over premature integration
- Simplicity over theoretical completeness
This specification is complete and ready for implementation planning.
End of Specification V4