Files
codebase-memory-mcp/tests
Andrew Hundt b6e8c8975f fix(mcp): reopen query stores after external publication
Before this change, src/mcp/mcp.c:3638 trusted a cached SQLite handle until an in-process notification arrived. A sibling CLI or MCP publisher cannot send that notification, so atomic database replacement left a long-lived server reading the old unlinked inode. The search_code handler at src/mcp/mcp.c:13580 also bypassed the canonical startup-index join and could return project not found or not indexed while indexing was active.

Add portable path identity reads in src/foundation/compat_fs.c:74 and :735, record identity only for query-only stores in src/store/store.c:1365, and reopen a replaced generation from resolve_store on the request-owning thread. Existing atomic writer publication remains unchanged; the read path adds one constant-time metadata probe and no database write, graph scan, process-wide lock, or unrelated-project serialization.

Route search_code through resolve_project_store, report its resolved target in JSON and TOON, release syntax-kind thread caches on every auto-index exit, and notify publication only for responses accepted by cbm_mcp_index_response_published.

TDD fixtures: tests/test_mcp.c:6891, :9517, and :11534. Verification: ASan/UBSan MCP 270/270, tool consolidation 113/113, CLI 232/232; focused TSan tests passed; macOS leaks reported 0 leaks/0 bytes for startup indexing and external replacement; source safety, git diff --check, and git clang-format --diff passed.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-19 23:44:20 -04:00
..
2026-07-08 00:05:19 +05:30