Repository navigation
feat(cache): cache tasks that rewrite files they read - #913
Merged
Merged
Conversation
wan9chi
force-pushed
the
feat/cache-rewritten-inputs
branch
from
October 30, 2026 03:19
7b723f5 to
fcf994a
Compare
fspy benchmarklinuxmacoswindows |
Two cases for caching a task that rewrites a file it read. In
`rewrite_own_file`, the task reads `state.txt` and writes it back, like a
tool that keeps a cache file, through `vtt fs`, a new test helper that
makes a sequence of file system calls in one process. In
`typescript_incremental`, `tsc --incremental --noEmit` (TypeScript 7)
probes for and writes `tsconfig.tsbuildinfo` on a clean run, rewrites it
after an edit, and only reads it when nothing changed.
Today every run that writes the file is refused ("not cached because it
modified its inputs"), and removing `tsconfig.tsbuildinfo`, as on a clean
checkout, is a cache miss.
On Windows, `tsc` also lists the package root, so `typescript_incremental`
runs on Unix only until listings leave out the files a task wrote.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A task that reads a file and writes it back, like `tsc --incremental`
rewriting `tsconfig.tsbuildinfo` or a tool updating its cache file, was
refused ("not cached because it modified its inputs") and ran every
time. Inputs are fingerprinted after the run, so such a file is compared
with how the task left it. A file the task wrote may also be missing, as
on a clean checkout, where a hit restores it: each inferred input now
records `may_be_missing`, and validation accepts a missing file when it
is set. What may be missing is decided in the new `rebuildable` module
from every write fspy recorded, before output exclusions and
`ignoreOutput` are applied; those still decide only what is archived.
The refusal, its run summary notice, its `--last-details` text and the
suggested exclusions are gone, with the `input_read_write_not_cached`
fixture and the docs section about them. The cache schema version is
bumped for the new inferred input format.
`node_compile_cache_outside_workspace` caught Node's compile cache
landing in the workspace only through the refusal; a cache there would
now just hit, so the fixture lists the workspace root after its runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wan9chi
force-pushed
the
feat/cache-rewritten-inputs
branch
from
October 30, 2026 04:07
fcf994a to
53150e0
Compare
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.
Motivation
A task that reads a file and writes it back is never cached today ("not cached because it modified its inputs"). That covers
tsc --incrementalrewritingtsconfig.tsbuildinfo, tools updating their cache files, formatters, and most build tools on a built tree, which read their previous outputs.Inputs are fingerprinted after the run, so such a file can simply be compared with how the task left it. And because the task wrote it, it may also be missing, as on a clean checkout, where a hit restores it.
Changes
may_be_missing, true for a path the task wrote. Validation accepts a missing path when it's set; a path that's there must still match.ignoreOutputare applied. Those still decide only what is archived.--last-detailstext and the suggested exclusions, along with theinput_read_write_not_cachedfixture and the docs section about it. The cache schema version is bumped.node_compile_cache_outside_workspacecaught a misplaced compile cache only through the refusal, so it now lists the workspace root after its runs.E2E cases:
rewrite_own_file(synthetic,vtt fs read/write) andtypescript_incremental(TypeScript 7tsc --incremental --noEmit). The first commit records today's refusals; the second shows hits, including aftertsconfig.tsbuildinfois removed.Part of a stack that lets automatic tracking cache tasks which read their own outputs and list the folders holding them, so they also hit on a clean checkout.
🤖 Generated with Claude Code