Summary
ChangeObserver re-hashes every file under its caps in both the before and after workspace snapshots taken around each exec_command. On large workspaces this is a meaningful per-command cost. A proposed cache keyed on {path, size, modTime} with TTL + LRU bounds (previously bundled into #1196, split out per review) avoids the rehash but changes what the observer can report, so it needs its own decision and a test pinning the chosen behavior.
The trade-off
Main detects a modified file by hash. With a {path, size, modTime} cache, a same-size rewrite that keeps its mtime is reported as unchanged to the Files panel and the bash tool result. Realistic triggers:
cp -p,touch -r,tar -x(restores mtimes)- two writes inside one timestamp tick on a coarse filesystem (FAT/exFAT, some network mounts, or any fs where the modTime resolution exceeds the write interval)
A content-hash-on-read cache (no TTL, invalidate on size/mtime change only) has the same blind spot by construction. Options the maintainer decision should weigh:
- Accept the miss and document it (cheapest; observable only in the Files panel / bash tool result diff).
- Add a cheap secondary signal (inode + ctime where available) to catch same-mtime rewrites.
- Cache only the before snapshot (it is taken at a known point), always hash fresh on the after pass — halves the cost, keeps detection exact.
- Skip caching entirely and reduce cost another way (cap/parallelism/xxhash instead of the current digest).
Acceptance criteria
- Maintainer decision on which behavior ships, recorded on this issue.
- Implementation with TTL/LRU bounds (if caching ships).
- Regression test pinning the chosen behavior, including a same-size/same-mtime rewrite case and at least one coarse-timestamp-tick case.
References
- Split out from #1196 (review feedback: this changes what the observer can see and needs its own decision).
Thanks for splitting this out. One data point before anyone picks: hashing is already capped at 1 MiB per file and 32 MiB per snapshot, and the walk stats up to 20,000 entries either way. A
{path, size, modTime}cache still needs that stat to check its key, so it only saves the hashing. A profile that separates the walk from the hashing on a large workspace would show how much option 1 or 2 actually buys.My preference is option 4, because it keeps detection exact. A faster stdlib hash (
hash/maphashwith one seed per process is enough to compare two snapshots) or hashing in parallel needs no new dependency. I would not ship 1 or 2: a miss there makes the Files panel and the tool result say nothing changed after a command that changed a file, which is worse than a slow snapshot.@kevincodex1, this one is your call.