MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / freshen

Method freshen

src/mcp/tools.ts:2709–2723  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 2

getCodeGraphMethod · 0.95
openProjectRootMethod · 0.95

Calls 2

reopenIfReplacedMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected