Skip to main content

Module watch

Module watch 

Source
Expand description

File watching, and the coalescing policy that makes it usable (ADR-0005 §5).

notify reports raw OS events, and a single “save” in an editor can produce half a dozen of them (write a temp file, rename it over the target, delete the backup). Left raw, that is one full directory re-read per event.

We coalesce in our own code rather than pulling in notify-debouncer-full: one dependency instead of two, the debouncer’s surface has moved across notify major versions, and — the real reason — a policy we own is a policy we can unit-test by feeding it synthetic batches with a synthetic clock, which is exactly what the tests below do.

Structs§

Coalescer
Accumulates changed paths and releases them once the window has elapsed.
RelevanceFilter
Decides which raw watch paths reach the coalescer.
RootWatcher
A running recursive watch over one root.

Constants§

DEFAULT_WINDOW
How long to gather events before emitting a batch. Long enough to absorb an editor’s save dance, short enough that the tree feels live.

Functions§

is_editor_noise
Paths that are noise no matter what the ignore rules say: editor swap and backup files, which appear and vanish around every save (ADR-0005 §5).
is_relevant
Whether a raw watch event is worth waking the tree for.