Create a [`FileWatcher`] using the best available backend. Attempts to connect to Watchman first. If Watchman is not running or the connection fails, falls back to the snapshot-based watcher. # Arguments `config` — Watcher configuration (repo root, ignore patterns) # Returns A boxed `FileWatcher` implementation. The caller does not need to know which backend was selected. # Implementation St
(config: WatcherConfig)
| 290 | /// Currently returns a `FallbackWatcher` unconditionally. The Watchman |
| 291 | /// backend will be implemented in Phase 16.2–16.3. |
| 292 | pub async fn create_watcher(config: WatcherConfig) -> AgentResult<Box<dyn FileWatcher>> { |
| 293 | // Watchman backend (Phase 16.2-16.3 in ATOMIC-AGENT-TASKS.md): |
| 294 | // |
| 295 | // When implemented, this function will attempt to connect to the Watchman |
| 296 | // daemon first. If successful, it returns a WatchmanTurnWatcher that uses |
| 297 | // clock + since queries for O(changed-files) detection. If Watchman is not |
| 298 | // running, it falls through to the snapshot-based fallback below. |
| 299 | // |
| 300 | // The Watchman backend will use: |
| 301 | // - watchman_client::Connector::new().connect() for connection |
| 302 | // - client.clock() + client.query(since: ...) for turn boundary diffing |
| 303 | // - client.state_enter/state_leave("atomic-turn") for subscriber coordination |
| 304 | // - Expr::Not(DirName(".atomic")) to exclude the repo metadata directory |
| 305 | |
| 306 | // Fall back to snapshot-based watcher (always available, O(all files) per boundary) |
| 307 | log::info!("Using fallback file watcher (install Watchman for faster change detection)"); |
| 308 | Ok(Box::new(fallback::FallbackWatcher::new(config))) |
| 309 | } |
| 310 | |
| 311 | // Tests |
| 312 |
no outgoing calls