Skip to content

Add external database directory support for network file systems#402

Open
felipecaldas wants to merge 1 commit intotirth8205:mainfrom
felipecaldas:main
Open

Add external database directory support for network file systems#402
felipecaldas wants to merge 1 commit intotirth8205:mainfrom
felipecaldas:main

Conversation

@felipecaldas
Copy link
Copy Markdown

Fixes SQLite WAL mode failures on Samba/CIFS shares by allowing users to store the graph database in an external local directory while keeping source code on network shares.

Problem:

  • SQLite's WAL mode requires filesystem features not fully supported by network file systems
  • Building graph on Samba/NFS shares fails with 'database is locked' error at PRAGMA journal_mode=WAL
  • Developers using network shares cannot use code-review-graph

Solution:

  • Add --data-dir CLI flag to store database in external location
  • Extend multi-repo registry to remember per-repo data_dir configuration
  • Implement resolution priority: registry > CRG_DATA_DIR env var > default .code-review-graph/
  • All CLI commands and MCP tools automatically use the external location

Changes:

  • code_review_graph/registry.py: Add set_data_dir() and get_data_dir_for_repo() methods
  • code_review_graph/incremental.py: Modify get_data_dir() to check registry first
  • code_review_graph/cli.py: Add --data-dir argument to build, update, status, watch, visualize, wiki, postprocess
  • code_review_graph/tools/registry_tools.py: Fix cross_repo_search to use get_db_path() for custom locations
  • tests/test_registry.py: Add TestSetDataDir class with 5 tests
  • tests/test_incremental.py: Add TestDataDirRegistry class with 5 tests

Benefits:

  • Eliminates database lock errors on network file systems
  • Better performance (local disk vs network I/O)
  • Clean separation of source code and index data
  • Persistent configuration via registry
  • 100% backward compatible
  • All 28 MCP tools work automatically with custom data_dir

Usage:
cd /mnt/repos/my-project code-review-graph build --data-dir ~/.crg-graphs/my-project

Testing:

  • All 83 tests pass (registry + incremental)
  • Manual testing successful on test project
  • Cross-repo search verified with custom data_dir
  • MCP server integration confirmed

Fixes SQLite WAL mode failures on Samba/CIFS shares by allowing users to store the graph database in an external local directory while keeping source code on network shares.

Problem:
- SQLite's WAL mode requires filesystem features not fully supported by network file systems
- Building graph on Samba/NFS shares fails with 'database is locked' error at PRAGMA journal_mode=WAL
- Developers using network shares cannot use code-review-graph

Solution:
- Add --data-dir CLI flag to store database in external location
- Extend multi-repo registry to remember per-repo data_dir configuration
- Implement resolution priority: registry > CRG_DATA_DIR env var > default .code-review-graph/
- All CLI commands and MCP tools automatically use the external location

Changes:
- code_review_graph/registry.py: Add set_data_dir() and get_data_dir_for_repo() methods
- code_review_graph/incremental.py: Modify get_data_dir() to check registry first
- code_review_graph/cli.py: Add --data-dir argument to build, update, status, watch, visualize, wiki, postprocess
- code_review_graph/tools/registry_tools.py: Fix cross_repo_search to use get_db_path() for custom locations
- tests/test_registry.py: Add TestSetDataDir class with 5 tests
- tests/test_incremental.py: Add TestDataDirRegistry class with 5 tests

Benefits:
- Eliminates database lock errors on network file systems
- Better performance (local disk vs network I/O)
- Clean separation of source code and index data
- Persistent configuration via registry
- 100% backward compatible
- All 28 MCP tools work automatically with custom data_dir

Usage:
  cd /mnt/repos/my-project
  code-review-graph build --data-dir ~/.crg-graphs/my-project

Testing:
- All 83 tests pass (registry + incremental)
- Manual testing successful on test project
- Cross-repo search verified with custom data_dir
- MCP server integration confirmed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant