Skip to content

Watch only the directories a table glob can reach - #1757

Merged
thekevinbot merged 18 commits into
mainfrom
bot/1756-glob-scoped-watch-1118
Nov 18, 2026
Merged

thekevinbot merged 18 commits into
mainfrom
bot/1756-glob-scoped-watch-1118

Conversation

@thekevinbot

@thekevinbot thekevinbot commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1756

The watcher's directory walk (scan_dirs) now prunes by the table globs, as the scan does: it enters only directories a table glob can reach and those on the way to them, and reaches_dir (which gates watching a directory that appears later) applies the same glob check. A matcher with no tables still enters everything. Gitignore handling is unchanged.

Symlinks (ruling: option (a)): the watch walk follows a symlinked directory a glob reaches and lists it once, at its canonical target, when that target lies under the root (one inotify watch per inode; events arrive at the target and are restated at the link path by the existing Link mapping). Each WatchScope remembers the links its walks entered, so a directory created later under such a target is walked through the link (WatchScope::walk_starts) and watched too. A target outside the root is not watched.

Red:

  • Glob pruning: Rust Unit tests job 134949367111 (run 44346259769) failed on scan_dirs_lists_only_the_directories_a_table_glob_can_reach (left held src/0 ... src/49/deep, .dirsql, docs/.cache; right = root, docs, docs/guide).
  • Symlink target: Rust Integration tests job 135014396395 (run 44359974745, commit 703b47b) failed on an_edit_at_a_target_no_glob_reaches_updates_the_rows_reached_through_the_link and a_directory_made_later_under_a_target_no_glob_reaches_is_watched_through_the_link (got: []).

Manual exercise:

  • dirsql server -c .dirsql.toml with one table docs/**/*.md over a tree of 1004 directories (500 src/N/deep): inotify watches 3 (was 1007 on the previous build). A docs/<new>/b.md written after startup still showed up in SELECT count(*).
  • Tree real/x.txt, link -> real, other/a, other/b, one table link/**/*.txt: 2 inotify watches (root, real). After startup, mkdir real/sub, write real/sub/y.txt, rewrite real/x.txt: the query returned both new bodies (three, two).

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: pass (impacted subset, 22 passed)
  • TypeScript SDK e2e: pass (impacted subset, 8 passed)
  • Rust core e2e (if applicable): N/A (covered by CI cargo test)
  • 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: uv run maturin develop --release, then testing-conventions e2e attest 'uv run python -m pytest tests/e2e/watch_fault_test.py tests/e2e/watch_speed_test.py tests/e2e/fanout_test.py tests/e2e/fresh_declared_repros_test.py tests/e2e/many_dirs_speed_test.py tests/e2e/query_contract_test.py tests/e2e/glob_speed_symlink_test.py -q -rf'; pnpm run build, then testing-conventions e2e attest 'pnpm exec vitest run --dir tests/e2e fresh-declared-repros fanout'
  • Result summary: all pass. watch_speed_test is noisy on this host (sub-millisecond native median): interleaved A/B, the branch passed 6/8 and main 4/8.

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 with the same slug added under <root>/<pkg>/migrations.d/ for each changed package (every subsection but Summary _None._ when nothing breaks)

@thekevinbot
thekevinbot marked this pull request as ready for review November 18, 2026 19:05
@thekevinbot
thekevinbot merged commit e036b4b into main Nov 18, 2026
89 checks passed
@thekevinbot
thekevinbot deleted the bot/1756-glob-scoped-watch-1118 branch November 18, 2026 19:05
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.

The watcher watches every directory under the root, not just those the table globs can match

1 participant