write(): Promise<void>
Best-effort write; failures are swallowed because a cache miss on the next read just degrades to "run all tests."
Publishes by writing a temp file and renaming it into place, because fs.writeFile truncates
on open: for the whole write window the cache is an empty (then partial) file, and any reader
in that window parses garbage and concludes there is no cache. That is not theoretical — watch
mode fires buildTestBundle (which lands here) and then calls getChangedFsTree, so a
--changed --watch run races its own write and intermittently reports "no metafile cache yet
— running all N test files" instead of the affected subset. rename is atomic, so a reader
always sees either the previous complete cache or this one, never a torn one. It also makes
concurrent writers (two runs sharing a checkout) and a process killed mid-write safe: the
worst case is a leftover temp file, never a corrupt cache.
import * as MetafileCache from './metafile-cache.ts'; await MetafileCache.write('/not/writable/anywhere', '/proj', { inputs: {} }); // resolves — an unwritable cache dir degrades silently, the next read is just a miss