fix(file_tools): refresh staleness timestamp after writes (#4390)

After a successful write_file or patch, update the stored read
timestamp to match the file's new modification time.  Without this,
consecutive edits by the same task (read → write → write) would
false-warn on the second write because the stored timestamp still
reflected the original read, not the first write.

Also renames the internal tracker key from 'file_mtimes' to
'read_timestamps' for clarity.
This commit is contained in:
Teknium 2026-04-01 00:50:08 -07:00 committed by GitHub
parent 83dec2b3ec
commit ef2ae3e48f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 7 deletions

View file

@ -221,7 +221,7 @@ class TestCheckFileStalenessHelper(unittest.TestCase):
_read_tracker["t1"] = {
"last_key": None, "consecutive": 0,
"read_history": set(), "dedup": {},
"file_mtimes": {"/tmp/other.py": 12345.0},
"read_timestamps": {"/tmp/other.py": 12345.0},
}
self.assertIsNone(_check_file_staleness("/tmp/x.py", "t1"))
@ -231,7 +231,7 @@ class TestCheckFileStalenessHelper(unittest.TestCase):
_read_tracker["t1"] = {
"last_key": None, "consecutive": 0,
"read_history": set(), "dedup": {},
"file_mtimes": {"/nonexistent/path": 99999.0},
"read_timestamps": {"/nonexistent/path": 99999.0},
}
# File doesn't exist → stat fails → returns None (let write handle it)
self.assertIsNone(_check_file_staleness("/nonexistent/path", "t1"))