feat(mcp): surface degraded watcher state to the agent in tool responses (#892)
When live file watching permanently degrades (watch-resource exhaustion, or a
write lock held past the retry budget), getPendingFiles() goes empty — so the
existing per-file staleness banner can't fire even though the index is now
frozen and silently drifting stale. The agent kept getting clean-looking
responses off a no-longer-updating index.
Read-tool responses now lead with a whole-index banner ("CodeGraph auto-sync
is DISABLED…") whenever the watcher is degraded, and codegraph_status gets a
dedicated "Auto-sync disabled" section. Both carry the degrade reason and tell
the agent to Read files directly. Expose isWatcherDegraded() /
getWatcherDegradedReason() on the CodeGraph class, and document the new banner
in the MCP server instructions.
Completes the agent-notification half of #876 (the operator-facing onDegraded
wiring shipped in #891).
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
cea4d086f9
commit
beca7116a0
@@ -584,6 +584,23 @@ export class CodeGraph {
|
||||
return this.watcher?.isActive() ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* True once live watching has permanently degraded (OS watch-resource
|
||||
* exhaustion, or a write lock held past the retry budget) and auto-sync is
|
||||
* disabled until the next {@link watch} call. Distinct from `!isWatching()`:
|
||||
* a stopped/never-started watcher is inactive but NOT degraded. MCP tools use
|
||||
* this to surface a whole-index "results may be stale" notice, since
|
||||
* `getPendingFiles()` goes empty once watching stops (#876).
|
||||
*/
|
||||
isWatcherDegraded(): boolean {
|
||||
return this.watcher?.isDegraded() ?? false;
|
||||
}
|
||||
|
||||
/** The reason live watching degraded, or null if it is healthy (#876). */
|
||||
getWatcherDegradedReason(): string | null {
|
||||
return this.watcher?.getDegradedReason() ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Files seen by the file watcher since the last successful sync —
|
||||
* the per-file "stale" signal MCP tools attach to responses so an agent
|
||||
|
||||
Reference in New Issue
Block a user