Build a Smaller Watchexec
Rebuild the event-to-process contract, not a thin wrapper around notify.
What are we preserving?
- concurrent event producers and bounded admission;
- filtering plus trailing-edge debounce;
- urgent lifecycle priority;
- one serialized action policy;
- a task-owned child state machine;
- start, signal, restart, queued run, and graceful stop;
- explicit recoverable-versus-fatal errors;
- joined shutdown.
Reconstruction stages
- Model
Event,Priority, and a bounded input channel; use synthetic events. - Implement filter-then-debounce and test that urgent events flush immediately.
- Give an action callback an immutable event batch and return an
Outcome. - Build one supervisor task around
tokio::process::Commandand a control enum. - Add busy policies: ignore, signal, restart, or one coalesced queued run.
- Add signal-then-deadline-then-kill, always awaiting the child afterward.
- Add multiple jobs, runtime error reporting, and structured task joining.
- Only then connect
notifyand platform process groups.
Production Watchexec still supplies portable watchers, ignore-file discovery, keyboard and OS signal sources, rich event tags, dynamic configuration, environment emission, process wrapping, shell interpretation, diagnostics, and many platform-specific failure paths.