Files
Mai/.planning/phases/04-memory-context-management/04-05-PLAN.md
Mai Development 47e4864049 docs(04): create gap closure plans for memory and context management
Phase 04: Memory & Context Management
- 3 gap closure plans to address verification issues
- 04-05: Personality learning integration (PersonalityAdaptation, MemoryManager integration, src/personality.py)
- 04-06: Vector Store missing methods (search_by_keyword, store_embeddings)
- 04-07: Context-aware search metadata integration (get_conversation_metadata)
- All gaps from verification report addressed
- Updated roadmap to reflect 7 total plans
2026-01-28 12:08:47 -05:00

9.0 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, gap_closure, must_haves
phase plan type wave depends_on files_modified autonomous gap_closure must_haves
04-memory-context-management 05 execute 1
04-04
src/memory/personality/adaptation.py
src/memory/__init__.py
src/personality.py
true true
truths artifacts key_links
Personality layers learn from conversation patterns
Personality system integrates with existing personality.py
path provides min_lines
src/memory/personality/adaptation.py Dynamic personality updates 50
path provides exports
src/memory/__init__.py Complete MemoryManager with personality learning
PersonalityLearner
path provides min_lines
src/personality.py Updated personality system with memory integration 20
from to via pattern
src/memory/personality/adaptation.py src/memory/personality/layer_manager.py layer updates for adaptation layer_manager.update_layer
from to via pattern
src/memory/__init__.py src/memory/personality/adaptation.py PersonalityLearner integration PersonalityLearner.*update_personality
from to via pattern
src/personality.py src/memory/personality/layer_manager.py personality overlay application layer_manager.get_active_layers
Complete personality learning integration by implementing missing PersonalityAdaptation class and connecting all personality learning components to the MemoryManager and existing personality system.

Purpose: Close the personality learning integration gap identified in verification Output: Working personality learning system fully integrated with memory and personality systems

<execution_context> @/.opencode/get-shit-done/workflows/execute-plan.md @/.opencode/get-shit-done/templates/summary.md </execution_context>

@.planning/phases/04-memory-context-management/04-CONTEXT.md @.planning/phases/04-memory-context-management/04-RESEARCH.md @.planning/phases/04-memory-context-management/04-memory-context-management-VERIFICATION.md

Reference existing personality components

@src/memory/personality/pattern_extractor.py @src/memory/personality/layer_manager.py @src/resource/personality.py

Reference memory manager

@src/memory/init.py

Task 1: Implement PersonalityAdaptation class src/memory/personality/adaptation.py Create src/memory/personality/adaptation.py with PersonalityAdaptation class to close the missing file gap:
  1. PersonalityAdaptation class with time-weighted learning:

    • update_personality_layer(patterns, layer_id, adaptation_rate)
    • calculate_adaptation_rate(conversation_history, user_feedback)
    • apply_stability_controls(proposed_changes, current_state)
    • integrate_user_feedback(feed_data, layer_weights)
  2. Time-weighted learning implementation:

    • Recent conversations have less influence (exponential decay)
    • Historical patterns provide stable baseline
    • Prevent rapid personality swings with rate limiting
    • Confidence scoring for pattern reliability
  3. Stability controls:

    • Maximum change per update (e.g., 10% weight shift)
    • Cooling period between major adaptations
    • Core value protection (certain aspects never change)
    • Reversion triggers for unwanted changes
  4. Integration methods:

    • import_pattern_data(pattern_extractor, conversation_range)
    • export_layer_config(layer_manager, output_format)
    • validate_layer_consistency(layers, core_personality)
  5. Configuration and persistence:

    • Learning rate configuration (slow/medium/fast)
    • Adaptation history tracking
    • Rollback capability for problematic changes
    • Integration with existing memory storage

Follow existing error handling patterns from layer_manager.py. Use similar data structures and method signatures for consistency. python -c "from src.memory.personality.adaptation import PersonalityAdaptation; pa = PersonalityAdaptation(); print('PersonalityAdaptation created successfully')" PersonalityAdaptation class provides time-weighted learning with stability controls

Task 2: Integrate personality learning with MemoryManager src/memory/__init__.py Update src/memory/__init__.py to integrate personality learning and export PersonalityLearner:
  1. Import PersonalityAdaptation in memory/personality/init.py:

    • Add from .adaptation import PersonalityAdaptation
    • Update all to include PersonalityAdaptation
  2. Create PersonalityLearner class in MemoryManager:

    • Combines PatternExtractor, LayerManager, and PersonalityAdaptation
    • Methods: learn_from_conversations(conversation_range), apply_learning(), get_current_personality()
    • Learning triggers: after conversations, periodic updates, manual requests
  3. Integration with existing MemoryManager:

    • Add personality_learner attribute to MemoryManager.init
    • Implement learning_workflow() method for coordinated learning
    • Add personality data persistence to existing storage
    • Provide learning controls (enable/disable, rate, triggers)
  4. Export PersonalityLearner from memory/init.py:

    • Add PersonalityLearner to all
    • Ensure it's importable as from src.memory import PersonalityLearner
  5. Learning workflow integration:

    • Hook into conversation storage for automatic learning triggers
    • Periodic learning schedule (e.g., daily pattern analysis)
    • Integration with existing configuration system
    • Memory usage monitoring for learning processes

Update existing MemoryManager methods to support personality learning without breaking current functionality. Follow the existing pattern of having feature-specific managers within the main MemoryManager. python -c "from src.memory import PersonalityLearner; pl = PersonalityLearner(); print('PersonalityLearner imported successfully')" PersonalityLearner is integrated with MemoryManager and available for import

Task 3: Create src/personality.py with memory integration src/personality.py Create src/personality.py to integrate with memory personality learning system:
  1. Core personality system:

    • Import PersonalityLearner from memory system
    • Maintain core personality values (immutable)
    • Apply learned personality layers as overlays
    • Protect core values from learned modifications
  2. Integration with existing personality:

    • Import and extend src/resource/personality.py functionality
    • Add memory integration to existing personality methods
    • Hybrid system prompt + behavior configuration
    • Context-aware personality layer activation
  3. Personality application methods:

    • get_personality_response(context, user_input) -> enhanced_response
    • apply_personality_layers(base_response, context) -> final_response
    • get_active_layers(conversation_context) -> List[PersonalityLayer]
    • validate_personality_consistency(applied_layers) -> bool
  4. Configuration and control:

    • Learning enable/disable flag
    • Layer activation rules
    • Core value protection settings
    • User feedback integration for personality tuning
  5. Integration points:

    • Connect to MemoryManager.PersonalityLearner
    • Use existing personality.py from src/resource as base
    • Ensure compatibility with existing conversation systems
    • Provide clear separation between core and learned personality

Follow the pattern established in src/resource/personality.py but extend it with memory learning integration. Ensure core personality values remain protected while allowing learned layers to enhance responses. python -c "from src.personality import get_personality_response; print('Personality system integration working')" src/personality.py integrates with memory learning while protecting core values

After completion, verify: 1. PersonalityAdaptation class exists and implements time-weighted learning 2. PersonalityLearner is integrated into MemoryManager and exportable 3. src/personality.py exists and integrates with memory personality system 4. Personality learning workflow connects all components (PatternExtractor -> LayerManager -> PersonalityAdaptation) 5. Core personality values are protected from learned modifications 6. Learning system can be enabled/disabled through configuration

<success_criteria>

  • Personality learning integration gap is completely closed
  • All personality components work together as a cohesive system
  • Personality layers learn from conversation patterns over time
  • Core personality values remain protected while allowing adaptive learning
  • Integration follows existing patterns and maintains code consistency
  • System is ready for testing and eventual user verification </success_criteria>
After completion, create `.planning/phases/04-memory-context-management/04-05-SUMMARY.md`