Skip to content

feat(cache): add output globs for cache restoration#375

Merged
branchseer merged 10 commits into
mainfrom
feat/output-globs
May 11, 2026
Merged

feat(cache): add output globs for cache restoration#375
branchseer merged 10 commits into
mainfrom
feat/output-globs

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented May 7, 2026

Summary

Adds an output field to cached tasks: archives files matching the configured globs after a successful run and restores them on cache hit.

  • Omitted or []: no output archiving (matches existing behavior)
  • ["dist/**"]: archive matching files; restore on cache hit
  • [{"pattern": "...", "base": "workspace" | "package"}]: explicit base directory
  • ["!dist/cache/**"]: negative patterns exclude files
  • This PR does not support {auto: true} — that comes in the follow-up feat(cache): restore output files on cache hit #321

Schema bumped to v12 (CacheEntryKey carries output_config, CacheEntryValue carries output_archive). Old caches reset on upgrade.

Test plan

  • CI green
  • New e2e fixture output_cache_test/ covers archive+restore and negative-pattern exclusion
  • All 87 plan snapshots updated to include the new output_config field (default empty)

🤖 Generated with Claude Code

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 7, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​zstd@​0.13.310010093100100

View full report

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9dbd5b86b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_task/src/session/execute/mod.rs
Adds an `output` field to cached tasks: archives files matching the
configured globs after a successful run and restores them on cache hit.

Supports glob patterns, negative patterns, and `{pattern, base}` form
with explicit base directory. When `output` is omitted or empty, no
output archiving happens (matches prior behavior).

Schema version bumped to 12 (CacheEntryKey carries output_config,
CacheEntryValue carries output_archive). Old caches are reset on upgrade.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@branchseer branchseer force-pushed the feat/output-globs branch from 9dbd5b8 to 6d03bc0 Compare May 7, 2026 08:22
Comment thread CHANGELOG.md Outdated
Comment thread crates/vite_task/src/session/cache/archive.rs Outdated
Comment thread crates/vite_task/src/session/cache/mod.rs Outdated
Comment thread crates/vite_task/src/session/cache/mod.rs
Comment thread crates/vite_task/src/session/execute/glob.rs
Comment thread crates/vite_task/src/session/execute/mod.rs
Combines the prior `exists()` precheck with the subsequent metadata
call into a single `metadata()` invocation. NotFound is the only
expected miss (file deleted between glob walk and archive write); any
other I/O error now propagates instead of being swallowed by `exists()`
returning false.
The old structure had a fallback `InputConfig` arm that was reachable
only if all three fields (spawn, input, output) matched — but
`get_by_cache_key` for the current key returned None earlier, so that
state is contradictory. Flatten to a single if/else-if chain in priority
order and assert the residual case with `debug_assert!`.
When archive restoration fails on cache hit (file missing, truncated,
or unreadable), wrap the I/O error with a recovery hint telling the
user to run `<program> cache clean`. This matches the message style
already used for schema-version mismatches.
… output collection

`compute_globbed_inputs` and `collect_glob_paths` had identical
walk-and-filter logic, differing only in what they did per file
(hash content vs. record path). Extract a common `walk_glob_files`
helper that takes a closure; both public functions are now thin
wrappers over it.
Adds `vtt list-dir <dir> [--ext <suffix>]` for inspecting cache state
from e2e tests, plus a UUID redactor so archive filenames (which are
random per run) stay stable across snapshot regenerations.

The new `output_globs___old_archive_removed_on_rewrite` fixture asserts
that after two cache-missing runs of the same task, the cache directory
contains exactly one `.tar.zst` archive — proving the cleanup path in
`ExecutionCache::update` actually runs.
Comment thread crates/vite_task/src/session/execute/glob.rs
Comment thread crates/vite_task/src/session/execute/glob_inputs.rs Outdated
Comment thread crates/vite_task/src/session/execute/glob_inputs.rs Outdated
Comment thread crates/vite_task_graph/src/config/mod.rs
- Rename crates/vite_task/src/session/execute/glob_inputs.rs to glob.rs
  to reflect its broader role (both input fingerprinting and output
  collection use it).
- Change `walk_glob_files` to call the user closure with `AbsolutePathBuf`
  (was `(&Path, RelativePathBuf)`); callers strip the root themselves
  when they need a relative path. The closure now returns
  `anyhow::Result<ControlFlow<()>>` so a caller can stop the walk
  without producing an error.
- Drop `workspace` from identifiers inside the module: positive globs
  are rooted at the caller-supplied `root`, which need not be a
  workspace root.
Adds a TODO note that this method will be folded into
`from_user_config` once auto output inference lands and `output`
becomes a `UserInputsConfig` like `input`.
- Move the descriptive comments out of TOML `#` lines (invisible to
  snapshots) and into per-step `comment =` fields, so the rendered
  snapshot describes what each step is doing.
- In the negative-excludes scenario, follow the restoration step with a
  `vtt print-file dist/skip.txt` to assert that the excluded file is
  reported as "not found" — proving the negative glob keeps the file
  out of the archive, not just out of the initial walk.
@branchseer branchseer requested a review from fengmk2 May 11, 2026 07:29
Copy link
Copy Markdown
Member Author

branchseer commented May 11, 2026

Merge activity

  • May 11, 7:43 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 11, 7:43 AM UTC: @branchseer merged this pull request with Graphite.
@branchseer branchseer merged commit 630722f into main May 11, 2026
12 checks passed
@branchseer branchseer deleted the feat/output-globs branch May 11, 2026 07:44
branchseer added a commit to voidzero-dev/vite-plus that referenced this pull request May 13, 2026
Bumps the vite-task git dependency from `88bacaa` to `c63db22`.

## Notable upstream changes

- feat(cache): add `output` globs for cache restoration
([vite-task#375](voidzero-dev/vite-task#375))
- feat(cache): store colored task logs, strip at display when needed
([vite-task#378](voidzero-dev/vite-task#378))
- fix(plan): move FORCE_COLOR fallback after pattern filtering
([vite-task#379](voidzero-dev/vite-task#379))
- fix: preserve `PATHEXT` for Windows cached tasks
([vite-task#366](voidzero-dev/vite-task#366))

## Vite+ side changes

- Added the new `output: None` field to all `EnabledCacheConfig`
initializers in `packages/cli/binding/src/cli/{handler,resolver}.rs` to
match the new field added in vite-task#375.
- Bumped `rusqlite` to `0.39.0` to match vite-task's new requirement and
resolve a `libsqlite3-sys` links conflict.
- Regenerated `packages/cli/src/run-config.ts` types snapshot (vite-task
task map type tightened).
- Removed the `pass-no-color-env` snap test, which is no longer relevant
now that `NO_COLOR` is not in vite-task's default env passthrough.
- Updated `docs/config/run.md`:
  - Added an `output` cache config section.
- Refreshed the default-passthrough terminal env vars list (only
`FORCE_COLOR` is auto-passed; other color vars need opt-in).

Compare:
voidzero-dev/vite-task@88bacaa...c63db22#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed

---------

Co-authored-by: Claude <noreply@anthropic.com>
otnc pushed a commit to otnc/viteplus-ja that referenced this pull request May 13, 2026
Bumps the vite-task git dependency from `88bacaa` to `c63db22`.

## Notable upstream changes

- feat(cache): add `output` globs for cache restoration
([vite-task#375](voidzero-dev/vite-task#375))
- feat(cache): store colored task logs, strip at display when needed
([vite-task#378](voidzero-dev/vite-task#378))
- fix(plan): move FORCE_COLOR fallback after pattern filtering
([vite-task#379](voidzero-dev/vite-task#379))
- fix: preserve `PATHEXT` for Windows cached tasks
([vite-task#366](voidzero-dev/vite-task#366))

## Vite+ side changes

- Added the new `output: None` field to all `EnabledCacheConfig`
initializers in `packages/cli/binding/src/cli/{handler,resolver}.rs` to
match the new field added in vite-task#375.
- Bumped `rusqlite` to `0.39.0` to match vite-task's new requirement and
resolve a `libsqlite3-sys` links conflict.
- Regenerated `packages/cli/src/run-config.ts` types snapshot (vite-task
task map type tightened).
- Removed the `pass-no-color-env` snap test, which is no longer relevant
now that `NO_COLOR` is not in vite-task's default env passthrough.
- Updated `docs/config/run.md`:
  - Added an `output` cache config section.
- Refreshed the default-passthrough terminal env vars list (only
`FORCE_COLOR` is auto-passed; other color vars need opt-in).

Compare:
voidzero-dev/vite-task@88bacaa...c63db22#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed

---------

Co-authored-by: Claude <noreply@anthropic.com>
branchseer added a commit that referenced this pull request May 18, 2026
The previous merge took `origin/main`'s `output_cache_test/snapshots.toml`
(which declares `output_globs___*` cases) but kept this branch's
`vite-task.json` and orphan `*.md` snapshots from the old
`30a97a2e` design (`auto-output`, `glob-output`, …). The result was a
fixture whose tasks didn't match the cases pnpm asked the test runner to
exercise, so the three `output_globs___*` jobs failed on every runner.

Replace the fixture wholesale with `origin/main`'s version so cases,
tasks, sources, and snapshots all describe the same scenarios. The
runner-aware-tools branch never relied on the dropped auto/glob cases
itself — they were artefacts of an earlier in-flight design that landed
upstream as #375 with a different surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants