Skip to content

Reuse unchanged directory listings in sight check - #445

Merged
jbearak merged 3 commits into
mainfrom
check-listing-cache
Nov 20, 2026
Merged

jbearak merged 3 commits into
mainfrom
check-listing-cache

Conversation

@jbearak

@jbearak jbearak commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

sight check resolves the calls of the files above each target again for every target, and each case-aware resolution lists every directory on its path. In a workspace where many files call one file, the same directories were listed thousands of times.

check now gives its three resolvers a filesystem view that reuses a directory's listing while the directory is unchanged (create_listing_cache_resolve_fs in src/utils/file-path-utils.ts):

  • Every reuse first stats the directory. Listings are kept per directory (device and inode), and one is reused only if the mtime and ctime also match.
  • The root of a volume and a directory with no inode number are never cached: a FAT root's timestamps do not move when its entries change.
  • A directory changed in the last 2 s is never cached, because a second change in the same timestamp tick would not move its timestamps (git's "racily clean" rule).
  • Existence and stat checks are not cached.

The language server is unchanged; it keeps the plain Node fs.

Workspace (sight check .) main this PR
349 callers of one file 25.1 s 1.4 s
7 mutually calling files and one sight: cd 14.0 s 4.1 s
150-file chain 0.26 s 0.25 s
5,000 flat files 0.42 s 0.34 s

Proof: sight check over Stata's 3,780 base ados gives the same 30,118 diagnostics as main, byte for byte. New unit tests cover reuse, a new file seen at once, a just-changed directory, a volume root, two paths to one directory, uncached existence checks, and a path that comes to name another directory. Each guard's test fails when the guard is removed.

Known limit: the cache relies on the filesystem moving a directory's timestamps when its entries change. Where it does not, a file created or renamed during a single run can be missed. All four gates pass locally.

Taken from #435.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 62 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: e4f720a1-e6c7-4087-94c2-091b73db5735
Commits

Reviewing files that changed from the base of the PR and between 57855ef and 7b004f5.

Files selected for processing: 3

  • src/cli/check.ts
  • src/utils/file-path-utils.ts
  • tests/unit/listing-cache-resolve-fs.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@jbearak

jbearak commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Note

🤖 Claude Fable 5.2 responding on behalf of jbearak

An independent cold review of 58836511 found three things; state at 7c7c663d:

  • Stale listing on a FAT volume root (fixed). A FAT root keeps the same device, inode, mtime and ctime when a file is created in it, so a file created during a run was missed. The root of a volume (device differs from its parent's) and a directory with no inode number are no longer cached. Remaining limit, now in the function comment: the cache relies on the filesystem moving a directory's timestamps when its entries change. On one that does not, a file created or renamed while a single sight check run is in progress can be missed. Files present before the run are unaffected.
  • One listing per symlink spelling (fixed). Listings are keyed by device and inode, not by path, so several paths to one directory share one listing.
  • A cache hit hides a directory-read error (not changed). With the process out of file descriptors, main fails to list the directory and reports the file missing; the cache returns the listing it already has. The cached answer is the correct one.

Tests: the recent-directory test depended on the clock and still passed 26 of 30 times with its guard removed; it and the identity test now use an injected stat, and no test needs a symlink. Each guard (settle interval, volume root, no inode) has a test that fails when the guard is removed.

Re-verified at 7c7c663d: all four gates pass (10,517 tests pass, 0 fail); sight check over the 3,780 base ados is byte-identical to main; the 349-caller workspace takes 1.4 s (25 s on main).

@jbearak
jbearak merged commit 4fb319c into main Nov 20, 2026
17 checks passed
@jbearak
jbearak deleted the check-listing-cache branch November 20, 2026 21:31
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.

1 participant