fix: Stop hashing files behind `node_modules` links as task inputs (#15108)
Since 2.11.11 an input glob that reached a directory link through `*` or
`**` read the linked package's files, so under pnpm a workspace link
such as `packages/a/node_modules/@s/b` put every file of `packages/b`
into `a`'s task inputs. `$TURBO_DEFAULT$` plus a test-file glob
therefore hashed every test file of every workspace dependency, once per
path through the package graph.
- A directory link under `node_modules` is not part of a walk unless the
pattern names it, which is what `follow_links_within_base` and the
non-Git walkers already promise: package managers own those links, and
the lockfile and package graph already capture the dependency.
- A pattern that names the link, such as
`node_modules/@scope/dep/src/**/*.txt`, and a link committed to the Git
index still hash the referent, so explicit selections and commit-visible
links keep the behavior they gained in 2.11.11.
- In-repo directory links outside `node_modules` are unchanged,
including reading a shared target once per walk.
Fixes #15084
<details><summary>Validation and details</summary>
### Validation
- `cargo test -p turborepo-scm -p globwalk -p wax`: pass.
- `cargo clippy -p globwalk -p turborepo-scm -p wax --all-targets -- -D
warnings`: pass.
- `cargo fmt --all --check`: pass.
- `cargo test -p turbo --test gitignored_inputs_test --test dry_json
--test run_caching --test global_inputs_test --test final_hash_contract
--test untracked_scoping_test`: pass.
- `cargo check -p globwalk -p turborepo-scm --all-targets --target
x86_64-pc-windows-msvc` and `cargo clippy -p globwalk --all-targets
--target x86_64-pc-windows-msvc -- -D warnings`: pass.
- Ran `cargo build -p turbo` and the report's script on a two-package
pnpm workspace, against published 2.11.10 and 2.11.13.
- Installed for these checks: the toolchain from `rust-toolchain.toml`
(nightly-2026-07-03) with `rustfmt` and `clippy`, `capnproto`,
`protobuf-compiler` and Zig 0.17.1.
### Inputs before and after
The report's script, `packages/a` depending on `@s/b` through a pnpm
workspace link, with `inputs: ["$TURBO_DEFAULT$",
"**/*.{test,spec}.{ts,tsx}"]`:
| Build | `@s/a#test` inputs |
| --- | --- |
| 2.11.10 | `package.json`, `src/a.test.ts` |
| 2.11.13 | `node_modules/@s/b/src/b.test.ts`, `package.json`,
`src/a.test.ts` |
| This branch | `package.json`, `src/a.test.ts` |
An unscoped link (`node_modules/b -> ../../b`) behaves the same way, and
so does a bare `**` input, which is back to the package's own files.
With the scoped link committed to the index, this branch and 2.11.13
hash identical inputs, so links the Git index names keep their referent
hashes.
The gate that bounds link following in `globwalk` now classifies a
directory link found below its root before deciding: a link under
`node_modules` that the pattern does not name is pruned without being
yielded, a link the pattern names or one inside the walk base's trust
boundary is followed once per target, and anything else is yielded as an
entry. Naming is decided per pattern on literal components, with escaped
characters read as themselves so a walk base containing glob specials
(including a Windows drive letter) still names its links.
### Tests
`symlink_inputs_tests::workspace_links_under_node_modules_are_not_followed`
covers the report across Git, indexed Git and manual hashing, with and
without default files, and asserts that explicitly named paths through
the same links still hash. Without the change its input set includes
`node_modules/@s/b/src/b.test.ts`. `globwalk::pattern_names_path_test`
covers the naming check, and
`symlink_inputs_tests::linked_directories_are_read_once_per_input_walk`
now uses in-repo links outside `node_modules`, since links under
`node_modules` are no longer read at all; its assertions about reading a
shared target once are unchanged.
</details>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>