From a3b6e6d421f5d9d722d6ad7d90532b02417a9213 Mon Sep 17 00:00:00 2001 From: Harenome Ranaivoarivony-Razanajato Date: Fri, 4 Dec 2026 14:07:49 +0100 Subject: [PATCH 1/2] test(osworld1): write the stand-in runner's given.json whole, as the runner does The driver read it as soon as it existed; the stand-in created it empty and filled it after, so a slow machine read nothing (1 of 60 runs at one loaded CPU). computer_port.ready writes a .part and renames it. --- app/tests/test_osworld1_entry_parts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/tests/test_osworld1_entry_parts.py b/app/tests/test_osworld1_entry_parts.py index bf8a16c09..4a3066370 100644 --- a/app/tests/test_osworld1_entry_parts.py +++ b/app/tests/test_osworld1_entry_parts.py @@ -818,7 +818,9 @@ def runner(self, code): def test_the_driver_answers_once_the_runner_says_the_window_is_closed(self): sock_dir = self.runner("import os, sys, json, time\nfd, data = int(sys.argv[1]), b''\n" "while b'task-given\\n' not in data:\n data += os.read(fd, 64)\n" - "json.dump({'ok': True}, open(os.path.join(sys.argv[2], 'given.json'), 'w'))\n" + "said = os.path.join(sys.argv[2], 'given.json')\n" + "json.dump({'ok': True}, open(said + '.part', 'w'))\n" # whole, as computer_port.ready writes it + "os.replace(said + '.part', said)\n" "time.sleep(30)\n") self.assertEqual(self.d.task_given("os__t1", self.ws), {}) self.assertFalse(os.path.exists(os.path.join(sock_dir, "given.json"))) From 601e64a440034a6625f0195b1ffad74dbb8bb424 Mon Sep 17 00:00:00 2001 From: Harenome Ranaivoarivony-Razanajato Date: Fri, 4 Dec 2026 14:07:50 +0100 Subject: [PATCH 2/2] test(standard): wait for the workspace kit's driver and the installed snapshot runs up to a shared limit PATIENCE, 60 s, in tests/__init__.py: each wait still stops on its condition. At one loaded CPU the kit's score failed 4 of 20 runs at 10 s and the snapshot runs 2 of 20 at 15 s each; none failed after. --- app/tests/__init__.py | 3 +++ app/tests/test_kit_check_isolation.py | 14 +++++++------- app/tests/test_standard_payload.py | 7 ++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/tests/__init__.py b/app/tests/__init__.py index 9dc4e90e5..7a3d8ce62 100644 --- a/app/tests/__init__.py +++ b/app/tests/__init__.py @@ -13,6 +13,9 @@ APP = Path(__file__).resolve().parents[1] FIXTURES = Path(__file__).resolve().parent / "fixtures" +# Seconds a test gives another process to answer or end. Each wait stops on its condition; this is only its +# limit, long enough for a machine shared with other work. +PATIENCE = 60 if str(APP) not in sys.path: sys.path.insert(0, str(APP)) diff --git a/app/tests/test_kit_check_isolation.py b/app/tests/test_kit_check_isolation.py index d20ab6318..59441a89e 100644 --- a/app/tests/test_kit_check_isolation.py +++ b/app/tests/test_kit_check_isolation.py @@ -20,7 +20,7 @@ from nullius.standard.backends import container from nullius.standard.contract import definitions from nullius.standard.protocols import jsonl -from tests import APP +from tests import APP, PATIENCE from tests.execution_support import gone KIT = os.path.join(definitions.KITS, "agent-workspace-v1", "driver.py") @@ -50,9 +50,9 @@ def plant_calc(self): def test_on_docker_the_fix_check_runs_in_a_container_of_the_units_image(self): d = self.driver(**{container.CHECK_IMAGE: "nullius/base:test", "PATH": self.bin + os.pathsep + os.environ["PATH"]}) - d.request("setup", unit="fix", dir=self.ws, timeout=10) + d.request("setup", unit="fix", dir=self.ws, timeout=PATIENCE) marker = self.plant_calc() - reply = d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=10) + reply = d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=PATIENCE) self.assertFalse(os.path.exists(marker)) # the agent's calc.py was never imported here self.assertTrue(reply["passed"]) argv = json.loads(Path(self.argv_log).read_text()) @@ -63,9 +63,9 @@ def test_on_docker_the_fix_check_runs_in_a_container_of_the_units_image(self): def test_locally_the_fix_check_runs_here_as_the_agent_did(self): d = self.driver() - d.request("setup", unit="fix", dir=self.ws, timeout=10) + d.request("setup", unit="fix", dir=self.ws, timeout=PATIENCE) marker = self.plant_calc() - self.assertTrue(d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=10)["passed"]) + self.assertTrue(d.request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=PATIENCE)["passed"]) self.assertTrue(os.path.exists(marker)) self.assertFalse(os.path.exists(self.argv_log)) @@ -74,11 +74,11 @@ def test_a_planted_link_is_not_followed(self): with open(secret, "w") as f: f.write("nullius-ok") # would even pass, read through the link os.symlink(secret, os.path.join(self.ws, "result.txt")) - reply = self.driver().request("score", unit="write", dir=self.ws, transcript="", answer="", timeout=10) + reply = self.driver().request("score", unit="write", dir=self.ws, transcript="", answer="", timeout=PATIENCE) self.assertEqual((reply["passed"], reply["detail"]["result.txt"]), (False, None)) bashrc = Path(self.tmp, "bashrc"); bashrc.write_text("mine\n") os.symlink(bashrc, os.path.join(self.ws, "test_calc.py")) # the test is rewritten in place, never through a link - self.driver().request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=10) + self.driver().request("score", unit="fix", dir=self.ws, transcript="", answer="", timeout=PATIENCE) self.assertEqual(bashrc.read_text(), "mine\n") diff --git a/app/tests/test_standard_payload.py b/app/tests/test_standard_payload.py index 4b486ae34..826513c24 100644 --- a/app/tests/test_standard_payload.py +++ b/app/tests/test_standard_payload.py @@ -17,6 +17,7 @@ from nullius.standard.requirements import install from nullius.standard.runner import payload from nullius.standard.contract import definitions, proofs +from tests import PATIENCE class Snapshot(unittest.TestCase): @@ -389,7 +390,7 @@ def test_installed_local_execution_has_one_backend_provider_and_keeps_helpers_an "catalogue_entry": definition["_here"], "args": sys.argv[1:]})) ''') cwd = self.tmp / "outside-checkout"; cwd.mkdir() - driver = '''import hashlib, json, pathlib, sys + driver = f"PATIENCE = {PATIENCE}\n" + '''import hashlib, json, pathlib, sys import nullius from nullius import execution, paths from nullius.standard.pages import recipe @@ -407,7 +408,7 @@ def inventory(): before = inventory() for index in range(3): execution_ = execution.Execution(make_plan(index)).start() - execution_.thread.join(15) + execution_.thread.join(PATIENCE) assert not execution_.thread.is_alive(), "fixture did not finish" assert execution_.state == "done", execution_.lines assert execution_.app_on_target == str(snapshot), "a later launch must reuse the same snapshot" @@ -420,7 +421,7 @@ def inventory(): "snapshot": execution_.app_on_target, "successful_launches": 3})) ''' ran = subprocess.run([str(python), "-I", "-B", "-c", driver], cwd=cwd, env=env, - capture_output=True, text=True, timeout=120) + capture_output=True, text=True, timeout=4 * PATIENCE) # three runs, and the venv's start self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr) parent = json.loads(ran.stdout) self.assertEqual(parent["providers"], [str(installed)])