feat: configurable database directory via CBM_CACHE_DIR env var#173
feat: configurable database directory via CBM_CACHE_DIR env var#173dLo999 wants to merge 3 commits intoDeusData:mainfrom
Conversation
…Data#154) Adds CBM_CACHE_DIR environment variable to override the default cache directory (~/.cache/codebase-memory-mcp). All four hardcoded path sites (store.c, main.c, cli.c x2) now route through a single cbm_resolve_cache_dir() function that checks the env var first. The config list/help output now shows cache_dir as a read-only field displaying the resolved directory. Closes DeusData#154
dLo999
left a comment
There was a problem hiding this comment.
Review Summary
Adds CBM_CACHE_DIR env var to make the database storage location configurable. All 4 previously hardcoded ~/.cache/codebase-memory-mcp/ paths now route through a single cbm_resolve_cache_dir() function. Config display updated to show resolved path.
Findings
No critical, warning, or blocking issues found. Implementation is clean:
- Single resolver function with correct priority (env var > default)
- Buffer safety maintained (
snprintfbounds-checked) - Backward compatible (default behavior unchanged)
- Chicken-and-egg problem correctly handled (env var, not config DB key)
- All callers check for NULL returns
store.cincludescli.happropriately for the new function
CI Status
No CI checks configured on fork branch. Local testing: 2741 tests passed, 0 regressions. Manual verification of all 3 scenarios (default, env var override, config help) confirmed working.
Verdict
APPROVE — Well-structured, thoroughly tested, ready to merge.
|
I guess, the environment variables should be documented somewhere, e.g. in README.md |
Documents CBM_CACHE_DIR, CBM_DOWNLOAD_URL, and CBM_DIAGNOSTICS env vars in the Configuration section. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Good point — pushed a commit adding an Environment Variables section to the README under Configuration. Documents |
Closes #154
Summary
Makes the database storage location configurable via the
CBM_CACHE_DIRenvironment variable. All previously hardcoded~/.cache/codebase-memory-mcp/paths across the codebase now route through a singlecbm_resolve_cache_dir()function.Changes
src/cli/cli.h: AddedCBM_CONFIG_CACHE_DIRkey andcbm_resolve_cache_dir()declarationsrc/cli/cli.c: Newcbm_resolve_cache_dir()function (env var → default), updatedconfig listandconfighelpsrc/store/store.c:cbm_store_open()uses resolversrc/main.c: Server startup uses resolversrc/pipeline/pipeline.c: Pipeline DB path construction uses resolver (2 sites)src/mcp/mcp.c: Cache dir helper and auto-index check use resolver (2 sites)src/ui/http_server.c: All 5 DB path constructions use resolversrc/ui/config.c: UI config path uses resolverUsage
Design decisions
cache_dirappears inconfig listas read-only display.CBM_CACHE_DIRenv var > default~/.cache/codebase-memory-mcpTest results
Build: Compiles cleanly on macOS (Apple Clang, arm64)
Test suite: 2740 passed, 1 flaky failure (timing:
test_incremental.c:371off by 2ms — unrelated to this change)Manual verification:
config list(no env var)cache_dir = ~/.cache/codebase-memory-mcpconfig listwithCBM_CACHE_DIR=/tmp/testcache_dir = /tmp/testconfighelpcache_dirkey with env var noteindex_repositorywithCBM_CACHE_DIR=/tmp/test-cbm-cache/tmp/test-cbm-cache/, NOT default dirindex_repositorywithout env var~/.cache/codebase-memory-mcp/(backward compat)Generated with agent-team via /issue