* On-disk drift check for a single indexed file (issue #1474). The code * renderers slice CURRENT bytes at INDEXED line ranges; when the file * changed after its last index sync those ranges can point at a DIFFERENT * symbol's code — served under the requested name with `isError: false`.
(cg: CodeGraph, relPath: string, content?: string)
| 2895 | * would needlessly push the agent back to Read. |
| 2896 | */ |
| 2897 | private isFileStaleOnDisk(cg: CodeGraph, relPath: string, content?: string): boolean { |
| 2898 | let root: string; |
| 2899 | try { |
| 2900 | root = cg.getProjectRoot(); |
| 2901 | } catch { |
| 2902 | return false; |
| 2903 | } |
| 2904 | const key = `${root}\0${relPath}`; |
| 2905 | const now = Date.now(); |
| 2906 | const hit = this.driftCache.get(key); |
| 2907 | if (hit && now - hit.at < ToolHandler.DRIFT_TTL_MS) return hit.stale; |
| 2908 | // The check itself is shared with the CLI's read commands (#3260). A file |
| 2909 | // gone from disk isn't flagged here: the not-found paths answer for it. |
| 2910 | const stale = fileDrift(cg, relPath, content) === 'changed'; |
| 2911 | this.driftCache.set(key, { at: now, stale }); |
| 2912 | return stale; |
| 2913 | } |
| 2914 | |
| 2915 | private answerResult(cg: CodeGraph, text: string, paths: Iterable<string>): ToolResult { |
| 2916 | const result = this.textResult(text); |
no test coverage detected