Phase 04: Memory & Context Management - 4 plan(s) in 3 wave(s) - 2 parallel, 2 sequential - Ready for execution
5.6 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 04-memory-context-management | 01 | execute | 1 |
|
true |
|
Purpose: Provide persistent, reliable storage that serves as the foundation for all memory operations Output: Working SQLite database with vector support and basic conversation/message storage
<execution_context>
@/.opencode/get-shit-done/workflows/execute-plan.md
@/.opencode/get-shit-done/templates/summary.md
</execution_context>
Reference existing models structure
@src/models/context_manager.py @src/models/conversation.py
Task 1: Create memory module structure and SQLite manager src/memory/__init__.py, src/memory/storage/__init__.py, src/memory/storage/sqlite_manager.py Create the memory module structure following the research pattern:- Create src/memory/init.py with MemoryManager class stub
- Create src/memory/storage/init.py
- Create src/memory/storage/sqlite_manager.py with:
- SQLiteManager class with connection management
- Database schema for conversations, messages, metadata
- Table creation with proper indexing
- Connection pooling and thread safety
- Database migration support
Use the schema from research with conversations table (id, title, created_at, updated_at, metadata) and messages table (id, conversation_id, role, content, timestamp, embedding_id).
Include proper error handling, connection management, and follow existing code patterns from src/models/ modules. python -c "from src.memory.storage.sqlite_manager import SQLiteManager; db = SQLiteManager(':memory:'); print('SQLite manager created successfully')" SQLite manager can create and connect to database with proper schema
Task 2: Implement vector store with sqlite-vec integration src/memory/storage/vector_store.py, requirements.txt Create src/memory/storage/vector_store.py with VectorStore class:- Add sqlite-vec to requirements.txt
- Implement VectorStore with:
- sqlite-vec extension loading
- Virtual table creation for embeddings (using vec0)
- Vector insertion and retrieval methods
- Support for different embedding dimensions (start with 384 for all-MiniLM-L6-v2)
- Integration with SQLiteManager for database connection
Follow the research pattern for sqlite-vec setup:
db.enable_load_extension(True)
db.load_extension("vec0")
CREATE VIRTUAL TABLE IF NOT EXISTS vec_memory USING vec0(embedding float[384], content text, message_id integer)
Include methods to:
- Store embeddings with message references
- Search by vector similarity
- Batch operations for multiple embeddings
- Handle embedding model version tracking
Use existing error handling patterns from src/models/ modules. python -c "from src.memory.storage.vector_store import VectorStore; import numpy as np; vs = VectorStore(':memory:'); test_vec = np.random.rand(384).astype(np.float32); print('Vector store created successfully')" Vector store can create tables and handle basic vector operations
After completion, verify: 1. SQLite database can be created with proper schema 2. Vector extension loads correctly 3. Basic conversation and message storage works 4. Vector embeddings can be stored and retrieved 5. Integration with existing model system works<success_criteria>
- Memory module structure created following research recommendations
- SQLite manager handles database operations with proper schema
- Vector store integrates sqlite-vec for embedding storage and search
- Error handling and connection management follow existing patterns
- Database persists data correctly across restarts </success_criteria>