Bug Description
index_repository always returns {"status":"error"} on Windows when the MCP server is running. The indexing pipeline completes successfully (builds the full graph), but the final rename(tmp_path, path) fails because the MCP server process holds the .db file open. Windows does not allow renaming over open files (unlike POSIX).
Steps to Reproduce
- Start Claude Code (MCP server connects and opens the project
.db file)
- Call
index_repository(repo_path="C:/dev/stockboard/FlipperCapital")
- Returns
{"status":"error"} — no further details
Expected Behavior
Re-indexing should succeed while the MCP server is running, or at minimum return a meaningful error message.
Evidence
- The
.db.tmp file (9.4 MB) is created successfully — the pipeline completed
- The existing
.db file (8.9 MB) is held open by codebase-memory-mcp.exe (SQLite WAL mode, .db-shm and .db-wal present)
- 3 instances of
codebase-memory-mcp.exe running simultaneously
rename() fails at graph_buffer.c line 981: rc = rename(tmp_path, path)
- Error logged as:
level=error msg=gbuf.dump op=rename path=...
- All read operations (search_graph, query_graph, trace_call_path) work fine against the stale index
Workaround
Kill the MCP server, then manually rename the .tmp file:
taskkill //F //IM codebase-memory-mcp.exe
cp ~/.cache/codebase-memory-mcp/PROJECT.db.tmp ~/.cache/codebase-memory-mcp/PROJECT.db
Suggested Fix
On Windows, rename() cannot replace an open file. Possible fixes:
- Use
MoveFileExW with MOVEFILE_REPLACE_EXISTING flag
- Close the server's store handle before the pipeline dump, then reopen afterward
- Write to a new filename and have the server swap its own handle
Environment
- OS: Windows 11 Pro 10.0.26200
- Version: v0.5.2 (also checked v0.5.6 changelog — not fixed)
- Shell: Git Bash (MINGW64)
- Project: 6046 nodes, 12998 edges (Go + Python + React monorepo)
Bug Description
index_repositoryalways returns{"status":"error"}on Windows when the MCP server is running. The indexing pipeline completes successfully (builds the full graph), but the finalrename(tmp_path, path)fails because the MCP server process holds the.dbfile open. Windows does not allow renaming over open files (unlike POSIX).Steps to Reproduce
.dbfile)index_repository(repo_path="C:/dev/stockboard/FlipperCapital"){"status":"error"}— no further detailsExpected Behavior
Re-indexing should succeed while the MCP server is running, or at minimum return a meaningful error message.
Evidence
.db.tmpfile (9.4 MB) is created successfully — the pipeline completed.dbfile (8.9 MB) is held open bycodebase-memory-mcp.exe(SQLite WAL mode,.db-shmand.db-walpresent)codebase-memory-mcp.exerunning simultaneouslyrename()fails atgraph_buffer.cline 981:rc = rename(tmp_path, path)level=error msg=gbuf.dump op=rename path=...Workaround
Kill the MCP server, then manually rename the
.tmpfile:Suggested Fix
On Windows,
rename()cannot replace an open file. Possible fixes:MoveFileExWwithMOVEFILE_REPLACE_EXISTINGflagEnvironment