Skip to content

fix: a folder's own "modified" event is no change; __pycache__ restarts nothing (#463) - #472

Merged
7schmiede merged 2 commits into
mainfrom
fix/restart-on-generated-dirs
Nov 6, 2026
Merged

7schmiede merged 2 commits into
mainfrom
fix/restart-on-generated-dirs

Conversation

@7schmiede

Copy link
Copy Markdown
Member

What and why

Closes #463.

Cause. On Windows, ReadDirectoryChangesW (notify FILE_ACTION_MODIFIED → Modify(Any)) reports a folder as modified when an entry is added to or removed from it, beside the entry's own Create/Remove event. A probe against the real watcher showed it for every new __pycache__: Modify(Any) shared, then Create(Any) shared\__pycache__. The entry is filtered (generated directory), but the folder's own event is not, and restart_on = ["shared"] covers it, so the first start of a Python service restarted every dev server naming the folder.

Fix. event_paths drops a Modify(Any | Data | Metadata) event whose path is a directory (asked of the file system only after the path-only filter, so generated directories are still never opened). A rename (Modify(Name)), a created or removed folder, and a modified file still count. What changed in the folder comes with its own path; covers still maps that to a folder pattern.

Bug class: an event about a container taken as a change of its contents, bypassing the filter on the contents. The same code path also feeds watch (candidates) and a lane's copy, so they are covered too. The remote lane's worktree watcher (remote.rs) only sets a "compare now" flag; a folder event there costs a comparison, no restart, so it is left as it is.

Tests

  • New unit test a_folder_reported_as_modified_is_no_change_of_its_own: red before the fix, green after. only_a_creation_lists_a_directory no longer expects a folder's Modify(Any) to count.
  • restart_on_a_folder_restarts_for_each_file_in_it (integration, DEVSTACK_INTEGRATION=1) now also creates a new __pycache__ in an existing package and expects no restart, and waits for the restart after during.txt itself. It passes with the fix. It also passes without the fix on this machine: the daemon in the test did not get the folder's event, although a standalone probe gets it every time. The unit test is the regression guard.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test -p devstack-daemon: green (Windows 11).

🤖 Generated with Claude Code

7schmiede and others added 2 commits November 6, 2026 13:38
…ts nothing (#463)

On Windows ReadDirectoryChangesW reports a folder as modified when an
entry is added to or removed from it, beside the entry's own event.
Python creating `__pycache__` in `shared` therefore restarted every dev
server with `restart_on = ["shared"]`, although `__pycache__` itself
never counts. The watcher now drops a modification event whose path is
a directory (a rename keeps its own kind and still counts); what changed
in the folder comes with its own path.

Bug-Class: an event about a container taken as a change of its contents, bypassing the filter on the contents
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pid read after the change during a restart could already be the
restarted process; up() then waited 60 s for one that never came (seen on
macos-15). One start, then one run per restart: counted in the daemon log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede force-pushed the fix/restart-on-generated-dirs branch from 52e7686 to ef3f975 Compare November 6, 2026 12:38
@7schmiede
7schmiede merged commit 8d1ce22 into main Nov 6, 2026
@7schmiede
7schmiede deleted the fix/restart-on-generated-dirs branch November 6, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

restart_on: a folder pattern fires when Python creates __pycache__ in it

1 participant