fix(watcher): prune sustained missing roots#738
Conversation
|
Thanks for reopening this as a clean replacement for #666. DCO and CI are green, and the PR now has a cleaner title/body/history. I’ve added the same triage labels and moved this into the maintainer review queue. |
7e42852 to
2bd8f7b
Compare
|
Thank you — this is the right mechanism for #286 and complements #537 (just merged) perfectly: event-driven unwatch for explicit deletion, your polling prune for silently vanished roots; neither covers the other's case. Two changes before merge, both about the delete being irreversible:
Update: to keep momentum on the bug backlog, we're going to carry the changes above over the line ourselves shortly — a distilled follow-up on current main implementing the notes in this thread, with you credited as |
Signed-off-by: pcristin <xxxokzxxx@protonmail.com>
2bd8f7b to
0d1f60d
Compare
|
Thanks for the detailed review. I pushed the requested update in 0d1f60d:
Local validation is green for |
|
Thank you — this was the right mechanism for #286 and the perfect complement to the unwatch-on-delete fix: polling prune is the only way to catch silently vanished roots. We carried it over the line as 836f90d (PR #817) with you credited as co-author, with the data-loss hardening from the review folded in: only ENOENT/ENOTDIR count as missing (an EACCES/EIO blip on a network mount resets the streak instead of deleting the DB), pruning additionally requires a 10-minute sustained-absence grace window (env-tunable), and the prune's entry removal now routes through the deferred-free discipline the unwatch fix introduced — one consistent freeing model. Your restore-reset behavior carried over as-is. Closes #286. Closing this in favor of the distill — thanks again! |
…grace window) Distilled from DeusData#738: the watcher now prunes a watched project whose root directory has genuinely disappeared - deleting the cached DB (+wal/shm, validated name, cache-dir-only paths) and removing the watch entry - so vanished worktrees stop being watched forever (DeusData#286). Hardened beyond the original PR to remove a data-loss hazard (the cached DB can hold user-authored data such as the ADR, unrecoverable once deleted): - Only ENOENT/ENOTDIR stat failures count as missing. Any other failure (EACCES, EIO, transient mounts, macOS TCC revocation) resets the streak and logs watcher.root_stat_error with the errno; Windows (mingw/UCRT) maps not-found to ENOENT so the check holds there. - Pruning requires BOTH >=3 consecutive missing polls AND a sustained- absence grace window since the streak's first miss (default 600s, override via CBM_WATCHER_PRUNE_GRACE_S), tracked with monotonic cbm_now_ms. - Root reappearance resets streak + timestamp (watcher.root_restored). - The pruned entry is released via the deferred-free list poll_once drains (one freeing model shared with cbm_watcher_unwatch). Limitation: only currently-watched projects are pruned; stale DBs left by older sessions are out of scope. Co-authored-by: pcristin <xxxokzxxx@protonmail.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
What does this PR do?
Implements the watcher stale-root cleanup discussed in #286:
Fixes #286.
Supersedes #666 after refreshing the branch/title/commit metadata to match the contribution guide.
Checklist
git commit -s) — required, CI rejects unsigned commits.make -f Makefile.cbm test).make -f Makefile.cbm lint-ci).Validation
bash scripts/check-no-test-skips.shgit diff --checkmake -f Makefile.cbm build/c/test-runnerbuild/c/test-runnerwas run after rebasing; the watcher regression passed. The full local runner still had unrelated local/environment failures.