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
+26 -14
View File
@@ -29,6 +29,9 @@ def reading(*paths: str) -> bytes:
return stream(*(call("Read", str(at), file_path=f"/work/{path}") for at, path in enumerate(paths)))
SIDES = {"base": "b" * 40, "head": "h" * 40}
class TraceTest(unittest.TestCase):
def test_a_read_names_the_file_in_the_project_and_the_lines_asked_for(self):
self.assertEqual(trace(stream(call("Read", file_path="/work/pick.go", offset=120, limit=61))), ["Read pick.go:120-180"])
@@ -38,8 +41,10 @@ class TraceTest(unittest.TestCase):
self.assertEqual(trace(stream(call("Read", file_path="/etc/hosts"))), ["Read /etc/hosts"])
def test_a_search_names_its_pattern_and_how_many_lines_it_found(self):
found = stream(call("Grep", pattern="readName"), result("1", "a.go:3: readName()\nb.go\n\nc.go\nd.go\n"))
self.assertEqual(trace(found), ['Grep "readName" → 4 hits'])
found = stream(call("Grep", pattern="readName"), result("1", "Found 3 files\na.go\nb.go\nc.go"))
self.assertEqual(trace(found), ['Grep "readName" → 3 hits'])
for printed, count in (("a.go:3: readName()\n\nb.go:9: readName()\n[Showing results with pagination = limit: 2]", "2 hits"), ("No matches found\nFound 0 total occurrences across 0 files.", "0 hits"), ("No entries at this offset. [Showing results with pagination = limit: 3]", "0 hits"), ("/work/a.go\n(Showing 1 of 240 matching files; narrow the pattern)", "1 hit")):
self.assertEqual(trace(stream(call("Grep", pattern="x"), result("1", printed))), [f'Grep "x" → {count}'])
self.assertEqual(trace(stream(call("Grep", pattern="x", path="/work/cmd"), result("1", "No matches found"))), ['Grep "x" in cmd → 0 hits'])
self.assertEqual(trace(stream(call("Glob", pattern="**/*.go"), result("1", "/work/a.go"))), ['Glob "**/*.go" → 1 hit'])
self.assertEqual(trace(stream(call("Glob", pattern="*.rs"), result("1", "No files found"))), ['Glob "*.rs" → 0 hits'])
@@ -84,8 +89,8 @@ class DecoysTest(unittest.TestCase):
self.assertEqual(decoys(failing[:3], "calc.go", lambda path: True), ["`README.md`, read by 2 of the 3 failing runs", "`sum.go`, read by 2 of the 3 failing runs"])
def test_counts_what_a_search_or_a_shell_command_read_and_leaves_out_folders_and_files_outside_the_project(self):
failing = [stream(call("Grep", pattern="Add", path="/work/sum.go"), call("Bash", "2", command="cat /work/mul.go /etc/hosts"), call("Grep", "3", pattern="Add", path="/work/cmd"))]
self.assertEqual(decoys(failing, "calc.go", lambda path: path != "cmd"), ["`mul.go`, read by 1 of the 1 failing run", "`sum.go`, read by 1 of the 1 failing run"])
failing = [stream(call("Grep", pattern="Add", path="/work/sum.go"), call("Bash", "2", command="cat /work/mul.go /etc/hosts ~/notes.go"), call("Grep", "3", pattern="Add", path="/work/cmd"))]
self.assertEqual(decoys(failing, "calc.go", lambda path: path != "cmd"), ["`mul.go`, read by the one failing run", "`sum.go`, read by the one failing run"])
def test_no_failing_run_gives_no_decoy(self):
self.assertEqual(decoys([], "calc.go", lambda path: True), [])
@@ -103,10 +108,12 @@ class DigestTest(unittest.TestCase):
]
def test_holds_the_figures_and_per_bug_its_decoys_and_two_traces_picked_by_rule(self):
held = digest(["| Bug | Side |", "|---|---|"], [Bug("1: calc.go:4:11 ARITHMETIC_BASE", "calc.go", "Add(1, 2) = -1, want 3", self.runs())], lambda path: True)
held = digest(SIDES, ["| Bug | Side |", "|---|---|"], [Bug("1: calc.go:4:11 ARITHMETIC_BASE", "calc.go", "Add(1, 2) = -1, want 3", self.runs())], lambda path: True)
self.assertEqual(held.splitlines(), [
"# task-bench digest",
"",
f"Base {'b' * 40}, head {'h' * 40}. 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 |",
"|---|---|",
"",
@@ -116,37 +123,42 @@ class DigestTest(unittest.TestCase):
"",
" Add(1, 2) = -1, want 3",
"",
"4 of the 6 runs passed. Decoys, the files more than half the failing runs read that the fix doesn't change:",
"4 of the 6 runs passed. Decoys, the files more than half the failing runs read that the bug isn't in:",
"",
"- `sum.go`, read by 2 of the 2 failing runs",
"",
"### bug-1-base-2, the failing run that spent the most tokens, 1200",
"### bug-1-base-2, the failing run that spent the most tokens, 1200 tokens",
"",
"Read sum.go",
"Read calc.go",
"",
# Of the passing runs' 300, 500, 700 and 800, the lower of the two in the middle.
"### bug-1-head-1, the passing run with the median tokens, 500",
"### bug-1-head-1, the passing run with the median tokens, 500 tokens",
"",
"Read calc.go",
])
def test_a_bug_every_run_fixed_has_no_decoys_and_one_trace(self):
held = digest([], [Bug("2: a.go:1:1 X", "a.go", "boom", [Run("bug-2-base-1", True, 10, reading("a.go"))])], lambda path: True)
held = digest(SIDES, [], [Bug("2: a.go:1:1 X", "a.go", "boom", [Run("bug-2-base-1", True, 10, reading("a.go"))])], lambda path: True)
self.assertIn("The 1 run passed. No run failed, so the bug has no decoys.", held.splitlines())
self.assertNotIn("failing run that", held)
self.assertIn("### bug-2-base-1, the passing run with the median tokens, 10", held.splitlines())
self.assertIn("### bug-2-base-1, the passing run with the median tokens, 10 tokens", held.splitlines())
def test_the_median_is_by_tokens_whatever_the_order_the_runs_ran_in(self):
runs = [Run("bug-2-base-1", True, 20, b""), Run("bug-2-head-1", True, 10, b""), Run("bug-2-base-2", True, 30, b"")]
self.assertEqual(digest([], [Bug("2: a.go:1:1 X", "a.go", "boom", runs)], lambda path: True).splitlines()[-2:], ["### bug-2-base-1, the passing run with the median tokens, 20", ""])
self.assertEqual(digest(SIDES, [], [Bug("2: a.go:1:1 X", "a.go", "boom", runs)], lambda path: True).splitlines()[-2:], ["### bug-2-base-1, the passing run with the median tokens, 20 tokens", ""])
def test_a_run_that_did_not_finish_is_the_failing_trace_and_is_left_out_of_the_median(self):
runs = [Run("bug-4-base-1", False, 900, b""), Run("bug-4-head-1", False, None, b""), Run("bug-4-base-2", True, None, b""), Run("bug-4-head-2", True, 60, b"")]
held = digest(SIDES, [], [Bug("4: a.go:1:1 X", "a.go", "boom", runs)], lambda path: True).splitlines()
self.assertEqual([line for line in held if line.startswith("###")], ["### bug-4-head-1, a failing run that didn't finish", "### bug-4-head-2, the passing run with the median tokens, 60 tokens"])
def test_a_bug_no_run_fixed_shows_the_failing_trace_alone_and_says_where_no_file_misled(self):
held = digest([], [Bug("3: a.go:1:1 X", "a.go", "boom\nat line 2", [Run("bug-3-base-1", False, 10, reading("a.go")), Run("bug-3-head-1", False, 10, reading("a.go"))])], lambda path: True)
self.assertEqual(held.splitlines()[10:14], ["0 of the 2 runs passed. No decoys: no file but the one the fix changes was read by more than half the 2 failing runs.", "", "### bug-3-base-1, the failing run that spent the most tokens, 10", ""])
held = digest(SIDES, [], [Bug("3: a.go:1:1 X", "a.go", "boom\nat line 2", [Run("bug-3-base-1", False, 10, reading("a.go")), Run("bug-3-head-1", False, 10, reading("a.go"))])], lambda path: True)
self.assertEqual(held.splitlines()[12:16], ["0 of the 2 runs passed. No decoys: no file but the one the bug is in was read by more than half the 2 failing runs.", "", "### bug-3-base-1, the failing run that spent the most tokens, 10 tokens", ""])
self.assertIn(" at line 2", held.splitlines())
# Of two failing runs that spent the same, the first.
self.assertIn("### bug-3-base-1, the failing run that spent the most tokens, 10", held.splitlines())
self.assertIn("### bug-3-base-1, the failing run that spent the most tokens, 10 tokens", held.splitlines())
self.assertNotIn("passing run with", held)