Skip to content

fix: drop the rows of a directory moved out of the watched root - #1118

Merged
thekevinscott merged 5 commits into
mainfrom
claude/1109-watch-moved-out
Sep 17, 2026
Merged

thekevinscott merged 5 commits into
mainfrom
claude/1109-watch-moved-out

Conversation

@thekevinbot

Copy link
Copy Markdown
Collaborator

Fixes #1109

Problem

A directory moved out of the watched root (or renamed within it) leaves behind every row its files produced. They persist until a cold rescan.

Root cause

inotify reports the move as one IN_MOVED_FROM naming the directory and nothing for the files beneath it. translate_event maps it to FileEvent::Deleted(<dir>); process_file_event matches the directory path against the table globs and handle_delete deletes by exact file_path, so at most a row for the directory itself (which never exists) is removed. The mirror case, a directory moved in, was #1096 / #1110.

Fix

Red first: this PR currently carries only the failing tests. Implementation follows once CI red is witnessed.

Red/green

  • Red commit: 4164888 (tests only).
  • Tests: dir_moved_out_of_root_deletes_its_rows and dir_renamed_within_root_deletes_rows_under_old_name in packages/rust/tests/watch_scan_correctness.rs (the rename test asserts only the disappearing side; the appearing side is Watch: a directory moved into the root is never indexed #1096's), and server_drops_the_rows_of_a_directory_moved_out_of_the_root in packages/rust/tests/cli_e2e.rs.
  • Local red: all three fail on their own assertion (rows: ["leaving/one/deep.txt", "leaving/a.txt", "keep.txt"], rows: ["a/x.txt", "b/x.txt"], rows: ["Hello-World.json", "Second-Post.json"]).

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: pending
  • TypeScript SDK e2e: pending
  • Rust core e2e (if applicable): pending
  • packages/python/e2e-attestations/<branch>.json receipt written if packages/python changed (just e2e-attest-python)
  • packages/ts/e2e-attestations/<branch>.json receipt written if packages/ts changed (just e2e-attest-ts)
  • Command(s) run: pending
  • Result summary: pending

Changelog / Migrations

  • Changelog fragment added under <root>/<pkg>/changelog.d/ for each changed package (or: skip-changelog trailer on a commit with reason)
  • Migration fragment added under <root>/<pkg>/migrations.d/ (or: not required -- additive/bugfix only)

Parity

Parity maintained, no drift. Watcher behavior fix in the shared Rust core; no SDK public surface changes. PARITY.md entry lands with the implementation commit.

Red for #1109. inotify reports the move as one event naming the
directory and none for the files beneath it; the rows those files
produced currently linger until a cold rescan.

Two watch integration tests (move out of the root, rename within it,
asserting only the disappearing side) and one CLI e2e test.
inotify reports a directory renamed out of (or within) the root as one
event naming the directory and none for the files beneath it, so their
rows lingered until a cold rescan. On a Deleted event the watcher now
also deletes every row recorded under `<path>/` in every table, one
Delete event per file, the same as if each file had been removed alone.

`Db::files_under` lists the distinct (table, file_path) pairs beneath a
directory; `delete_subtree` in `process_file_event` drives the existing
per-file delete over them.

Fixes #1109
@thekevinbot thekevinbot reopened this Sep 17, 2026
The stale release-ci check runs left on the previous sha carry version
numbers willfire no longer predicts, so CI Gate reports them as
unpredicted checks and cannot confirm the set is complete.
@thekevinscott
thekevinscott merged commit f45c134 into main Sep 17, 2026
77 checks passed
@thekevinscott
thekevinscott deleted the claude/1109-watch-moved-out branch September 17, 2026 17:07
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.

Watch: a directory moved out of the root leaves its rows behind

2 participants