From 14e84e1fc5c896d075447855ae972b1f7c843abb Mon Sep 17 00:00:00 2001 From: sim Date: Tue, 8 Sep 2026 16:35:25 -0400 Subject: [PATCH] fix(#4460): use fs.realpathSync.native for the Windows-CI tmp fixture path Round 3's `.replace(/\brealpath -m\b/, 'realpath')` workaround did not actually fix the "test (windows-latest, 24, shard 1/3)" failure -- the same widened-to-5-files symptom recurred identically on PR #4552's next push, proving the `-m` flag was never the real cause. Root-caused via tests/helpers.cjs's own documented Windows caveat (tmpRootCandidates(), ~line 369): GitHub's Windows runners report os.tmpdir() in the 8.3 SHORT form (C:\Users\RUNNER~1\...), and fs.realpathSync() -- what this test used -- does not reliably expand that; only fs.realpathSync.native() does. The un-expanded short-form tmpDir path this test's Node side used for cwd/file construction can diverge from what bash's own `git rev-parse --show-toplevel` / `realpath` independently resolve inside Tier 1's containment check, which is exactly the failure mode observed: --files gets classified as "outside the repository", REVIEW_FILES stays empty, and control falls through to the full-diff path instead of exercising the gate under test. Co-Authored-By: Claude Sonnet 5 --- ...-review-tier3-files-override-scoping.test.cjs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/code-review-tier3-files-override-scoping.test.cjs b/tests/code-review-tier3-files-override-scoping.test.cjs index 1a861cd52..705223d5f 100644 --- a/tests/code-review-tier3-files-override-scoping.test.cjs +++ b/tests/code-review-tier3-files-override-scoping.test.cjs @@ -173,7 +173,19 @@ describe('#4460: code-review.md Tier 3 does not widen an explicit --files overri }); test('real execution: --files=src/alpha.js stays scoped to exactly that file (issue #4460 repro)', () => { - const tmpDir = fs.realpathSync(createTempDir('gsd-4460-')); + // fs.realpathSync.native (not the plain fs.realpathSync used elsewhere in + // this file's original revision) — tests/helpers.cjs's own + // tmpRootCandidates() documents that GitHub's Windows runners report + // os.tmpdir() in the 8.3 SHORT form (C:\Users\RUNNER~1\...) and that + // fs.realpathSync() does not reliably expand it, only the .native variant + // does. Without this, this test's tmpDir can carry a short-name segment + // that bash's own `git rev-parse --show-toplevel` / `realpath` resolve + // differently inside Tier 1, so its REPO_ROOT-prefix containment check + // spuriously treats every --files entry as "outside the repository" — + // REVIEW_FILES stays empty and control falls through to the full-diff + // path, which is what actually caused this test's prior Windows CI + // failure (all 5 files instead of the requested 1), not the `-m` flag. + const tmpDir = fs.realpathSync.native(createTempDir('gsd-4460-')); try { buildFixture(tmpDir); const files = runTiers(tmpDir, { filesOverride: 'src/alpha.js' }); @@ -188,7 +200,7 @@ describe('#4460: code-review.md Tier 3 does not widen an explicit --files overri }); test('without --files, the #2666 cross-check still widens a partial (Tier-2-equivalent) scope (no regression to the cross-check itself)', () => { - const tmpDir = fs.realpathSync(createTempDir('gsd-4460-')); + const tmpDir = fs.realpathSync.native(createTempDir('gsd-4460-')); try { buildFixture(tmpDir); // seedReviewFiles stands in for Tier 2's real output (["src/alpha.js"],