Skip to content

fix(cache): resolve .. before checking that a tracked path is in the workspace - #940

Merged
wan9chi merged 2 commits into
mainfrom
fix/cache-dotdot-paths
Nov 5, 2026
Merged

wan9chi merged 2 commits into
mainfrom
fix/cache-dotdot-paths

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Motivation

On Linux and macOS, a task that writes outside the workspace through a relative path with .., like cp -r dist ../site publishing a build next to the repo, fails with ✗ Cache update failed: paths in archives must not have ... fspy reports a relative open as the working directory joined with the path, .. included, so the write is <workspace>/../site/index.html. vt stripped the workspace root before resolving .., so the path passed the check that it's in the workspace and became the output ../site/index.html, which the archive rejects. A file read that way became an input outside the workspace, unlike the same file read through an absolute path.

Changes

Tracked paths have . and .. resolved lexically, as before, but before the workspace root is stripped, so such a path is outside the workspace and dropped like any other. A path that stays inside, like packages/sub-pkg/../shared/dist/output.js, is still packages/shared/dist/output.js. vt_path gets clean_and_strip_path_prefix, and fspy's IpcPath a method of the same name next to strip_path_prefix, which is unchanged. Windows resolves .. before fspy sees the path, so it wasn't affected. A unit test covers the order, and the malformed Windows drive path that the cleaning after the strip used to catch.

E2E case: write_outside_workspace_through_dotdot (synthetic, vtt fs mkdir ../site write ../site/index.html hi, where .. is the harness's folder holding the staged workspace). Both runs fail today; after, the first is cached and the second hits. The first commit runs it on Unix only, since Windows already caches it.

A standalone fix for main. The stack that lets automatic tracking cache tasks which read their own outputs and list the folders holding them, so they also hit on a clean checkout, sits on it and no longer checks for .. itself.

🤖 Generated with Claude Code


Note

Medium Risk
Changes how automatic file-access tracking classifies workspace inputs/outputs, which directly affects cache keys and archive contents; behavior is covered by new unit and e2e tests but touches core caching logic.

Overview
On Linux and macOS, cached tasks that write outside the repo via relative paths like ../site (e.g. cp -r dist ../site) no longer fail with Cache update failed: paths in archives must not have ... The second run can cache hit instead.

Tracked path normalization now lexically resolves . and .. before stripping the workspace root, so paths such as <workspace>/../site/index.html are treated as outside the workspace and dropped from inputs/outputs (same as absolute paths outside the repo). In-workspace paths like packages/sub-pkg/../shared/dist/output.js still normalize to packages/shared/dist/output.js.

Adds vt_path::clean_and_strip_path_prefix and IpcPath::clean_and_strip_path_prefix, wired through tracked_workspace_path; the old strip-then-clean() flow is removed. Unit tests cover ordering and the Windows malformed-path case; an e2e fixture asserts a ../site deploy task caches on repeat run.

Reviewed by Cursor Bugbot for commit 827bef8. Bugbot is set up for automated code reviews on this repo. Configure here.

@wan9chi wan9chi added ci: full Run the slow CI jobs (macOS x64, musl) on this pull request read-write overlap Caching tasks that read and write the same paths labels Nov 5, 2026
…` isn't cached

A case for a task that writes outside the workspace through a relative
path with `..`, like `cp -r dist ../site` publishing a build next to the
workspace. In `write_outside_workspace_through_dotdot`, the task makes
`../site` and writes `../site/index.html` through `vtt fs`; `..` is the
folder holding the staged workspace, which the harness removes.

Today fspy reports the write as `<workspace>/../site/index.html`. That
passes the check that a tracked path is in the workspace and becomes the
output `../site/index.html`, so every run fails to update the cache with
`paths in archives must not have ..`.

The case runs on Unix only for now. On Windows, `..` is resolved before
fspy reports the path, so the write is outside the workspace and the task
is already cached there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…workspace

On Unix, fspy reports a relative path as the working directory joined
with it, `..` included, so a task that writes `../site/index.html` from
the workspace root, like `cp -r dist ../site`, is tracked as writing
`<workspace>/../site/index.html`. vt stripped the workspace root from
that path before resolving `..`, so it passed as `../site/index.html`,
and with automatic output tracking, archiving it failed the run with
`Cache update failed: paths in archives must not have ..`. A file read
that way became an input outside the workspace.

vt now resolves `.` and `..` lexically, as before, but before stripping
the workspace root, so such a path is outside the workspace and skipped
like any other. A path that stays inside, like
`packages/sub-pkg/../shared/dist/output.js`, is still
`packages/shared/dist/output.js`, and one that leaves the workspace and
comes back, like `<workspace>/../<workspace folder>/a`, is now `a`.
`vt_path` gets `clean_and_strip_path_prefix`, which fspy's `IpcPath`
offers next to `strip_path_prefix`.

`write_outside_workspace_through_dotdot` now runs on Windows too. There
`..` is resolved before fspy sees the path, so the task was cached
already, and the case now has the same result on every platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wan9chi
wan9chi force-pushed the fix/cache-dotdot-paths branch from 5c87b9e to 827bef8 Compare November 5, 2026 08:53
@wan9chi
wan9chi added this pull request to stack #942 November 5, 2026 08:55
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  -0.18%  [ -5.58% ..  +6.45%]  overhead   +57.28%
dynamic/access             change  -1.08%  [ -7.60% ..  +4.95%]  overhead   +19.73%
dynamic/access-relative    change  +0.25%  [ -4.98% ..  +5.64%]  overhead   +67.33%
dynamic/access-contended   change  -2.42%  [-16.19% ..  +9.18%]  overhead    +9.26%
static/launch              change  +1.42%  [ -6.49% ..  +9.24%]  overhead  +183.01%
static/access              change  +0.35%  [ -5.12% .. +15.05%]  overhead +1445.53%
static/access-relative     change  +0.41%  [ -2.19% ..  +2.74%]  overhead +1979.63%
static/access-contended    change  -1.27%  [ -6.48% ..  +3.12%]  overhead +1084.89%

macos

dynamic/launch             change  -0.41%  [ -5.06% ..  +4.72%]  overhead  +237.06%
dynamic/access             change  +0.35%  [ -1.76% ..  +2.91%]  overhead    +3.28%
dynamic/access-relative    change  -0.52%  [ -7.62% ..  +7.73%]  overhead  +267.22%
dynamic/access-contended   change  +1.72%  [ -6.93% ..  +5.93%]  overhead    +0.49%

windows

dynamic/launch             change  -0.48%  [ -6.92% ..  +4.27%]  overhead   +26.97%
dynamic/access             change  +0.00%  [ -1.10% ..  +1.47%]  overhead    +1.48%
dynamic/access-relative    change  +0.17%  [ -1.96% ..  +1.24%]  overhead    +1.27%
dynamic/access-contended   change  +1.26%  [ -9.82% .. +36.22%]  overhead    +1.74%

@wan9chi
wan9chi merged commit 6570fdc into main Nov 5, 2026
23 checks passed
@wan9chi
wan9chi deleted the fix/cache-dotdot-paths branch November 5, 2026 10:44
wan9chi added a commit that referenced this pull request Nov 5, 2026
## Motivation

Follow-ups to the rebuildable-inputs stack (#913–#919, #940, #941), now
merged:

- The real-world case for files renamed into place (#916) used Vitest's
`fsModuleCache`, which renames cache entries rather than outputs.
- #919's e2e cases test a listing entry like any other, so they add no
coverage of their own.
- The stack added eight changelog entries, most of them for what users
see as one feature.
- Socket flagged Astro 6.4.8, which #917 added for its real-world case:
critical advisory GHSA-26w7-cxv4-gfx2 (remote code execution through
AVIF image optimization), fixed in Astro 7.2.8.

## Changes

- New case `next_build_moved_pages`: Next.js 15's `next build` renders
each static page (`index.html`, `404.html`, `500.html`) into
`.next/export` and renames it into `.next/server/pages`. After `.next`
is removed, the next run is a cache hit that restores the pages. The
build log is redacted, since its progress lines, sizes and chunk hashes
vary. It replaces `vitest_fs_module_cache`, along with the SHA-1
redaction only that case used. `next`, `react` and `react-dom` join
`packages/tools`.
- `dist_appears_in_listed_folder` and `oxlint_dist` are removed.
- The changelog entries of #913–#918 are combined into one **Added**
item for rebuildable inputs; #919 (`dist` in listings) and #941 (input
exclusions apply to listings) stay their own short items, and so does
#940's fix.
- On Windows CI, the e2e harness stages fixtures in `RUNNER_TEMP`, on
the checkout's drive: the staged workspaces resolve `node_modules` into
the checkout, and Next.js builds its client entry from a path relative
to the project, which can't cross drives.
- Astro 6.4.8 → 7.3.8, the newest release that still supports the repo's
Node 22.19. Astro 7 needs upstream Vite 8, so its scoped override now
points at Vite 8.3.2. `astro_empty_collections` passes unchanged; its
comment now says Astro 7 stats the project root rather than listing it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Test harness, changelog, and dependency catalog changes only; no
changes to task caching or file-tracking behavior in this diff.
> 
> **Overview**
> Follow-up after the rebuildable-inputs stack lands: **no runtime cache
logic changes**—mostly release notes, snapshot tests, and toolchain
bumps.
> 
> The **changelog** folds the former #913–#918 narrative into one
**Added** “rebuildable inputs” entry and shortens the #919 / #941
**Changed** bullets; #940 stays separate.
> 
> **E2E snapshots** swap coverage: **`next_build_moved_pages`** (Next.js
15 renaming `.next/export` → `.next/server/pages`, cache hit after
deleting `.next`) replaces **`vitest_fs_module_cache`**;
**`dist_appears_in_listed_folder`** and **`oxlint_dist`** are dropped as
redundant with listing behavior elsewhere. Snapshot **redaction** drops
SHA-1 normalization (Vitest-only). On **Windows CI**, fixtures stage
under **`RUNNER_TEMP`** so Next’s client entry paths stay on the
checkout drive.
> 
> **Deps**: catalog adds **Next 15**, **React 19**, bumps **Astro 6 →
7.3.8** (security advisory), and scopes **`astro>vite`** to upstream
**Vite 8.3.2**. The Astro empty-collections fixture comment reflects
Astro 7 **stat**-ing the project root instead of listing it.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4c8f40c. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: full Run the slow CI jobs (macOS x64, musl) on this pull request read-write overlap Caching tasks that read and write the same paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant