From 602e76a88b3628a83deb2986b77bbe8d1338559f Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Mon, 21 Sep 2026 15:41:19 -0700 Subject: [PATCH] fix: bind baseline reads to the task local path --- tests/tools/test_file_read_guards.py | 8 ++++---- tests/tools/test_file_staleness.py | 2 +- tools/file_tools.py | 2 +- tools/file_tools_read_tracking.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/tools/test_file_read_guards.py b/tests/tools/test_file_read_guards.py index 9331759f61..4b03076dab 100644 --- a/tests/tools/test_file_read_guards.py +++ b/tests/tools/test_file_read_guards.py @@ -49,7 +49,7 @@ class _FakeReadResult: def _make_fake_ops(content="hello\n", total_lines=1, file_size=6): - fake = MagicMock() + fake = MagicMock(env=None) fake.read_file = lambda path, offset=1, limit=500: _FakeReadResult( content=content, total_lines=total_lines, file_size=file_size, ) @@ -445,7 +445,7 @@ class TestFileDedup(unittest.TestCase): @patch("tools.file_tools._get_file_ops") def test_write_rejects_internal_read_status_text(self, mock_ops): """write_file must not persist internal read_file status text.""" - fake = MagicMock() + fake = MagicMock(env=None) fake.write_file = MagicMock() mock_ops.return_value = fake @@ -806,7 +806,7 @@ class TestWriteInvalidatesDedup(unittest.TestCase): read would previously cause the second read to return a stale dedup stub because the mtime comparison saw no change. """ - fake = MagicMock() + fake = MagicMock(env=None) fake.read_file = lambda path, offset=1, limit=500: _FakeReadResult( content="original content\n", total_lines=1, file_size=18, ) @@ -835,7 +835,7 @@ class TestWriteInvalidatesDedup(unittest.TestCase): @patch("tools.file_tools._get_file_ops") def test_write_invalidates_all_offsets(self, mock_ops): """A write invalidates dedup entries for ALL offset/limit combos.""" - fake = MagicMock() + fake = MagicMock(env=None) fake.read_file = lambda path, offset=1, limit=500: _FakeReadResult( content="line1\nline2\nline3\n", total_lines=3, file_size=20, ) diff --git a/tests/tools/test_file_staleness.py b/tests/tools/test_file_staleness.py index cb580aee62..ce3495e464 100644 --- a/tests/tools/test_file_staleness.py +++ b/tests/tools/test_file_staleness.py @@ -57,7 +57,7 @@ class _FakePatchResult: def _make_fake_ops(read_content="hello\n", file_size=6): - fake = MagicMock() + fake = MagicMock(env=None) fake.read_file = lambda path, offset=1, limit=500: _FakeReadResult( content=read_content, total_lines=1, file_size=file_size, ) diff --git a/tools/file_tools.py b/tools/file_tools.py index 174a23d025..9985643121 100644 --- a/tools/file_tools.py +++ b/tools/file_tools.py @@ -675,7 +675,7 @@ def read_file_tool(path: str, offset: int = 1, limit: int = DEFAULT_READ_LIMIT, and version_before == cached_version and content_served_in_generation): return _dedup_stub_or_block(task_data, dedup_key, path) - result = file_ops.read_file(path, offset, limit) + result = file_ops.read_file(resolved_str if _file_ops_uses_host_paths(file_ops) else path, offset, limit) result_dict = result.to_dict() # Failed reads cannot establish whole-file knowledge. diff --git a/tools/file_tools_read_tracking.py b/tools/file_tools_read_tracking.py index 10475c6a7a..80dcdb1418 100644 --- a/tools/file_tools_read_tracking.py +++ b/tools/file_tools_read_tracking.py @@ -255,7 +255,7 @@ def _file_version(resolved: str) -> tuple | None: try: if not stat.S_ISREG(os.stat(resolved).st_mode): return None - fd = os.open(resolved, os.O_RDONLY | getattr(os, "O_NONBLOCK", 0)) + fd = os.open(resolved, os.O_RDONLY | getattr(os, "O_NONBLOCK", 0) | getattr(os, "O_BINARY", 0)) with os.fdopen(fd, "rb") as stream: before = os.fstat(stream.fileno()) if not stat.S_ISREG(before.st_mode):