-
Notifications
You must be signed in to change notification settings - Fork 5
Improve dialectic testing with real file persistence #8
Description
Improve dialectic testing with real file persistence
Status: Complete ✅
Implementation Summary
Successfully replaced simulated mode with real file persistence using temporary directories in dialectic tests. The solution enables proper testing of multi-step memory workflows that require persistence between conversation steps.
What Was Implemented
1. Temporary Directory Management in Dialectic
- Added automatic creation of unique temp directories for each test run
- Implemented
.memoriessubdirectory creation within temp directories - Added cleanup logic to remove temp directories after tests complete
- Temp directories use descriptive names:
/tmp/dialectic-{test-name}-{random}
2. Memory Bank Integration
- Modified dialectic to pass
--memories-dirflag pointing to test-specific temp directory - Memory bank server uses provided directory exclusively (no upward walking)
- Real file operations replace simulated mode for all tests
3. Test Infrastructure Updates
- Created comprehensive test suite for memory persistence scenarios
- Tests now validate actual file I/O operations
- Multi-step workflows work correctly with persistence between steps
Key Design Decisions
- Kept simulated mode in memory bank - While we don't use it in dialectic tests, the
--simulatedflag remains available for other testing scenarios - Temp directory per test - Each test gets its own isolated environment, preventing test interference
- Automatic cleanup - Temp directories are removed after each test to avoid disk clutter
- Descriptive naming - Temp directories include test names for easier debugging if cleanup fails
Files Modified
-
dialectic/dialectic.py:
- Added temp directory creation in
setup_test() - Modified MCP server config to pass
--memories-dir - Implemented
cleanup_temp_dir()for proper resource management
- Added temp directory creation in
-
dialectic/tests/memory-basic/:
persistence-test.yaml- Tests memory persistence across conversation stepsread-update-flow-test.yaml- Validates read-then-update concurrency patternsituation-context-test.yaml- Tests situation parameter handling
Testing Approach
Created focused test cases that exercise:
- Memory creation and retrieval across steps
- Read-before-update concurrency control
- Situation parameter persistence
- Multi-step conversation flows
All tests pass successfully, confirming the implementation works as designed.
Insights Learned
- Test isolation is critical - Using shared directories between tests causes interference. Temp directories provide clean slate for each test.
- Real persistence reveals bugs - The move from simulated to real file I/O exposed edge cases in path handling that simulated mode masked.
- Cleanup prevents confusion - Automatic temp directory cleanup prevents developers from debugging stale test artifacts.
Success Criteria Met
✅ Multi-step dialectic tests work correctly with file persistence
✅ Clean separation: MCP server operates on explicit directory, dialectic manages test environment
✅ No reliance on simulated mode complexity for testing
✅ Tests exercise actual file I/O paths and validate persistence
The implementation successfully enables comprehensive testing of the memory bank's multi-step workflows.