Description
packages/shared/src/utils/cache.ts writes the cache data file and then updates the index file in two separate writeFile calls. If the process is interrupted (crash, SIGKILL) between the two writes, or if the index write fails, the index no longer reflects the actual cache contents. Subsequent reads may return stale or missing entries while the data file is orphaned.
Location
packages/shared/src/utils/cache.ts
Expected Fix
Write to a temp file then rename() (atomic on POSIX), or write both files and verify. At minimum, catch index write failures and invalidate/remove the data entry to keep them consistent.