Summary
codebase-memory-mcp v0.8.1 (and earlier) contains a deleting corrupt db code
path that silently unlinks the project database file when its startup
integrity check raises any anomaly. This is a "delete on first suspicion"
design that causes total data loss with no backup, no log warning, and no
recovery path — even when the "corruption" is a false positive.
Evidence
The behavior is in the compiled binary and observable via strings:
deleting corrupt db
ERROR store.corrupt table=projects rows=%d (expected 1)
ERROR store.corrupt table=projects bad_root_path=%s
integrity_check_failed
malformed database schema (%s)
file is not a database
broke stale lock on %s
Related binary paths (WAL mode + atomic rename used for normal writes):
PRAGMA journal_mode = WAL;
%s.tmp
dump: rename failed
rename_to_cache
Trigger conditions (false positives)
In my case the project DB was deleted after I performed a sequence of
pkill -9 on the cbm process and binary swaps between standard and ui
variants (the install.sh --ui switch). The next cbm startup detected
"corruption" and deleted the 28 MB <project>.db file. Other plausible
triggers I can think of:
- WAL file leftover from a previously-SIGKILL'd cbm (most likely in
my case). When the old process is killed, SQLite's -wal and -shm
sidecar files can be left in a state the new process interprets as
corruption.
- Binary version drift between cbm builds (e.g., switching between
codebase-memory-mcp-darwin-arm64.tar.gz and
codebase-memory-mcp-ui-darwin-arm64.tar.gz). Even minor schema-version
differences would trip the check.
- Lock-file contention — the
broke stale lock on %s string shows cbm
forcibly breaks stale locks; the DB state immediately after lock break
may look anomalous and trigger the delete.
Repro
codebase-memory-mcp cli index_repository '{"repo_path":"/path/to/proj","mode":"full"}'
pkill -9 -f "codebase-memory-mcp" while index is in progress (or
between operations)
- Start cbm again. The
<proj>.db file disappears.
- No log line other than
level=info msg=mem.init ... precedes the loss.
Impact
- Total data loss of the indexed project (in my case: 8 740 nodes /
26 412 edges / 28 MB SQLite, plus the graph.db.zst artifact)
- No backup, no
.corrupt.<timestamp> rename, no in-process log warning
- User has no idea what happened until they re-open the UI and see
"No indexed projects"
- Recovery requires re-running the full reindex, which costs time
(3-4 min for Linux kernel per the README, several minutes for any
real codebase)
Suggested fix
Replace the unlink with a rename to a timestamped .corrupt file and
emit a prominent stderr log so the user has a chance to act:
// pseudocode for the recovery branch
if (integrity_check_fails) {
char corrupt_path[PATH_MAX];
snprintf(corrupt_path, sizeof(corrupt_path),
"%s.corrupt.%ld", db_path, (long)time(NULL));
rename(db_path, corrupt_path);
fprintf(stderr,
"ERROR project database marked corrupt: %s\n"
"ERROR preserved as: %s\n"
"ERROR re-index: codebase-memory-mcp cli index_repository "
"'{\"repo_path\":\"...\",\"mode\":\"full\"}'\n",
db_path, corrupt_path);
}
This preserves the evidence, lets the user inspect what was wrong, and
gives them a recovery path (file a bug with the corrupt DB attached).
Environment
- cbm 0.8.1 (binary
--version and serverInfo.version both report 0.8.1;
note: prior 0.6.1 release had a serverInfo.version: 0.10.0 mismatch
per issue #350)
- macOS 26.4.1, Darwin 25.4.0 arm64, Apple Silicon
- Binary:
Mach-O 64-bit executable arm64, 270.9 MB (UI variant)
- Related: issue #350
(UI HTTP server doesn't bind, closed) and
issue #402
(UI binary crashes mid-render, open) — both UI-related
Summary
codebase-memory-mcpv0.8.1 (and earlier) contains adeleting corrupt dbcodepath that silently unlinks the project database file when its startup
integrity check raises any anomaly. This is a "delete on first suspicion"
design that causes total data loss with no backup, no log warning, and no
recovery path — even when the "corruption" is a false positive.
Evidence
The behavior is in the compiled binary and observable via
strings:Related binary paths (WAL mode + atomic rename used for normal writes):
Trigger conditions (false positives)
In my case the project DB was deleted after I performed a sequence of
pkill -9on the cbm process and binary swaps betweenstandardanduivariants (the
install.sh --uiswitch). The next cbm startup detected"corruption" and deleted the 28 MB
<project>.dbfile. Other plausibletriggers I can think of:
my case). When the old process is killed, SQLite's
-waland-shmsidecar files can be left in a state the new process interprets as
corruption.
codebase-memory-mcp-darwin-arm64.tar.gzandcodebase-memory-mcp-ui-darwin-arm64.tar.gz). Even minor schema-versiondifferences would trip the check.
broke stale lock on %sstring shows cbmforcibly breaks stale locks; the DB state immediately after lock break
may look anomalous and trigger the delete.
Repro
codebase-memory-mcp cli index_repository '{"repo_path":"/path/to/proj","mode":"full"}'pkill -9 -f "codebase-memory-mcp"while index is in progress (orbetween operations)
<proj>.dbfile disappears.level=info msg=mem.init ...precedes the loss.Impact
26 412 edges / 28 MB SQLite, plus the
graph.db.zstartifact).corrupt.<timestamp>rename, no in-process log warning"No indexed projects"
(3-4 min for Linux kernel per the README, several minutes for any
real codebase)
Suggested fix
Replace the
unlinkwith arenameto a timestamped.corruptfile andemit a prominent stderr log so the user has a chance to act:
This preserves the evidence, lets the user inspect what was wrong, and
gives them a recovery path (file a bug with the corrupt DB attached).
Environment
--versionandserverInfo.versionboth report 0.8.1;note: prior 0.6.1 release had a
serverInfo.version: 0.10.0mismatchper issue #350)
Mach-O 64-bit executable arm64, 270.9 MB (UI variant)(UI HTTP server doesn't bind, closed) and
issue #402
(UI binary crashes mid-render, open) — both UI-related