fix(file_tools): resolve relative paths against TERMINAL_CWD for worktree isolation#13161
Merged
Conversation
…tree isolation Adds a _resolve_path() helper that reads TERMINAL_CWD and uses it as the base for relative path resolution. Applied to _check_sensitive_path, read_file_tool, _update_read_timestamp, and _check_file_staleness. Absolute paths and non-worktree sessions (no TERMINAL_CWD) are unaffected — falls back to os.getcwd(). Fixes #12689.
This was referenced Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves relative paths in file_tools.py against
TERMINAL_CWDinstead of process CWD, so pre-check guards (binary detection, dedup, staleness, sensitive path) resolve the same file the actual I/O targets.Fixes #12689. Salvaged from PR #12695 (@aniruddhaadak80, first submitter). Supersedes PR #13080 (@bennytimz, same fix submitted later).
Changes
tools/file_tools.py: new_resolve_path()helper, applied to 4 call sitestests/tools/test_resolve_path.py: 5 tests covering relative, absolute, tilde, fallback, and traversal normalizationscripts/release.py: AUTHOR_MAP entry for contributorValidation
-wmodeTests: 21/21 file_tools + 5/5 new resolve_path tests passing.