* Heal a long-lived connection whose `.codegraph/` was removed and recreated * at the same path (a worktree recreated, or `rm -rf .codegraph` + re-init) * before handing it to a tool. Otherwise the daemon keeps serving the * pre-removal snapshot from its now-unlinked file handle until resta
(cg: CodeGraph)
| 1115 | * tool call. |
| 1116 | */ |
| 1117 | private freshen(cg: CodeGraph): CodeGraph { |
| 1118 | try { |
| 1119 | if (cg.reopenIfReplaced()) { |
| 1120 | process.stderr.write( |
| 1121 | '[CodeGraph MCP] The index was replaced on disk (e.g. a git worktree ' + |
| 1122 | 'recreated at the same path); reopened the live database in place.\n' |
| 1123 | ); |
| 1124 | } |
| 1125 | } catch { |
| 1126 | // Best-effort self-heal — a failed reopen must never break the tool call; |
| 1127 | // the (still stale) handle keeps serving and the next call retries. |
| 1128 | } |
| 1129 | return cg; |
| 1130 | } |
| 1131 | |
| 1132 | /** |
| 1133 | * Close all cached project connections |
no test coverage detected