mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-26 04:19:33 +08:00
fix(mcp,extraction): exit a daemon whose install changed; never store a grammar-load failure (#2335, #2336) (#2346)
* fix(mcp,extraction): a daemon whose install changed exits; grammar-load failures are never stored (#2335, #2336) A daemon that outlived an upgrade loaded grammars lazily from an install that no longer existed, and stored every file its watcher re-indexed as a zero-node row under the file's new content hash: no hash-based sync ever revisited those rows, and `codegraph status` called the index up to date. - The daemon checks its own package.json every 30 s (CODEGRAPH_DAEMON_INSTALL_CHECK_MS, 0 turns it off) and exits once the file is gone or carries another version, so the next session starts a daemon from the current install. - A result whose grammar failed to load (`parser_error`) is never stored: the file keeps its previous data and the next sync or index retries it, and a row an older engine stored that way is re-indexed even though its hash matches. The tag-based CFML path reports a missing grammar with the same code. - A launcher whose own install was deleted no longer crashes on the spawn error of the daemon it tried to start. - `codegraph status` and `status --json` (filesNeedingReindex, filesWithParseErrors) report indexed files whose symbols are missing although their content is current (#2336), and `files --json` carries each file's recorded errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(mcp): a session whose own install changed never claims the writer lock (#2335) A daemon now exits once its install is upgraded or removed, and nobody holds the writer slot for a successor at that point. Its sessions run the same replaced code and serve themselves in-process the moment it goes; one that found the slot free claimed it as its writer even though its engine could not load (a real npm upgrade: "Cannot find module './sqlite-adapter'"), and so kept a daemon from the current install from starting. Such a session now falls back read-only and says to restart it. Also adds the CHANGELOG entries for the install check and grammar-load failures (#2335) and for the status report (#2336). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
511d86e94d
commit
dea076fd1e
@@ -25,6 +25,7 @@ import {
|
||||
BuildContextOptions,
|
||||
FindRelevantContextOptions,
|
||||
UnresolvedReference,
|
||||
IndexHealth,
|
||||
} from './types';
|
||||
import { DatabaseConnection, getDatabasePath, removeDatabaseFiles } from './db';
|
||||
import { WalCheckpointValve, resolveWalValveMb } from './db/wal-valve';
|
||||
@@ -43,6 +44,7 @@ import {
|
||||
extractFromSource,
|
||||
initGrammars,
|
||||
} from './extraction';
|
||||
import { hasGrammarLoadFailure, isFileLevelOnlyLanguage } from './extraction/grammars';
|
||||
import {
|
||||
ReferenceResolver,
|
||||
createResolver,
|
||||
@@ -2065,6 +2067,34 @@ export class CodeGraph {
|
||||
return this.queries.countGeneratedFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indexed files whose symbols are missing although their content is current
|
||||
* — rows a content-hash comparison calls up to date (#2336). Reported by
|
||||
* `status`; `sync` repairs the `needsReindex` group.
|
||||
*/
|
||||
getIndexHealth(): IndexHealth {
|
||||
const needsReindex: string[] = [];
|
||||
const parseErrors: string[] = [];
|
||||
for (const file of this.queries.getFilesWithoutNodesOrWithErrors()) {
|
||||
const errors = file.errors ?? [];
|
||||
if (hasGrammarLoadFailure(errors)) {
|
||||
// Stored without being parsed — its grammar could not load (#2335).
|
||||
needsReindex.push(file.path);
|
||||
} else if (file.nodeCount === 0) {
|
||||
// Every parse stores at least the file node, so zero nodes means a
|
||||
// wiped row (#1541) or a recorded failure — except file-level-only
|
||||
// languages and files over the size limit, which are empty on purpose.
|
||||
if (isFileLevelOnlyLanguage(file.language)) continue;
|
||||
if (errors.length === 0) needsReindex.push(file.path);
|
||||
else if (errors.some((e) => e.severity === 'error' || e.code === 'parse_error')) parseErrors.push(file.path);
|
||||
} else if (errors.some((e) => e.code === 'parse_error')) {
|
||||
// Parsed, but the tree had errors and no symbols survived.
|
||||
parseErrors.push(file.path);
|
||||
}
|
||||
}
|
||||
return { needsReindex, parseErrors };
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Graph Query Methods
|
||||
// ===========================================================================
|
||||
|
||||
Reference in New Issue
Block a user