From 4620365931440b15b051d3a210a3224f11d1838e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 23 Nov 2026 23:14:36 +0100 Subject: [PATCH 1/6] Plant a mutant in a Python file whose lines end in CRLF --- bin/task_bench/planted_mutant.py | 12 +++++++++--- bin/task_bench/test_planted_mutant.py | 10 ++++++++++ bin/task_bench/test_python_bugs.py | 10 +++++++++- docs/reading-cost.md | 13 +++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/bin/task_bench/planted_mutant.py b/bin/task_bench/planted_mutant.py index a1fe0c7a..f47cca80 100644 --- a/bin/task_bench/planted_mutant.py +++ b/bin/task_bench/planted_mutant.py @@ -21,12 +21,18 @@ class Mutant(typing.NamedTuple): def mutated(source: bytes, mutant: Mutant) -> bytes | None: - """A file's source with the mutant applied, or None where the lines the mutant changes don't stand at the mutant's line.""" + """A file's source with the mutant applied, or None where the lines the mutant changes don't stand at the mutant's line. + + The mutant's lines come from a file read as text, so they hold no `\\r`: they match a file's lines without theirs, and go in with + the line end the file uses.""" lines = source.split(b"\n") first = mutant.line - 1 - if not 0 <= first <= len(lines) or tuple(lines[first:first + len(mutant.was)]) != mutant.was: + end = first + len(mutant.was) + if not 0 <= first <= len(lines) or tuple(line.removesuffix(b"\r") for line in lines[first:end]) != mutant.was: return None - lines[first:first + len(mutant.was)] = mutant.now + # The file's last line has no line end, so none of its lines takes one. + line_end = b"\r" if len(lines) > 1 and lines[0].endswith(b"\r") and end < len(lines) else b"" + lines[first:end] = (line + line_end for line in mutant.now) return b"\n".join(lines) diff --git a/bin/task_bench/test_planted_mutant.py b/bin/task_bench/test_planted_mutant.py index 60729552..187019cc 100644 --- a/bin/task_bench/test_planted_mutant.py +++ b/bin/task_bench/test_planted_mutant.py @@ -29,6 +29,16 @@ class MutatedTest(unittest.TestCase): self.assertEqual(mutated(b"a\nb + c", Mutant("calc.go", 2, "x", (b"b + c",), (b"b - c",))), b"a\nb - c") self.assertIsNone(mutated(b"a\nb + c", Mutant("calc.go", 3, "x", (b"b + c",), (b"b - c",)))) + def test_a_file_with_crlf_line_ends_matches_the_lines_without_their_cr_and_gets_the_mutants_lines_with_one(self): + source = b"a\r\n\tb + c\r\n\td,\r\n\te\r\n" + self.assertEqual(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c", b"\td,"), (b"\tb", b"\t- c", b"\td"))), b"a\r\n\tb\r\n\t- c\r\n\td\r\n\te\r\n") + self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (), (b"\tf,",))), b"a\r\n\tb + c\r\n\tf,\r\n\td,\r\n\te\r\n") + self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (b"\td,",), ())), b"a\r\n\tb + c\r\n\te\r\n") + self.assertIsNone(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c\r",), (b"z",)))) + + def test_the_last_line_of_a_crlf_file_has_no_line_end_to_take(self): + self.assertEqual(mutated(b"a\r\nb + c", Mutant("calc.py", 2, "x", (b"b + c",), (b"b - c",))), b"a\r\nb - c") + class LineAtHeadTest(unittest.TestCase): # Lines 3 and 4 became one, two lines went in after line 9, and line 20 went. diff --git a/bin/task_bench/test_python_bugs.py b/bin/task_bench/test_python_bugs.py index ca335598..ccca6141 100644 --- a/bin/task_bench/test_python_bugs.py +++ b/bin/task_bench/test_python_bugs.py @@ -8,7 +8,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure from task_bench.python_bugs import killed_mutants, task_text -from task_bench.planted_mutant import Mutant +from task_bench.planted_mutant import Mutant, mutated from mutate_changes.tool_process import Ran CALC = "def double(n):\n\treturn n * 2\n\n\ndef triple(n):\n\treturn (\n\t\tn * 3\n\t)\n" @@ -163,6 +163,14 @@ class KilledMutantsTest(unittest.TestCase): killed_mutants(str(self.top), ["bin/pkg/ends.py"], self.mutmut(), 3) self.assertEqual(self.ran[0][0][4:], ["pkg.ends.x_first*", "pkg.ends.x_last*"]) + def test_a_file_with_crlf_line_ends_gives_the_same_mutants_without_the_cr_and_applies_to_it(self): + (self.top / "bin/pkg/calc.py").write_bytes(CALC.replace("\n", "\r\n").encode()) + found = killed_mutants(str(self.top), ["bin/pkg/calc.py"], self.mutmut(RESULTS.replace("calc.x_", "pkg.calc.x_")), 3) + self.assertEqual([(mutant.line, mutant.was, mutant.now) for mutant in found], [(2, (b"\treturn n * 2",), (b"\treturn n / 2",)), (6, (b"\treturn (", b"\t\tn * 3", b"\t)"), (b"\treturn [", b"\t\tn * 3", b"\t]"))]) + changed = mutated((self.top / "bin/pkg/calc.py").read_bytes(), found[0]) + self.assertIsNotNone(changed) + self.assertIn(b"\treturn n / 2\r\n", changed or b"") + def test_keeps_the_mutants_of_every_folder_mutmut_runs_in(self): for path, text in (("tools/setup.cfg", "[tool:pytest]\n"), ("tools/pkg/calc.py", CALC)): (self.top / path).parent.mkdir(parents=True, exist_ok=True) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 91f2b06f..e3d29537 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -3508,3 +3508,16 @@ Read most (opens and searches): - `bin/task_bench/runs.py` 1 - `bin/task_bench/tasks.py` 1 - `docs/score-anchors.md` 1 + +## Reading cost, chunk 33264f8a9040, finished 2026-11-23T22:13:25Z + +64108 new input tokens before the first commit. + +Read most (opens and searches): + +- `README.md` 3 +- `docs/decisions.md` 3 +- `skills/larv-review/SKILL.md` 3 +- `bin/task_bench/main.py` 2 +- `CHANGELOG.md` 1 +- `todo.md` 1 -- 2.52.0 From a45279fe54db3a36ad15b2390d6ee1c49096920c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 23 Nov 2026 23:32:20 +0100 Subject: [PATCH 2/6] Take a CRLF file's line end from its first line, with a test of a mixed file --- bin/task_bench/planted_mutant.py | 4 ++-- bin/task_bench/test_planted_mutant.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/task_bench/planted_mutant.py b/bin/task_bench/planted_mutant.py index f47cca80..46dbf24e 100644 --- a/bin/task_bench/planted_mutant.py +++ b/bin/task_bench/planted_mutant.py @@ -24,14 +24,14 @@ def mutated(source: bytes, mutant: Mutant) -> bytes | None: """A file's source with the mutant applied, or None where the lines the mutant changes don't stand at the mutant's line. The mutant's lines come from a file read as text, so they hold no `\\r`: they match a file's lines without theirs, and go in with - the line end the file uses.""" + the line end the file's first line has.""" lines = source.split(b"\n") first = mutant.line - 1 end = first + len(mutant.was) if not 0 <= first <= len(lines) or tuple(line.removesuffix(b"\r") for line in lines[first:end]) != mutant.was: return None # The file's last line has no line end, so none of its lines takes one. - line_end = b"\r" if len(lines) > 1 and lines[0].endswith(b"\r") and end < len(lines) else b"" + line_end = b"\r" if lines[0].endswith(b"\r") and end < len(lines) else b"" lines[first:end] = (line + line_end for line in mutant.now) return b"\n".join(lines) diff --git a/bin/task_bench/test_planted_mutant.py b/bin/task_bench/test_planted_mutant.py index 187019cc..0937247e 100644 --- a/bin/task_bench/test_planted_mutant.py +++ b/bin/task_bench/test_planted_mutant.py @@ -36,6 +36,10 @@ class MutatedTest(unittest.TestCase): self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (b"\td,",), ())), b"a\r\n\tb + c\r\n\te\r\n") self.assertIsNone(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c\r",), (b"z",)))) + def test_a_file_that_mixes_line_ends_takes_the_one_of_its_first_line(self): + self.assertEqual(mutated(b"a\r\nb\nc\n", Mutant("calc.py", 2, "x", (b"b",), (b"z",))), b"a\r\nz\r\nc\n") + self.assertEqual(mutated(b"a\nb\r\nc\r\n", Mutant("calc.py", 2, "x", (b"b",), (b"z",))), b"a\nz\nc\r\n") + def test_the_last_line_of_a_crlf_file_has_no_line_end_to_take(self): self.assertEqual(mutated(b"a\r\nb + c", Mutant("calc.py", 2, "x", (b"b + c",), (b"b - c",))), b"a\r\nb - c") -- 2.52.0 From 763ee78296f73722af06d2604927683c3c4f9ffe Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 23 Nov 2026 23:52:25 +0100 Subject: [PATCH 3/6] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(1=20misread);=20mutated=20m?= =?UTF-8?q?atches=20Gremlins'=20lines=20that=20keep=20their=20CR=20as=20we?= =?UTF-8?q?ll=20as=20mutmut's,=20and=20the=20last=20line=20of=20a=20mutant?= =?UTF-8?q?=20that=20ends=20the=20file=20takes=20no=20line=20end;=20the=20?= =?UTF-8?q?prose=20findings'=20rewording=20is=20in=20this=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/task_bench/planted_mutant.py | 15 +++++++++------ bin/task_bench/test_planted_mutant.py | 13 +++++++++++-- bin/task_bench/test_python_bugs.py | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/bin/task_bench/planted_mutant.py b/bin/task_bench/planted_mutant.py index 46dbf24e..6ff0d6ae 100644 --- a/bin/task_bench/planted_mutant.py +++ b/bin/task_bench/planted_mutant.py @@ -23,16 +23,19 @@ class Mutant(typing.NamedTuple): def mutated(source: bytes, mutant: Mutant) -> bytes | None: """A file's source with the mutant applied, or None where the lines the mutant changes don't stand at the mutant's line. - The mutant's lines come from a file read as text, so they hold no `\\r`: they match a file's lines without theirs, and go in with - the line end the file's first line has.""" + A mutant's lines hold no `\\r` where its tool read the file as text, as mutmut does, and hold it where the tool split the bytes on + `\\n`, as Gremlins' planter does. Both match a file's lines, and a new line without `\\r` gets the line end of the file's first line.""" lines = source.split(b"\n") first = mutant.line - 1 end = first + len(mutant.was) - if not 0 <= first <= len(lines) or tuple(line.removesuffix(b"\r") for line in lines[first:end]) != mutant.was: + if not 0 <= first <= len(lines) or tuple(line.removesuffix(b"\r") for line in lines[first:end]) != tuple(line.removesuffix(b"\r") for line in mutant.was): return None - # The file's last line has no line end, so none of its lines takes one. - line_end = b"\r" if lines[0].endswith(b"\r") and end < len(lines) else b"" - lines[first:end] = (line + line_end for line in mutant.now) + line_end = b"\r" if lines[0].endswith(b"\r") else b"" + new = [line if line.endswith(b"\r") else line + line_end for line in mutant.now] + # Where the mutant's lines end the file, the last of them has no line end. + if new and end >= len(lines): + new[-1] = mutant.now[-1] + lines[first:end] = new return b"\n".join(lines) diff --git a/bin/task_bench/test_planted_mutant.py b/bin/task_bench/test_planted_mutant.py index 0937247e..cc9d397a 100644 --- a/bin/task_bench/test_planted_mutant.py +++ b/bin/task_bench/test_planted_mutant.py @@ -29,12 +29,21 @@ class MutatedTest(unittest.TestCase): self.assertEqual(mutated(b"a\nb + c", Mutant("calc.go", 2, "x", (b"b + c",), (b"b - c",))), b"a\nb - c") self.assertIsNone(mutated(b"a\nb + c", Mutant("calc.go", 3, "x", (b"b + c",), (b"b - c",)))) - def test_a_file_with_crlf_line_ends_matches_the_lines_without_their_cr_and_gets_the_mutants_lines_with_one(self): + def test_a_crlf_file_matches_a_mutants_lines_without_cr_and_gets_its_new_lines_with_one(self): source = b"a\r\n\tb + c\r\n\td,\r\n\te\r\n" self.assertEqual(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c", b"\td,"), (b"\tb", b"\t- c", b"\td"))), b"a\r\n\tb\r\n\t- c\r\n\td\r\n\te\r\n") self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (), (b"\tf,",))), b"a\r\n\tb + c\r\n\tf,\r\n\td,\r\n\te\r\n") self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (b"\td,",), ())), b"a\r\n\tb + c\r\n\te\r\n") - self.assertIsNone(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c\r",), (b"z",)))) + self.assertIsNone(mutated(source, Mutant("calc.py", 2, "x", (b"\tb - c",), (b"z",)))) + self.assertEqual(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c", b"\td,"), (b"x", b"y"))), b"a\r\nx\r\ny\r\n\te\r\n") + + def test_a_mutant_whose_lines_keep_their_cr_matches_and_goes_in_as_it_is(self): + source = b"a\r\n\tb + c\r\n\te" + self.assertEqual(mutated(source, Mutant("calc.go", 2, "x", (b"\tb + c\r",), (b"\tb - c\r",))), b"a\r\n\tb - c\r\n\te") + self.assertEqual(mutated(source, Mutant("calc.go", 3, "x", (b"\te",), (b"\tf",))), b"a\r\n\tb + c\r\n\tf") + self.assertEqual(mutated(source, Mutant("calc.go", 3, "x", (), (b"\tf\r",))), b"a\r\n\tb + c\r\n\tf\r\n\te") + self.assertEqual(mutated(source, Mutant("calc.go", 3, "x", (), (b"\tf",))), b"a\r\n\tb + c\r\n\tf\r\n\te") + self.assertEqual(mutated(source, Mutant("calc.go", 2, "x", (b"\tb + c", b"\te"), (b"x", b"y"))), b"a\r\nx\r\ny") def test_a_file_that_mixes_line_ends_takes_the_one_of_its_first_line(self): self.assertEqual(mutated(b"a\r\nb\nc\n", Mutant("calc.py", 2, "x", (b"b",), (b"z",))), b"a\r\nz\r\nc\n") diff --git a/bin/task_bench/test_python_bugs.py b/bin/task_bench/test_python_bugs.py index ccca6141..42013f06 100644 --- a/bin/task_bench/test_python_bugs.py +++ b/bin/task_bench/test_python_bugs.py @@ -163,7 +163,7 @@ class KilledMutantsTest(unittest.TestCase): killed_mutants(str(self.top), ["bin/pkg/ends.py"], self.mutmut(), 3) self.assertEqual(self.ran[0][0][4:], ["pkg.ends.x_first*", "pkg.ends.x_last*"]) - def test_a_file_with_crlf_line_ends_gives_the_same_mutants_without_the_cr_and_applies_to_it(self): + def test_a_crlf_file_gives_the_same_mutants_without_the_cr_and_they_apply_to_it(self): (self.top / "bin/pkg/calc.py").write_bytes(CALC.replace("\n", "\r\n").encode()) found = killed_mutants(str(self.top), ["bin/pkg/calc.py"], self.mutmut(RESULTS.replace("calc.x_", "pkg.calc.x_")), 3) self.assertEqual([(mutant.line, mutant.was, mutant.now) for mutant in found], [(2, (b"\treturn n * 2",), (b"\treturn n / 2",)), (6, (b"\treturn (", b"\t\tn * 3", b"\t)"), (b"\treturn [", b"\t\tn * 3", b"\t]"))]) -- 2.52.0 From 9541d0df549dd929a20c1d93cbe974c4bbc570e7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 23 Nov 2026 23:52:25 +0100 Subject: [PATCH 4/6] =?UTF-8?q?Answer=20prose=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(1=20misread);=20the=20docst?= =?UTF-8?q?ring=20now=20says=20both=20tools'=20lines,=20the=20comment=20sa?= =?UTF-8?q?ys=20only=20the=20mutant's=20last=20line=20goes=20without=20a?= =?UTF-8?q?=20line=20end,=20and=20the=20two=20test=20names=20are=20reworde?= =?UTF-8?q?d=20in=20the=20commit=20before?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From b367f6fe19c625dcf63cce845a882578d9e20339 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 24 Nov 2026 00:10:13 +0100 Subject: [PATCH 5/6] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20approved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From c86d15f25f5b20cc278dabff477cfb78a8902353 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 24 Nov 2026 00:10:25 +0100 Subject: [PATCH 6/6] Finish item 530 in the plan --- CHANGELOG.md | 1 + todo.md | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 351cc4be..0187817f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `task-bench` plants a Python mutant in a file whose lines end in CRLF, which it could not re-apply before, and a Go mutant there keeps applying. - This repo documents its own `task-bench` command in the README → Test, with `task-bench-image/Dockerfile`, an image that holds pytest, git and tmux, so each scoring run in `larv-review` benches claude-config and records its figures. - The stability reviewer now checks a lookup key built by joining path segments, or matched by prefix, for two inputs that give one key, such as a column named like its own table or the namespaces `ns` and `ns.sub`. - The release review now goes over a project's bench features: it reapplies each reference patch and rewrites one that no longer applies, deletes a feature that no longer breaks a goal, and adds features until each place the comprehension seats find hardest has one. diff --git a/todo.md b/todo.md index cdcfe0da..6de38a62 100644 --- a/todo.md +++ b/todo.md @@ -18,7 +18,6 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 507 | 0.16.0 | | owner | **Bench rebuilding a feature the project shipped: revert its commit at the head, hand Haiku its item tagline, and check with the tests that commit added.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 3 | 0.7 | | 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 | -| 530 | 0.16.0 | | owner | **Plant a mutant in a Python file whose lines end in CRLF.** | 1 | 1 | 1 | 1 | 2 | 1.1 by 1 | 0.4 | | 526 | 0.16.0 | | owner | **Plant bugs for `task-bench` in Rust, from the mutants cargo-mutants kills.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 1 | 0.3 | | 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 | @@ -130,15 +129,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. -### 530. Plant a mutant in a Python file whose lines end in CRLF. - -mutmut's planter reads a file as text, which turns `\r\n` into `\n`, and the planter re-applies a mutant to the file's bytes split on `\n` alone. So no mutant of a Python file with CRLF line ends ever re-applies, and the bench doesn't say why. A stability review of item 508 reproduced it. Compare the lines without their `\r`, and write the mutant's lines with the line end the file uses. - -Touches: -- `bin/task_bench/planted_mutant.py`: `mutated` -- `bin/task_bench/python_bugs.py`: `killed_mutants` -- `bin/task_bench/test_python_bugs.py` - ### 526. Plant bugs for `task-bench` in Rust, from the mutants cargo-mutants kills. cargo-mutants 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 the diffs it writes under `mutants.out`. Tell Haiku the failure `cargo test` 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 Rust. -- 2.52.0