Return the read status of a file for write/edit staleness checks. Returns one of: - ``"not_read"`` -- no prior read recorded - ``"partial"`` -- file was read with offset/limit (partial view) - ``"modified"`` -- file changed on disk since last read - ``"ok"``
(self, path: Path)
| 256 | return (mtime, size) == (int(stat.st_mtime), int(stat.st_size)) |
| 257 | |
| 258 | def file_read_status(self, path: Path) -> str: |
| 259 | """Return the read status of a file for write/edit staleness checks. |
| 260 | |
| 261 | Returns one of: |
| 262 | - ``"not_read"`` -- no prior read recorded |
| 263 | - ``"partial"`` -- file was read with offset/limit (partial view) |
| 264 | - ``"modified"`` -- file changed on disk since last read |
| 265 | - ``"ok"`` -- file was fully read and unchanged |
| 266 | """ |
| 267 | resolved = path.resolve() |
| 268 | fingerprint = self.read_file_fingerprints.get(resolved) |
| 269 | if fingerprint is None: |
| 270 | return "not_read" |
| 271 | mtime, size = fingerprint[0], fingerprint[1] |
| 272 | is_partial = fingerprint[2] if len(fingerprint) > 2 else False |
| 273 | if is_partial: |
| 274 | return "partial" |
| 275 | stat = resolved.stat() |
| 276 | if (mtime, size) != (int(stat.st_mtime), int(stat.st_size)): |
| 277 | return "modified" |
| 278 | return "ok" |
| 279 | |
| 280 | def allowed_roots(self) -> tuple[Path, ...]: |
| 281 | roots: list[Path] = [self.workspace_root] |