The @ref hygiene gate dies on a mid-rename working tree instead of reporting (#942) - #947
Merged
Conversation
Contributor
Author
Issues #940 and #942 are follow-ups from two different PRs (#929 and #933), but both
Both branch off This needs a human call: pick one approach (or merge one and rebase the other onto |
…porting (#942) `git ls-files` reports the index, not the working tree, so a path it names can have no file behind it: mid-rebase, mid-rename, or any other moment where the two have not converged. `trackedFiles()` in the `@ref` hygiene gate fed that list straight into `fs.readFileSync` at module scope, so one such path threw ENOENT before a single test ran and took the whole file with it. A developer on a transiently inconsistent checkout got a stack trace where a hygiene result belonged. Extract the listing into `test/helpers/tracked_files.js` and filter it to paths that are present on disk, so every caller of the shared gate listing gets the guarantee that what it returns can be read. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
philcunliffe
force-pushed
the
fix/issue-942
branch
from
August 19, 2026 19:39
2c81db8 to
e3b6072
Compare
philcunliffe
marked this pull request as ready for review
August 19, 2026 19:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clears the one deferred finding from the PR #933 triage.
The defect
trackedFiles()intest/core/llp-ref-hygiene.test.jsenumerated the scan set withgit ls-files -zand fed it straight intofs.readFileSyncat module scope.git ls-filesreports the index, not the working tree, so a path it names can have no file behind it: mid-rebase, mid-rename, or any other moment where the two have not converged. One such path threw ENOENT before a single test ran and took the whole test file with it, so a developer on a transiently inconsistent checkout got a stack trace where a hygiene result belonged.Reproduced directly in a worktree by deleting a tracked file (
README.md) and running the gate:With the fix applied and
README.mdstill absent, the same run is# tests 11 / # pass 11 / # fail 0.The fix
The listing is extracted into
test/helpers/tracked_files.jsand filtered to paths that are present on disk, so it is a shared, testable unit rather than a private detail of one gate, and every caller of it gets the guarantee that what it returns can be read.test/core/llp-ref-hygiene.test.jsnow imports it at both call sites (the module-scopeREFSscan and the suppression-marker gate).This is the same guard the sibling listing in PR #933 carries, factored so there is one copy of the reasoning rather than two.
Regression test
New:
test/core/tracked-files.test.js(4 tests).a tracked path with no file behind it is left out of the listingevery listed path can be read, which is what the gates do nextthe extension filter and the presence filter both applythe real repository listing is non-empty and entirely readableThe first three build a throwaway git repo, stage files, then delete some from the working tree.
Fail -> pass evidence, with only the
existsSyncfilter removed from the helper:Restored:
Checks
npm test:# tests 4533 / # pass 4532 / # fail 0 / # skipped 1npm run typecheck: cleanNot a production defect, and no LLP change: this is test-harness robustness only.
Fixes #942