GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(cache): add explicit auto output tracking by wan9chi · Pull Request #460 · voidzero-dev/vite-task

feat(cache): add explicit auto output tracking #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
wan9chi merged 1 commit into main from infra-explicit-auto-output
Jun 15, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(cache): add explicit auto output tracking #460

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
a077de0
feat(cache): add explicit auto output tracking
wan9chi Jun 14, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

1 change: 1 addition & 0 deletions 1 CHANGELOG.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- **Added** Runner-aware tools can now call `ignoreInput(path)` to exclude non-semantic reads from auto-inferred task cache inputs.
- **Added** Runner-aware tools can now call `ignoreOutput(path)` to exclude non-semantic writes from read/write overlap checks.
- **Added** Cached tasks can opt into automatic output restoration with `output: [{ auto: true }]`.
- **Changed** Tracked environment values in task cache fingerprints are now stored only as SHA-256 digests, and env-related cache miss details report names without values.
- **Added** Runner-aware `getEnvs` match sets can now participate in task cache fingerprints, so changing, adding, or removing a matching env var invalidates the cache ([#450](https://github.com/voidzero-dev/vite-task/pull/450)).
- **Added** Runner-aware `getEnvs` calls now return env values served by the runner for matching env glob patterns ([#449](https://github.com/voidzero-dev/vite-task/pull/449)).
Expand Down
134 changes: 96 additions & 38 deletions 134 crates/vite_task/src/session/execute/cache_update.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use crate::{
/// value is only ever `Some` when tracking happened (see [`observe_fspy`]).
struct TrackingOutcome {
path_reads: HashMap<RelativePathBuf, PathRead>,
/// Auto-output writes after output exclusions are applied. Empty when
/// `output_config.includes_auto` is false.
path_writes: FxHashSet<RelativePathBuf>,
/// First path that was both read and written during execution, if any.
/// A non-empty value means caching this task is unsound.
read_write_overlap: Option<RelativePathBuf>,
Expand Down Expand Up @@ -58,7 +61,6 @@ pub(super) async fn update_cache(
) -> (CacheUpdateStatus, Option<ExecutionError>) {
let CacheState { metadata, globbed_inputs, std_outputs, tracking } = state;
let fspy = tracking.fspy.as_ref();
let input_negative_globs = fspy.map(|t| t.input_negative_globs.as_slice());

if let Some(reports) = reports
&& reports.cache_disabled
Expand Down Expand Up @@ -89,7 +91,8 @@ pub(super) async fn update_cache(

let fspy_outcome = observe_fspy(
outcome,
input_negative_globs,
metadata,
fspy,
&ignored_input_rels,
&ignored_output_rels,
workspace_root,
Expand Down Expand Up @@ -150,7 +153,12 @@ pub(super) async fn update_cache(
}
};

let output_archive = match collect_and_archive_outputs(metadata, workspace_root, cache_dir) {
let output_archive = match collect_and_archive_outputs(
metadata,
fspy_outcome.as_ref(),
workspace_root,
cache_dir,
) {
Ok(archive) => archive,
Err(err) => {
return (
Expand All @@ -177,12 +185,18 @@ pub(super) async fn update_cache(
}

/// Summarize the run's fspy observations. `Some` iff tracking was both
/// requested (`input_negative_globs.is_some()`) and compiled in (`cfg(fspy)`). On a
/// requested (`tracking.fspy.is_some()`) and compiled in (`cfg(fspy)`). On a
/// `cfg(not(fspy))` build this is always `None`, and [`update_cache`]
/// short-circuits to `FspyUnsupported` when tracking was needed.
///
/// `path_reads` is gated on `input_config.includes_auto`, filtered by
/// user-configured input negatives, and by tool-reported `ignoreInput` paths.
/// `path_writes` is filtered by user-configured output negatives and
/// tool-reported `ignoreOutput` paths before read-write overlap detection.
fn observe_fspy(
outcome: &ChildOutcome,
input_negative_globs: Option<&[wax::Glob<'static>]>,
metadata: &CacheMetadata,
fspy: Option<&super::FspyTracking>,
ignored_input_rels: &FxHashSet<RelativePathBuf>,
ignored_output_rels: &FxHashSet<RelativePathBuf>,
workspace_root: &AbsolutePath,
Expand All @@ -191,31 +205,56 @@ fn observe_fspy(
{
use super::tracked_accesses::TrackedPathAccesses;

outcome.path_accesses.as_ref().zip(input_negative_globs).map(|(raw, negatives)| {
let tracked = TrackedPathAccesses::from_raw(raw, workspace_root, negatives);
let path_reads: HashMap<RelativePathBuf, PathRead> = tracked
.path_reads
.into_iter()
.filter(|(path, _)| !is_ignored(path, ignored_input_rels))
.collect();
let path_writes: FxHashSet<RelativePathBuf> = tracked
.path_writes
.into_iter()
.filter(|path| !is_ignored(path, ignored_output_rels))
.collect();
let read_write_overlap = path_reads.keys().find(|p| path_writes.contains(*p)).cloned();
TrackingOutcome { path_reads, read_write_overlap }
outcome.path_accesses.as_ref().map(|raw| {
let tracked = TrackedPathAccesses::from_raw(raw, workspace_root);
let filtered_path_reads: HashMap<RelativePathBuf, PathRead> =
// fspy can be attached for auto-output-only tasks. In that
// mode reads must not become inferred inputs.
if metadata.input_config.includes_auto
&& let Some(fspy) = fspy
{
tracked
.path_reads
.iter()
.filter(|(path, _)| {
!matches_any_glob(path, &fspy.input_negative_globs)
&& !is_ignored(path, ignored_input_rels)
})
.map(|(path, read)| (path.clone(), *read))
.collect()
} else {
HashMap::default()
};
let filtered_path_writes: FxHashSet<RelativePathBuf> =
// fspy can also be attached for auto-input-only tasks. In that
// mode writes must not become auto outputs or overlap candidates.
if metadata.output_config.includes_auto
&& let Some(fspy) = fspy
{
tracked
.path_writes
.iter()
.filter(|path| {
!matches_any_glob(path, &fspy.output_negative_globs)
&& !is_ignored(path, ignored_output_rels)
})
.cloned()
.collect()
} else {
FxHashSet::default()
};
let read_write_overlap =
filtered_path_reads.keys().find(|p| filtered_path_writes.contains(*p)).cloned();
TrackingOutcome {
path_reads: filtered_path_reads,
path_writes: filtered_path_writes,
read_write_overlap,
}
})
}
#[cfg(not(fspy))]
{
let _ = (
outcome,
input_negative_globs,
ignored_input_rels,
ignored_output_rels,
workspace_root,
);
let _ = (outcome, metadata, fspy, ignored_input_rels, ignored_output_rels, workspace_root);
None
}
}
Expand Down Expand Up @@ -256,6 +295,12 @@ fn is_ignored(path: &RelativePathBuf, ignored: &FxHashSet<RelativePathBuf>) -> b
ignored.contains(path) || ignored.iter().any(|ig| path.strip_prefix(ig).is_some())
}

fn matches_any_glob(path: &RelativePathBuf, globs: &[wax::Glob<'static>]) -> bool {
use wax::Program as _;

globs.iter().any(|glob| glob.is_match(path.as_str()))
}

/// Select tool-reported env records to embed in the post-run fingerprint.
/// Names that the user already declared as fingerprinted are skipped because
/// their values are already in the spawn fingerprint.
Expand Down Expand Up @@ -309,36 +354,49 @@ fn collect_tracked_env_globs(reports: &Reports) -> anyhow::Result<TrackedEnvGlob
Ok(tracked_env_globs)
}

/// Collect output files matching the configured globs and create a tar.zst
/// archive in the cache directory.
/// Collect output files and create a tar.zst archive in the cache directory.
///
/// Output files are determined by:
/// - fspy-tracked writes (already empty when `output_config.includes_auto` is false)
/// - Positive output globs (always, if configured)
/// - Negative output globs and tool-reported `ignoreOutput` paths filter
/// fspy-tracked writes before this function receives them
///
/// Returns `Some(archive_filename)` if files were archived, `None` if the
/// output config has no positive globs or no files matched.
/// Returns `Some(archive_filename)` if files were archived, `None` if no output files.
fn collect_and_archive_outputs(
cache_metadata: &CacheMetadata,
tracking: Option<&TrackingOutcome>,
workspace_root: &AbsolutePath,
cache_dir: &AbsolutePath,
) -> anyhow::Result<Option<Str>> {
let output_config = &cache_metadata.output_config;

if output_config.positive_globs.is_empty() {
return Ok(None);
let mut output_files: FxHashSet<RelativePathBuf> = FxHashSet::default();

if let Some(t) = tracking {
output_files.extend(t.path_writes.iter().cloned());
}

let output_files = glob::collect_glob_paths(
workspace_root,
&output_config.positive_globs,
&output_config.negative_globs,
)?;
if !output_config.positive_globs.is_empty() {
let glob_paths = glob::collect_glob_paths(
workspace_root,
&output_config.positive_globs,
&output_config.negative_globs,
)?;
output_files.extend(glob_paths);
}

if output_files.is_empty() {
return Ok(None);
}

let mut sorted_files: Vec<RelativePathBuf> = output_files.into_iter().collect();
sorted_files.sort();

let archive_name: Str = vite_str::format!("{}.tar.zst", uuid::Uuid::new_v4());
let archive_path = cache_dir.join(archive_name.as_str());

archive::create_output_archive(workspace_root, &output_files, &archive_path)?;
archive::create_output_archive(workspace_root, &sorted_files, &archive_path)?;

Ok(Some(archive_name))
}
Expand Down
24 changes: 16 additions & 8 deletions 24 crates/vite_task/src/session/execute/mod.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ struct CacheState<'a> {
/// always present (possibly empty) once we reach the cache-update phase.
std_outputs: Vec<StdOutput>,
/// Runner-aware tracking for cached tasks: an IPC server is always
/// available, and fspy path tracing is attached only when auto input
/// inference needs it. Parts are borrowed in place during the wait/join;
/// the struct is never moved out.
/// available, and fspy path tracing is attached only when auto input or
/// output inference needs it. Parts are borrowed in place during the
/// wait/join; the struct is never moved out.
tracking: Tracking,
}

Expand All @@ -100,9 +100,10 @@ struct CacheState<'a> {
type IpcDriver = LocalBoxFuture<'static, Result<Recorder, vite_task_server::Error>>;

/// fspy path-tracking state, present only when a cached task needs automatic
/// input inference.
/// input or output inference.
struct FspyTracking {
input_negative_globs: Vec<wax::Glob<'static>>,
output_negative_globs: Vec<wax::Glob<'static>>,
}

/// Per-task runner-aware tracking: IPC server handle plus optional fspy state.
Expand Down Expand Up @@ -164,17 +165,24 @@ impl<'a> ExecutionMode<'a> {
});
};

let fspy = if metadata.input_config.includes_auto {
// Resolve input negative globs for fspy path filtering (already
let fspy = if metadata.input_config.includes_auto || metadata.output_config.includes_auto {
// Resolve negative globs for fspy path filtering (already
// workspace-root-relative).
let negatives = metadata
let input_negative_globs = metadata
.input_config
.negative_globs
.iter()
.map(|p| Ok(wax::Glob::new(p.as_str())?.into_owned()))
.collect::<anyhow::Result<Vec<_>>>()
.map_err(ExecutionError::PostRunFingerprint)?;
Some(FspyTracking { input_negative_globs: negatives })
let output_negative_globs = metadata
.output_config
.negative_globs
.iter()
.map(|p| Ok(wax::Glob::new(p.as_str())?.into_owned()))
.collect::<anyhow::Result<Vec<_>>>()
.map_err(ExecutionError::PostRunFingerprint)?;
Some(FspyTracking { input_negative_globs, output_negative_globs })
} else {
None
};
Expand Down
33 changes: 12 additions & 21 deletions 33 crates/vite_task/src/session/execute/tracked_accesses.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
//! Normalize raw fspy path accesses into workspace-relative, filtered form.
//!
//! User-configured negative globs are NOT applied here. They are applied later,
//! separately for reads (input config) and writes (output config), since those
//! two configs are independent.
#![cfg(fspy)]

use std::collections::hash_map::Entry;
Expand All @@ -21,22 +25,19 @@ pub struct TrackedPathAccesses {
}

impl TrackedPathAccesses {
/// Build from fspy's raw iterable by stripping the workspace prefix,
/// normalizing `..` components, and filtering against the negative globs.
pub fn from_raw(
raw: &PathAccessIterable,
workspace_root: &AbsolutePath,
resolved_negatives: &[wax::Glob<'static>],
) -> Self {
/// Build from fspy's raw iterable by stripping the workspace prefix and
/// normalizing `..` components. `.git/*` paths are skipped. User-configured
/// negatives are applied by the caller (see module docs).
pub fn from_raw(raw: &PathAccessIterable, workspace_root: &AbsolutePath) -> Self {
let mut accesses = Self::default();
for access in raw.iter() {
// Strip workspace root, clean `..` components, and filter in one pass.
// Strip workspace root and clean `..` components in one pass.
// fspy may report paths like `packages/sub-pkg/../shared/dist/output.js`.
let relative_path = access.path.strip_path_prefix(workspace_root, |strip_result| {
let Ok(stripped_path) = strip_result else {
return None;
};
normalize_tracked_workspace_path(stripped_path, resolved_negatives)
normalize_tracked_workspace_path(stripped_path)
});

let Some(relative_path) = relative_path else {
Expand Down Expand Up @@ -71,10 +72,7 @@ impl TrackedPathAccesses {
clippy::disallowed_types,
reason = "fspy strip_path_prefix exposes std::path::Path; convert to RelativePathBuf immediately"
)]
fn normalize_tracked_workspace_path(
stripped_path: &std::path::Path,
resolved_negatives: &[wax::Glob<'static>],
) -> Option<RelativePathBuf> {
fn normalize_tracked_workspace_path(stripped_path: &std::path::Path) -> Option<RelativePathBuf> {
// On Windows, paths are possible to be still absolute after stripping the workspace root.
// For example: c:\workspace\subdir\c:\workspace\subdir
// Just ignore those accesses.
Expand All @@ -90,12 +88,6 @@ fn normalize_tracked_workspace_path(
return None;
}

if !resolved_negatives.is_empty()
&& resolved_negatives.iter().any(|neg| wax::Program::is_match(neg, relative.as_str()))
{
return None;
}

Some(relative)
}

Expand All @@ -111,8 +103,7 @@ mod tests {
clippy::disallowed_types,
reason = "normalize_tracked_workspace_path requires std::path::Path for fspy strip_path_prefix output"
)]
let relative_path =
normalize_tracked_workspace_path(std::path::Path::new(r"foo\C:\bar"), &[]);
let relative_path = normalize_tracked_workspace_path(std::path::Path::new(r"foo\C:\bar"));
assert!(relative_path.is_none());
}
}
5 changes: 1 addition & 4 deletions 5 ...tests/e2e_snapshots/fixtures/input_read_write_not_cached/packages/normal-pkg/package.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"name": "@test/normal-pkg",
"scripts": {
"task": "vtt print hello"
}
"name": "@test/normal-pkg"
}
8 changes: 8 additions & 0 deletions 8 ...sts/e2e_snapshots/fixtures/input_read_write_not_cached/packages/normal-pkg/vite-task.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tasks": {
"task": {
"command": "vtt print hello",
"output": [{ "auto": true }]
}
}
}
3 changes: 0 additions & 3 deletions 3 ...bin/tests/e2e_snapshots/fixtures/input_read_write_not_cached/packages/rw-pkg/package.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"name": "@test/rw-pkg",
"scripts": {
"task": "vtt replace-file-content src/data.txt i !"
},
"dependencies": {
"@test/touch-pkg": "workspace:*"
}
Expand Down
8 changes: 8 additions & 0 deletions 8 ...n/tests/e2e_snapshots/fixtures/input_read_write_not_cached/packages/rw-pkg/vite-task.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tasks": {
"task": {
"command": "vtt replace-file-content src/data.txt i !",
"output": [{ "auto": true }]
}
}
}
3 changes: 0 additions & 3 deletions 3 .../tests/e2e_snapshots/fixtures/input_read_write_not_cached/packages/touch-pkg/package.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"name": "@test/touch-pkg",
"scripts": {
"task": "vtt touch-file src/data.txt"
},
"dependencies": {
"@test/normal-pkg": "workspace:*"
}
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.