diff --git a/app/nullius/runs/feasibility.py b/app/nullius/runs/feasibility.py
index 9febcea4..cef33655 100644
--- a/app/nullius/runs/feasibility.py
+++ b/app/nullius/runs/feasibility.py
@@ -355,7 +355,11 @@ def related(job, jobs) -> dict:
Matched by the builder's naming: a job's own base name, and — for an
agent job named `-` — the base with its last segment
- dropped. A control job is always its own side. The dataset must agree
+ dropped. A control still unfound is then looked for under the base
+ with the job's recorded agent dropped, and the version a standard
+ job's name adds (`-claude-code`, `-codex-2.2.2`), so a
+ match the first rule makes stays as it was.
+ A control job is always its own side. The dataset must agree
where both record one, so a control over another dataset that happens
to share a name is not read as this job's.
"""
@@ -366,14 +370,20 @@ def related(job, jobs) -> dict:
bases = [base_name(job.job_id)]
if not own and "-" in job.job_id:
bases.append(job.job_id.rsplit("-", 1)[0])
- wanted = {f"{b}{infix}{c}": c for b in bases for infix in ("-", "-bracket-") for c in CONTROLS}
- for other in jobs:
- c = wanted.get(other.job_id)
- if not c or c in out or control_of(other) != c:
- continue
- if job.dataset and other.dataset and job.dataset != other.dataset:
- continue
- out[c] = other
+ tiers = [bases]
+ agent = job.agent_label
+ m = re.fullmatch(rf"(.+)-{re.escape(agent)}(?:-.+)?", job.job_id) if agent and not own else None
+ if m:
+ tiers.append([m.group(1)])
+ for tier in tiers:
+ wanted = {f"{b}{infix}{c}": c for b in tier for infix in ("-", "-bracket-") for c in CONTROLS}
+ for other in jobs:
+ c = wanted.get(other.job_id)
+ if not c or c in out or control_of(other) != c:
+ continue
+ if job.dataset and other.dataset and job.dataset != other.dataset:
+ continue
+ out[c] = other
return out
diff --git a/app/tests/test_feasibility_hyphen_agent.py b/app/tests/test_feasibility_hyphen_agent.py
new file mode 100644
index 00000000..d432fa5e
--- /dev/null
+++ b/app/tests/test_feasibility_hyphen_agent.py
@@ -0,0 +1,61 @@
+"""An agent job named `-` finds its recipe's nop and oracle
+jobs, whatever hyphens the agent's name holds."""
+from __future__ import annotations
+
+import tempfile
+import unittest
+
+from nullius.runs import feasibility
+
+from .test_feasibility import write_job
+
+
+class HyphenatedAgentNames(unittest.TestCase):
+ def setUp(self):
+ tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(tmp.cleanup)
+ self.root = tmp.name
+
+ def test_each_agent_job_of_one_launch_finds_the_same_controls(self):
+ base = "run-0000-terminal-bench"
+ jobs = [write_job(self.root, f"{base}-nop", "nop", {"a": 0}),
+ write_job(self.root, f"{base}-oracle", "oracle", {"a": 1})]
+ for agent in ("codex", "claude-code", "terminus-2", "mini-swe-agent"):
+ jobs.append(write_job(self.root, f"{base}-{agent}", agent, {"a": 1}))
+ for job in jobs[2:]:
+ with self.subTest(job=job.job_id):
+ self.assertEqual(sorted(feasibility.related(job, jobs)), ["nop", "oracle"])
+ self.assertEqual([c.job_id for c in feasibility.report(job, jobs).executed],
+ [f"{base}-nop", f"{base}-oracle"])
+
+ def test_a_standard_job_whose_word_holds_a_version_finds_its_controls(self):
+ jobs = [write_job(self.root, "std-nop", "nop", {"a": 0}),
+ write_job(self.root, "std-oracle", "oracle", {"a": 1}),
+ write_job(self.root, "std-codex-2.2.2", "codex", {"a": 1})]
+ self.assertEqual({c: j.job_id for c, j in feasibility.related(jobs[2], jobs).items()},
+ {"nop": "std-nop", "oracle": "std-oracle"})
+
+ def test_a_job_whose_agent_is_not_its_suffix_keeps_todays_rule(self):
+ jobs = [write_job(self.root, "x-nop", "nop", {"a": 0}),
+ write_job(self.root, "x-oracle", "oracle", {"a": 1}),
+ write_job(self.root, "x-mine", "claude-code", {"a": 1})]
+ self.assertEqual(sorted(feasibility.related(jobs[2], jobs)), ["nop", "oracle"])
+
+ def test_a_control_todays_rule_finds_is_kept_over_the_agents(self):
+ jobs = [write_job(self.root, "y-nop", "nop", {"a": 0}),
+ write_job(self.root, "y-claude-nop", "nop", {"a": 0}),
+ write_job(self.root, "y-oracle", "oracle", {"a": 1}),
+ write_job(self.root, "y-claude-code", "claude-code", {"a": 1})]
+ self.assertEqual({c: j.job_id for c, j in feasibility.related(jobs[3], jobs).items()},
+ {"nop": "y-claude-nop", "oracle": "y-oracle"})
+
+ def test_a_job_without_an_agent_suffix_finds_nothing_new(self):
+ jobs = [write_job(self.root, "z-nop", "nop", {"a": 0}),
+ write_job(self.root, "solo", "claude-code", {"a": 1}),
+ write_job(self.root, "w-other", "codex", {"a": 1})]
+ self.assertEqual(feasibility.related(jobs[1], jobs), {})
+ self.assertEqual(feasibility.related(jobs[2], jobs), {})
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/app/ui_tests/test_feasibility_routes.py b/app/ui_tests/test_feasibility_routes.py
index 73f5b3ec..6bb5a681 100644
--- a/app/ui_tests/test_feasibility_routes.py
+++ b/app/ui_tests/test_feasibility_routes.py
@@ -36,6 +36,7 @@ def setUp(self):
write_job(self.tmp.name, "tb-x4-oracle", "oracle", {"good": 1, "leaky": 1, "env": 1}, n_tasks=4),
write_job(self.tmp.name, "tb-x4-agent", "my-agent", {"good": 1, "leaky": 1, "env": 0, "half": 0}, n_tasks=4),
write_job(self.tmp.name, "unrelated", "my-agent", {"good": 1}),
+ write_job(self.tmp.name, "tb-x4-claude-code", "claude-code", {"good": 1}, n_tasks=4),
]
self.stack.enter_context(patch.object(web.shared, "_jobs_for_request", return_value=self.jobs))
self.client = web.app.test_client()
@@ -106,6 +107,10 @@ def test_the_job_page_links_the_report_only_when_a_control_exists(self):
self.assertIn('href="/job/tb-x4-nop/feasibility"', self.get("/job/tb-x4-nop"))
self.assertNotIn("/feasibility", self.get("/job/unrelated"))
+ def test_an_agent_whose_name_has_a_hyphen_links_the_report_too(self):
+ self.assertIn('href="/job/tb-x4-claude-code/feasibility"', self.get("/job/tb-x4-claude-code"))
+ self.assertIn("nop · 4 trials", text_of(self.get("/job/tb-x4-claude-code/feasibility")))
+
class TaskBrokenRow(unittest.TestCase):
"""A task whose nop control failed previously-passing tests is