Answer stability round 1: 0 🔴, 5 🟡 (1 misread); keep locks out of compress-archives, count only a search's hits, show an unfinished failing run, and test the walk and the home

This commit is contained in:
2026-11-21 12:18:32 +01:00
parent 27e5014322
commit 101c8a7c3d
12 changed files with 118 additions and 71 deletions
+11 -7
View File
@@ -166,24 +166,24 @@ class BenchTest(unittest.TestCase):
def test_writes_a_digest_of_the_runs_with_each_bugs_decoys_and_traces(self):
folder = pathlib.Path(self.bench()[-1].removeprefix(main.KEPT))
digest = (folder / "digest.md").read_text().splitlines()
self.assertEqual(digest[:4], ["# task-bench digest", "", "| Bug | Side | Passed | Input | Cache write | Cache read | Output | Turns | Wall, s | Reads |", "|---|---|---|---|---|---|---|---|---|---|"])
self.assertEqual(digest[10:], [
self.assertEqual(digest[:6], ["# task-bench digest", "", f"Base {self.base}, head {self.head}. A bug's name gives its line at the base. Each side's code without the bugs is in `trees/base` and `trees/head` in the bench's folder.", "", "| Bug | Side | Passed | Input | Cache write | Cache read | Output | Turns | Wall, s | Reads |", "|---|---|---|---|---|---|---|---|---|---|"])
self.assertEqual(digest[12:], [
"## Bug 1: calc.go:4:11 ARITHMETIC_BASE",
"",
"The failing test printed, at the base:",
"",
" Add(1, 2) = -1, want 3",
"",
"2 of the 4 runs passed. Decoys, the files more than half the failing runs read that the fix doesn't change:",
"2 of the 4 runs passed. Decoys, the files more than half the failing runs read that the bug isn't in:",
"",
"- `README.md`, read by 2 of the 2 failing runs",
"",
"### bug-1-base-1, the failing run that spent the most tokens, 61840",
"### bug-1-base-1, the failing run that spent the most tokens, 61840 tokens",
"",
"Read README.md",
"Read calc.go",
"",
"### bug-1-head-1, the passing run with the median tokens, 61840",
"### bug-1-head-1, the passing run with the median tokens, 61840 tokens",
"",
"Read README.md",
"Read calc.go",
@@ -195,12 +195,16 @@ class BenchTest(unittest.TestCase):
(reports / name / "task-bench/runs").mkdir(parents=True)
(reports / "crashed/task-bench.lock").touch()
(reports / "crashed/task-bench/trees/task-bench").mkdir(parents=True)
# A tree a running bench copied holds such a pair of its own, which the walk must not reach.
(reports / "running/task-bench/trees/task-bench").mkdir(parents=True)
(reports / "running/task-bench/trees/task-bench.lock").touch()
with bench_folder.held(reports / "running") as running:
self.assertNotIsInstance(self.bench(**{"--runs": "1"}), Failure)
self.assertEqual(running, reports / "running/task-bench")
# A project named task-bench has a review folder of that name, without a lock beside it.
self.assertEqual([(reports / name / "task-bench").exists() for name in ("crashed", "running", "a-project")], [False, True, True])
self.assertTrue((reports / "crashed/task-bench.lock").exists())
self.assertTrue((reports / "running/task-bench/trees/task-bench").exists())
def test_the_command_line_runs_the_bench_on_the_seats_places_and_prints_its_report(self):
argv = [part for name, value in self.given.items() for part in (name, value)]
@@ -372,13 +376,13 @@ class MainTest(unittest.TestCase):
self.assertEqual(out.getvalue().count("usage: task-bench --image <image> --test <shell text>"), 2)
def test_a_run_that_did_not_finish_counts_as_spending_no_tokens_in_the_digest(self):
def test_a_run_that_did_not_finish_has_no_tokens_in_the_digest(self):
with tempfile.TemporaryDirectory() as folder:
pathlib.Path(folder, "runs").mkdir()
pathlib.Path(folder, "runs/bug-1-base-2.jsonl").write_bytes(b"{}")
task = main.Task(1, Mutant("calc.go", 4, 11, "ARITHMETIC_BASE"), {}, {"base": "boom", "head": "bang"})
bug = main.digested(task, [Result(1, "base", 2, False, None), Result(2, "base", 1, True, None)], pathlib.Path(folder))
self.assertEqual(bug, ("1: calc.go:4:11 ARITHMETIC_BASE", "calc.go", "boom", [("bug-1-base-2", False, 0, b"{}")]))
self.assertEqual(bug, ("1: calc.go:4:11 ARITHMETIC_BASE", "calc.go", "boom", [("bug-1-base-2", False, None, b"{}")]))
def test_records_a_run_that_did_not_finish_without_figures(self):
self.assertEqual(main.recorded(Result(1, "base", 2, False, None)), {"bug": 1, "side": "base", "run": 2, "passed": False, "finished": False})