fix: Restore a remote cache hit below the anchor of the fetch (#15092)
## Description
A fetch names the directory its files are restored below, and the local
cache restores there. The remote cache restored below the repository
root, whatever the anchor was.
`turbo trace affected` fetches the packed graph of a nearby commit with
the graph directory (`.turbo/trace`) as the anchor. From a remote cache
the file therefore landed at the repository root as `transport.graph`:
- the graph was not installed, so every CI run built it from scratch and
uploaded it again;
- the file stayed in the working tree, where `turbo trace affected`
counted it as an added file and selected the tests that read the
repository root.
Two commits:
1. The remote cache restores below the anchor, as the local cache does.
Task outputs are fetched with the repository root as the anchor, so
nothing changes for them. This one touches `turborepo-cache`:
`HTTPCache::fetch` takes the anchor, and the `repo_root` field is gone.
2. The entries `turbo trace` itself leaves in turbo's local cache
directory (`<hash>.tar.zst`, `-meta.json`, `-manifest.json`) no longer
count as changes in a repository that does not ignore `.turbo`. Only
files with those names, directly in the cache directory, are left out.
Note for review: with this, graphs restored from a remote cache are used
for the first time. A restored graph is refreshed against the working
tree before it answers, and that is tested on fixtures here; it has not
yet been compared against a cold build on a large repository.
## Testing Instructions
- `cargo test -p turborepo-cache`:
`test_remote_fetch_restores_below_the_anchor` fails on `main`.
- `cargo test -p turbo --test trace_test`:
`the_graph_from_the_remote_cache_is_installed_and_is_not_a_change` and
`the_cache_entries_of_the_graph_are_not_a_change` fail on `main`.
- `cargo test -p 'turborepo-trace*'` and `cargo test -p turborepo-cli`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>