Skip to content

Commit 635c207

Browse files
yangshunbranchseer
andauthored
docs: sync task cache reference with current types (#263)
## Summary **Note:** I used AI to identify inconsistencies between the docs and the code, and this were the parts they identified. I've also verified them myself. - sync the task cache docs with current type names and structures - update environment and cache key terminology in the cache documentation - refresh module/file references for the current implementation layout ## Testing - not run (docs only) Co-authored-by: branchseer <3612422+branchseer@users.noreply.github.com>
1 parent 4a5c9bc commit 635c207

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

crates/vite_task/docs/task-cache.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,19 @@ The spawn fingerprint captures the complete execution context:
103103
```rust
104104
pub struct SpawnFingerprint {
105105
pub cwd: RelativePathBuf,
106-
pub command_fingerprint: CommandFingerprint,
107-
pub fingerprinted_envs: BTreeMap<Str, Str>,
108-
pub untracked_env: BTreeSet<Str>,
109-
pub fingerprint_ignores: Option<Vec<Str>>,
106+
pub program_fingerprint: ProgramFingerprint,
107+
pub args: Arc<[Str]>,
108+
pub env_fingerprints: EnvFingerprints,
110109
}
111110

112-
enum CommandFingerprint {
113-
Program { program_fingerprint: ProgramFingerprint, args: Vec<Str> },
114-
ShellScript { script: Str, extra_args: Vec<Str> },
111+
pub struct EnvFingerprints {
112+
pub fingerprinted_envs: BTreeMap<Str, Arc<str>>,
113+
pub untracked_env_config: Arc<[Str]>,
115114
}
116115

117116
enum ProgramFingerprint {
118117
OutsideWorkspace { program_name: Str },
119-
InsideWorkspace { relative_path: RelativePathBuf },
118+
InsideWorkspace { relative_program_path: RelativePathBuf },
120119
}
121120
```
122121

@@ -129,7 +128,7 @@ This ensures cache invalidation when:
129128

130129
### 3. Environment Variable Impact on Cache
131130

132-
The `fingerprinted_envs` field is crucial for cache correctness:
131+
The `fingerprinted_envs` field in `EnvFingerprints` is crucial for cache correctness:
133132

134133
- Only includes env vars explicitly declared in the task's `env` array
135134
- Does NOT include untracked envs (PATH, CI, etc.)
@@ -142,7 +141,7 @@ When a task runs:
142141
3. If a declared env var changes value, cache will miss
143142
4. If an untracked env changes, cache will still hit
144143

145-
The `untracked_env` field stores env names (not values) — if the set of untracked env names changes, the cache invalidates, but value changes don't.
144+
The `untracked_env_config` field stores env names (not values) — if the set of untracked env names changes, the cache invalidates, but value changes don't.
146145

147146
### 4. Execution Cache Key
148147

@@ -152,11 +151,11 @@ The execution cache key associates a task identity with its cache entry:
152151
pub enum ExecutionCacheKey {
153152
UserTask {
154153
task_name: Str,
155-
and_item_index: Option<usize>,
154+
and_item_index: usize,
156155
extra_args: Arc<[Str]>,
157156
package_path: RelativePathBuf,
158157
},
159-
ExecAPI(Str),
158+
ExecAPI(Arc<[Str]>),
160159
}
161160
```
162161

@@ -169,7 +168,7 @@ pub struct CacheEntryValue {
169168
pub post_run_fingerprint: PostRunFingerprint,
170169
pub std_outputs: Arc<[StdOutput]>,
171170
pub duration: Duration,
172-
pub globbed_inputs: Option<GlobbedInputs>,
171+
pub globbed_inputs: BTreeMap<RelativePathBuf, u64>,
173172
}
174173
```
175174

@@ -204,7 +203,7 @@ Vite Task uses `fspy` to monitor file system access during task execution:
204203
│ enum PathFingerprint { │
205204
│ NotFound, // File doesn't exist │
206205
│ FileContentHash(u64), // xxHash3 of content │
207-
│ Folder(Option<HashMap>), // Directory listing
206+
│ Folder(Option<BTreeMap<Str, DirEntryKind>>), │
208207
│ } ▲ │
209208
│ │ │
210209
│ This value is `None` when fspy reports that the task is │
@@ -213,7 +212,7 @@ Vite Task uses `fspy` to monitor file system access during task execution:
213212
│ `openat(2)`. In such case, the folder's entries don't need │
214213
│ to be fingerprinted. │
215214
│ Folders with empty entries fingerprinted are represented as │
216-
│ `Folder(Some(empty hashmap))`.
215+
│ `Folder(Some(empty BTreeMap))`. │
217216
│ │
218217
└──────────────────────────────────────────────────────────────┘
219218
```
@@ -378,8 +377,8 @@ Cache entries are automatically invalidated when:
378377

379378
1. **Command changes**: Different command, arguments, or working directory
380379
2. **Package location changes**: Working directory (`cwd`) in spawn fingerprint changes
381-
3. **Environment changes**: Modified declared environment variables (pass-through values don't affect cache)
382-
4. **Pass-through config changes**: Pass-through environment names added/removed from configuration
380+
3. **Environment changes**: Modified declared environment variables (untracked env values don't affect cache)
381+
4. **Untracked env config changes**: Untracked environment names added/removed from configuration
383382
5. **Input files change**: Content hash differs (detected via xxHash3)
384383
6. **File structure changes**: Files added, removed, or type changed
385384
7. **Input config changes**: The `input` configuration itself changes
@@ -567,14 +566,16 @@ Each `&&` separated command is cached independently. If only terser config chang
567566
crates/vite_task/src/session/
568567
├── cache/
569568
│ ├── mod.rs # ExecutionCache, CacheEntryKey/Value, FingerprintMismatch
570-
│ └── fingerprint.rs # SpawnFingerprint, CommandFingerprint, ProgramFingerprint
569+
│ └── display.rs # Cache status display formatting
571570
├── execute/
572571
│ ├── mod.rs # execute_spawn, SpawnOutcome
572+
│ ├── fingerprint.rs # PostRunFingerprint, PathFingerprint, DirEntryKind
573573
│ └── spawn.rs # spawn_with_tracking, fspy integration
574574
└── reporter/
575575
└── mod.rs # Reporter traits for cache hit/miss display
576576
577577
crates/vite_task_plan/src/
578-
├── cache_metadata.rs # ExecutionCacheKey, CacheMetadata
578+
├── cache_metadata.rs # ExecutionCacheKey, SpawnFingerprint, ProgramFingerprint, CacheMetadata
579+
├── envs.rs # EnvFingerprints
579580
└── plan.rs # Planning logic
580581
```

0 commit comments

Comments
 (0)