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
This commit is contained in:
159
.planning/phases/04-memory-context-management/04-07-PLAN.md
Normal file
159
.planning/phases/04-memory-context-management/04-07-PLAN.md
Normal file
@@ -0,0 +1,159 @@
|
||||
---
|
||||
phase: 04-memory-context-management
|
||||
plan: 07
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: ["04-01"]
|
||||
files_modified: ["src/memory/storage/sqlite_manager.py"]
|
||||
autonomous: true
|
||||
gap_closure: true
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "Context-aware search prioritizes current topic discussions"
|
||||
artifacts:
|
||||
- path: "src/memory/storage/sqlite_manager.py"
|
||||
provides: "SQLite database operations and schema management"
|
||||
contains: "get_conversation_metadata method"
|
||||
key_links:
|
||||
- from: "src/memory/retrieval/context_aware.py"
|
||||
to: "src/memory/storage/sqlite_manager.py"
|
||||
via: "conversation metadata for topic analysis"
|
||||
pattern: "sqlite_manager\\.get_conversation_metadata"
|
||||
---
|
||||
|
||||
<objective>
|
||||
Complete SQLiteManager by adding missing get_conversation_metadata method to enable ContextAwareSearch topic analysis functionality.
|
||||
|
||||
Purpose: Close the metadata integration gap to enable context-aware search prioritization
|
||||
Output: Complete SQLiteManager with metadata access for topic-based search enhancement
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@~/.opencode/get-shit-done/workflows/execute-plan.md
|
||||
@~/.opencode/get-shit-done/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/phases/04-memory-context-management/04-CONTEXT.md
|
||||
@.planning/phases/04-memory-context-management/04-memory-context-management-VERIFICATION.md
|
||||
|
||||
# Reference existing sqlite manager implementation
|
||||
@src/memory/storage/sqlite_manager.py
|
||||
|
||||
# Reference context aware search that needs this method
|
||||
@src/memory/retrieval/context_aware.py
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Implement get_conversation_metadata method in SQLiteManager</name>
|
||||
<files>src/memory/storage/sqlite_manager.py</files>
|
||||
<action>
|
||||
Add missing get_conversation_metadata method to SQLiteManager class to close the verification gap:
|
||||
|
||||
1. get_conversation_metadata method implementation:
|
||||
- get_conversation_metadata(self, conversation_ids: List[str]) -> Dict[str, Dict]
|
||||
- Retrieve comprehensive metadata for specified conversations
|
||||
- Include topics, timestamps, message counts, user engagement metrics
|
||||
- Return structured data suitable for topic analysis
|
||||
|
||||
2. Metadata fields to include:
|
||||
- Conversation metadata: title, summary, created_at, updated_at
|
||||
- Topic information: main_topics, topic_frequency, topic_sentiment
|
||||
- Engagement metrics: message_count, user_message_ratio, response_times
|
||||
- Temporal data: time_of_day patterns, day_of_week patterns
|
||||
- Context clues: related_conversations, conversation_chain_position
|
||||
|
||||
3. Database queries for metadata:
|
||||
- Query conversations table for basic metadata
|
||||
- Aggregate message data for engagement metrics
|
||||
- Join with message metadata if available
|
||||
- Calculate topic statistics from existing topic fields
|
||||
- Use existing indexes for efficient querying
|
||||
|
||||
4. Integration with existing SQLiteManager patterns:
|
||||
- Follow same connection and cursor management
|
||||
- Use existing error handling and transaction patterns
|
||||
- Return data in formats compatible with existing methods
|
||||
- Handle missing or incomplete data gracefully
|
||||
|
||||
5. Performance optimizations:
|
||||
- Batch queries when multiple conversation_ids provided
|
||||
- Use appropriate indexes for metadata fields
|
||||
- Cache frequently accessed metadata
|
||||
- Limit result size for large conversation sets
|
||||
|
||||
The method should support the needs identified in ContextAwareSearch for topic analysis. Check context_aware.py to understand the specific metadata requirements and expected return format.
|
||||
</action>
|
||||
<verify>python -c "from src.memory.storage.sqlite_manager import SQLiteManager; sm = SQLiteManager(); result = sm.get_conversation_metadata(['test_id']); print(f'get_conversation_metadata returned: {type(result)} with keys: {list(result.keys()) if result else \"None\"}')"</verify>
|
||||
<done>SQLiteManager.get_conversation_metadata method provides comprehensive conversation metadata</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Integrate metadata access in ContextAwareSearch</name>
|
||||
<files>src/memory/retrieval/context_aware.py</files>
|
||||
<action>
|
||||
Update ContextAwareSearch to use the new get_conversation_metadata method for proper topic analysis:
|
||||
|
||||
1. Import and use sqlite_manager.get_conversation_metadata:
|
||||
- Update imports if needed to access sqlite_manager
|
||||
- Replace any mock or placeholder metadata calls with real method
|
||||
- Integrate metadata results into topic analysis algorithms
|
||||
- Handle missing metadata gracefully
|
||||
|
||||
2. Topic analysis enhancement:
|
||||
- Use real conversation metadata for topic relevance scoring
|
||||
- Incorporate temporal patterns and engagement metrics
|
||||
- Weight recent conversations appropriately in topic matching
|
||||
- Use conversation chains and relationships for context
|
||||
|
||||
3. Context-aware search improvements:
|
||||
- Enhance topic analysis with real metadata
|
||||
- Improve current topic discussion prioritization
|
||||
- Better handle multi-topic conversations
|
||||
- More accurate context relevance scoring
|
||||
|
||||
4. Error handling and fallbacks:
|
||||
- Handle cases where metadata is incomplete or missing
|
||||
- Provide fallback to basic topic analysis
|
||||
- Log metadata access issues for debugging
|
||||
- Maintain search functionality even with metadata failures
|
||||
|
||||
5. Integration verification:
|
||||
- Ensure ContextAwareSearch calls sqlite_manager.get_conversation_metadata
|
||||
- Verify metadata is properly used in topic analysis
|
||||
- Test with various conversation metadata scenarios
|
||||
- Confirm search results improve with real metadata
|
||||
|
||||
Update the existing ContextAwareSearch implementation to leverage the new metadata capability while maintaining backward compatibility and handling edge cases appropriately.
|
||||
</action>
|
||||
<verify>python -c "from src.memory.retrieval.context_aware import ContextAwareSearch; cas = ContextAwareSearch(); print('ContextAwareSearch ready for metadata integration')"</verify>
|
||||
<done>ContextAwareSearch integrates with SQLiteManager metadata for enhanced topic analysis</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<verification>
|
||||
After completion, verify:
|
||||
1. get_conversation_metadata method exists in SQLiteManager and is callable
|
||||
2. Method returns comprehensive metadata suitable for topic analysis
|
||||
3. ContextAwareSearch successfully calls and uses the metadata method
|
||||
4. Topic analysis is enhanced with real conversation metadata
|
||||
5. Context-aware search results are more accurate with metadata integration
|
||||
6. No broken method calls or missing imports remain
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Metadata integration gap is completely closed
|
||||
- ContextAwareSearch can access conversation metadata for topic analysis
|
||||
- Topic analysis is enhanced with real engagement and temporal data
|
||||
- Current topic discussion prioritization works with real metadata
|
||||
- Integration follows existing patterns and maintains performance
|
||||
- All verification issues related to metadata access are resolved
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.planning/phases/04-memory-context-management/04-07-SUMMARY.md`
|
||||
</output>
|
||||
Reference in New Issue
Block a user