Skip to content

Commit 2112e60

Browse files
wan9chicodex
andcommitted
feat(cache): default outputs to automatic tracking
Co-authored-by: GPT-5 Codex <codex@openai.com>
1 parent c34daeb commit 2112e60

91 files changed

Lines changed: 303 additions & 228 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- **Added** Runner-aware tools can now call `ignoreInput(path)` to exclude non-semantic reads from auto-inferred task cache inputs.
44
- **Added** Runner-aware tools can now call `ignoreOutput(path)` to exclude non-semantic writes from read/write overlap checks.
55
- **Added** Cached tasks can opt into automatic output restoration with `output: [{ auto: true }]`.
6+
- **Changed** Cached tasks now automatically restore written output files when `output` is omitted; use `output: []` to disable output restoration.
67
- **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.
78
- **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)).
89
- **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)).

crates/vite_task_bin/tests/e2e_snapshots/fixtures/input_cache_test/snapshots.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ steps = [
233233
[[e2e]]
234234
name = "fspy_env___not_set_when_auto_inference_disabled"
235235
comment = """
236-
When auto-inference is disabled (explicit globs only), the task process should not see `FSPY` set.
236+
When both input and output auto-inference are disabled, the task process should not see `FSPY` set.
237237
"""
238238
steps = [
239-
# Run task without auto inference - should see (undefined)
239+
# Run task without input or output auto inference - should see (undefined)
240240
["vt", "run", "check-fspy-env-without-auto"],
241241
]
242242

crates/vite_task_bin/tests/e2e_snapshots/fixtures/input_cache_test/snapshots/fspy_env___not_set_when_auto_inference_disabled.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# fspy_env___not_set_when_auto_inference_disabled
22

3-
When auto-inference is disabled (explicit globs only), the task process should not see `FSPY` set.
3+
When both input and output auto-inference are disabled, the task process should not see `FSPY` set.
44

55
## `vt run check-fspy-env-without-auto`
66

crates/vite_task_bin/tests/e2e_snapshots/fixtures/input_cache_test/vite-task.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"check-fspy-env-without-auto": {
6363
"command": "vtt print-env FSPY",
6464
"input": ["src/**/*.ts"],
65+
"output": [],
6566
"cache": true
6667
},
6768
"folder-input": {

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ipc_client_test/snapshots.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,35 @@ steps = [
8787
], comment = "restored from the auto output archive" },
8888
]
8989

90+
[[e2e]]
91+
name = "default_auto_output_restores_written_files"
92+
comment = """
93+
Exercises the default output behavior. When `output` is omitted, the runner automatically tracks writes, archives the generated file, and restores it on cache hit.
94+
"""
95+
ignore = true
96+
steps = [
97+
{ argv = [
98+
"vt",
99+
"run",
100+
"auto-output-default",
101+
], comment = "first run writes dist/default.txt and archives fspy-tracked outputs" },
102+
{ argv = [
103+
"vtt",
104+
"rm",
105+
"dist/default.txt",
106+
], comment = "remove the output so restoration is observable" },
107+
{ argv = [
108+
"vt",
109+
"run",
110+
"auto-output-default",
111+
], comment = "cache hit: default auto output is restored" },
112+
{ argv = [
113+
"vtt",
114+
"print-file",
115+
"dist/default.txt",
116+
], comment = "restored from the default auto output archive" },
117+
]
118+
90119
[[e2e]]
91120
name = "disable_cache_forces_reexecution"
92121
comment = """
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# default_auto_output_restores_written_files
2+
3+
Exercises the default output behavior. When `output` is omitted, the runner automatically tracks writes, archives the generated file, and restores it on cache hit.
4+
5+
## `vt run auto-output-default`
6+
7+
first run writes dist/default.txt and archives fspy-tracked outputs
8+
9+
```
10+
$ vtt write-file dist/default.txt ok
11+
```
12+
13+
## `vtt rm dist/default.txt`
14+
15+
remove the output so restoration is observable
16+
17+
```
18+
```
19+
20+
## `vt run auto-output-default`
21+
22+
cache hit: default auto output is restored
23+
24+
```
25+
$ vtt write-file dist/default.txt ok ◉ cache hit, replaying
26+
27+
---
28+
vt run: cache hit.
29+
```
30+
31+
## `vtt print-file dist/default.txt`
32+
33+
restored from the default auto output archive
34+
35+
```
36+
ok
37+
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/ipc_client_test/vite-task.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
"output": [{ "auto": true }],
1616
"cache": true
1717
},
18+
"auto-output-default": {
19+
"command": "vtt write-file dist/default.txt ok",
20+
"input": [],
21+
"cache": true
22+
},
1823
"disable-cache": {
1924
"command": "node scripts/disable_cache.mjs",
2025
"cache": true

crates/vite_task_graph/run-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ untrackedEnv?: Array<string>,
5757
*/
5858
input?: Array<string | GlobWithBase | AutoInput>,
5959
/**
60-
* Output files to archive after a successful run and restore on cache hit.
60+
* Output files to archive and restore on cache hit.
6161
*
62-
* - Omitted or `[]` (empty): no output archiving (default)
62+
* - Omitted: automatically tracks which files the task writes
63+
* - `[]` (empty): disables output restoration entirely
6364
* - Glob patterns (e.g. `"dist/**"`) select specific output files, relative to the package directory
6465
* - `{pattern: "...", base: "workspace" | "package"}` specifies a glob with an explicit base directory
6566
* - `{auto: true}` enables automatic output tracking

crates/vite_task_graph/src/config/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ impl ResolvedGlobConfig {
198198

199199
/// Resolve from user output configuration, making glob patterns workspace-root-relative.
200200
///
201-
/// Unlike [`Self::from_user_config`], `None` and `Some([])` both produce an
202-
/// empty config with `includes_auto = false` (no output archiving).
201+
/// Unlike [`Self::from_user_config`], `None` defaults to automatic output
202+
/// tracking while `Some([])` disables output archiving.
203203
///
204204
/// # Errors
205205
///
@@ -215,7 +215,7 @@ impl ResolvedGlobConfig {
215215
let mut includes_auto = false;
216216

217217
let Some(entries) = user_outputs else {
218-
return Ok(Self { includes_auto: false, positive_globs, negative_globs });
218+
return Ok(Self::default_auto());
219219
};
220220

221221
for entry in entries {

crates/vite_task_graph/src/config/user.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ pub struct EnabledCacheConfig {
145145
#[cfg_attr(all(test, not(clippy)), ts(inline))]
146146
pub input: Option<UserInputsConfig>,
147147

148-
/// Output files to archive after a successful run and restore on cache hit.
148+
/// Output files to archive and restore on cache hit.
149149
///
150-
/// - Omitted or `[]` (empty): no output archiving (default)
150+
/// - Omitted: automatically tracks which files the task writes
151+
/// - `[]` (empty): disables output restoration entirely
151152
/// - Glob patterns (e.g. `"dist/**"`) select specific output files, relative to the package directory
152153
/// - `{pattern: "...", base: "workspace" | "package"}` specifies a glob with an explicit base directory
153154
/// - `{auto: true}` enables automatic output tracking

0 commit comments

Comments
 (0)