From 5e7beb5748d00c2f38225e2fbf7ff96a2c8ea584 Mon Sep 17 00:00:00 2001 From: Etienne Filhol Date: Tue, 1 Dec 2026 15:00:39 +0100 Subject: [PATCH] fix(runs): count a trial's parts.json and gateway.log in its cache signature --- app/nullius/workspace.py | 7 ++++--- app/tests/test_workspace.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/nullius/workspace.py b/app/nullius/workspace.py index f3684d206..3675c5dcb 100644 --- a/app/nullius/workspace.py +++ b/app/nullius/workspace.py @@ -14,8 +14,8 @@ A name is a slug the user typed, or two words picked at random. The cache is keyed by a *signature* of the job directory (every result.json, -and each trial's trajectory.json, trace.json and verifier/score.json, with -size and mtime), never by time: a run +and each trial's trajectory.json, trace.json, gateway.log, verifier/score.json +and verifier/parts.json, with size and mtime), never by time: a run still going changes its files, the signature moves, the job is parsed again. A cached job that was parsed by an older version of ``parse`` is refreshed too — the signature carries ``parse.SCHEMA`` and the Job and Trial field names, so a @@ -416,7 +416,8 @@ def stat(path): continue own = [s for s in (stat(os.path.join(sub, rel)) for rel in ("result.json", os.path.join("agent", "trajectory.json"), os.path.join("agent", "trace.json"), - os.path.join("verifier", "score.json"))) if s] + os.path.join("agent", "gateway.log"), os.path.join("verifier", "score.json"), + os.path.join("verifier", "parts.json"))) if s] parts += own trials[sub] = "\n".join(own) return hashlib.sha256("\n".join(parts).encode()).hexdigest(), trials diff --git a/app/tests/test_workspace.py b/app/tests/test_workspace.py index 59d1ce4d0..1eebddd21 100644 --- a/app/tests/test_workspace.py +++ b/app/tests/test_workspace.py @@ -505,6 +505,27 @@ def test_a_standard_trial_s_stop_reason_follows_its_score_file_alone(self): workspace._DECODED.clear() # a new process: the cache on disk, by its signature self.assertEqual(workspace.load_job(self.ws, self.job_dir)[0].trials[1].ended_by, "") + def test_a_trial_s_parts_and_rate_limits_follow_their_files_alone(self): + self._end(n_running_trials=1) + trial = os.path.join(self.job_dir, "tau3-bench__t1__abc") + parts, log = os.path.join(trial, "verifier", "parts.json"), os.path.join(trial, "agent", "gateway.log") + + def seen(): + t = workspace.load_job(self.ws, self.job_dir)[0].trials[1] + return t.part_groups, t.n_rate_limited_retries + self.assertEqual(seen(), ({}, None)) + _write_json(parts, {"by": "category", "parts": [{"group": "a", "score": 1.0}]}) + self.assertEqual(seen(), ({"a": [1.0, 1]}, None)) + os.makedirs(os.path.dirname(log), exist_ok=True) + with open(log, "w", encoding="utf-8") as fh: + fh.write("2026-09-04T01:00:20+00:00 openai/m status 429\n") + self.assertEqual(seen(), ({"a": [1.0, 1]}, 1)) + os.remove(parts) + self.assertEqual(seen(), ({}, 1)) + os.remove(log) + workspace._DECODED.clear() # a new process: the cache on disk, by its signature + self.assertEqual(seen(), ({}, None)) + def test_a_host_run_s_trial_copied_after_its_job_is_read_once_the_run_ends(self): """A host run's copy can bring the job's final result.json with a trial's file still mid-write, and the next copy correct the trial alone."""