From c79407331281ca4648852843b953d351dd668f5a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 25 Nov 2026 23:29:11 +0100 Subject: [PATCH 01/11] Keep a Rust file's test modules as planted when task-bench checks a fix --- bin/task_bench/main.py | 9 +- bin/task_bench/runs.py | 17 +++- bin/task_bench/rust_test_modules.py | 87 +++++++++++++++++++ bin/task_bench/test_rust_test_modules.py | 105 +++++++++++++++++++++++ bin/task_bench/test_task_bench.py | 17 ++++ 5 files changed, 231 insertions(+), 4 deletions(-) create mode 100644 bin/task_bench/rust_test_modules.py create mode 100644 bin/task_bench/test_rust_test_modules.py diff --git a/bin/task_bench/main.py b/bin/task_bench/main.py index 17579781..6bd45925 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -29,8 +29,9 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream. Claude home is new and empty, so the project's own CLAUDE.md, or AGENTS.md, in the copy is all the setup that loads. Its network reaches api.anthropic.com and nothing else. A fix ends after 30 minutes. - Check. The test command runs over the planted tree with each file that is no test as Haiku left it; a fix passes where it exits 0. - A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. A Rust test that - stands in the file of the code it tests is the exception: the bench takes that file whole, so a change to such a test counts. + A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. In a Rust file, each + inline `#[cfg(test)]` module stands as the planted file has it, and the rest is as Haiku left it. A Rust mutant is passed over + where its file's modules cannot be told apart, as where two share a name or a brace, string or comment is never closed. --image is the project's development image, such as golang:1.27.4. The bench adds Claude Code to it, as its installer installs it, so the image needs curl and bash; the result names the version. Haiku works in that image. So does --test: sh runs that text at @@ -173,6 +174,7 @@ import uuid from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, SHIPPED, Task, tests_in_copy from task_bench.planted_mutant import bug_at_sides, Mutant +from task_bench.rust_test_modules import modules from claude_code.reply import Claude from task_bench.bench_folder import clear_left, held from task_bench.runs import closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TimedOut, TOKEN, WORK @@ -489,7 +491,8 @@ def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None: if isinstance(sources, Failure): return sources bugs = bug_at_sides(mutant, diff, sources) - if bugs is None: + # The check keeps a Rust file's test modules as planted, which it can only do where it tells them apart. + if bugs is None or (mutant.path.endswith(".rs") and any(modules(source.decode("utf-8", "surrogateescape")) is None for source in bugs.values())): return None trees: dict[Side, str] = {} messages: dict[Side, str] = {} diff --git a/bin/task_bench/runs.py b/bin/task_bench/runs.py index 842debd8..7a638d8a 100644 --- a/bin/task_bench/runs.py +++ b/bin/task_bench/runs.py @@ -11,6 +11,7 @@ import typing from mutate_changes.tool_process import failed, Ran from failure import Failure from mutate_changes.changed_lines import is_test +from task_bench.rust_test_modules import with_tests_of from task_bench.api_proxy import PORT MODEL = "claude-haiku-5-5" @@ -166,7 +167,7 @@ def in_tree(containers: Containers, tree: str) -> list[str]: def checked_tree(planted: str, copy: str, into: str) -> None: """Makes at `into` the tree the tests check a fix in: `planted`, the code with the bug as Haiku got it, with each file that is no test as `copy` holds it after the fix. So a test Haiku changed, removed or added doesn't count, and neither does a file under - a `testdata` folder, where Go's tests keep the output they expect. + a `testdata` folder, where Go's tests keep the output they expect. A Rust file's `#[cfg(test)]` modules are the planted file's. Raises OSError where a file cannot be copied.""" shutil.copytree(planted, into, symlinks=True) @@ -184,6 +185,20 @@ def checked_tree(planted: str, copy: str, into: str) -> None: with contextlib.suppress(FileNotFoundError): os.unlink(target) shutil.copy2(os.path.join(copy, path), target, follow_symlinks=False) + if path.endswith(".rs"): + keep_rust_tests(os.path.join(planted, path), target) + + +def keep_rust_tests(planted_file: str, target: str) -> None: + """Puts into the Rust file at target, a copy of Haiku's, the test modules of planted_file; see `with_tests_of`. A file the planted + tree lacks, as a link or as a file, is left as it is, since it has no test to keep. + + Raises OSError where a file cannot be read or written.""" + if os.path.islink(planted_file) or os.path.islink(target) or not os.path.isfile(planted_file): + return + # A Rust file is UTF-8; a byte that isn't survives the round trip. + planted, copied = (pathlib.Path(file).read_bytes().decode("utf-8", "surrogateescape") for file in (planted_file, target)) + pathlib.Path(target).write_bytes(with_tests_of(planted, copied).encode("utf-8", "surrogateescape")) def of_tests(path: str) -> bool: diff --git a/bin/task_bench/rust_test_modules.py b/bin/task_bench/rust_test_modules.py new file mode 100644 index 00000000..b36fe084 --- /dev/null +++ b/bin/task_bench/rust_test_modules.py @@ -0,0 +1,87 @@ +"""The `#[cfg(test)]` modules of a Rust file, which stand in the file of the code they test: where each is, and a file with the modules +of another file put in place of its own.""" +import re + +# What the scan steps over or stops at, in the order Rust's own lexer tries them. A string, a char and a comment may hold a brace. +SCAN = re.compile( + r"""//[^\n]*""" + r"""|/\*""" + r"""|(?\#*)\"""" + r"""|\"""" + r"""|'(?:\\(?:u\{[0-9a-fA-F_]+\}|x[0-9a-fA-F]{2}|.)|[^\\'\n])'""" + r"""|[{}]""" + r"""|\#\[cfg\(test\)\]""", + re.DOTALL, +) +COMMENT_EDGE = re.compile(r"/\*|\*/") +# What must follow the attribute for it to start an inline module: other attributes, a visibility, then `mod name {`. +MODULE = re.compile(r"\s*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?mod\s+(?P\w+)\s*\{") + + +def modules(source: str) -> dict[str, tuple[int, int]] | None: + """Each inline `#[cfg(test)] mod name { ... }` of source by its name, as the offsets from its attribute to its closing brace. A + module inside another is not listed. None where the modules cannot be told apart: two hold one name, or a brace, string or + comment is never closed. A `#[cfg(test)]` on anything but an inline module is not listed.""" + found: dict[str, tuple[int, int]] = {} + depth, open_at, start, name = 0, 0, -1, "" + position = 0 + while match := SCAN.search(source, position): + token, position = match.group(), match.end() + if token == "/*": + position = after_comment(source, position) + elif token == '"': + position = after_string(source, position, '"') + elif match.group("hashes") is not None: + position = after_string(source, position, '"' + match.group("hashes"), raw=True) + elif token == "{": + depth += 1 + elif token == "}": + depth -= 1 + if start >= 0 and depth == open_at: + if name in found: + return None + found[name], start = (start, position), -1 + elif start < 0 and (module := MODULE.match(source, position)): + start, name, open_at = match.start(), module.group("name"), depth + position = module.end() + depth += 1 + if position < 0: + return None + return found if depth == 0 and start < 0 else None + + +def after_comment(source: str, position: int) -> int: + """The offset after the block comment whose `/*` ends at position, -1 where it is never closed. Block comments nest in Rust.""" + level = 1 + while level and (match := COMMENT_EDGE.search(source, position)): + level += 1 if match.group() == "/*" else -1 + position = match.end() + return position if level == 0 else -1 + + +def after_string(source: str, position: int, closing: str, raw: bool = False) -> int: + """The offset after the string whose opening quote ends at position, -1 where it is never closed. A raw string has no escapes.""" + while (found := source.find(closing, position)) >= 0: + backslashes = len(source[position:found]) - len(source[position:found].rstrip("\\")) + if raw or backslashes % 2 == 0: + return found + len(closing) + position = found + 1 + return -1 + + +def with_tests_of(planted: str, copy: str) -> str: + """copy with each test module as planted holds it, and each test module planted lacks left out. So a test a fix changed, removed + or added doesn't count. + + Where planted's modules cannot be told apart, copy is returned as it is. Where copy's cannot, or copy lacks one of planted's, + planted is returned: Haiku's file has no module to put them in.""" + before, after = modules(planted), modules(copy) + if before is None: + return copy + if after is None or before.keys() - after.keys(): + return planted + text = copy + for name, (start, end) in sorted(after.items(), key=lambda item: -item[1][0]): + was = planted[before[name][0]:before[name][1]] if name in before else "" + text = text[:start] + was + text[end:] + return text diff --git a/bin/task_bench/test_rust_test_modules.py b/bin/task_bench/test_rust_test_modules.py new file mode 100644 index 00000000..e5a47817 --- /dev/null +++ b/bin/task_bench/test_rust_test_modules.py @@ -0,0 +1,105 @@ +"""The test modules of a Rust file: where they are, and a fixed file with the planted tests put back.""" +import pathlib +import sys +import textwrap +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from task_bench.rust_test_modules import modules, with_tests_of + +LIB = textwrap.dedent("""\ + pub fn add(a: i32, b: i32) -> i32 { + a + b + } + + #[cfg(test)] + mod tests { + use super::*; + + #[test] + fn adds() { + assert_eq!(add(1, 2), 3); + } + } + """) + + +def spelt(source: str) -> dict[str, str] | None: + found = modules(source) + return None if found is None else {name: source[start:end] for name, (start, end) in found.items()} + + +class ModulesTest(unittest.TestCase): + def test_holds_each_test_module_from_its_attribute_to_its_closing_brace(self): + self.assertEqual(spelt(LIB), {"tests": LIB[LIB.index("#[cfg(test)]"):LIB.rindex("}") + 1]}) + + def test_holds_none_where_the_file_has_no_test_module(self): + self.assertEqual(modules("fn main() {}\n"), {}) + + def test_takes_a_module_with_a_visibility_and_another_attribute(self): + source = "#[cfg(test)]\n#[allow(dead_code)]\npub(crate) mod checks {\n}\nfn after() {}\n" + self.assertEqual(spelt(source), {"checks": source[:source.index("}") + 1]}) + + def test_leaves_out_what_the_attribute_is_not_on_an_inline_module(self): + self.assertEqual(modules("#[cfg(test)]\nmod tests;\n#[cfg(test)]\nuse std::fmt;\n#[cfg(test)]\nfn helper() {}\n"), {}) + + def test_leaves_out_a_module_inside_a_module(self): + source = "#[cfg(test)]\nmod outer {\n #[cfg(test)]\n mod inner {}\n}\n" + self.assertEqual(list(spelt(source)), ["outer"]) + + def test_reads_past_a_brace_in_a_string_a_char_or_a_comment(self): + source = textwrap.dedent("""\ + #[cfg(test)] + mod tests { + // } + /* } /* } */ } */ + const A: &str = "}\\"}"; + const B: &str = r#"}"}"#; + const C: char = '}'; + const D: char = '\\''; + fn lifetime<'a>(x: &'a str) -> &'a str { x } + } + fn after() {} + """) + self.assertEqual(spelt(source), {"tests": source[:source.index("}\nfn after")+1]}) + + def test_cannot_tell_the_modules_apart_where_two_hold_one_name(self): + self.assertIsNone(modules("#[cfg(test)]\nmod tests {}\nfn a() { #[cfg(test)] mod tests {} }\n")) + + def test_cannot_tell_the_modules_apart_where_a_brace_string_or_comment_is_never_closed(self): + for source in ("#[cfg(test)]\nmod tests {\n", "fn a() {\n", "const A: &str = \"\n", "/* open\n", "const A: &str = r#\"\n"): + with self.subTest(source=source): + self.assertIsNone(modules(source)) + + +class WithTestsOfTest(unittest.TestCase): + def test_takes_the_code_as_fixed_and_the_tests_as_planted(self): + planted = LIB.replace("a + b", "a - b") + fixed = LIB.replace("assert_eq!(add(1, 2), 3);", "assert_eq!(add(1, 2), 0);") + self.assertEqual(with_tests_of(planted, fixed), LIB) + + def test_takes_the_planted_tests_where_the_fix_deleted_them(self): + planted = LIB.replace("a + b", "a - b") + fixed = "pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n" + self.assertEqual(with_tests_of(planted, fixed), planted) + + def test_leaves_out_a_test_module_the_fix_added(self): + planted = "fn a() {}\n" + fixed = "fn a() {}\n#[cfg(test)]\nmod mine {}\nfn b() {}\n" + self.assertEqual(with_tests_of(planted, fixed), "fn a() {}\n\nfn b() {}\n") + + def test_puts_each_planted_module_where_the_fixed_module_of_its_name_stands(self): + planted = "fn a() { 1 }\n#[cfg(test)]\nmod x { fn t() {} }\nfn b() {}\n#[cfg(test)]\nmod y { fn u() {} }\n" + fixed = "fn a() { 2 }\n#[cfg(test)]\nmod y { fn changed() {} }\n#[cfg(test)]\nmod x { fn changed() {} }\nfn c() {}\n" + self.assertEqual(with_tests_of(planted, fixed), "fn a() { 2 }\n#[cfg(test)]\nmod y { fn u() {} }\n#[cfg(test)]\nmod x { fn t() {} }\nfn c() {}\n") + + def test_takes_the_file_as_fixed_where_the_planted_modules_cannot_be_told_apart(self): + self.assertEqual(with_tests_of("#[cfg(test)]\nmod tests {\n", "fixed {}"), "fixed {}") + + def test_takes_the_planted_file_where_the_fixed_modules_cannot_be_told_apart(self): + self.assertEqual(with_tests_of(LIB, "fn broken() {"), LIB) + + +if __name__ == "__main__": + unittest.main() diff --git a/bin/task_bench/test_task_bench.py b/bin/task_bench/test_task_bench.py index c40d6ee7..afef522f 100644 --- a/bin/task_bench/test_task_bench.py +++ b/bin/task_bench/test_task_bench.py @@ -578,6 +578,11 @@ class RunOutcomesTest(unittest.TestCase): bench = dataclasses.replace(self.bench(), trees={"base": str(self.tree), "head": str(head)}) self.assertIsNone(main.planted(bench, 1, self.MUTANT)) + def test_a_rust_mutant_in_a_file_whose_test_module_cannot_be_told_apart_is_passed_over(self): + (self.tree / "lib.rs").write_text("pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n#[cfg(test)]\nmod tests {\n") + mutant = Mutant("lib.rs", 2, "lib.rs:2:7 replace + with -", (b" a + b",), (b" a - b",)) + self.assertIsNone(main.planted(self.bench(), 1, mutant)) + class ContainersTest(unittest.TestCase): IN_TREE = ["--memory", "512m", "--memory-swap", "512m", "--user", "1000:1000", "--env", "HOME=/tmp", "--volume", "/tree:/work", "--workdir", "/work"] @@ -718,6 +723,18 @@ class CheckedTreeTest(unittest.TestCase): checked_tree(planted, copy, str(self.root / "check")) self.assertEqual(self.held("check"), {"calc.go": "fixed", "sub/testdata/gone.golden": "4", "testdata.go": "fixed", "testdata/want.golden": "3"}) + def test_takes_a_rust_files_test_module_as_planted_and_the_rest_as_fixed(self): + planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 1 }\n"}) + copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests {}\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"}) + checked_tree(planted, copy, str(self.root / "check")) + self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"}) + + def test_takes_the_planted_rust_file_where_the_fix_deleted_its_test_module(self): + planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"}) + copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n"}) + checked_tree(planted, copy, str(self.root / "check")) + self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"}) + def test_copies_a_link_as_a_link(self): planted = self.tree("planted", {"calc.go": "bug"}) copy = self.tree("copy", {"calc.go": "fixed"}) -- 2.52.0 From dd156909038e61fadc8431bb473ac8072a7c690e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 00:00:33 +0100 Subject: [PATCH 02/11] Tell a Rust file's test modules apart as bytes and kill the surviving mutants --- bin/task_bench/main.py | 4 +- bin/task_bench/runs.py | 5 +- bin/task_bench/rust_test_modules.py | 98 ++++++++++++------------ bin/task_bench/test_rust_test_modules.py | 46 ++++++++++- bin/task_bench/test_task_bench.py | 7 ++ 5 files changed, 106 insertions(+), 54 deletions(-) diff --git a/bin/task_bench/main.py b/bin/task_bench/main.py index 6bd45925..b9b1c74d 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -174,7 +174,7 @@ import uuid from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, SHIPPED, Task, tests_in_copy from task_bench.planted_mutant import bug_at_sides, Mutant -from task_bench.rust_test_modules import modules +from task_bench.rust_test_modules import tells_apart from claude_code.reply import Claude from task_bench.bench_folder import clear_left, held from task_bench.runs import closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TimedOut, TOKEN, WORK @@ -492,7 +492,7 @@ def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None: return sources bugs = bug_at_sides(mutant, diff, sources) # The check keeps a Rust file's test modules as planted, which it can only do where it tells them apart. - if bugs is None or (mutant.path.endswith(".rs") and any(modules(source.decode("utf-8", "surrogateescape")) is None for source in bugs.values())): + if bugs is None or not all(tells_apart(mutant.path, source) for source in bugs.values()): return None trees: dict[Side, str] = {} messages: dict[Side, str] = {} diff --git a/bin/task_bench/runs.py b/bin/task_bench/runs.py index 7a638d8a..aba3dc63 100644 --- a/bin/task_bench/runs.py +++ b/bin/task_bench/runs.py @@ -196,9 +196,8 @@ def keep_rust_tests(planted_file: str, target: str) -> None: Raises OSError where a file cannot be read or written.""" if os.path.islink(planted_file) or os.path.islink(target) or not os.path.isfile(planted_file): return - # A Rust file is UTF-8; a byte that isn't survives the round trip. - planted, copied = (pathlib.Path(file).read_bytes().decode("utf-8", "surrogateescape") for file in (planted_file, target)) - pathlib.Path(target).write_bytes(with_tests_of(planted, copied).encode("utf-8", "surrogateescape")) + planted, copied = (pathlib.Path(file).read_bytes() for file in (planted_file, target)) + pathlib.Path(target).write_bytes(with_tests_of(planted, copied)) def of_tests(path: str) -> bool: diff --git a/bin/task_bench/rust_test_modules.py b/bin/task_bench/rust_test_modules.py index b36fe084..e950801a 100644 --- a/bin/task_bench/rust_test_modules.py +++ b/bin/task_bench/rust_test_modules.py @@ -1,75 +1,79 @@ """The `#[cfg(test)]` modules of a Rust file, which stand in the file of the code they test: where each is, and a file with the modules -of another file put in place of its own.""" +of another file put in place of its own. A file is bytes, since a Rust file is UTF-8 and a module is found by ASCII text alone.""" import re -# What the scan steps over or stops at, in the order Rust's own lexer tries them. A string, a char and a comment may hold a brace. +# What the scan steps over or stops at. A string, a char and a comment may hold a brace. SCAN = re.compile( - r"""//[^\n]*""" - r"""|/\*""" - r"""|(?\#*)\"""" - r"""|\"""" - r"""|'(?:\\(?:u\{[0-9a-fA-F_]+\}|x[0-9a-fA-F]{2}|.)|[^\\'\n])'""" - r"""|[{}]""" - r"""|\#\[cfg\(test\)\]""", + rb"""//[^\n]*""" + rb"""|/\*""" + rb"""|(?\#*)\"""" + rb"""|\"""" + rb"""|'(?:\\(?:u\{[0-9a-fA-F_]+\}|x[0-9a-fA-F]{2}|.)|[^\\'\n])'""" + rb"""|[{}]""" + rb"""|\#\[cfg\(test\)\]""", re.DOTALL, ) -COMMENT_EDGE = re.compile(r"/\*|\*/") +COMMENT_EDGE = re.compile(rb"/\*|\*/") # What must follow the attribute for it to start an inline module: other attributes, a visibility, then `mod name {`. -MODULE = re.compile(r"\s*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?mod\s+(?P\w+)\s*\{") +MODULE = re.compile(rb"\s*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?mod\s+(?P\w+)\s*\{") -def modules(source: str) -> dict[str, tuple[int, int]] | None: +def tells_apart(path: str, source: bytes) -> bool: + """Whether source, the file at path, is no Rust file or has test modules that `modules` tells apart.""" + return not path.endswith(".rs") or modules(source) is not None + + +def modules(source: bytes) -> dict[bytes, tuple[int, int]] | None: """Each inline `#[cfg(test)] mod name { ... }` of source by its name, as the offsets from its attribute to its closing brace. A - module inside another is not listed. None where the modules cannot be told apart: two hold one name, or a brace, string or + module inside a test module is not listed. None where the modules cannot be told apart: two hold one name, or a brace, string or comment is never closed. A `#[cfg(test)]` on anything but an inline module is not listed.""" - found: dict[str, tuple[int, int]] = {} - depth, open_at, start, name = 0, 0, -1, "" - position = 0 - while match := SCAN.search(source, position): + found: dict[bytes, tuple[int, int]] = {} + depth = 0 + # The module being read: its name, the offset of its attribute and the depth outside it. + inside: tuple[bytes, int, int] | None = None + position: int | None = 0 + while position is not None and (match := SCAN.search(source, position)): token, position = match.group(), match.end() - if token == "/*": + if token == b"/*": position = after_comment(source, position) - elif token == '"': - position = after_string(source, position, '"') + elif token == b'"': + position = after_string(source, position, b'"') elif match.group("hashes") is not None: - position = after_string(source, position, '"' + match.group("hashes"), raw=True) - elif token == "{": + position = after_string(source, position, b'"' + match.group("hashes"), raw=True) + elif token == b"{": depth += 1 - elif token == "}": + elif token == b"}": depth -= 1 - if start >= 0 and depth == open_at: - if name in found: + if inside and depth == inside[2]: + if inside[0] in found: return None - found[name], start = (start, position), -1 - elif start < 0 and (module := MODULE.match(source, position)): - start, name, open_at = match.start(), module.group("name"), depth - position = module.end() + found[inside[0]], inside = (inside[1], position), None + elif token.startswith(b"#[") and inside is None and (module := MODULE.match(source, position)): + inside, position = (module.group("name"), match.start(), depth), module.end() depth += 1 - if position < 0: - return None - return found if depth == 0 and start < 0 else None + return found if position is not None and depth == 0 and inside is None else None -def after_comment(source: str, position: int) -> int: - """The offset after the block comment whose `/*` ends at position, -1 where it is never closed. Block comments nest in Rust.""" +def after_comment(source: bytes, position: int) -> int | None: + """The offset after the block comment whose `/*` ends at position, None where it is never closed. Block comments nest in Rust.""" level = 1 while level and (match := COMMENT_EDGE.search(source, position)): - level += 1 if match.group() == "/*" else -1 + level += 1 if match.group() == b"/*" else -1 position = match.end() - return position if level == 0 else -1 + return position if level == 0 else None -def after_string(source: str, position: int, closing: str, raw: bool = False) -> int: - """The offset after the string whose opening quote ends at position, -1 where it is never closed. A raw string has no escapes.""" +def after_string(source: bytes, position: int, closing: bytes, raw: bool = False) -> int | None: + """The offset after the string whose opening quote ends at position, None where it is never closed. A raw string has no escapes.""" while (found := source.find(closing, position)) >= 0: - backslashes = len(source[position:found]) - len(source[position:found].rstrip("\\")) - if raw or backslashes % 2 == 0: + between = source[position:found] + if raw or (len(between) - len(between.rstrip(b"\\"))) % 2 == 0: return found + len(closing) position = found + 1 - return -1 + return None -def with_tests_of(planted: str, copy: str) -> str: +def with_tests_of(planted: bytes, copy: bytes) -> bytes: """copy with each test module as planted holds it, and each test module planted lacks left out. So a test a fix changed, removed or added doesn't count. @@ -80,8 +84,8 @@ def with_tests_of(planted: str, copy: str) -> str: return copy if after is None or before.keys() - after.keys(): return planted - text = copy - for name, (start, end) in sorted(after.items(), key=lambda item: -item[1][0]): - was = planted[before[name][0]:before[name][1]] if name in before else "" - text = text[:start] + was + text[end:] - return text + text, last = b"", 0 + for (start, end), name in sorted((span, name) for name, span in after.items()): + text += copy[last:start] + (planted[before[name][0]:before[name][1]] if name in before else b"") + last = end + return text + copy[last:] diff --git a/bin/task_bench/test_rust_test_modules.py b/bin/task_bench/test_rust_test_modules.py index e5a47817..d1f9630e 100644 --- a/bin/task_bench/test_rust_test_modules.py +++ b/bin/task_bench/test_rust_test_modules.py @@ -6,7 +6,8 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from task_bench.rust_test_modules import modules, with_tests_of +from task_bench import rust_test_modules +from task_bench.rust_test_modules import tells_apart LIB = textwrap.dedent("""\ pub fn add(a: i32, b: i32) -> i32 { @@ -25,9 +26,17 @@ LIB = textwrap.dedent("""\ """) +def modules(source: str) -> dict[bytes, tuple[int, int]] | None: + return rust_test_modules.modules(source.encode()) + + +def with_tests_of(planted: str, copy: str) -> str: + return rust_test_modules.with_tests_of(planted.encode(), copy.encode()).decode() + + def spelt(source: str) -> dict[str, str] | None: found = modules(source) - return None if found is None else {name: source[start:end] for name, (start, end) in found.items()} + return None if found is None else {name.decode(): source[start:end] for name, (start, end) in found.items()} class ModulesTest(unittest.TestCase): @@ -64,6 +73,26 @@ class ModulesTest(unittest.TestCase): """) self.assertEqual(spelt(source), {"tests": source[:source.index("}\nfn after")+1]}) + def test_reads_a_string_that_ends_in_backslashes_or_in_an_escaped_quote(self): + source = textwrap.dedent("""\ + #[cfg(test)] + mod tests { + const A: &str = r"\\"; + const B: &str = "\\\\"; + const C: &str = "a\\""; + const D: &str = "\\}\\}"; + } + fn after() {} + """) + self.assertEqual(spelt(source), {"tests": source[:source.index("}\nfn after") + 1]}) + + def test_leaves_out_a_module_a_comment_or_a_char_stands_before(self): + self.assertEqual(modules("// helpers\nmod util {}\nfn a() { let c = 'x'; }\nmod more {}\n"), {}) + + def test_lists_a_test_module_inside_a_module_that_is_no_test(self): + source = "mod outer {\n #[cfg(test)]\n mod inner {}\n fn after() {}\n}\n" + self.assertEqual(spelt(source), {"inner": "#[cfg(test)]\n mod inner {}"}) + def test_cannot_tell_the_modules_apart_where_two_hold_one_name(self): self.assertIsNone(modules("#[cfg(test)]\nmod tests {}\nfn a() { #[cfg(test)] mod tests {} }\n")) @@ -73,6 +102,14 @@ class ModulesTest(unittest.TestCase): self.assertIsNone(modules(source)) +class TellsApartTest(unittest.TestCase): + def test_tells_a_rust_file_apart_where_its_modules_can_be(self): + self.assertEqual([tells_apart("lib.rs", b"fn a() {}"), tells_apart("lib.rs", b"fn a() {")], [True, False]) + + def test_takes_a_file_of_another_language_whatever_it_holds(self): + self.assertTrue(tells_apart("calc.go", b"func a() {")) + + class WithTestsOfTest(unittest.TestCase): def test_takes_the_code_as_fixed_and_the_tests_as_planted(self): planted = LIB.replace("a + b", "a - b") @@ -94,6 +131,11 @@ class WithTestsOfTest(unittest.TestCase): fixed = "fn a() { 2 }\n#[cfg(test)]\nmod y { fn changed() {} }\n#[cfg(test)]\nmod x { fn changed() {} }\nfn c() {}\n" self.assertEqual(with_tests_of(planted, fixed), "fn a() { 2 }\n#[cfg(test)]\nmod y { fn u() {} }\n#[cfg(test)]\nmod x { fn t() {} }\nfn c() {}\n") + def test_puts_the_planted_modules_in_where_their_names_sort_in_file_order(self): + planted = "#[cfg(test)]\nmod a { 1 }\n#[cfg(test)]\nmod b { 22 }\nfn code() {}\n" + fixed = "#[cfg(test)]\nmod a { 333 }\n#[cfg(test)]\nmod b { 4444444 }\nfn fixed() {}\n" + self.assertEqual(with_tests_of(planted, fixed), "#[cfg(test)]\nmod a { 1 }\n#[cfg(test)]\nmod b { 22 }\nfn fixed() {}\n") + def test_takes_the_file_as_fixed_where_the_planted_modules_cannot_be_told_apart(self): self.assertEqual(with_tests_of("#[cfg(test)]\nmod tests {\n", "fixed {}"), "fixed {}") diff --git a/bin/task_bench/test_task_bench.py b/bin/task_bench/test_task_bench.py index afef522f..7bd3766b 100644 --- a/bin/task_bench/test_task_bench.py +++ b/bin/task_bench/test_task_bench.py @@ -735,6 +735,13 @@ class CheckedTreeTest(unittest.TestCase): checked_tree(planted, copy, str(self.root / "check")) self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"}) + def test_leaves_a_rust_link_as_a_link_whatever_it_points_at(self): + planted = self.tree("planted", {"lib.rs": "fn a() {}\n#[cfg(test)]\nmod tests {}\n", "real.txt": "text"}) + copy = self.tree("copy", {"real.txt": "text"}) + os.symlink("real.txt", os.path.join(copy, "lib.rs")) + checked_tree(planted, copy, str(self.root / "check")) + self.assertEqual((os.readlink(self.root / "check/lib.rs"), self.held("check")["real.txt"]), ("real.txt", "text")) + def test_copies_a_link_as_a_link(self): planted = self.tree("planted", {"calc.go": "bug"}) copy = self.tree("copy", {"calc.go": "fixed"}) -- 2.52.0 From 6719d10034c3f5a9cbe7458967c16dafce7864c9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 00:28:10 +0100 Subject: [PATCH 03/11] Read a Rust string with a regex and kill the surviving mutants --- bin/task_bench/rust_test_modules.py | 24 ++++++++++++++---------- bin/task_bench/test_rust_test_modules.py | 21 +++++++++------------ bin/task_bench/test_task_bench.py | 8 ++++---- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/bin/task_bench/rust_test_modules.py b/bin/task_bench/rust_test_modules.py index e950801a..fc245f5c 100644 --- a/bin/task_bench/rust_test_modules.py +++ b/bin/task_bench/rust_test_modules.py @@ -13,6 +13,7 @@ SCAN = re.compile( rb"""|\#\[cfg\(test\)\]""", re.DOTALL, ) +STRING_BODY = re.compile(rb'(?:[^"\\]|\\.)*"', re.DOTALL) COMMENT_EDGE = re.compile(rb"/\*|\*/") # What must follow the attribute for it to start an inline module: other attributes, a visibility, then `mod name {`. MODULE = re.compile(rb"\s*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?mod\s+(?P\w+)\s*\{") @@ -37,9 +38,9 @@ def modules(source: bytes) -> dict[bytes, tuple[int, int]] | None: if token == b"/*": position = after_comment(source, position) elif token == b'"': - position = after_string(source, position, b'"') + position = after_string(source, position) elif match.group("hashes") is not None: - position = after_string(source, position, b'"' + match.group("hashes"), raw=True) + position = after_raw_string(source, position, match.group("hashes")) elif token == b"{": depth += 1 elif token == b"}": @@ -63,14 +64,17 @@ def after_comment(source: bytes, position: int) -> int | None: return position if level == 0 else None -def after_string(source: bytes, position: int, closing: bytes, raw: bool = False) -> int | None: - """The offset after the string whose opening quote ends at position, None where it is never closed. A raw string has no escapes.""" - while (found := source.find(closing, position)) >= 0: - between = source[position:found] - if raw or (len(between) - len(between.rstrip(b"\\"))) % 2 == 0: - return found + len(closing) - position = found + 1 - return None +def after_string(source: bytes, position: int) -> int | None: + """The offset after the string whose opening quote ends at position, None where it is never closed. A backslash escapes the next byte.""" + closed = STRING_BODY.match(source, position) + return closed.end() if closed else None + + +def after_raw_string(source: bytes, position: int, hashes: bytes) -> int | None: + """The offset after the raw string, opened by `r`, hashes and a quote, that ends at position, None where it is never closed. It has no escapes.""" + closing = b'"' + hashes + found = source.find(closing, position) + return found + len(closing) if found >= 0 else None def with_tests_of(planted: bytes, copy: bytes) -> bytes: diff --git a/bin/task_bench/test_rust_test_modules.py b/bin/task_bench/test_rust_test_modules.py index d1f9630e..458246e8 100644 --- a/bin/task_bench/test_rust_test_modules.py +++ b/bin/task_bench/test_rust_test_modules.py @@ -73,18 +73,15 @@ class ModulesTest(unittest.TestCase): """) self.assertEqual(spelt(source), {"tests": source[:source.index("}\nfn after")+1]}) - def test_reads_a_string_that_ends_in_backslashes_or_in_an_escaped_quote(self): - source = textwrap.dedent("""\ - #[cfg(test)] - mod tests { - const A: &str = r"\\"; - const B: &str = "\\\\"; - const C: &str = "a\\""; - const D: &str = "\\}\\}"; - } - fn after() {} - """) - self.assertEqual(spelt(source), {"tests": source[:source.index("}\nfn after") + 1]}) + def test_reads_a_raw_string_that_ends_in_a_backslash(self): + source = "#[cfg(test)]\nmod tests {\n const A: &str = r\"\\\";\n}\nfn after() {}\n" + self.assertEqual(list(spelt(source)), ["tests"]) + + def test_reads_a_string_that_ends_in_two_backslashes_or_in_an_escaped_quote(self): + for literal in ('"\\\\"', '"a\\""', '"\\}\\}"'): + with self.subTest(literal=literal): + source = "#[cfg(test)]\nmod tests {\n const A: &str = " + literal + ";\n}\nfn after() {}\n" + self.assertEqual(list(spelt(source)), ["tests"]) def test_leaves_out_a_module_a_comment_or_a_char_stands_before(self): self.assertEqual(modules("// helpers\nmod util {}\nfn a() { let c = 'x'; }\nmod more {}\n"), {}) diff --git a/bin/task_bench/test_task_bench.py b/bin/task_bench/test_task_bench.py index 7bd3766b..eaf43441 100644 --- a/bin/task_bench/test_task_bench.py +++ b/bin/task_bench/test_task_bench.py @@ -736,11 +736,11 @@ class CheckedTreeTest(unittest.TestCase): self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"}) def test_leaves_a_rust_link_as_a_link_whatever_it_points_at(self): - planted = self.tree("planted", {"lib.rs": "fn a() {}\n#[cfg(test)]\nmod tests {}\n", "real.txt": "text"}) - copy = self.tree("copy", {"real.txt": "text"}) - os.symlink("real.txt", os.path.join(copy, "lib.rs")) + planted = self.tree("planted", {"z.rs": "fn a() {}\n#[cfg(test)]\nmod tests {}\n", "a.txt": "text"}) + copy = self.tree("copy", {"a.txt": "text"}) + os.symlink("a.txt", os.path.join(copy, "z.rs")) checked_tree(planted, copy, str(self.root / "check")) - self.assertEqual((os.readlink(self.root / "check/lib.rs"), self.held("check")["real.txt"]), ("real.txt", "text")) + self.assertEqual((os.readlink(self.root / "check/z.rs"), self.held("check")["a.txt"]), ("a.txt", "text")) def test_copies_a_link_as_a_link(self): planted = self.tree("planted", {"calc.go": "bug"}) -- 2.52.0 From 347368040e12e891fb79368dcf0984585d92a273 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 00:53:45 +0100 Subject: [PATCH 04/11] End a raw string at its first closing quote by regex --- bin/task_bench/rust_test_modules.py | 5 ++--- bin/task_bench/test_rust_test_modules.py | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/task_bench/rust_test_modules.py b/bin/task_bench/rust_test_modules.py index fc245f5c..18641c03 100644 --- a/bin/task_bench/rust_test_modules.py +++ b/bin/task_bench/rust_test_modules.py @@ -72,9 +72,8 @@ def after_string(source: bytes, position: int) -> int | None: def after_raw_string(source: bytes, position: int, hashes: bytes) -> int | None: """The offset after the raw string, opened by `r`, hashes and a quote, that ends at position, None where it is never closed. It has no escapes.""" - closing = b'"' + hashes - found = source.find(closing, position) - return found + len(closing) if found >= 0 else None + closed = re.compile(b'"' + hashes).search(source, position) + return closed.end() if closed else None def with_tests_of(planted: bytes, copy: bytes) -> bytes: diff --git a/bin/task_bench/test_rust_test_modules.py b/bin/task_bench/test_rust_test_modules.py index 458246e8..1ec7a883 100644 --- a/bin/task_bench/test_rust_test_modules.py +++ b/bin/task_bench/test_rust_test_modules.py @@ -77,6 +77,10 @@ class ModulesTest(unittest.TestCase): source = "#[cfg(test)]\nmod tests {\n const A: &str = r\"\\\";\n}\nfn after() {}\n" self.assertEqual(list(spelt(source)), ["tests"]) + def test_ends_a_raw_string_at_its_first_closing_quote(self): + source = "#[cfg(test)]\nmod tests {\n const A: &str = r#\"x\"#;\n}\nconst B: &str = r#\"y\"#;\n" + self.assertEqual(list(spelt(source)), ["tests"]) + def test_reads_a_string_that_ends_in_two_backslashes_or_in_an_escaped_quote(self): for literal in ('"\\\\"', '"a\\""', '"\\}\\}"'): with self.subTest(literal=literal): -- 2.52.0 From cecabf324a338e4b9882eabcbc98b034301e8ae4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 01:30:46 +0100 Subject: [PATCH 05/11] Answer review: keep Rust test modules for bugs only, order imports, reword --- bin/task_bench/main.py | 12 ++++++++---- bin/task_bench/runs.py | 19 ++++++++++--------- bin/task_bench/rust_test_modules.py | 21 +++++++++++---------- bin/task_bench/tasks.py | 5 +++-- bin/task_bench/test_rust_test_modules.py | 14 +++++++------- bin/task_bench/test_task_bench.py | 11 ++++++++++- 6 files changed, 49 insertions(+), 33 deletions(-) diff --git a/bin/task_bench/main.py b/bin/task_bench/main.py index b9b1c74d..70eeb5fb 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -30,8 +30,11 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream. reaches api.anthropic.com and nothing else. A fix ends after 30 minutes. - Check. The test command runs over the planted tree with each file that is no test as Haiku left it; a fix passes where it exits 0. A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. In a Rust file, each - inline `#[cfg(test)]` module stands as the planted file has it, and the rest is as Haiku left it. A Rust mutant is passed over - where its file's modules cannot be told apart, as where two share a name or a brace, string or comment is never closed. + inline `#[cfg(test)]` module stands as the planted file has it, and the rest is as Haiku left it. Where Haiku's file lacks one of + those modules, or its modules cannot be told apart, the planted file stands whole; where the planted file's cannot be told apart, + Haiku's stands. A Rust mutant whose file's modules cannot be told apart, as where two share a name or a brace, string or comment + is never closed, is passed over. A Rust test in a file of its own, as `#[cfg(test)] mod tests;` names, counts, since the bench + tells no such file from code. --image is the project's development image, such as golang:1.27.4. The bench adds Claude Code to it, as its installer installs it, so the image needs curl and bash; the result names the version. Haiku works in that image. So does --test: sh runs that text at @@ -68,7 +71,8 @@ project's config names as `bench-tasks`, in the order of their names. Each holds A feature counts where, at the base and at the head, the test command fails with the acceptance tests in the tree, and passes once the reference patch is applied too. The bench passes over any other feature, and the report says which and why. Haiku works in a copy of the side's tree without the `bench-tasks` folder. A build passes where the test command exits 0 over the -side's tree with each file that is no test as Haiku left it, and the acceptance tests put over that. The reference patch is +side's tree with each file that is no test as Haiku left it, a Rust file's test modules included, and the acceptance tests put +over that. The reference patch is checked the same way, so a test or a `testdata` file it adds doesn't count either. Keep the folder where the project's own test command doesn't find the acceptance tests, which fail by design: outside the checkout, or in a folder the test runner skips, as Go skips `testdata`. The table then has a row per feature and side, and `-` for the reads. No mutation tool @@ -174,7 +178,6 @@ import uuid from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, SHIPPED, Task, tests_in_copy from task_bench.planted_mutant import bug_at_sides, Mutant -from task_bench.rust_test_modules import tells_apart from claude_code.reply import Claude from task_bench.bench_folder import clear_left, held from task_bench.runs import closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TimedOut, TOKEN, WORK @@ -194,6 +197,7 @@ from larv_review.history_commands import read_places from task_bench.shipped_features import read_shipped, shipped_tasks, ShippedFeatures from task_bench.record_figures import recorded_bench from run_heavy.capped_docker import SHARE_VARIABLE +from task_bench.rust_test_modules import tells_apart USAGE = "usage: task-bench --image --test [--base ] [--head ] [--prefix ] [--seed ] [--bugs ] [--runs ] [--record-figures], or task-bench --tasks features|data-sources --image --test [--base ] [--head ] [--runs ] [--record-figures], or task-bench --tasks shipped-features --image --test [--base ] [--head ] [--shipped ] [--runs ] [--record-figures], or task-bench gather" # A panel of three readers, seated as the README's audience, picked these options on 2026-11-21, each 3 to 0. diff --git a/bin/task_bench/runs.py b/bin/task_bench/runs.py index aba3dc63..28337af8 100644 --- a/bin/task_bench/runs.py +++ b/bin/task_bench/runs.py @@ -11,8 +11,8 @@ import typing from mutate_changes.tool_process import failed, Ran from failure import Failure from mutate_changes.changed_lines import is_test -from task_bench.rust_test_modules import with_tests_of from task_bench.api_proxy import PORT +from task_bench.rust_test_modules import with_tests_of MODEL = "claude-haiku-5-5" # Where each run's container mounts its copy of the code, and its home folder: the paths in a run's stream start there. @@ -164,10 +164,11 @@ def in_tree(containers: Containers, tree: str) -> list[str]: return [*containers.limits(), "--user", containers.user, "--env", f"HOME={HOME}", "--volume", f"{tree}:{WORK}", "--workdir", WORK] -def checked_tree(planted: str, copy: str, into: str) -> None: +def checked_tree(planted: str, copy: str, into: str, rust_tests_planted: bool = True) -> None: """Makes at `into` the tree the tests check a fix in: `planted`, the code with the bug as Haiku got it, with each file that is no test as `copy` holds it after the fix. So a test Haiku changed, removed or added doesn't count, and neither does a file under - a `testdata` folder, where Go's tests keep the output they expect. A Rust file's `#[cfg(test)]` modules are the planted file's. + a `testdata` folder, where Go's tests keep the output they expect. Where rust_tests_planted, a Rust file's inline `#[cfg(test)]` + modules stand as the planted file has them too, as `with_tests_of` says. Raises OSError where a file cannot be copied.""" shutil.copytree(planted, into, symlinks=True) @@ -185,19 +186,19 @@ def checked_tree(planted: str, copy: str, into: str) -> None: with contextlib.suppress(FileNotFoundError): os.unlink(target) shutil.copy2(os.path.join(copy, path), target, follow_symlinks=False) - if path.endswith(".rs"): + if rust_tests_planted and path.endswith(".rs"): keep_rust_tests(os.path.join(planted, path), target) def keep_rust_tests(planted_file: str, target: str) -> None: - """Puts into the Rust file at target, a copy of Haiku's, the test modules of planted_file; see `with_tests_of`. A file the planted - tree lacks, as a link or as a file, is left as it is, since it has no test to keep. + """Puts into the Rust file at target, a copy of Haiku's, the test modules of planted_file, as `with_tests_of` says. A planted tree + without the file has no test module, so a file Haiku added keeps none. A link, planted's or Haiku's, is left as it is. Raises OSError where a file cannot be read or written.""" - if os.path.islink(planted_file) or os.path.islink(target) or not os.path.isfile(planted_file): + if os.path.islink(planted_file) or os.path.islink(target): return - planted, copied = (pathlib.Path(file).read_bytes() for file in (planted_file, target)) - pathlib.Path(target).write_bytes(with_tests_of(planted, copied)) + planted = pathlib.Path(planted_file).read_bytes() if os.path.isfile(planted_file) else b"" + pathlib.Path(target).write_bytes(with_tests_of(planted, pathlib.Path(target).read_bytes())) def of_tests(path: str) -> bool: diff --git a/bin/task_bench/rust_test_modules.py b/bin/task_bench/rust_test_modules.py index 18641c03..71907e3a 100644 --- a/bin/task_bench/rust_test_modules.py +++ b/bin/task_bench/rust_test_modules.py @@ -1,5 +1,5 @@ -"""The `#[cfg(test)]` modules of a Rust file, which stand in the file of the code they test: where each is, and a file with the modules -of another file put in place of its own. A file is bytes, since a Rust file is UTF-8 and a module is found by ASCII text alone.""" +"""The `#[cfg(test)]` modules of a Rust file, which stand in the file of the code they test. Here are where each is, and a file with +the modules of another file put in place of its own. A file is bytes: a Rust file is UTF-8, and a module is found by ASCII text alone.""" import re # What the scan steps over or stops at. A string, a char and a comment may hold a brace. @@ -15,19 +15,19 @@ SCAN = re.compile( ) STRING_BODY = re.compile(rb'(?:[^"\\]|\\.)*"', re.DOTALL) COMMENT_EDGE = re.compile(rb"/\*|\*/") -# What must follow the attribute for it to start an inline module: other attributes, a visibility, then `mod name {`. +# What follows the attribute that starts an inline module: any other attributes, an optional visibility, then `mod name {`. MODULE = re.compile(rb"\s*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?mod\s+(?P\w+)\s*\{") def tells_apart(path: str, source: bytes) -> bool: - """Whether source, the file at path, is no Rust file or has test modules that `modules` tells apart.""" + """Whether source, the file at path, is no Rust file, or holds test modules that `modules` can tell apart.""" return not path.endswith(".rs") or modules(source) is not None def modules(source: bytes) -> dict[bytes, tuple[int, int]] | None: - """Each inline `#[cfg(test)] mod name { ... }` of source by its name, as the offsets from its attribute to its closing brace. A - module inside a test module is not listed. None where the modules cannot be told apart: two hold one name, or a brace, string or - comment is never closed. A `#[cfg(test)]` on anything but an inline module is not listed.""" + """Each inline `#[cfg(test)] mod name { ... }` of source by its name, with the offsets of its first byte, the attribute's, and of the + byte after its closing brace. A module inside a test module and a `#[cfg(test)]` on anything but an inline module are not listed. + None where the modules cannot be told apart: two share a name, or a brace, string or comment is never closed.""" found: dict[bytes, tuple[int, int]] = {} depth = 0 # The module being read: its name, the offset of its attribute and the depth outside it. @@ -71,14 +71,15 @@ def after_string(source: bytes, position: int) -> int | None: def after_raw_string(source: bytes, position: int, hashes: bytes) -> int | None: - """The offset after the raw string, opened by `r`, hashes and a quote, that ends at position, None where it is never closed. It has no escapes.""" + """The offset after the raw string, `r` or `br` then hashes and a quote, whose opening ends at position, None where it is never closed. + It has no escapes.""" closed = re.compile(b'"' + hashes).search(source, position) return closed.end() if closed else None def with_tests_of(planted: bytes, copy: bytes) -> bytes: - """copy with each test module as planted holds it, and each test module planted lacks left out. So a test a fix changed, removed - or added doesn't count. + """copy with each of its test modules replaced by the one of that name in planted, and each that planted lacks left out. So a test a + fix changed, removed or added doesn't count. Where planted's modules cannot be told apart, copy is returned as it is. Where copy's cannot, or copy lacks one of planted's, planted is returned: Haiku's file has no module to put them in.""" diff --git a/bin/task_bench/tasks.py b/bin/task_bench/tasks.py index adb4a3f9..541098b7 100644 --- a/bin/task_bench/tasks.py +++ b/bin/task_bench/tasks.py @@ -114,10 +114,11 @@ def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path) -> Ra def check_made(tree: str, copy: str, check: str, acceptance: str | None) -> None: """Makes at check the tree that checks what was built in copy, a copy of tree: `checked_tree`'s, then a feature's acceptance - tests over it, where acceptance names their folder. A run of Haiku's and a feature's reference patch are checked alike. + tests over it, where acceptance names their folder. A run of Haiku's and a feature's reference patch are checked alike. Only a + task without acceptance tests has its Rust test modules kept as the tree has them: a feature's change may update such a module. Raises OSError where a file cannot be copied.""" - checked_tree(tree, copy, check) + checked_tree(tree, copy, check, rust_tests_planted=not acceptance) if acceptance: with_acceptance(check, acceptance) diff --git a/bin/task_bench/test_rust_test_modules.py b/bin/task_bench/test_rust_test_modules.py index 1ec7a883..1497ea5a 100644 --- a/bin/task_bench/test_rust_test_modules.py +++ b/bin/task_bench/test_rust_test_modules.py @@ -43,21 +43,21 @@ class ModulesTest(unittest.TestCase): def test_holds_each_test_module_from_its_attribute_to_its_closing_brace(self): self.assertEqual(spelt(LIB), {"tests": LIB[LIB.index("#[cfg(test)]"):LIB.rindex("}") + 1]}) - def test_holds_none_where_the_file_has_no_test_module(self): + def test_lists_no_module_where_the_file_has_no_test_module(self): self.assertEqual(modules("fn main() {}\n"), {}) def test_takes_a_module_with_a_visibility_and_another_attribute(self): source = "#[cfg(test)]\n#[allow(dead_code)]\npub(crate) mod checks {\n}\nfn after() {}\n" self.assertEqual(spelt(source), {"checks": source[:source.index("}") + 1]}) - def test_leaves_out_what_the_attribute_is_not_on_an_inline_module(self): + def test_lists_no_module_where_the_attribute_is_on_anything_but_an_inline_module(self): self.assertEqual(modules("#[cfg(test)]\nmod tests;\n#[cfg(test)]\nuse std::fmt;\n#[cfg(test)]\nfn helper() {}\n"), {}) - def test_leaves_out_a_module_inside_a_module(self): + def test_lists_no_module_inside_a_test_module(self): source = "#[cfg(test)]\nmod outer {\n #[cfg(test)]\n mod inner {}\n}\n" self.assertEqual(list(spelt(source)), ["outer"]) - def test_reads_past_a_brace_in_a_string_a_char_or_a_comment(self): + def test_reads_past_a_brace_in_a_string_a_char_a_comment_or_an_escape(self): source = textwrap.dedent("""\ #[cfg(test)] mod tests { @@ -87,7 +87,7 @@ class ModulesTest(unittest.TestCase): source = "#[cfg(test)]\nmod tests {\n const A: &str = " + literal + ";\n}\nfn after() {}\n" self.assertEqual(list(spelt(source)), ["tests"]) - def test_leaves_out_a_module_a_comment_or_a_char_stands_before(self): + def test_lists_no_plain_module_that_follows_a_comment_or_a_char(self): self.assertEqual(modules("// helpers\nmod util {}\nfn a() { let c = 'x'; }\nmod more {}\n"), {}) def test_lists_a_test_module_inside_a_module_that_is_no_test(self): @@ -104,7 +104,7 @@ class ModulesTest(unittest.TestCase): class TellsApartTest(unittest.TestCase): - def test_tells_a_rust_file_apart_where_its_modules_can_be(self): + def test_tells_the_modules_of_a_rust_file_apart_where_they_can_be(self): self.assertEqual([tells_apart("lib.rs", b"fn a() {}"), tells_apart("lib.rs", b"fn a() {")], [True, False]) def test_takes_a_file_of_another_language_whatever_it_holds(self): @@ -132,7 +132,7 @@ class WithTestsOfTest(unittest.TestCase): fixed = "fn a() { 2 }\n#[cfg(test)]\nmod y { fn changed() {} }\n#[cfg(test)]\nmod x { fn changed() {} }\nfn c() {}\n" self.assertEqual(with_tests_of(planted, fixed), "fn a() { 2 }\n#[cfg(test)]\nmod y { fn u() {} }\n#[cfg(test)]\nmod x { fn t() {} }\nfn c() {}\n") - def test_puts_the_planted_modules_in_where_their_names_sort_in_file_order(self): + def test_puts_in_planted_modules_whose_length_differs_from_the_fixed_ones(self): planted = "#[cfg(test)]\nmod a { 1 }\n#[cfg(test)]\nmod b { 22 }\nfn code() {}\n" fixed = "#[cfg(test)]\nmod a { 333 }\n#[cfg(test)]\nmod b { 4444444 }\nfn fixed() {}\n" self.assertEqual(with_tests_of(planted, fixed), "#[cfg(test)]\nmod a { 1 }\n#[cfg(test)]\nmod b { 22 }\nfn fixed() {}\n") diff --git a/bin/task_bench/test_task_bench.py b/bin/task_bench/test_task_bench.py index eaf43441..e85687cc 100644 --- a/bin/task_bench/test_task_bench.py +++ b/bin/task_bench/test_task_bench.py @@ -727,7 +727,7 @@ class CheckedTreeTest(unittest.TestCase): planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 1 }\n"}) copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests {}\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"}) checked_tree(planted, copy, str(self.root / "check")) - self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"}) + self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "\nfn c() {}\n"}) def test_takes_the_planted_rust_file_where_the_fix_deleted_its_test_module(self): planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"}) @@ -742,6 +742,15 @@ class CheckedTreeTest(unittest.TestCase): checked_tree(planted, copy, str(self.root / "check")) self.assertEqual((os.readlink(self.root / "check/z.rs"), self.held("check")["a.txt"]), ("a.txt", "text")) + def test_a_task_with_acceptance_tests_takes_its_rust_test_modules_as_fixed(self): + planted = self.tree("planted", {"lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn old() {} }\n"}) + copy = self.tree("copy", {"lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn new() {} }\n"}) + acceptance = self.tree("acceptance", {"tests/feature.rs": "accepts"}) + main.check_made(planted, copy, str(self.root / "kept"), None) + main.check_made(planted, copy, str(self.root / "check"), acceptance) + self.assertEqual(self.held("kept"), {"lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn old() {} }\n"}) + self.assertEqual(self.held("check"), {"lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn new() {} }\n", "tests/feature.rs": "accepts"}) + def test_copies_a_link_as_a_link(self): planted = self.tree("planted", {"calc.go": "bug"}) copy = self.tree("copy", {"calc.go": "fixed"}) -- 2.52.0 From 42b23ac235873d33f369683fc53e652fe8404d1f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 01:32:09 +0100 Subject: [PATCH 06/11] File item: leave out of a task-bench fix a change Haiku makes to a Rust test in a file of its own --- todo.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/todo.md b/todo.md index 992c34f4..3b3db7b6 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 539` +`Next ID = 540` ## Items @@ -23,6 +23,7 @@ | 523 | 0.17.0 | | | **Make the security pass and stability-reviewer check that a new secret's docs name its scope and its reach, such as the other repositories its account can use.** | 1 | 1 | 2 | 2 | 1 | 1.1 by 2 | 0.9 | | 537 | 0.17.0 | | | **Flag regexes that use `$` to validate a whole input, since `$` also matches before a final newline.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.9 | | 538 | 0.17.0 | | | **Flag validation that checks a value other than the one the code goes on to use, such as before trimming, stripping or converting it.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.9 | +| 539 | 0.17.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test kept in a file of its own.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 | | 480 | 0.18.0 | | owner | **Resolve every path the tools use in one module: the release root (the folder the running code ships in), the config folder, the state folder and the Claude home. Then only that module names `~/.claude`, and the loop still runs from `~/.claude`.** | 3 | 2 | 3 | 6 | 6 | 1.6 by 3, code health by 3 | 2.4 | | 481 | 0.18.0 | 480 | owner | **Put the release's tools on `PATH` for every session the loop starts and every hook it runs, name them bare in the prose in place of `~/.claude/bin/`, and refuse the old spelling in new prose.** | 3 | 2 | 3 | 6 | 6 | 1.4 by 2, code health by 2 | 1.6 | | 482 | 0.19.0 | 478, 481 | owner | **Install the setup with `uv tool install` from a release tag, with `do-release` and `do-epic` on `PATH`, and replace `deploy-release` with `do-release self-update`.** | 3 | 2 | 3 | 6 | 7 | 1.6 by 4, 1.3 by 3 | 1.3 | @@ -215,6 +216,18 @@ An outside human reviewer found input validation that checked the value the clie Touches: - `agents/stability-reviewer.md`: `### 5. Edge Cases & Input Validation` (small) +### 539. Leave out of a `task-bench` fix a change Haiku makes to a Rust test kept in a file of its own. + +Rust may keep its unit tests out of line: `#[cfg(test)] mod tests;` in `src/lib.rs`, the tests in `src/tests.rs`. `mutate_changes.changed_lines.is_test` tells a test by a folder named `test`, `tests` or `__tests__`, or by a file name such as `test_*.py` or `*_test.go`, so `src/tests.rs` counts as code, and `checked_tree` in `bin/task_bench/runs.py` takes it as Haiku left it. A fix that edits or deletes the failing test there passes. The help's Check paragraph says so. It holds at the base and at the head alike. + +Recommended: treat as a test a `.rs` file that a `#[cfg(test)] mod ;` declaration in another file of the planted tree names (src/.rs or src//mod.rs, beside the declaring file), found with the scanner in `bin/task_bench/rust_test_modules.py`; where the file cannot be found, pass the mutant over. A product-owner / stability finding on item 532's chunk raised this. Changing `is_test` itself would change what `mutate-changes` skips, so keep the change inside task-bench. + +Touches: +- `bin/task_bench/runs.py`: `of_tests`, `checked_tree` (small) +- `bin/task_bench/rust_test_modules.py` +- `bin/task_bench/test_task_bench.py` +- `bin/task_bench/main.py`: lines 30-37 + ### 480. Resolve every path the tools use in one module: the release root (the folder the running code ships in), the config folder, the state folder and the Claude home. Then only that module names `~/.claude`, and the loop still runs from `~/.claude`. Part of the standalone-install plan lilleman approved on 2026-11-20. `do-release` and `do-epic` stand for the names item 478 picks. Today about 160 references in some 40 modules name `~/.claude`; `bin/loop_state/paths.py` holds a few. This item changes no behaviour. -- 2.52.0 From 90d88b9967a4105cbad5e229a393fbad4d1bee58 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 01:32:20 +0100 Subject: [PATCH 07/11] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20order=20imp?= =?UTF-8?q?orts,=20state=20in=20the=20help=20which=20Rust=20files=20count,?= =?UTF-8?q?=20file=20item=20539=20for=20out-of-line=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From d3fa35372d669d1006862ddde75c6e7716e153cc Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 01:32:20 +0100 Subject: [PATCH 08/11] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20keep=20R?= =?UTF-8?q?ust=20test=20modules=20for=20bugs=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From b0c5aa3390ed17e94e35283c489eee6cd61c1aa8 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 01:32:20 +0100 Subject: [PATCH 09/11] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=208=20=F0=9F=9F=A1=20(0=20misread);=20reword=20th?= =?UTF-8?q?e=20help,=20docstrings=20and=20test=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 7c01eb1f8b03d3ab273a3b858abbda0d75d998f6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 02:03:10 +0100 Subject: [PATCH 10/11] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20keep=20a=20?= =?UTF-8?q?Rust=20file=20whose=20modules=20cannot=20be=20told=20apart=20as?= =?UTF-8?q?=20Haiku=20left=20it=20where=20the=20planted=20file=20has=20no?= =?UTF-8?q?=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/task_bench/main.py | 6 +++--- bin/task_bench/rust_test_modules.py | 7 ++++--- bin/task_bench/test_rust_test_modules.py | 5 +++++ bin/task_bench/test_task_bench.py | 7 +++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bin/task_bench/main.py b/bin/task_bench/main.py index 70eeb5fb..4d4f6ac8 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -30,9 +30,9 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream. reaches api.anthropic.com and nothing else. A fix ends after 30 minutes. - Check. The test command runs over the planted tree with each file that is no test as Haiku left it; a fix passes where it exits 0. A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. In a Rust file, each - inline `#[cfg(test)]` module stands as the planted file has it, and the rest is as Haiku left it. Where Haiku's file lacks one of - those modules, or its modules cannot be told apart, the planted file stands whole; where the planted file's cannot be told apart, - Haiku's stands. A Rust mutant whose file's modules cannot be told apart, as where two share a name or a brace, string or comment + inline `#[cfg(test)]` module stands as the planted file has it, and the rest is as Haiku left it. Where the planted file has such + modules and Haiku's file lacks one of them, or its modules cannot be told apart, the planted file stands whole; where the planted + file has none, or its modules cannot be told apart, Haiku's stands. A Rust mutant whose file's modules cannot be told apart, as where two share a name or a brace, string or comment is never closed, is passed over. A Rust test in a file of its own, as `#[cfg(test)] mod tests;` names, counts, since the bench tells no such file from code. diff --git a/bin/task_bench/rust_test_modules.py b/bin/task_bench/rust_test_modules.py index 71907e3a..cdb5381e 100644 --- a/bin/task_bench/rust_test_modules.py +++ b/bin/task_bench/rust_test_modules.py @@ -81,10 +81,11 @@ def with_tests_of(planted: bytes, copy: bytes) -> bytes: """copy with each of its test modules replaced by the one of that name in planted, and each that planted lacks left out. So a test a fix changed, removed or added doesn't count. - Where planted's modules cannot be told apart, copy is returned as it is. Where copy's cannot, or copy lacks one of planted's, - planted is returned: Haiku's file has no module to put them in.""" + Where planted's modules cannot be told apart, or planted has none and copy's cannot be told apart, copy is returned as it is. Where + planted has some and copy's cannot be told apart, or copy lacks one of planted's, planted is returned: Haiku's file has no module + to put them in.""" before, after = modules(planted), modules(copy) - if before is None: + if before is None or (after is None and not before): return copy if after is None or before.keys() - after.keys(): return planted diff --git a/bin/task_bench/test_rust_test_modules.py b/bin/task_bench/test_rust_test_modules.py index 1497ea5a..6db68697 100644 --- a/bin/task_bench/test_rust_test_modules.py +++ b/bin/task_bench/test_rust_test_modules.py @@ -143,6 +143,11 @@ class WithTestsOfTest(unittest.TestCase): def test_takes_the_planted_file_where_the_fixed_modules_cannot_be_told_apart(self): self.assertEqual(with_tests_of(LIB, "fn broken() {"), LIB) + def test_takes_the_file_as_fixed_where_planted_has_no_module_and_the_fixed_modules_cannot_be_told_apart(self): + for planted in ("", "fn a() {}\n"): + with self.subTest(planted=planted): + self.assertEqual(with_tests_of(planted, "fn broken() {"), "fn broken() {") + if __name__ == "__main__": unittest.main() diff --git a/bin/task_bench/test_task_bench.py b/bin/task_bench/test_task_bench.py index e85687cc..b8527059 100644 --- a/bin/task_bench/test_task_bench.py +++ b/bin/task_bench/test_task_bench.py @@ -735,6 +735,13 @@ class CheckedTreeTest(unittest.TestCase): checked_tree(planted, copy, str(self.root / "check")) self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"}) + def test_takes_a_rust_file_the_fix_added_as_it_is_where_its_modules_cannot_be_told_apart(self): + planted = self.tree("planted", {"src/lib.rs": "fn a() {}\n"}) + added = "#[cfg(test)]\nmod tests {}\nfn b() { #[cfg(test)] mod tests {} }\n" + copy = self.tree("copy", {"src/lib.rs": "fn a() {}\n", "src/new.rs": added}) + checked_tree(planted, copy, str(self.root / "check")) + self.assertEqual(self.held("check")["src/new.rs"], added) + def test_leaves_a_rust_link_as_a_link_whatever_it_points_at(self): planted = self.tree("planted", {"z.rs": "fn a() {}\n#[cfg(test)]\nmod tests {}\n", "a.txt": "text"}) copy = self.tree("copy", {"a.txt": "text"}) -- 2.52.0 From 3fd7a841c7612e0a027af46a5e1023a9e5f2d1f7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 26 Nov 2026 02:49:46 +0100 Subject: [PATCH 11/11] Finish item 532 in the plan --- CHANGELOG.md | 1 + todo.md | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d42d46..3fe7fa8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- task-bench leaves out of a fix a change Haiku makes to a Rust test module that stands in the file of the code it tests, and passes over a Rust mutant whose test modules it cannot tell apart. - loop-claude starts a chunk on a fresh session where its session's transcript is empty, in place of resuming a session claude cannot find, which failed three times and waited for the human. - larv-review's prose pass takes a second round after a fix that rewrites a claim a command or a source file can check, such as generated output, a number or a licence term. - `deploy-release --cut-patch ` cuts the newest tag's next patch release, such as 0.15.2 after v0.15.1, holding only the commits named, for a fix that must ship before main's other unreleased work. It runs `ci.sh` on the patch, tags and pushes it, merges the tag back into main through a pull request, and moves `~/.claude` to it. Plain `--cut` now refuses a patch release, and a release review counts only for a release later than the last cut. diff --git a/todo.md b/todo.md index 57c4301f..73564e31 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 524 | 0.16.0 | | owner | **Write fejkdata's first six bench features, each a spec, acceptance tests in Go and a reference patch that builds it, in the `bench-tasks` folder its config names.** | 3 | 2 | 1 | 4 | 6 | 1.1 by 3 | 0.5 | -| 532 | 0.16.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test that stands in the file of the code it tests.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 | | 527 | 0.16.0 | | owner | **Plant bugs for `task-bench` in TypeScript, from the mutants Stryker kills.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 1 | 0.3 | | 528 | 0.16.0 | | owner | **Plant bugs for `task-bench` in PHP, from the mutants Infection kills.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 1 | 0.3 | | 525 | 0.16.0 | | owner | **Write fejkdata's first five source-data tasks for `task-bench`, each a seeded register for a made-up country, a spec, a checker and a reference patch, in the `bench-tasks` folder its config names.** | 3 | 2 | 1 | 4 | 7 | 1.1 by 3 | 0.3 | @@ -126,17 +125,6 @@ The second part of item 504, which says what a bench feature is and when a run c Done when `task-bench` counts a run of each: its acceptance tests fail at fejkdata's base and head and pass with its reference patch. The six land in fejkdata's checkout or its config folder, wherever its `bench-tasks` setting points, so the item changes no file of this repo and carries no `Touches:` list. About 1,000 lines of Go and specs. -### 532. Leave out of a `task-bench` fix a change Haiku makes to a Rust test that stands in the file of the code it tests. - -Today the check takes each file that is no test as Haiku left it, and `is_test` tells a test by its file's path. Rust keeps unit tests in the source file, in a `#[cfg(test)]` module, so a fix that edits or deletes the failing test there passes. The help's Check paragraph says so. It holds at the base and at the head alike, so the head's change against the base still compares like with like; the Passed column of a Rust bench counts such a run as a fix. - -Recommended: keep each `#[cfg(test)]` module of a Rust file as the planted tree has it, and take the rest of the file from Haiku's copy; where the module cannot be told apart, pass the mutant over. Passing over every mutant that a test in a source file kills would leave most Rust bugs out, since unit tests are where most Rust tests stand. A product-owner finding on item 526's chunk raised this. - -Touches: -- `bin/task_bench/runs.py`: `checked_tree`, `of_tests` (small) -- `bin/task_bench/test_task_bench.py` -- `bin/task_bench/main.py`: lines 30-33 - ### 527. Plant bugs for `task-bench` in TypeScript, from the mutants Stryker kills. Stryker runs over the changed lines only today. Run it over the files that hold the seats' places, at the tree's top without git, and turn each killed mutant into the lines it changes, read from its JSON report. Tell Haiku the failure the project's test runner prints, without the test's name or file. Check the module against the tool's real output on a small project in a container, since this repo holds no TypeScript. -- 2.52.0