fix(tools): avoid false read-before-edit blocks#952
Merged
XingYu-Zhong merged 2 commits intoJul 18, 2026
Merged
Conversation
2 tasks
luoye520ww
force-pushed
the
codex/fix-943-read-before-edit-guard
branch
from
July 16, 2026 06:35
86820ad to
fc5432d
Compare
XingYu-Zhong
approved these changes
Jul 18, 2026
XingYu-Zhong
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed against current develop after branch update. Scope is focused, the change remains needed, and no blocking issue was found. Required CI must pass before merge.
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.
Problem
The
read_before_edit_requiredguard could reject a valid edit after the agent read a line window that reached EOF but started below line 1. The issue also mentions intermittent read failures, but no read-failure log or reproducible read execution failure was provided.Root cause
ReadTrackerinferred completeness only fromend_line < total_lines. A window such asread(path, offset: 3)on a file without a trailing newline reportsend_line === total_lines, even though it omitted the leading lines. The guard therefore treated the window as a full snapshot and rejected an edit whoseoldTextwas outside that window.Scope
This PR fixes only the read-before-edit guard classification. It does not change read execution, sandbox policy, approval policy, or edit matching.
Changes
start_line > 1as partial even when they end at EOF.oldTextvalidation in place.LocalToolHostregression:read(offset: 3)to EOF, then edit line 1.Safety
oldTextis absent.Validation
The integration test uses a real temporary workspace and
LocalToolHost. With the old completeness predicate temporarily restored, that same test failed because the edit returnedisError: true; with this change it passes.The broader command below was also run:
It completed with 57 passed and 2 skipped, plus 3 unrelated Windows background-shell cleanup/lifecycle failures: two
EBUSYtemporary-directory removals and one lifecycle settlement timeout. Those failures are not represented as passing and are outside this PR's changed read/edit paths.Review performed
Issue
Fixes #943