GeezerVison is showing github.com — feat(cache): runner-aware auto output tracking + ignore consumption · voidzero-dev/vite-task@655ba31
File treeExpand file treeCollapse file tree Open diff view settings vite_task_bin/tests/e2e_snapshots/fixtures input_cache_test/snapshots
vite_task_graph/src/config vite_task_plan/tests/plan_snapshots/fixtures cache_cli_override/snapshots cache_scripts_default/snapshots cache_scripts_enabled/snapshots cache_scripts_task_override/snapshots cache_subcommand/snapshots cache_tasks_disabled/snapshots cache_true_no_force_enable/snapshots comprehensive_task_graph/snapshots cycle_dependency/snapshots dependency_both_topo_and_explicit/snapshots duplicate_package_names/snapshots empty_package_test/snapshots explicit_deps_workspace/snapshots extra_args_not_forwarded_to_depends_on/snapshots filter_workspace/snapshots input_trailing_slash/snapshots input_workspace_base/snapshots nested_cache_override/snapshots package_self_dependency/snapshots parallel_and_concurrency/snapshots pnpm_workspace_packages_optional/snapshots prefix_env_path_lookup/snapshots recursive_topological_workspace/snapshots script_hooks_disabled/snapshots script_hooks_nested_run/snapshots script_hooks_task_no_hook/snapshots synthetic_cache_disabled/snapshots synthetic_in_subpackage/snapshots task_command_shorthands/snapshots transitive_skip_intermediate/snapshots windows_cmd_shim_rewrite/snapshots workspace_root_cd_no_skip/snapshots workspace_root_depends_on_passthrough/snapshots workspace_root_multi_command/snapshots workspace_root_mutual_recursion/snapshots workspace_root_no_package_json/snapshots workspace_root_self_reference/snapshots
vite_task/src/session/execute
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: crates/vite_task/src/session/execute/mod.rs +71-7Lines changed: 71 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -728,13 +728,16 @@ pub async fn execute_spawn( | 728 | 728 | ); | 729 | 729 | } | 730 | 730 |
| 731 | | - // `ignoreInput`/`ignoreOutput` are accepted over IPC but not yet | 732 | | - // applied — runner-aware output tracking (which consumes them) lands | 733 | | - // in a follow-up. Treat the reported ignore sets as empty so they | 734 | | - // have no effect on input/output inference or the read-write overlap | 735 | | - // check. | 736 | | - let ignored_input_rels: FxHashSet<RelativePathBuf> = FxHashSet::default(); | 737 | | - let ignored_output_rels: FxHashSet<RelativePathBuf> = FxHashSet::default(); | | 731 | + // Tool-reported paths to exclude from auto-tracking. Absolute paths | | 732 | + // are normalized to workspace-relative; anything outside is dropped. | | 733 | + let ignored_input_rels: FxHashSet<RelativePathBuf> = reports | | 734 | + .as_ref() | | 735 | + .map(|r| normalize_ignored_paths(&r.ignored_inputs, workspace_root)) | | 736 | + .unwrap_or_default(); | | 737 | + let ignored_output_rels: FxHashSet<RelativePathBuf> = reports | | 738 | + .as_ref() | | 739 | + .map(|r| normalize_ignored_paths(&r.ignored_outputs, workspace_root)) | | 740 | + .unwrap_or_default(); | 738 | 741 |
| 739 | 742 | // Post-execution summary of what fspy observed. `Some` iff fspy was | 740 | 743 | // both requested (`tracking.is_some()` => input or output auto) and | @@ -908,6 +911,67 @@ pub async fn execute_spawn( | 908 | 911 | SpawnOutcome::Spawned(outcome.exit_status) | 909 | 912 | } | 910 | 913 |
| | 914 | +/// Normalize tool-reported absolute paths to workspace-relative. Paths outside | | 915 | +/// the workspace are dropped — they can't contribute to inputs or outputs. | | 916 | +fn normalize_ignored_paths( | | 917 | + paths: &FxHashSet<Arc<AbsolutePath>>, | | 918 | + workspace_root: &AbsolutePath, | | 919 | +) -> FxHashSet<RelativePathBuf> { | | 920 | + // On Windows, `workspace_root` may carry a `\\?\` extended-path prefix | | 921 | + // (it does when the runner derived it from `std::fs::canonicalize`) | | 922 | + // while a tool's `current_dir()`-based ignoreInput/ignoreOutput path | | 923 | + // doesn't. `Path::strip_prefix` is a byte-exact comparison so the | | 924 | + // prefix mismatch silently drops every tool-reported path. Pre-build | | 925 | + // an alternate workspace root with the `\\?\` / `\\.\` / `\??\` | | 926 | + // prefix dropped and try it as a fallback. `fspy_shared::NativePath:: | | 927 | + // strip_path_prefix` does the inverse (strips `\\?\` from incoming | | 928 | + // fspy paths) so each side stays agnostic to how the other side | | 929 | + // canonicalised. | | 930 | + #[cfg(windows)] | | 931 | + let workspace_root_stripped: Option<vite_path::AbsolutePathBuf> = | | 932 | + windows_strip_verbatim_prefix(workspace_root.as_path().as_os_str()); | | 933 | + | | 934 | + paths | | 935 | + .iter() | | 936 | + .filter_map(|p| { | | 937 | + if let Some(rel) = p.strip_prefix(workspace_root).ok().flatten() { | | 938 | + return Some(rel); | | 939 | + } | | 940 | + #[cfg(windows)] | | 941 | + if let Some(alt_root) = workspace_root_stripped.as_ref() { | | 942 | + if let Some(rel) = p.strip_prefix(alt_root).ok().flatten() { | | 943 | + return Some(rel); | | 944 | + } | | 945 | + } | | 946 | + None | | 947 | + }) | | 948 | + .collect() | | 949 | +} | | 950 | + | | 951 | +/// Build an alternate workspace-root path by dropping a `\\?\`, `\\.\`, | | 952 | +/// or `\??\` prefix if present. Returns `None` when the input is already | | 953 | +/// in plain `C:\...` form (no fallback needed). Mirrors | | 954 | +/// `fspy_shared::NativePath::strip_path_prefix`'s helper so the inputs of | | 955 | +/// `strip_prefix` can match across `current_dir`-derived and | | 956 | +/// `canonicalize`-derived paths. | | 957 | +#[cfg(windows)] | | 958 | +#[expect( | | 959 | + clippy::disallowed_types, | | 960 | + reason = "OsStr-level prefix matching for Windows extended-path normalization" | | 961 | +)] | | 962 | +fn windows_strip_verbatim_prefix(p: &std::ffi::OsStr) -> Option<vite_path::AbsolutePathBuf> { | | 963 | + use std::os::windows::ffi::{OsStrExt, OsStringExt}; | | 964 | + let wide: Vec<u16> = p.encode_wide().collect(); | | 965 | + for prefix in [r"\\?\", r"\\.\", r"\??\"] { | | 966 | + let prefix_wide: Vec<u16> = prefix.encode_utf16().collect(); | | 967 | + if wide.starts_with(prefix_wide.as_slice()) { | | 968 | + let stripped = std::ffi::OsString::from_wide(&wide[prefix_wide.len()..]); | | 969 | + return vite_path::AbsolutePathBuf::new(std::path::PathBuf::from(stripped)); | | 970 | + } | | 971 | + } | | 972 | + None | | 973 | +} | | 974 | + | 911 | 975 | /// Whether `path` is covered by any `ignored` entry. An ignored entry matches | 912 | 976 | /// itself (exact file) and everything under it (directory subtree). | 913 | 977 | fn is_ignored(path: &RelativePathBuf, ignored: &FxHashSet<RelativePathBuf>) -> bool { | |
Collapse file Copy file name to clipboardExpand all lines: crates/vite_task_bin/tests/e2e_snapshots/fixtures/input_cache_test/snapshots/fspy_env___not_set_when_auto_inference_disabled.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,5 +6,5 @@ When auto-inference is disabled (explicit globs only), the task process should n | 6 | 6 |
| 7 | 7 | ``` | 8 | 8 | $ vtt print-env FSPY | 9 | | -(undefined) | | 9 | +1 | 10 | 10 | ``` |
Collapse file Copy file name to clipboardExpand all lines: crates/vite_task_bin/tests/e2e_snapshots/fixtures/ipc_client_test/snapshots.toml +58Lines changed: 58 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +[[e2e]] | | 2 | +name = "ignore_input_keeps_cache_valid" | | 3 | +comment = """ | | 4 | +Exercises `ignoreInput` through `@voidzero-dev/vite-task-client`. | | 5 | +The runner treats `cache_like/` as non-input, so mutations to it between | | 6 | +runs do not invalidate the cache. | | 7 | +""" | | 8 | +ignore = true | | 9 | +steps = [ | | 10 | + { argv = [ | | 11 | + "vt", | | 12 | + "run", | | 13 | + "ignore-input", | | 14 | + ], comment = "populate the cache" }, | | 15 | + { argv = [ | | 16 | + "vtt", | | 17 | + "write-file", | | 18 | + "cache_like/other.txt", | | 19 | + "after", | | 20 | + ], comment = "mutate the ignored directory — would invalidate if tracked" }, | | 21 | + { argv = [ | | 22 | + "vt", | | 23 | + "run", | | 24 | + "ignore-input", | | 25 | + ], comment = "cache hit: cache_like/ was ignored via ignoreInput" }, | | 26 | +] | | 27 | + | | 28 | +[[e2e]] | | 29 | +name = "ignore_output_allows_read_write_overlap" | | 30 | +comment = """ | | 31 | +Exercises `ignoreOutput`. The task reads and writes `sidecar/tmp.txt`; | | 32 | +without the ignore the runner's read-write overlap check would refuse to | | 33 | +cache the run ("read and wrote 'sidecar/tmp.txt'"). | | 34 | +""" | | 35 | +ignore = true | | 36 | +steps = [ | | 37 | + { argv = [ | | 38 | + "vt", | | 39 | + "run", | | 40 | + "ignore-output", | | 41 | + ], comment = "first run populates the cache" }, | | 42 | + { argv = [ | | 43 | + "vtt", | | 44 | + "rm", | | 45 | + "dist/out.txt", | | 46 | + ], comment = "remove the real output so the cache-hit restore is observable" }, | | 47 | + { argv = [ | | 48 | + "vt", | | 49 | + "run", | | 50 | + "ignore-output", | | 51 | + ], comment = "cache hit: sidecar/ writes were ignored" }, | | 52 | + { argv = [ | | 53 | + "vtt", | | 54 | + "print-file", | | 55 | + "dist/out.txt", | | 56 | + ], comment = "restored from the cache archive" }, | | 57 | +] | | 58 | + | 1 | 59 | [[e2e]] | 2 | 60 | name = "disable_cache_forces_reexecution" | 3 | 61 | comment = """ | |
Collapse file Copy file name to clipboard +31Lines changed: 31 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# ignore_input_keeps_cache_valid | | 2 | + | | 3 | +Exercises `ignoreInput` through `@voidzero-dev/vite-task-client`. | | 4 | +The runner treats `cache_like/` as non-input, so mutations to it between | | 5 | +runs do not invalidate the cache. | | 6 | + | | 7 | +## `vt run ignore-input` | | 8 | + | | 9 | +populate the cache | | 10 | + | | 11 | +``` | | 12 | +$ node scripts/ignore_input.mjs | | 13 | +``` | | 14 | + | | 15 | +## `vtt write-file cache_like/other.txt after` | | 16 | + | | 17 | +mutate the ignored directory — would invalidate if tracked | | 18 | + | | 19 | +``` | | 20 | +``` | | 21 | + | | 22 | +## `vt run ignore-input` | | 23 | + | | 24 | +cache hit: cache_like/ was ignored via ignoreInput | | 25 | + | | 26 | +``` | | 27 | +$ node scripts/ignore_input.mjs ◉ cache hit, replaying | | 28 | +
| | 29 | +--- | | 30 | +vt run: cache hit. | | 31 | +``` |
Collapse file Copy file name to clipboard +39Lines changed: 39 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# ignore_output_allows_read_write_overlap | | 2 | + | | 3 | +Exercises `ignoreOutput`. The task reads and writes `sidecar/tmp.txt`; | | 4 | +without the ignore the runner's read-write overlap check would refuse to | | 5 | +cache the run ("read and wrote 'sidecar/tmp.txt'"). | | 6 | + | | 7 | +## `vt run ignore-output` | | 8 | + | | 9 | +first run populates the cache | | 10 | + | | 11 | +``` | | 12 | +$ node scripts/ignore_output.mjs | | 13 | +``` | | 14 | + | | 15 | +## `vtt rm dist/out.txt` | | 16 | + | | 17 | +remove the real output so the cache-hit restore is observable | | 18 | + | | 19 | +``` | | 20 | +``` | | 21 | + | | 22 | +## `vt run ignore-output` | | 23 | + | | 24 | +cache hit: sidecar/ writes were ignored | | 25 | + | | 26 | +``` | | 27 | +$ node scripts/ignore_output.mjs ◉ cache hit, replaying | | 28 | +
| | 29 | +--- | | 30 | +vt run: cache hit. | | 31 | +``` | | 32 | + | | 33 | +## `vtt print-file dist/out.txt` | | 34 | + | | 35 | +restored from the cache archive | | 36 | + | | 37 | +``` | | 38 | +ok | | 39 | +``` |
Collapse file Copy file name to clipboardExpand all lines: crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite_build_cache/snapshots.toml +36Lines changed: 36 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +[[e2e]] | | 2 | +name = "vite_build_caches_and_restores_outputs" | | 3 | +comment = """ | | 4 | +`vt run --cache build` must produce a cache hit on the second run without any manual input/output configuration. Vite reports `ignoreInput(outDir)` + `ignoreInput/Output(cacheDir)` via `@voidzero-dev/vite-task-client`, so fspy-detected reads of `dist/` and writes to `node_modules/.vite/` don't poison the cache. | | 5 | +""" | | 6 | +ignore = true | | 7 | +steps = [ | | 8 | + { argv = [ | | 9 | + "vt", | | 10 | + "run", | | 11 | + "--cache", | | 12 | + "build", | | 13 | + ], comment = "first run: cache miss, emits dist/" }, | | 14 | + { argv = [ | | 15 | + "vtt", | | 16 | + "stat-file", | | 17 | + "dist/assets/main.js", | | 18 | + ], comment = "existence check — content would drift across Vite versions" }, | | 19 | + { argv = [ | | 20 | + "vtt", | | 21 | + "rm", | | 22 | + "dist/assets/main.js", | | 23 | + ], comment = "remove the artefact so the cache-hit restore is observable" }, | | 24 | + { argv = [ | | 25 | + "vt", | | 26 | + "run", | | 27 | + "--cache", | | 28 | + "build", | | 29 | + ], comment = "cache hit: outputs restored without manual config" }, | | 30 | + { argv = [ | | 31 | + "vtt", | | 32 | + "stat-file", | | 33 | + "dist/assets/main.js", | | 34 | + ], comment = "restored from the cache archive" }, | | 35 | +] | | 36 | + | 1 | 37 | [[e2e]] | 2 | 38 | name = "vite_prefix_env_change_invalidates_cache" | 3 | 39 | comment = """ | |
Collapse file Copy file name to clipboard +45Lines changed: 45 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# vite_build_caches_and_restores_outputs | | 2 | + | | 3 | +`vt run --cache build` must produce a cache hit on the second run without any manual input/output configuration. Vite reports `ignoreInput(outDir)` + `ignoreInput/Output(cacheDir)` via `@voidzero-dev/vite-task-client`, so fspy-detected reads of `dist/` and writes to `node_modules/.vite/` don't poison the cache. | | 4 | + | | 5 | +## `vt run --cache build` | | 6 | + | | 7 | +first run: cache miss, emits dist/ | | 8 | + | | 9 | +``` | | 10 | +$ vite build | | 11 | +``` | | 12 | + | | 13 | +## `vtt stat-file dist/assets/main.js` | | 14 | + | | 15 | +existence check — content would drift across Vite versions | | 16 | + | | 17 | +``` | | 18 | +dist/assets/main.js: exists | | 19 | +``` | | 20 | + | | 21 | +## `vtt rm dist/assets/main.js` | | 22 | + | | 23 | +remove the artefact so the cache-hit restore is observable | | 24 | + | | 25 | +``` | | 26 | +``` | | 27 | + | | 28 | +## `vt run --cache build` | | 29 | + | | 30 | +cache hit: outputs restored without manual config | | 31 | + | | 32 | +``` | | 33 | +$ vite build ◉ cache hit, replaying | | 34 | +
| | 35 | +--- | | 36 | +vt run: cache hit. | | 37 | +``` | | 38 | + | | 39 | +## `vtt stat-file dist/assets/main.js` | | 40 | + | | 41 | +restored from the cache archive | | 42 | + | | 43 | +``` | | 44 | +dist/assets/main.js: exists | | 45 | +``` |
Collapse file Copy file name to clipboardExpand all lines: crates/vite_task_bin/tests/e2e_snapshots/fixtures/vite_build_cache/vite-task.json -9Lines changed: 0 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | // No `"env": [...]` — vite's patched `loadEnv` asks the runner for | 6 | 6 | // every `VITE_*` env via `getEnvs`, so the glob + match-set are | 7 | 7 | // fingerprinted automatically. | 8 | | - // | 9 | | - // Auto output tracking (which lets vite `ignoreInput`/`ignoreOutput` the | 10 | | - // out dir and the dirs it writes-then-reads) is not implemented yet, so | 11 | | - // excluding them from auto input inference keeps `vite build` cacheable: | 12 | | - // it stops fspy's reads of the build's own outputs (`dist/`) and vite's | 13 | | - // write-then-read config-timestamp temp files (`node_modules/.vite-temp/`) | 14 | | - // from being treated as inputs, which would otherwise trip the read-write | 15 | | - // overlap check. | 16 | | - "input": ["!dist/**", "!node_modules/.vite-temp/**", { "auto": true }], | 17 | 8 | "cache": true | 18 | 9 | } | 19 | 10 | } | |
Collapse file Copy file name to clipboardExpand all lines: crates/vite_task_graph/src/config/mod.rs +5-19Lines changed: 5 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -75,15 +75,11 @@ impl ResolvedTaskOptions { | 75 | 75 | workspace_root, | 76 | 76 | )?; | 77 | 77 |
| 78 | | - // Auto output restoration is not implemented yet — it lands with | 79 | | - // runner-aware output tracking (which consumes `ignoreOutput`). | 80 | | - // Until then `output: None` defaults to disabled rather than | 81 | | - // auto-inference, so a cache hit never restores an unverified, | 82 | | - // fspy-inferred output set. | 83 | | - let output_config = match enabled_cache_config.output.as_ref() { | 84 | | - None => ResolvedGlobConfig::disabled(), | 85 | | - output => ResolvedGlobConfig::from_user_config(output, dir, workspace_root)?, | 86 | | - }; | | 78 | + let output_config = ResolvedGlobConfig::from_user_config( | | 79 | + enabled_cache_config.output.as_ref(), | | 80 | + dir, | | 81 | + workspace_root, | | 82 | + )?; | 87 | 83 |
| 88 | 84 | Some(CacheConfig { | 89 | 85 | env_config: EnvConfig { | @@ -144,16 +140,6 @@ impl ResolvedGlobConfig { | 144 | 140 | } | 145 | 141 | } | 146 | 142 |
| 147 | | - /// Disabled configuration: no auto-inference and no explicit patterns. | 148 | | - #[must_use] | 149 | | - pub const fn disabled() -> Self { | 150 | | - Self { | 151 | | - includes_auto: false, | 152 | | - positive_globs: BTreeSet::new(), | 153 | | - negative_globs: BTreeSet::new(), | 154 | | - } | 155 | | - } | 156 | | - | 157 | 143 | /// Resolve from user configuration, making glob patterns workspace-root-relative. | 158 | 144 | /// | 159 | 145 | /// - `None`: defaults to auto-inference (`[{auto: true}]`) | |
Collapse file Copy file name to clipboardExpand all lines: crates/vite_task_plan/tests/plan_snapshots/fixtures/additional_env/snapshots/query_tool_synthetic_task_in_user_task.jsonc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 62 | 62 | "negative_globs": [] | 63 | 63 | }, | 64 | 64 | "output_config": { | 65 | | - "includes_auto": false, | | 65 | + "includes_auto": true, | 66 | 66 | "positive_globs": [], | 67 | 67 | "negative_globs": [] | 68 | 68 | } | |
|