* 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)
| 2707 | * tool call. |
| 2708 | */ |
| 2709 | private freshen(cg: CodeGraph): CodeGraph { |
| 2710 | try { |
| 2711 | if (cg.reopenIfReplaced()) { |
| 2712 | process.stderr.write( |
| 2713 | '[CodeGraph MCP] The index was replaced on disk (e.g. a git worktree ' + |
| 2714 | 'recreated at the same path); reopened the live database in place.\n' |
| 2715 | ); |
| 2716 | this.onDatabaseReopened?.(cg); |
| 2717 | } |
| 2718 | } catch { |
| 2719 | // Best-effort self-heal — a failed reopen must never break the tool call; |
| 2720 | // the (still stale) handle keeps serving and the next call retries. |
| 2721 | } |
| 2722 | return cg; |
| 2723 | } |
| 2724 | |
| 2725 | /** |
| 2726 | * A query worker kept through a quiet spell gives back what it can without |
no test coverage detected