feat: skip caching tasks that modify their inputs#248
Merged
branchseer merged 4 commits intomainfrom Mar 15, 2026
Merged
Conversation
…trun fingerprint Two changes to improve cache correctness and performance: 1. If fspy detects a task both read and wrote the same file, skip cache storage (InputModified). Caching such tasks is unsound because the prerun glob hashes become stale. 2. Skip paths already in globbed_inputs when building the postrun fingerprint. This avoids redundant storage and double-validation on cache hit checks. Safe because rule 1 guarantees no input was modified. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Surface the read-write overlap detection in both compact and full summaries so users understand why their task wasn't cached. Compact: "app#build not cached because it modified its input." Full: "→ Not cached: read and wrote 'src/data.txt'" Thread CacheUpdateStatus through the reporter so InputModified (with the overlapping path) reaches SpawnOutcome::Success and the summary rendering. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a `touch-file` tool that opens a file with O_RDWR in a single syscall (unlike replace-file-content which uses separate read/write opens). This tests that fspy correctly detects a single O_RDWR open as both READ and WRITE for the input-modified cache skip. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cd16a68 to
eec87f0
Compare
fengmk2
approved these changes
Mar 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
Tasks like formatters (
prettier --write) and auto-fix linters (eslint --fix) read and write the same files. Caching these tasks doesn't work — the stored input hash goes stale after every run, causing the cache to always miss next time.We now detect when a task reads and writes the same file (via fspy) and skip caching it entirely. The user sees a clear message explaining why.
Also, files already covered by explicit glob inputs (
input: ["src/**"]) are no longer fingerprinted again in the post-run check, saving storage and I/O.Output examples
Single task that modifies its input:
Multiple tasks, one modifies its input:
Multiple tasks, several modify their inputs:
--verbose/--last-detailsshows the specific file in the full summary:Test plan
cargo test -p vite_task— unit testscargo test -p vite_task_bin --test e2e_snapshots— E2E snapshot tests covering:cargo clippy -- -D warnings— no new warnings🤖 Generated with Claude Code