Keeps the file watcher from overflowing in session folders that hold several Git repositories and stops recovery work from blocking tool calls (issue #645).
Watcher exclusions
Nested .git trees are excluded at the kernel level; sibling copies of the same directory name are no longer assumed covered by a root copy.
Ecosystem exclusion gates walk up to the containing repository and its manifests, so nested checkouts are excluded correctly; the bound repository's own HEAD/ref watches are preserved.
Overflow recovery
Per-root search refreshes are coalesced into one worker; superseded walks stop reading files, never publish a partial index, and log as build_cancelled rather than failure.
Backend overflow paths no longer bound the loss scope, so a buffered ignore edit discarded with the overflow still triggers a matcher rebuild off the dispatch thread.
Overflows occurring during a rescan yield to the next dispatch slice instead of looping; completed cache bytes survive cancelled builds.
Multiple losses within a burst log one summary with count and window, flushing after ten seconds of sustained flood to stay visible.
Confidence Score: 5/5
The PR appears safe to merge; no new actionable defects were found.
Summary
The PR reduces watcher noise in folders containing several repositories and moves overflow recovery away from interactive requests.
Nested repositories get their own watcher exclusions.
Lost watcher events trigger a bounded ignore-rule scan and rescan.
Overflow warnings summarize losses in short bursts.
A newer search refresh replaces older work for the same root.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Watcher reports lost events] --> B[Request recovery]
B --> C[Build ignore matcher in background]
C --> D[Publish matcher on current binding]
D --> E[Run one recovery pass]
E --> F[Submit search refresh]
F --> G[One worker per root]
G --> H[Cancel superseded build]
G --> I[Publish completed index]
E --> J{More events were lost?}
J -- Yes --> B