Show actual file changes recorded for each Agent task
Verify control plane / verify (push) Canceled after 0s
Verify control plane / verify (pull_request) Canceled after 0s

This commit is contained in:
WebUp Cloud committed 2026-11-08 09:10:32 +08:00
1 parent d04777247b
commit 3296d378c9
14 files changed
+453 -16

No files matched your search

+31 -2
View File
@@ -17,8 +17,10 @@ spec.loader.exec_module(gateway)
class GatewayTests(unittest.TestCase):
def execute_file_tool(self, root, name, arguments):
payload = base64.b64encode(json.dumps({"name": name, "arguments": arguments}).encode()).decode()
def execute_file_tool(self, root, name, arguments, track_changes=False):
payload = base64.b64encode(json.dumps({
"name": name, "arguments": arguments, "trackChanges": track_changes
}).encode()).decode()
script = gateway.SCRIPT.replace("pathlib.Path('/workspace')", "pathlib.Path(" + repr(str(root)) + ")")
result = subprocess.run([sys.executable, "-X", "utf8", "-c", "PAYLOAD=" + repr(payload) + "\n" + script], capture_output=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr.decode())
@@ -39,6 +41,33 @@ class GatewayTests(unittest.TestCase):
(root / "large.txt").write_bytes(b"x" * 64001)
self.assertIn("error", self.execute_file_tool(root, "read_file", {"path": "large.txt"}))
def test_agent_file_change_counts_and_manual_edits_are_separate(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
self.assertNotIn("fileChanges", self.execute_file_tool(root, "write_file", {
"path": "manual.txt", "content": "user\n"
}))
results = []
for tool, args in [
("write_file", {"path": "src/code.js", "content": "one\ntwo\n"}),
("write_file", {"path": "src/code.js", "content": "one\nthree\nfour\n"}),
("delete_file", {"path": "src/code.js"}),
]:
result = self.execute_file_tool(root, tool, args, track_changes=True)
self.assertTrue(result["fileChanges"]["complete"])
files = result["fileChanges"]["files"]
self.assertEqual(["src/code.js"], [file["path"] for file in files])
results.append(tuple(files[0][key] for key in ("status", "added", "removed")))
self.assertEqual([("ADDED", 2, 0), ("MODIFIED", 2, 1), ("DELETED", 0, 3)], results)
def test_source_scan_failure_reports_partial_and_keeps_successful_write(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "large.dat").write_bytes(b"x" * 8_000_001)
result = self.execute_file_tool(root, "write_file", {"path": "index.js", "content": "ok"}, True)
self.assertEqual(2, result["written"])
self.assertEqual({"complete": False, "files": []}, result["fileChanges"])
def test_workspace_inspection_requires_nonempty_source_and_excludes_dependencies(self):
with tempfile.TemporaryDirectory() as directory:
root=Path(directory)