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/bin/task_bench/main.py b/bin/task_bench/main.py index eee0812c..b19aa4b4 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -29,8 +29,12 @@ 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. 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. --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 @@ -67,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 @@ -196,6 +201,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. @@ -493,7 +499,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 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 842debd8..28337af8 100644 --- a/bin/task_bench/runs.py +++ b/bin/task_bench/runs.py @@ -12,6 +12,7 @@ from mutate_changes.tool_process import failed, Ran from failure import Failure from mutate_changes.changed_lines import is_test 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. @@ -163,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 `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) @@ -184,6 +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 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, 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): + return + 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 new file mode 100644 index 00000000..cdb5381e --- /dev/null +++ b/bin/task_bench/rust_test_modules.py @@ -0,0 +1,96 @@ +"""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. +SCAN = re.compile( + rb"""//[^\n]*""" + rb"""|/\*""" + rb"""|(?\#*)\"""" + rb"""|\"""" + rb"""|'(?:\\(?:u\{[0-9a-fA-F_]+\}|x[0-9a-fA-F]{2}|.)|[^\\'\n])'""" + rb"""|[{}]""" + rb"""|\#\[cfg\(test\)\]""", + re.DOTALL, +) +STRING_BODY = re.compile(rb'(?:[^"\\]|\\.)*"', re.DOTALL) +COMMENT_EDGE = re.compile(rb"/\*|\*/") +# 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 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, 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. + 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 == b"/*": + position = after_comment(source, position) + elif token == b'"': + position = after_string(source, position) + elif match.group("hashes") is not None: + position = after_raw_string(source, position, match.group("hashes")) + elif token == b"{": + depth += 1 + elif token == b"}": + depth -= 1 + if inside and depth == inside[2]: + if inside[0] in found: + return None + 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 + return found if position is not None and depth == 0 and inside is None else None + + +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() == b"/*" else -1 + position = match.end() + return position if level == 0 else 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, `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 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, 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 or (after is None and not before): + return copy + if after is None or before.keys() - after.keys(): + return planted + 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/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 new file mode 100644 index 00000000..6db68697 --- /dev/null +++ b/bin/task_bench/test_rust_test_modules.py @@ -0,0 +1,153 @@ +"""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 import rust_test_modules +from task_bench.rust_test_modules import tells_apart + +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 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.decode(): 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_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_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_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_a_comment_or_an_escape(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_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_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): + source = "#[cfg(test)]\nmod tests {\n const A: &str = " + literal + ";\n}\nfn after() {}\n" + self.assertEqual(list(spelt(source)), ["tests"]) + + 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): + 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")) + + 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 TellsApartTest(unittest.TestCase): + 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): + 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") + 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_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") + + 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) + + 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 c40d6ee7..b8527059 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,41 @@ 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": "\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_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"}) + 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/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"}) diff --git a/todo.md b/todo.md index f8213299..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 | @@ -23,6 +22,7 @@ | 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 | | 541 | 0.17.0 | | | **Find a Gitea pull request by its branch and head however many pull requests are newer, so `chunk-pr clean`, `chunk-pr merge` and `chunk-preflight` see an older one.** | 2 | 2 | 3 | 5 | 2 | 1 by 2 | 0.8 | +| 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 | @@ -125,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. @@ -213,6 +202,18 @@ Touches: - `bin/forge/pulls.py`: `pull_at` - `bin/forge/test_forge.py` +### 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.