From 4396f05c2150ec19b42c5ea5ab84b095fa28e958 Mon Sep 17 00:00:00 2001 From: Etienne Filhol Date: Tue, 1 Dec 2026 11:44:28 +0100 Subject: [PATCH] fix(runs): count a trial's score.json in its cache signature --- app/nullius/workspace.py | 8 +++++--- app/tests/test_workspace.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/nullius/workspace.py b/app/nullius/workspace.py index a2a8e49f2..f3684d206 100644 --- a/app/nullius/workspace.py +++ b/app/nullius/workspace.py @@ -13,8 +13,9 @@ ``home`` is ``WORKSPACES_DIR`` or ``workspaces/`` in the persistent user data directory. 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 trajectory.json under it, with size and mtime), never by time: a run +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 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 @@ -414,7 +415,8 @@ def stat(path): if not os.path.isdir(sub): 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"))) if s] + ("result.json", os.path.join("agent", "trajectory.json"), os.path.join("agent", "trace.json"), + os.path.join("verifier", "score.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 a53b1056c..59d1ce4d0 100644 --- a/app/tests/test_workspace.py +++ b/app/tests/test_workspace.py @@ -489,6 +489,22 @@ def test_a_running_job_updates_with_each_trial(self): job, from_cache = workspace.load_job(self.ws, self.job_dir) self.assertFalse(from_cache); self.assertEqual(job.trials[1].reward, reward) + def test_a_standard_trial_s_stop_reason_follows_its_score_file_alone(self): + self._end(n_running_trials=1) + trial = os.path.join(self.job_dir, "tau3-bench__t1__abc") + with open(os.path.join(trial, "result.json"), encoding="utf-8") as fh: + data = json.load(fh) + _write_json(os.path.join(trial, "result.json"), {**data, "standard": {}}) # a standard trial + score = os.path.join(trial, "verifier", "score.json") + _write_json(score, {"reward": 0.0, "detail": {"ended": "done"}}) + self.assertEqual(workspace.load_job(self.ws, self.job_dir)[0].trials[1].ended_by, "done") + time.sleep(0.01) + _write_json(score, {"reward": 0.0, "detail": {"ended": "steps"}}) + self.assertEqual(workspace.load_job(self.ws, self.job_dir)[0].trials[1].ended_by, "steps") + os.remove(score) + 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_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."""