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: split deps.py into feature modules + reduce import graph
Why
basic_memory/deps.py currently centralizes many unrelated dependency factories (DB/session, repositories, services, sync/watch, etc.). This increases coupling and the import graph; small changes ripple across unrelated features.
Scope
Split dependency wiring into feature-scoped modules:
basic_memory/deps/db.py
basic_memory/deps/projects.py
basic_memory/deps/services.py
basic_memory/deps/sync.py
basic_memory/deps/http.py
Keep deps.py as a temporary thin re-export layer during migration (optional), then delete it once callers are migrated.
Acceptance criteria
Routers/tools only import the deps they need (no global deps.py imports for unrelated deps).
Import graph is measurably smaller (qualitative is fine: fewer cross-module imports; no new circulars).
Tests pass (SQLite + Postgres-focused runs).
Dependencies
Best done after composition roots are introduced (see the container issue), but can start in parallel.
I've analyzed this refactoring proposal and here's my assessment:
Classification
Type: Enhancement/Refactoring - Architectural improvement to reduce coupling Component: Core architecture (dependency injection) Complexity: Medium-to-Complex Priority: Medium - Important for maintainability but not blocking
Current State Analysis
The deps.py file is 722 lines containing:
Database/session factories
All repository factories (Project, Entity, Observation, Relation, Search)
All service factories (Entity, Search, Link, Context, Sync, Project, Directory, File)
All importer factories (ChatGPT, Claude Conversations, Claude Projects, Memory JSON)
Both v1 and v2 API variants
Project resolution logic
This creates a large import graph where changes ripple across unrelated features.
Proposed Refactoring
Split into feature-scoped modules:
basic_memory/deps/db.py - Database and session factories
basic_memory/deps/projects.py - Project resolution and config
Activity
claude commentedon Dec 31, 2025
Claude finished @phernandez's task in 1m 42s —— View job
Issue Triage Complete
I've analyzed this refactoring proposal and here's my assessment:
Classification
Type: Enhancement/Refactoring - Architectural improvement to reduce coupling
Component: Core architecture (dependency injection)
Complexity: Medium-to-Complex
Priority: Medium - Important for maintainability but not blocking
Current State Analysis
The
deps.pyfile is 722 lines containing:This creates a large import graph where changes ripple across unrelated features.
Proposed Refactoring
Split into feature-scoped modules:
basic_memory/deps/db.py- Database and session factoriesbasic_memory/deps/projects.py- Project resolution and configbasic_memory/deps/services.py- Service factoriesbasic_memory/deps/sync.py- Sync-related factoriesbasic_memory/deps/http.py- HTTP client factoriesWith a temporary re-export layer during migration.
Relationship to #490
This issue is part of a larger architectural refactoring:
The issue notes: "Best done after composition roots are introduced, but can start in parallel"
Both issues work together toward better SOLID principles and reduced coupling.
Impact & Risk Assessment
Benefits:
Risks:
Migration Strategy:
Recommendation
This is a valuable refactoring that should proceed incrementally and test-driven:
The acceptance criteria are well-defined and measurable.
Labels applied:
enhancementrefactor: add composition roots for API, MCP, and CLI entrypoints (#492)
refactor: split deps.py into feature-scoped modules (#491)