You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: eliminate stale file race condition and fix error misclassification
- Use file's actual `mtime` instead of `new Date()` in `FileTime.read()` to
eliminate clock drift between Node.js and filesystem (WSL, networked drives)
- Increase staleness tolerance from 50ms to 2s (p50 gap was 651ms, caused
782-retry loops on WSL)
- Split `file_stale` out of `validation` error class for cleaner triage
- Move `http_error` pattern before `validation` and add `HTTP 4xx` keywords
to prevent WebFetch 404s from being misclassified as validation errors
- Update tests to use `fs.utimes()` for deterministic mtime manipulation
Closes#610
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
if(!time)thrownewError(`You must read file ${filepath} before overwriting it. Use the Read tool first`)
63
68
constmtime=Filesystem.stat(filepath)?.mtime
64
-
// Allow a 50ms tolerance for Windows NTFS timestamp fuzziness / async flushing
65
-
if(mtime&&mtime.getTime()>time.getTime()+50){
69
+
// Allow a 2s tolerance for filesystem clock drift.
70
+
// WSL (NTFS-over-9P) and networked drives routinely show 400ms–1.2s gaps
71
+
// between Node.js Date.now() and filesystem mtime. The previous 50ms
72
+
// tolerance caused massive retry loops (782 retries in one session).
73
+
if(mtime&&mtime.getTime()>time.getTime()+2000){
66
74
thrownewError(
67
75
`File ${filepath} has been modified since it was last read.\nLast modification: ${mtime.toISOString()}\nLast read: ${time.toISOString()}\n\nPlease read the file again before modifying it.`,
0 commit comments