feat: isolate default sqlite db by config dir#567
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 33s —— View job Code Review Complete ✓SummaryThis PR cleanly implements per-instance SQLite isolation by making the default database path derive from Review ChecklistCode Quality & Standards ✓
Testing & Documentation ✓
Basic Memory Architecture ✓
Security & Performance ✓
Compatibility ✓
Key ObservationsStrengths
Implementation Detailsconfig.py:371 - Changed from: database_path = Path.home() / DATA_DIR_NAME / APP_DATABASE_NAMEto: database_path = self.data_dir_path / APP_DATABASE_NAMEconfig.py:417-423 - New @property
def data_dir_path(self) -> Path:
"""Get app state directory for config and default SQLite database."""
if config_dir := os.getenv("BASIC_MEMORY_CONFIG_DIR"):
return Path(config_dir)
home = os.getenv("HOME", Path.home())
return Path(home) / DATA_DIR_NAMEThis creates a single source of truth for the config directory path, used by both config storage and database storage. Verification✓ Logic is consistent with RecommendationAPPROVE - This PR is ready to merge. The implementation is clean, well-tested, and achieves the stated goal of enabling per-instance SQLite isolation through The solution is appropriately scoped (doesn't touch Postgres schema logic) and maintains backward compatibility while enabling the new use case (multiple worktrees/MCP instances). |
Summary
This keeps the solution simple: when
BASIC_MEMORY_CONFIG_DIRis set, Basic Memory now stores the default SQLite index DB (memory.db) in that same directory.app_database_pathnow derives fromdata_dir_pathdata_dir_pathnow respectsBASIC_MEMORY_CONFIG_DIR(falls back to~/.basic-memory)Why
This enables separate config+db state per worktree/process/MCP instance without introducing new URL parsing or Postgres schema logic.
Scope
Tests
uv run pytest tests/test_config.py -quv run ruff check src/basic_memory/config.py tests/test_config.pySupersedes #540.