Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Improve dialectic testing with real file persistence #8

@nikomatsakis

Description

@nikomatsakis

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 .memories subdirectory 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-dir flag 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

  1. Kept simulated mode in memory bank - While we don't use it in dialectic tests, the --simulated flag remains available for other testing scenarios
  2. Temp directory per test - Each test gets its own isolated environment, preventing test interference
  3. Automatic cleanup - Temp directories are removed after each test to avoid disk clutter
  4. 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
  • dialectic/tests/memory-basic/:

    • persistence-test.yaml - Tests memory persistence across conversation steps
    • read-update-flow-test.yaml - Validates read-then-update concurrency pattern
    • situation-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

  1. Test isolation is critical - Using shared directories between tests causes interference. Temp directories provide clean slate for each test.
  2. Real persistence reveals bugs - The move from simulated to real file I/O exposed edge cases in path handling that simulated mode masked.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-managedAllows AI to update OP and add commentsenhancementNew feature or requesttracking-issueOngoing work item tracked as living document

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions