Answer architecture round 1: 2 🔴, 8 🟡 (0 misread); split task-bench's benched into phases and its table into one column list, parse each stream once, move do-epic's parking out with pure move and news decisions, share the round summaries, rename scoring_due, and file the version question as item 517
CI / tests (pull_request) Successful in 5m2s

This commit is contained in:
2026-11-23 01:20:55 +01:00
parent 21200cb698
commit 0bf87b736e
29 changed files with 678 additions and 368 deletions
+31 -10
View File
@@ -17,10 +17,12 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench import api_proxy, bench_folder, main, runs
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, opened, ran_tests, TimedOut
from task_bench.plant import drawn, Mutant
from claude_code.entries import Entry
from failure import Failure
from task_bench.figures import Figures, Result, table
from test_env import isolated_env
from mutate_changes.tool_process import Ran
from task_bench.figures import Result
from claude_code.tokens import Tokens
BASE_CODE = "package calc\n\nfunc Add(a, b int) int {\n\treturn a + b\n}\n\nfunc Twice(a int) int {\n\treturn a * 2\n}\n"
# The head adds a line right above Add, which moves it down, and rewrites Twice's line.
@@ -344,6 +346,24 @@ class BenchTest(unittest.TestCase):
self.assertIn("docker build", found.reason)
class ReportTest(unittest.TestCase):
SIDES = {"base": "b" * 40, "head": "h" * 40}
NAMES = {1: "calc.go:4:11 ARITHMETIC_BASE"}
RESULTS = [Result(1, "base", 1, True, Figures("2.1.330", "claude-haiku-5-5", Tokens(40, 0, 9000, 52000, 800), 7, 61.5, 2)), Result(1, "head", 1, False, None)]
def test_names_the_commits_the_bugs_the_runs_and_what_ran_them_above_the_table(self):
told = main.report(self.SIDES, self.NAMES, main.Asked(seed=1, bugs=1, runs=2), self.RESULTS)
self.assertEqual(told, ["task-bench: base bbbbbbbbbbbb, head hhhhhhhhhhhh. 1 bug, each run 2 times at each side by claude-haiku-5-5 in Claude Code 2.1.330.", "", *table(self.RESULTS, self.NAMES), ""])
def test_says_where_fewer_bugs_were_planted_than_asked_for_and_where_no_run_finished(self):
told = main.report(self.SIDES, self.NAMES, main.Asked(seed=1, bugs=3, runs=1), self.RESULTS[1:])
self.assertEqual(told[:3], ["task-bench: base bbbbbbbbbbbb, head hhhhhhhhhhhh. 1 bug, each run 1 time at each side by no run that finished.", "Planted 1 of the 3 bugs asked for: no other mutant the tests kill becomes one.", ""])
def test_a_stopped_bench_tells_why_then_how_far_it_came_then_the_table(self):
told = main.stopped_report(Failure("claude could not use the API: Invalid bearer token"), self.RESULTS, 10, self.NAMES, pathlib.Path("/reviews/task-bench"))
self.assertEqual(told, Failure("\n".join(["claude could not use the API: Invalid bearer token", "task-bench stopped after 2 of 10 runs, which results.json holds in /reviews/task-bench:", "", *table(self.RESULTS, self.NAMES)])))
class MainTest(unittest.TestCase):
def run_main(self, *argv: str, token: str = "t") -> tuple[int, str]:
with contextlib.redirect_stderr(io.StringIO()) as errors, contextlib.redirect_stdout(io.StringIO()):
@@ -377,12 +397,10 @@ class MainTest(unittest.TestCase):
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, None, b"{}")]))
task = main.Task(1, Mutant("calc.go", 4, 11, "ARITHMETIC_BASE"), {}, {"base": "boom", "head": "bang"})
entries = (Entry(),)
bug = main.digested(task, [Result(1, "base", 2, False, None, entries), Result(2, "base", 1, True, None)], pathlib.Path("/bench"))
self.assertEqual(bug, ("1: calc.go:4:11 ARITHMETIC_BASE", "calc.go", "boom", [("bug-1-base-2", False, None, entries)]))
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})
@@ -431,6 +449,9 @@ class RunOutcomesTest(unittest.TestCase):
def containers(self, *runs: Ran | Failure) -> Containers:
return Containers(InTurn(*runs), "bench", "go test ./...", 512, "1000:1000")
def bench(self, *runs: Ran | Failure) -> main.Bench:
return main.Bench("", {"base": "b", "head": "h"}, self.trees, main.Asked(seed=1, bugs=1, runs=1), self.containers(*runs), self.folder, lambda *args, **given: "")
def test_a_fix_whose_tests_run_out_of_time_does_not_pass(self):
late = TimedOut("docker run still ran after 30 min")
self.assertEqual(main.fixed(self.task, "base", 1, self.containers(Ran(0, ""), late), self.folder), Result(1, "base", 1, False, None))
@@ -441,15 +462,15 @@ class RunOutcomesTest(unittest.TestCase):
def test_tests_docker_could_not_run_without_a_bug_fail_the_bench(self):
broke = Failure("docker could not start: No such file or directory")
self.assertEqual(main.benched({}, "", {}, self.trees, [], self.containers(broke), self.folder, None), broke)
self.assertEqual(main.benched(self.bench(broke), []), broke)
def test_a_mutant_whose_tests_run_out_of_time_is_passed_over(self):
late = TimedOut("docker run still ran after 30 min")
self.assertIsNone(main.planted(1, self.MUTANT, "", {"base": "b", "head": "h"}, self.trees, self.containers(late), self.folder, lambda *args, **given: ""))
self.assertIsNone(main.planted(self.bench(late), 1, self.MUTANT))
def test_a_mutant_whose_tests_docker_could_not_run_fails_the_bench(self):
broke = Failure("docker could not start: No such file or directory")
self.assertEqual(main.planted(1, self.MUTANT, "", {"base": "b", "head": "h"}, self.trees, self.containers(broke), self.folder, lambda *args, **given: ""), broke)
self.assertEqual(main.planted(self.bench(broke), 1, self.MUTANT), broke)
class ContainersTest(unittest.TestCase):