Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/nullius/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions app/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down