Skip to content

Commit c4a3709

Browse files
branchseerclaude
andcommitted
feat(cache): add explicit inputs config for cache fingerprinting
Add `inputs` field to task configuration supporting: - Explicit glob patterns: `inputs: ["src/**/*.ts"]` - Auto-inference from fspy: `inputs: [{ auto: true }]` - Negative patterns: `inputs: ["src/**", "!**/*.test.ts"]` - Mixed mode: `inputs: ["package.json", { auto: true }, "!dist/**"]` - Empty array to disable file tracking: `inputs: []` Key changes: - Add `ResolvedInputConfig` to parse and normalize user input config - Add `glob_inputs.rs` for walking glob patterns and hashing files - Update `PreRunFingerprint` to include `input_config` and `glob_base` - Bump cache DB version to 6 for new fingerprint structure - Add comprehensive e2e tests for all input combinations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 389ca7a commit c4a3709

144 files changed

Lines changed: 3319 additions & 287 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.

Cargo.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/fspy/src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl SpyImpl {
100100
)
101101
.map_err(|err| SpawnError::Injection(err.into()))?;
102102
command.set_exec(exec);
103+
command.env("FSPY", "1");
103104

104105
let mut tokio_command = command.into_tokio_command();
105106

crates/fspy/src/windows/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ impl SpyImpl {
7373
}
7474

7575
#[expect(clippy::unused_async, reason = "async signature required by SpyImpl trait")]
76-
pub(crate) async fn spawn(&self, command: Command) -> Result<TrackedChild, SpawnError> {
76+
pub(crate) async fn spawn(&self, mut command: Command) -> Result<TrackedChild, SpawnError> {
7777
let ansi_dll_path_with_nul = Arc::clone(&self.ansi_dll_path_with_nul);
78+
command.env("FSPY", "1");
7879
let mut command = command.into_tokio_command();
7980

8081
command.creation_flags(CREATE_SUSPENDED);

crates/vite_task/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fspy = { workspace = true }
2323
futures-util = { workspace = true }
2424
once_cell = { workspace = true }
2525
owo-colors = { workspace = true }
26+
path-clean = { workspace = true }
2627
pty_terminal_test_client = { workspace = true }
2728
rayon = { workspace = true }
2829
rusqlite = { workspace = true, features = ["bundled"] }
@@ -33,13 +34,16 @@ thiserror = { workspace = true }
3334
tokio = { workspace = true, features = ["rt-multi-thread", "io-std", "io-util", "macros", "sync"] }
3435
tracing = { workspace = true }
3536
twox-hash = { workspace = true }
36-
vite_glob = { workspace = true }
3737
vite_path = { workspace = true }
3838
vite_select = { workspace = true }
3939
vite_str = { workspace = true }
4040
vite_task_graph = { workspace = true }
4141
vite_task_plan = { workspace = true }
4242
vite_workspace = { workspace = true }
43+
wax = { workspace = true }
44+
45+
[dev-dependencies]
46+
tempfile = { workspace = true }
4347

4448
[target.'cfg(unix)'.dependencies]
4549
nix = { workspace = true }

crates/vite_task/src/session/cache/display.rs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ pub enum SpawnFingerprintChange {
3939
// Working directory change
4040
/// Working directory changed
4141
CwdChanged,
42-
43-
// Fingerprint ignores changes
44-
/// Fingerprint ignore pattern added
45-
FingerprintIgnoreAdded { pattern: Str },
46-
/// Fingerprint ignore pattern removed
47-
FingerprintIgnoreRemoved { pattern: Str },
4842
}
4943

5044
/// Format a single spawn fingerprint change as human-readable text.
@@ -70,12 +64,6 @@ pub fn format_spawn_change(change: &SpawnFingerprintChange) -> Str {
7064
SpawnFingerprintChange::ProgramChanged => Str::from("program changed"),
7165
SpawnFingerprintChange::ArgsChanged => Str::from("args changed"),
7266
SpawnFingerprintChange::CwdChanged => Str::from("working directory changed"),
73-
SpawnFingerprintChange::FingerprintIgnoreAdded { pattern } => {
74-
vite_str::format!("fingerprint ignore '{pattern}' added")
75-
}
76-
SpawnFingerprintChange::FingerprintIgnoreRemoved { pattern } => {
77-
vite_str::format!("fingerprint ignore '{pattern}' removed")
78-
}
7967
}
8068
}
8169

@@ -141,20 +129,6 @@ pub fn detect_spawn_fingerprint_changes(
141129
changes.push(SpawnFingerprintChange::CwdChanged);
142130
}
143131

144-
// Check fingerprint ignores changes
145-
let old_ignores: FxHashSet<_> =
146-
old.fingerprint_ignores().map(|v| v.iter().collect()).unwrap_or_default();
147-
let new_ignores: FxHashSet<_> =
148-
new.fingerprint_ignores().map(|v| v.iter().collect()).unwrap_or_default();
149-
for pattern in old_ignores.difference(&new_ignores) {
150-
changes
151-
.push(SpawnFingerprintChange::FingerprintIgnoreRemoved { pattern: (*pattern).clone() });
152-
}
153-
for pattern in new_ignores.difference(&old_ignores) {
154-
changes
155-
.push(SpawnFingerprintChange::FingerprintIgnoreAdded { pattern: (*pattern).clone() });
156-
}
157-
158132
changes
159133
}
160134

@@ -196,13 +170,15 @@ pub fn format_cache_status_inline(cache_status: &CacheStatus) -> Option<Str> {
196170
Some(SpawnFingerprintChange::ProgramChanged) => "program changed",
197171
Some(SpawnFingerprintChange::ArgsChanged) => "args changed",
198172
Some(SpawnFingerprintChange::CwdChanged) => "working directory changed",
199-
Some(
200-
SpawnFingerprintChange::FingerprintIgnoreAdded { .. }
201-
| SpawnFingerprintChange::FingerprintIgnoreRemoved { .. },
202-
) => "fingerprint ignores changed",
203173
None => "configuration changed",
204174
}
205175
}
176+
FingerprintMismatch::ConfigChanged => "configuration changed",
177+
FingerprintMismatch::GlobbedInputChanged { path } => {
178+
return Some(vite_str::format!(
179+
"✗ cache miss: content of input '{path}' changed, executing"
180+
));
181+
}
206182
FingerprintMismatch::PostRunFingerprintMismatch(diff) => {
207183
use crate::session::execute::fingerprint::PostRunFingerprintMismatch;
208184
match diff {

0 commit comments

Comments
 (0)