You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: add composition roots for API, MCP, and CLI entrypoints (#492)
Introduces composition roots (containers) that centralize reading ConfigManager
and environment variables at entrypoints. This is the foundation for reducing
coupling and scattered cloud_mode/config checks throughout the codebase.
Changes:
- Add `basic_memory/runtime.py` with RuntimeMode enum and resolve_runtime_mode()
- Add `api/container.py` with ApiContainer composition root
- Add `mcp/container.py` with McpContainer composition root
- Add `cli/container.py` with CliContainer composition root
- Update API lifespan to use ApiContainer for config and mode decisions
- Update MCP lifespan to use McpContainer for config and mode decisions
- Update CLI callback to use CliContainer for config access
- Update integration test to patch container methods instead of module imports
The containers provide:
- Single point of config access (only composition roots read ConfigManager)
- Runtime mode resolution (cloud/local/test) in one place
- Centralized sync/watch decision logic (should_sync_files property)
This is step 1 of the refactoring roadmap in issue #490. Future steps will:
- Split deps.py into feature modules (#491)
- Inject config explicitly rather than reading globally (#496)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: phernandez <paul@basicmachines.co>
0 commit comments