Problem
FileChangeBatcher keeps pending filesystem events in an unbounded HashSet<string>. Add records every changed path until the debounce window drains, and TryDrain snapshots the whole set into a new List<string>. A sustained event storm with many unique paths can grow memory before watch mode has a chance to process the batch.
Suggested fix
Add a maximum pending path count or byte budget. When the budget is exceeded, collapse the batch into a full rescan request and clear individual path storage.
Evidence
src/CodeIndex/Cli/IndexWatchRunner.cs: FileChangeBatcher
_pending
Add
TryDrain
Problem
FileChangeBatcherkeeps pending filesystem events in an unboundedHashSet<string>.Addrecords every changed path until the debounce window drains, andTryDrainsnapshots the whole set into a newList<string>. A sustained event storm with many unique paths can grow memory before watch mode has a chance to process the batch.Suggested fix
Add a maximum pending path count or byte budget. When the budget is exceeded, collapse the batch into a full rescan request and clear individual path storage.
Evidence
src/CodeIndex/Cli/IndexWatchRunner.cs:FileChangeBatcher_pendingAddTryDrain