Compare commits

..

16 Commits

Author SHA1 Message Date
lilleman 11e7f90b01 Finish item 525 in the plan
CI / tests (pull_request) Successful in 9m23s
2026-11-26 16:11:14 +01:00
lilleman 606cf25ed2 Record the comprehension check: two scoring runs at 68611733, floor item 300 refreshed
CI / tests (pull_request) Has been cancelled
2026-11-26 16:10:57 +01:00
lilleman 68611733fe Record the reading cost before item 525
CI / tests (pull_request) Successful in 4m51s
2026-11-26 13:17:12 +01:00
lilleman 79ae24abf4 Finish item 528 in the plan
CI / tests (pull_request) Successful in 6m37s
2026-11-26 12:38:48 +01:00
lilleman c259d5fbb2 Finish item 527 in the plan 2026-11-26 12:38:47 +01:00
lilleman 87f168c4c9 Answer stability round 2: 0 🔴, 0 🟡 (0 misread); drop a report the tree held before the run, move a comment back to its function
CI / tests (pull_request) Has been cancelled
2026-11-26 12:35:53 +01:00
lilleman 794adafb91 Leave the scratch folder out of its own copy by name
CI / tests (pull_request) Successful in 6m14s
2026-11-26 12:08:55 +01:00
lilleman 8b1c9ff184 Fail the scratch copy's test on a socket, not a patched function
CI / tests (pull_request) Successful in 8m49s
2026-11-26 11:45:36 +01:00
lilleman 014d085f26 Answer prose round 1: 0 🔴, 5 🟡 (0 misread); reworded in the two answers before this one
CI / tests (pull_request) Has been cancelled
2026-11-26 11:42:20 +01:00
lilleman ea4d2408b2 Answer product-owner round 1: 0 🔴, 3 🟡 (0 misread); say how the tools get their dependencies and which names count as tests, file item 544 2026-11-26 11:42:20 +01:00
lilleman 874e417e27 Answer stability round 1: 0 🔴, 5 🟡 (0 misread); run both tools in a scratch copy, read Infection's two sources, end PHPUnit's list, spell glob characters 2026-11-26 11:42:20 +01:00
lilleman 76de4fa497 Answer security round 1: 0 🔴, 0 🟡 (0 misread); no finding 2026-11-26 11:42:20 +01:00
lilleman 47084dc3df Test the planters' edges that mutants survived
CI / tests (pull_request) Successful in 6m5s
2026-11-26 11:03:39 +01:00
lilleman 632023ed21 Sort the two planters' imports
CI / tests (pull_request) Successful in 5m35s
2026-11-26 10:42:42 +01:00
lilleman ffe2048b73 Plant task-bench's bugs in TypeScript and PHP, from Stryker's and Infection's killed mutants
CI / tests (pull_request) Has been cancelled
2026-11-26 10:39:36 +01:00
lilleman 48270c0439 Record the reading cost 2026-11-26 10:39:36 +01:00
18 changed files with 1080 additions and 105 deletions
+2
View File
@@ -2,6 +2,8 @@
## Unreleased
- `task-bench` plants bugs in PHP, from the mutants Infection logs as killed, and reads the task it gives from the message PHPUnit prints.
- `task-bench` plants bugs in TypeScript and JavaScript, from the mutants Stryker reports as killed, and reads the task it gives from the error `node --test` prints.
- Testing principles now say that a test scanning rows for an exception asserts the exception exists, and that a data importer does not drop a row its own fixups complete.
- 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.
+2 -2
View File
@@ -236,7 +236,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
- `settings_filter.py` is git's clean filter for `settings.json`: it drops `"model"` and sorts the keys. `.gitattributes` sets the filter `settings` on `settings.json`, and Install's `git config` line makes this script that filter.
- `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it.
- `subagent-rung [--plan] <model> <L>` prints the Agent tool's model and effort for a subagent's task, picked by its L from the project's model on the project's routing ladder, and with `--plan` never below the project's rung; `subagent-rung --help` states the rule.
- `task-bench --image <image> --test <shell text> [<options>]` plants bugs that the tests catch, in the Go, Python and Rust files that hold the places the comprehension seats found hardest, has Haiku fix each at the base and at the head, and prints how often the fix passes and what it took. It needs docker and a token from `claude setup-token`; `task-bench --help` says how it plants, runs and checks. It leaves a digest of why runs failed. With `--tasks features` it has Haiku build each feature in the folder the config names as `bench-tasks` instead, from its spec, and checks the build with acceptance tests Haiku never sees. With `--tasks data-sources` it has Haiku add each data source there: a folder that also holds `generate-register`, the seeded script whose made-up register Haiku imports. With `--tasks shipped-features` it has Haiku rebuild features the project shipped: it takes each one's change out of the code, tells Haiku the tagline of the plan item, and checks the build with the tests that change holds. With `--record-figures`, a bench that finishes appends its figures over every task to the comprehension history. A scoring run starts the bench that way where the project's README documents its `task-bench` command. `task-bench gather` starts a claude on the project's rung, which files a plan item for each place the digest shows to be hard; then gather removes the bench's folder, digest and streams.
- `task-bench --image <image> --test <shell text> [<options>]` plants bugs that the tests catch, in the Go, PHP, Python, Rust, TypeScript and JavaScript files that hold the places the comprehension seats found hardest, has Haiku fix each at the base and at the head, and prints how often the fix passes and what it took. It needs docker and a token from `claude setup-token`; `task-bench --help` says how it plants, runs and checks. It leaves a digest of why runs failed. With `--tasks features` it has Haiku build each feature in the folder the config names as `bench-tasks` instead, from its spec, and checks the build with acceptance tests Haiku never sees. With `--tasks data-sources` it has Haiku add each data source there: a folder that also holds `generate-register`, the seeded script whose made-up register Haiku imports. With `--tasks shipped-features` it has Haiku rebuild features the project shipped: it takes each one's change out of the code, tells Haiku the tagline of the plan item, and checks the build with the tests that change holds. With `--record-figures`, a bench that finishes appends its figures over every task to the comprehension history. A scoring run starts the bench that way where the project's README documents its `task-bench` command. `task-bench gather` starts a claude on the project's rung, which files a plan item for each place the digest shows to be hard; then gather removes the bench's folder, digest and streams.
- `todo-item` reads and changes a project's plan, whatever holds it: `list` prints the items in the plan's order and `show <ID>` one item's row and detail; `add …` files an item under the next free ID, `edit <ID> …` sets an item's cells or detail, and `move <ID> --release <version>` sets an item's release; `finish <ID>` removes a finished item and adds the bullet passed with `--changelog` to `CHANGELOG.md`, except for a plan kept in Jira. Each change ranks a markdown plan. `todo-item --help` states the flags.
- `touch-predictions record <ID>...` appends what a chunk's items were predicted to touch, under `Touches:` in their details, beside the files and parts its branch touched, to the record the config names as `touch-predictions`; `touch-predictions --help` shows the spelling and how a part is named. `chunk-preflight` reads the same predictions to name the items that may start chunks at once.
- `wait-for <file> [<pattern>] [--timeout <seconds>]` waits until a file a background job writes holds a line matching the pattern, and prints it.
@@ -286,7 +286,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
- `review_rules/` holds the larv-review rules that several tools apply: its passes, its review folder, its round commit titles and the comprehension history's format.
- `routing_figures/` measures loop-claude's archive, and each of its projects' default branches, for loop-claude's routing calls.
- `rung_replay/` holds what `judge_replay` and `review_replay` share: the parallel replay runner, the argument reader, the candidate rungs and the exits, and `judge_replay`'s rung search. It reads `agent_cycle`'s retry count and `chunk_driver`'s models file, and finds that file through `loop_state`'s paths. Its `archive.py` keeps each replay's runs and its report in a `replays/` folder of loop-claude's archive.
- `task_bench/` holds `task-bench`, which plants bugs in a project's Go, Python and Rust files, or takes the project's bench features, its data sources or the features its history shipped, and has Haiku fix, build or add them in containers.
- `task_bench/` holds `task-bench`, which plants bugs in a project's Go, PHP, Python, Rust, TypeScript and JavaScript files, or takes the project's bench features, its data sources or the features its history shipped, and has Haiku fix, build or add them in containers.
- `test_env.py` serves the tests.
- `text_files/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, reads the text piped into a command, stamps times in UTC, replaces a file in one step, private where it is new, and gzips a file beside its plain name, by which it reads it afterwards.
- `transcript_archive/` stores loop-claude's transcripts. Its `project_key.py` names each project's archive folder, loop-claude session and models-file entry.
+15 -5
View File
@@ -2,6 +2,7 @@
import json
import os
import pathlib
import re
import typing
from mutate_changes.changed_lines import by_folder, label, runs
@@ -12,6 +13,9 @@ from git_cli.git_repo import Git
# cargo-mutants' exit codes for a run that finished: every mutant caught, some missed, and some timed out.
CARGO_FINISHED = frozenset({0, 2, 3})
CARGO_OUTCOMES = ("caught", "missed", "timeout", "unviable")
INFECTION = "vendor/bin/infection" # the project's own, as Composer installs it
# npx runs the project's own @stryker-mutator/core, else one an earlier npx run cached, and installs none.
STRYKER_RUN = ["npx", "--no", "--package=@stryker-mutator/core", "stryker", "run"]
GREMLINS_UNKILLED = frozenset({"LIVED", "NOT COVERED"})
# What Gremlins v0.6.0 needs of the diff it reads from git: one run of lines per hunk is all it mutates, so a hunk holds the changed
# lines and none around them, nor a neighbouring change; it takes each file's path after a b/; and it reads no colour codes. A user's git
@@ -112,14 +116,20 @@ def outcome_lines(path: pathlib.Path) -> list[str]:
return path.read_text(encoding="utf-8", errors="replace").splitlines() if path.is_file() else []
def glob_escaped(path: str) -> str:
"""A path as a glob that matches it. Stryker 10.1.1 reads each entry of --mutate as a glob, in which `app/[slug]/page.tsx`
matches `app/s/page.tsx` and not the file of that name. It reads a backslash as a slash, so no character can be escaped: a `?`
stands for each one a glob gives a meaning, and matches it."""
return re.sub(r"[][!()*+@{}]", "?", path)
# Stryker and Infection also exit nonzero on a mutation score below a threshold the project sets, which their exit code doesn't
# tell from a run that broke, so either fails the run.
def run_stryker(top: str, changed: dict[str, frozenset[int]], run: Run, jobs: int) -> list[str] | Failure:
"""For each folder Stryker runs in, a line naming it, then Stryker's own report of the mutants on the changed lines. Last, a line
naming the files with no package.json above them, if any.
Stryker runs in the nearest folder above each file that holds a package.json. npx runs the project's own @stryker-mutator/core, else
one an earlier npx run cached, and installs none."""
Stryker runs in the nearest folder above each file that holds a package.json."""
report: list[str] = []
unplaced: list[str] = []
for folder, files in sorted(by_folder(top, changed, ("package.json",)).items()):
@@ -127,8 +137,8 @@ def run_stryker(top: str, changed: dict[str, frozenset[int]], run: Run, jobs: in
if not os.path.isfile(os.path.join(top, folder, "package.json")):
unplaced = sorted(files)
continue
mutate = ",".join(f"{path}:{first}-{last}" for path, lines in sorted(files.items()) for first, last in runs(lines))
ran = run(["npx", "--no", "--package=@stryker-mutator/core", "stryker", "run", "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "clear-text"], os.path.join(top, folder))
mutate = ",".join(f"{glob_escaped(path)}:{first}-{last}" for path, lines in sorted(files.items()) for first, last in runs(lines))
ran = run([*STRYKER_RUN, "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "clear-text"], os.path.join(top, folder))
if isinstance(ran, Failure) or ran.code:
return ran if isinstance(ran, Failure) else whole_output(f"Stryker in {label(folder)}", ran)
report.extend([f"Stryker in {label(folder)}:", *ran.output.splitlines()])
@@ -137,7 +147,7 @@ def run_stryker(top: str, changed: dict[str, frozenset[int]], run: Run, jobs: in
def run_infection(top: str, base: str, run: Run, jobs: int) -> list[str] | Failure:
"""A line naming where Infection ran, top, then its own report of the mutants on the lines the branch changes since base."""
ran = run(["vendor/bin/infection", "--git-diff-lines", f"--git-diff-base={base}", f"--threads={jobs}", "--show-mutations=max", "--no-progress"], top)
ran = run([INFECTION, "--git-diff-lines", f"--git-diff-base={base}", f"--threads={jobs}", "--show-mutations=max", "--no-progress"], top)
if isinstance(ran, Failure) or ran.code:
return ran if isinstance(ran, Failure) else whole_output("Infection", ran)
return ["Infection in the checkout's top:", *ran.output.splitlines()]
+13 -1
View File
@@ -17,12 +17,12 @@ from mutate_changes.changed_lines import added_lines, by_folder, not_mutated, ru
from mutate_changes.mutmut_tool import copy_files, Ended, Folder, mutate_folder, NO_MUTANT, reported
from mutate_changes.mutmut_mutants import crash_in_mutmut, function_keys, mutant_globs, mutated_lines, named, statuses
from failure import Failure
from mutate_changes.in_diff_tools import glob_escaped, run_stryker, with_plain_git_diff
from mutate_changes.bare_imports import imported_by_file_name
from test_env import isolated_env
from mutate_changes.mutmut_setup import left_out, mutmut_config
from mutate_changes import main
from mutate_changes.tool_process import Ran, run_tool, scratch_folder
from mutate_changes.in_diff_tools import with_plain_git_diff
SOURCE = "def double(n):\n\treturn n * 2\n\n\nclass Pt:\n\tdef moved(self, by=1):\n\t\treturn self.x + by\n"
# The shape of the file mutmut 3 writes under mutants/: the original of each function and its mutants, with the original's lines.
@@ -163,6 +163,18 @@ class InDiffTools(unittest.TestCase):
self.assertEqual((env["GIT_CONFIG_COUNT"], env["GIT_CONFIG_KEY_0"], env["GIT_CONFIG_KEY_6"], "GIT_CONFIG_KEY_7" in env), ("7", "diff.context", "diff.interHunkContext", False))
def test_a_path_goes_to_stryker_with_a_question_mark_for_each_character_a_glob_gives_a_meaning(self):
self.assertEqual(glob_escaped("app/[slug]/(shop)/{a}/b!c*d+e@f.tsx"), "app/?slug?/?shop?/?a?/b?c?d?e?f.tsx")
self.assertEqual(glob_escaped("src/pick-one_two.test.ts"), "src/pick-one_two.test.ts")
def test_stryker_is_handed_a_changed_file_whose_path_holds_a_globs_characters_as_a_glob_that_matches_it(self):
with tempfile.TemporaryDirectory() as top:
pathlib.Path(top, "package.json").write_text("{}")
ran: list[list[str]] = []
run_stryker(top, {"app/[slug]/page.tsx": frozenset({3, 4})}, lambda argv, cwd: ran.append(argv) or Ran(0, ""), 1)
self.assertEqual(ran[0][5:7], ["--mutate", "app/?slug?/page.tsx:3-4"])
class MutmutSetup(unittest.TestCase):
def test_the_config_mutates_the_sources_and_copies_each_entry_of_the_folder(self):
for existing in ("", "[mutmut]\nsource_paths = old.py\nalso_copy = old\n"):
+35 -18
View File
@@ -14,14 +14,20 @@ origin's as last fetched, else main or master. Where --base names the head's own
No model judges anything: the bench runs programs, and reads Haiku's own stream.
- Plant. It copies the tree at the base and runs a mutation tool there, over the files that hold the places `larv-review places`
prints, the ones the comprehension seats found hardest: Gremlins over the Go files, as `gremlins unleash`, mutmut 3 over
the Python files, as `mutmut run`, and cargo-mutants over the Rust files, as `cargo mutants`. No other language is planted
in so far. It takes the mutants the tests kill in the order --seed sets, 1 by default, until --bugs of
them, 5 by default, have become bugs. A mutant becomes a bug where the lines it changes stand unchanged at the head, and where,
planted at each side, a test fails and prints a message that says more than the test's name. The bench reads that message
from `go test`'s output for a Go file, from pytest's for a Python file and from `cargo test`'s for a Rust file, so --test must
run the tests of each language the places name, with that runner: pytest as it prints by default, or with --tb=short, and
`cargo test` without --nocapture. Any other mutant is passed over, so a change to the very lines of a bug is not benched.
prints, the ones the comprehension seats found hardest: Gremlins over the Go files, as `gremlins unleash`, Infection over the
PHP files, as `vendor/bin/infection`, mutmut 3 over the Python files, as `mutmut run`, cargo-mutants over the Rust files, as
`cargo mutants`, and Stryker over the TypeScript and JavaScript files, as `npx --no --package=@stryker-mutator/core stryker
run`, which runs the Stryker the project installs and downloads none. No other language is planted in so far. Infection and
Stryker each run at the top of a copy of that tree, with the project's config for the tool there, and the copy is removed
with all the tool wrote. Stryker's json reporter must write where it does by default, `reports/mutation/mutation.json`.
The bench takes the mutants the tests kill in the order --seed sets, 1 by default, until --bugs of them, 5 by default, have
become bugs. A mutant becomes a bug where the lines it changes stand unchanged at the head, and where, planted at each side,
a test fails and prints a message that says more than the test's name. The bench reads that message from `go test`'s output
for a Go file, from PHPUnit's for a PHP file, from pytest's for a Python file, from `cargo test`'s for a Rust file and from
`node --test`'s for a TypeScript or JavaScript file. So --test must run the tests of each language the places name, with
that runner: PHPUnit as it prints by default, pytest as it prints by default or with --tb=short, `cargo test` without
--nocapture, and `node --test --test-reporter=spec`. Any other mutant is passed over, so a change to the very lines of a
bug is not benched.
- Run. Haiku fixes each bug --runs times at each side, 5 by default, the sides in turn. A fix starts from a copy of that side's
tree with the bug in it, committed once, so git doesn't show which line the bug is on. In the copy, in a container, `claude -p
--strict-mcp-config --disable-slash-commands --no-session-persistence --model claude-haiku-5-5 --effort low` works with every
@@ -29,7 +35,10 @@ 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. In a Rust file, each
A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. The bench
tells a test by its path: a folder named `test`, `tests` or `__tests__`, or a file named `test_*.py`, `*_test.py`,
`*_test.go`, `*.test.*` or `*.spec.*`. A test of any other name counts as code, such as `src/PickTest.php` or
`src/pick-test.js`, so Haiku's change to it stands. 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
@@ -40,10 +49,13 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream.
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
the copy's top, with no network, so the image must hold what the tests would otherwise download.
--prefix is shell text that runs the mutation tool, on the host, as mutate-changes' --prefix does: sh runs `<prefix> "$@"` with
the tool's command as "$@", such as `gremlins unleash ...`, `mutmut run ...` or `cargo mutants ...`. Gremlins and
cargo-mutants run in the copy of the base, and mutmut in a copy of the folder there that holds its settings; $PWD is the folder
the tool runs in. Without --prefix, the bench runs the `gremlins`, the `mutmut` or the `cargo` on the host's PATH. For example,
for Go, for Python and then for Rust:
the tool's command as "$@", such as `gremlins unleash ...`, `mutmut run ...` or `cargo mutants ...`. Gremlins and cargo-mutants
run in the copy of the base, Infection and Stryker in a copy of that copy, and mutmut in a copy of the folder there that holds
its settings; $PWD is the folder the tool runs in. That folder holds the files git tracks and no others, so for Infection and
Stryker the prefix first installs the project's dependencies there, as `composer install` and `npm ci` do. Infection also
needs PHP with a coverage driver, pcov or Xdebug. Without --prefix, the bench runs the `gremlins`, the `mutmut`, the `cargo`
or the `npx` on the host's PATH, or the tree's own `vendor/bin/infection`, which only a project that tracks `vendor` has.
For example, for Go, for Python, for Rust and then for TypeScript:
docker run --rm --memory 16g --memory-swap 16g -v "$PWD:$PWD" -w "$PWD" golang:1.27.4 \
sh -c 'shift; exec go run github.com/go-gremlins/gremlins/cmd/gremlins@v0.6.0 "$@"' sh
@@ -53,8 +65,12 @@ for Go, for Python and then for Rust:
docker run --rm --memory 16g --memory-swap 16g --user "$(id -u):$(id -g)" -e CARGO_HOME=/tmp/cargo -v "$PWD:$PWD" -w "$PWD" \
rust:1.100.0 sh -c 'cargo install --quiet --locked cargo-mutants@27.1.0 && exec "$@"' sh
docker run --rm --memory 16g --memory-swap 16g --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:$PWD" -w "$PWD" \
node:24.19.0-alpine3.24 sh -c 'npm ci --silent && exec "$@"' sh
Where the places name files in more than one language, the one prefix gets each tool's command, Gremlins' first and
cargo-mutants' last, and a tool it cannot run fails the bench. Such a prefix picks the tool by "$1", which is `gremlins`, `mutmut` or `cargo`, as here for Go
Stryker's last, and a tool it cannot run fails the bench. Such a prefix picks the tool by "$1", which is `gremlins`,
`vendor/bin/infection`, `mutmut`, `cargo` or `npx`, as here for Go
and Python:
sh -c 'case "$1" in
@@ -152,7 +168,7 @@ not, unless a bench or a gather is using it. So gather a bench before the next o
Exit 1, saying why, on an unknown or repeated argument, a missing --image or --test, a --seed, --bugs or --runs that is no whole
number from 1, a --tasks that is none of bugs, features, data-sources and shipped-features, or no token; and where git, docker or a mutation tool
fails, the seats' places don't name any Go, Python or Rust file, the tests fail at a side without a bug, or no mutant becomes a bug. With --tasks
fails, the seats' places don't name any file in a language the bench plants bugs in, the tests fail at a side without a bug, or no mutant becomes a bug. With --tasks
features or data-sources it exits 1 on a --seed, --bugs or --prefix; where no config names the checkout or its config sets no
`bench-tasks`, or the folder holds no task of that kind, one that lacks a part, or a `generate-register` that is no executable
file, each before docker runs; and where the tests fail at a side without the acceptance tests, or no task counts.
@@ -359,11 +375,12 @@ def features_planner(features: Features, checkout: str, trees: dict[Side, str])
def bugs_planner(given: dict[str, str], env: typing.Mapping[str, str], places: str, base: str) -> typing.Callable[[Bench], Planned | Failure] | Failure:
"""What plans a bench of bugs: of the mutants the tests kill in the Go, Python and Rust files of the tree at base that hold a place
in places, those --seed draws first become bugs, until --bugs of them have."""
"""What plans a bench of bugs. The bugs' files are those of the tree at base that hold a place in places and are in a language
of plant's LANGUAGES. Of the mutants the tests kill in those files, the ones --seed draws first become bugs, until --bugs of
them have."""
files = [path for path in place_files(places) if pathlib.Path(base, path).is_file()]
if not files:
return Failure("The places the seats found hard don't name any Go, Python or Rust file that the base holds, so there is nowhere to plant a bug.")
return Failure("The places the seats found hard don't name any file at the base in a language the bench plants bugs in, so there is nowhere to plant a bug.")
run = functools.partial(run_tool, prefix=given.get("--prefix"), env=env, killpg=os.killpg)
mutants = killed_mutants(base, files, run, CPUS_PER_SLOT)
return mutants if isinstance(mutants, Failure) else functools.partial(planted_tasks, mutants=mutants, seed=int(given["--seed"]), bugs=int(given["--bugs"]))
+104
View File
@@ -0,0 +1,104 @@
"""The bugs task-bench plants in PHP: Infection's killed mutants, each read from the two sources in its JSON log, and the message
PHPUnit prints when a test fails on one."""
import json
import pathlib
import re
from mutate_changes.tool_process import failed, remove, Run
from failure import Failure
from mutate_changes import in_diff_tools
from task_bench.planted_mutant import Mutant
from task_bench.scratch_copy import scratch_copy
# Where Infection writes its JSON log, from the copy's top.
LOG = "infection-log.json"
# The heading of PHPUnit's list of the tests that failed, or of those that threw: `There were 3 failures:`.
LISTED = re.compile(r"^There (?:was|were) \d+ (?:error|failure)s?:$")
# The heading of another list PHPUnit prints in the same form: `There was 1 risky test:`, `1 test triggered 1 deprecation:`.
OTHER_LIST = re.compile(r"^(?:There (?:was|were) \d+ |\d+ tests? triggered \d+ ).+:$")
# A listed test, by its number in the list: `1) Probe\Tests\PickTest::testNamesOne`, or with ` with data set #0 (1, 'one')` after it.
TEST = re.compile(r"^\d+\) (\S+)")
# What ends a listed test's message: the file and line that failed, as `/w/tests/PickTest.php:12`, the line between the two
# lists, or the summary's heading.
AFTER_MESSAGE = re.compile(r"^(?:\S.*\.php:\d+|--|ERRORS!|FAILURES!)$")
TEST_FILE = re.compile(r"Test\.php\b")
def killed_mutants(top: str, files: list[str], run: Run, jobs: int) -> list[Mutant] | Failure:
"""The mutants in `files` that the tests of the tree at top kill, as Infection finds them in a copy of that tree.
Infection runs at the copy's top, with the Infection config there. It ends without an error whatever score that config
asks for, since the files' score is not the project's."""
copied = scratch_copy(top)
if isinstance(copied, Failure):
return copied
scratch, copy = copied
try:
ran = run([in_diff_tools.INFECTION, f"--filter={','.join(files)}", f"--threads={jobs}", "--no-progress", "--min-msi=0", "--min-covered-msi=0", f"--logger-json={LOG}"], copy)
if isinstance(ran, Failure) or ran.code:
return ran if isinstance(ran, Failure) else failed("Infection", ran)
killed = [logged["mutator"] for logged in json.loads(pathlib.Path(copy, LOG).read_bytes())["killed"]]
return [mutant for mutator in killed if (mutant := planted(mutator, files))]
except (OSError, ValueError, KeyError, TypeError, AttributeError) as failure:
return Failure(f"could not read Infection's log, {LOG} in {copy}: {failure}")
finally:
remove(scratch)
def planted(mutator: dict, files: list[str]) -> Mutant | None:
"""A mutant of Infection's log as the lines it changes, or None where it is in none of `files` or doesn't change any line.
The log names a file by its whole path where Infection ran. That path ends with the file's path from the top, and where it
ends with more than one of `files`, the longest is the file."""
logged = mutator["originalFilePath"]
path = max((path for path in files if logged == path or logged.endswith(f"/{path}")), key=len, default=None)
if path is None:
return None
found = changed(mutator["originalSourceCode"], mutator["mutatedSourceCode"])
return Mutant(path, found[0], f"{path}:{mutator['originalStartLine']} {mutator['mutatorName']}", found[1], found[2]) if found else None
def changed(original: str, mutated: str) -> tuple[int, tuple[bytes, ...], tuple[bytes, ...]] | None:
"""The lines a mutant changes, from the file's source and the mutant's, both of which Infection 0.35.12 logs: the number of
the first line that differs, from 1, the file's lines from there to the last that differs, and what the mutant has in their
place. An unchanged line between two changed ones is in both. None where the two sources are the same."""
was, now = original.split("\n"), mutated.split("\n")
if was == now:
return None
shorter = min(len(was), len(now))
first = next((index for index in range(shorter) if was[index] != now[index]), shorter)
after = next((count for count in range(shorter - first) if was[-1 - count] != now[-1 - count]), shorter - first)
return first + 1, tuple(line.encode() for line in was[first:len(was) - after]), tuple(line.encode() for line in now[first:len(now) - after])
def task_text(output: str) -> str | None:
"""What Haiku is told of a planted bug: the message of the first test that has a message in PHPUnit's list of the tests that
threw or failed, without the test's name, class or file, so it says what goes wrong and not which test shows it. A test in
another of PHPUnit's lists, such as the risky tests, did not fail.
None where PHPUnit lists no such test, as on a passing run, a file that fails to parse or a run with --testdox, or where each
message only names its test."""
messages: list[tuple[str, list[str]]] = []
listing = within = False
for line in output.splitlines():
if LISTED.match(line):
listing, within = True, False
elif OTHER_LIST.match(line):
listing = within = False
elif listing and (test := TEST.match(line)):
messages.append((test[1], []))
within = True
elif AFTER_MESSAGE.match(line):
within = False
elif within:
messages[-1][1].append(line)
kept = (kept_lines(test, message) for test, message in messages)
return next(("\n".join(lines) for lines in kept if lines), None)
def kept_lines(test: str, message: list[str]) -> list[str]:
"""A message's lines, without the empty ones and those that name the test: the whole of `Probe\\Tests\\PickTest::testNamesOne`,
its class with or without the namespace, its method, or a test's file."""
of_class, _, method = test.partition("::")
names = {test, of_class, of_class.rpartition("\\")[2], method} - {""}
return [text for text in message if text and not TEST_FILE.search(text) and not any(name in text for name in names)]
+5 -2
View File
@@ -6,8 +6,8 @@ import re
import typing
from failure import Failure
from task_bench import go_bugs, python_bugs, rust_bugs
from mutate_changes.changed_lines import is_test
from task_bench import go_bugs, php_bugs, python_bugs, rust_bugs, typescript_bugs
from mutate_changes.changed_lines import is_test, STRYKER
from task_bench.planted_mutant import Mutant
from mutate_changes.tool_process import Run
@@ -28,8 +28,11 @@ class Language(typing.NamedTuple):
LANGUAGES = (
Language("Go", (".go",), go_bugs.killed_mutants, go_bugs.task_text),
Language("PHP", (".php",), php_bugs.killed_mutants, php_bugs.task_text),
Language("Python", (".py",), python_bugs.killed_mutants, python_bugs.task_text),
Language("Rust", (".rs",), rust_bugs.killed_mutants, rust_bugs.task_text),
# Stryker mutates JavaScript as it does TypeScript, and `node --test` reports both alike.
Language("TypeScript", STRYKER, typescript_bugs.killed_mutants, typescript_bugs.task_text),
)
+2 -1
View File
@@ -11,7 +11,8 @@ class Mutant(typing.NamedTuple):
"""A mutant the project's tests killed, as the lines it changes in the tree its tool ran in: the number of the first, from 1,
those lines as the tree has them, and what the mutant has in their place. Where it only adds lines, the number is that of the
line they go in before. name is what the report calls the bug it becomes: the path and line, then what the tool tells the
mutant by, which is Gremlins' column and mutator, or mutmut's name. cargo-mutants' own name for a mutant holds all of it."""
mutant by, which is Gremlins' or Stryker's column and mutator, Infection's mutator, or mutmut's name. cargo-mutants' own name for a mutant
holds all of it."""
path: str
line: int
+24
View File
@@ -0,0 +1,24 @@
"""A copy of a tree for a mutation tool to run in, so that what the tool writes there goes with the copy."""
import os
import shutil
from failure import Failure
from mutate_changes.tool_process import remove, scratch_folder
def scratch_copy(top: str) -> tuple[str, str] | Failure:
"""A new scratch folder in top, and in it a copy of top's other entries, links kept as links: the two folders' paths. The
caller removes the scratch folder.
A mutation tool leaves files where it runs: its cache, and each log the project's config asks for, which tells where every
mutant is. A bug's tree is a copy of top, so the tool runs in this copy and top stays as it was."""
scratch = scratch_folder(top)
if isinstance(scratch, Failure):
return scratch
copy = os.path.join(scratch, "copy")
try:
shutil.copytree(top, copy, symlinks=True, ignore=shutil.ignore_patterns(os.path.basename(scratch)))
except OSError as failure:
remove(scratch)
return Failure(f"could not copy {top} into {scratch}: {failure}")
return scratch, copy
+275
View File
@@ -0,0 +1,275 @@
"""task-bench's PHP planter: which files Infection mutates, how its log's mutants become lines and what PHPUnit's output tells Haiku.
The four mutants of PICK and FAILING are what Infection 0.35.12 and PHPUnit 12.5.45 wrote for a small project on PHP 8.5.13. Each
logged mutant is cut down to the keys the planter reads. The other mutants and outputs are made up in the same form."""
import json
import pathlib
import sys
import tempfile
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench.php_bugs import changed, killed_mutants, task_text
from failure import Failure
from task_bench.planted_mutant import Mutant, mutated
from mutate_changes.tool_process import Ran
PICK = """<?php
namespace Probe;
final class Pick
{
/** @param list<int> $items */
public static function sum(array $items, int $floor): int
{
$sum = 0;
foreach ($items as $item) {
if ($item >= $floor) {
$sum += $item;
}
}
return $sum;
}
public static function label(int $count): string
{
return $count === 1
? 'one item'
: $count . ' items';
}
}
"""
LINES = PICK.split("\n")
def with_lines(first: int, count: int, *now: str) -> str:
"""PICK with `count` lines from line `first` on replaced by `now`: the mutated source Infection logged for such a mutant."""
return "\n".join([*LINES[:first - 1], *now, *LINES[first - 1 + count:]])
OPERATOR = with_lines(12, 1, "\t\t\tif ($item > $floor) {")
# Infection prints the lines of a statement it rewrote with its own indent, and leaves the ones between them as they were.
FOREACH = with_lines(11, 5, "\t\tforeach ([] as $item) {", " if ($item >= $floor) {", "\t\t\t\t$sum += $item;", "\t\t\t}", " }")
TERNARY = with_lines(21, 3, "\t\treturn $count === 1 ? $count . ' items' : 'one item';")
VISIBILITY = with_lines(19, 1, "\tprotected static function label(int $count): string")
OPERATOR_NOW = (b"\t\t\tif ($item > $floor) {",)
def logged(mutator: str, line: int, mutated_source: str, path: str = "/w/src/Pick.php", source: str = PICK) -> dict:
return {"mutator": {"mutatorName": mutator, "originalSourceCode": source, "mutatedSourceCode": mutated_source, "originalFilePath": path, "originalStartLine": line}}
FAILING = """PHPUnit 12.5.45 by Sebastian Bergmann and contributors.
Runtime: PHP 8.5.13
Configuration: /w/phpunit.xml
FFF 3 / 3 (100%)
Time: 00:00.002, Memory: 18.00 MB
There were 3 failures:
1) Probe\\Tests\\PickTest::testAddsTheItemsAtOrAboveTheFloor
Failed asserting that 3 is identical to 5.
/w/tests/PickTest.php:12
2) Probe\\Tests\\PickTest::testNamesOne
one is singular
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'one item'
+''
/w/tests/PickTest.php:17
3) Probe\\Tests\\PickTest::testNamesMany
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- 'text' => '3 items'
+ 'text' => '3'
)
/w/tests/PickTest.php:22
FAILURES!
Tests: 3, Assertions: 3, Failures: 3.
"""
PASSING = "PHPUnit 12.5.45 by Sebastian Bergmann and contributors.\n\n... 3 / 3 (100%)\n\nOK (3 tests, 3 assertions)\n"
def failing(test: str, *lines: str) -> str:
return "\n".join(["F 1 / 1 (100%)", "", "There was 1 failure:", "", f"1) {test}", *lines, "", "FAILURES!", "Tests: 1, Assertions: 1, Failures: 1.", ""])
class ChangedTest(unittest.TestCase):
def test_is_the_line_an_operator_mutant_changes(self):
self.assertEqual(changed(PICK, OPERATOR), (12, (b"\t\t\tif ($item >= $floor) {",), OPERATOR_NOW))
def test_is_every_line_from_the_first_changed_one_to_the_last(self):
was = tuple(line.encode() for line in LINES[10:15])
now = (b"\t\tforeach ([] as $item) {", b" if ($item >= $floor) {", b"\t\t\t\t$sum += $item;", b"\t\t\t}", b" }")
self.assertEqual(changed(PICK, FOREACH), (11, was, now))
def test_a_mutant_may_have_fewer_lines_than_it_replaces(self):
was = (b"\t\treturn $count === 1", b"\t\t\t? 'one item'", b"\t\t\t: $count . ' items';")
self.assertEqual(changed(PICK, TERNARY), (21, was, (b"\t\treturn $count === 1 ? $count . ' items' : 'one item';",)))
def test_a_mutant_may_only_remove_a_line_or_only_add_one(self):
self.assertEqual(changed("a\nb\nc", "a\nc"), (2, (b"b",), ()))
self.assertEqual(changed("a\nc", "a\nb\nc"), (2, (), (b"b",)))
def test_a_line_counts_as_unchanged_before_the_change_or_after_it_never_both(self):
self.assertEqual(changed("a\nb\nb", "a\nb"), (3, (b"b",), ()))
self.assertEqual(changed("b\nb\nc", "b\nc"), (2, (b"b",), ()))
def test_reaches_the_first_line_and_the_last(self):
self.assertEqual(changed("a\nb", "c\nb"), (1, (b"a",), (b"c",)))
self.assertEqual(changed("a\nb", "a\nc"), (2, (b"b",), (b"c",)))
def test_is_none_where_the_mutant_changes_no_line(self):
self.assertIsNone(changed(PICK, PICK))
def test_what_it_returns_plants_as_the_mutant(self):
for source in (OPERATOR, FOREACH, TERNARY, VISIBILITY):
line, was, now = changed(PICK, source)
self.assertEqual(mutated(PICK.encode(), Mutant("src/Pick.php", line, "a name", was, now)), source.encode())
class KilledMutantsTest(unittest.TestCase):
def setUp(self):
folder = tempfile.TemporaryDirectory()
self.addCleanup(folder.cleanup)
self.top = pathlib.Path(folder.name)
(self.top / "src").mkdir()
(self.top / "src/Pick.php").write_text(PICK, encoding="utf-8")
self.ran: list[tuple[list[str], str, str]] = []
def infection(self, log: dict | str | None, code: int = 0):
"""A run that writes Infection's log where its --logger-json names, or none where log is None, and another log beside it."""
def run(argv: list[str], cwd: str) -> Ran:
self.ran.append((argv, cwd, pathlib.Path(cwd, "src/Pick.php").read_text(encoding="utf-8")))
pathlib.Path(cwd, "infection.html").write_text("every mutant", encoding="utf-8")
if log is not None:
path = next(argument.partition("=")[2] for argument in argv if argument.startswith("--logger-json="))
pathlib.Path(cwd, path).write_text(log if isinstance(log, str) else json.dumps(log), encoding="utf-8")
return Ran(code, "the tool's last words\n")
return run
def test_runs_infection_over_the_files_in_a_copy_of_the_tree_with_a_json_log_and_no_score_to_reach(self):
killed_mutants(str(self.top), ["src/Pick.php", "src/Last.php"], self.infection({"killed": []}), 3)
(argv, cwd, source), = self.ran
self.assertRegex(cwd, rf"^{self.top}/\.mutate-changes-[^/]+/copy$")
self.assertEqual(source, PICK)
self.assertEqual(argv, ["vendor/bin/infection", "--filter=src/Pick.php,src/Last.php", "--threads=3", "--no-progress", "--min-msi=0", "--min-covered-msi=0", "--logger-json=infection-log.json"])
def test_is_each_killed_mutant_as_the_lines_it_changes(self):
log = {"killed": [logged("GreaterThanOrEqualTo", 12, OPERATOR), logged("Ternary", 21, TERNARY)], "escaped": [logged("PublicVisibility", 19, VISIBILITY)]}
found = killed_mutants(str(self.top), ["src/Pick.php"], self.infection(log), 1)
ternary = (b"\t\treturn $count === 1", b"\t\t\t? 'one item'", b"\t\t\t: $count . ' items';")
self.assertEqual(found, [
Mutant("src/Pick.php", 12, "src/Pick.php:12 GreaterThanOrEqualTo", (b"\t\t\tif ($item >= $floor) {",), OPERATOR_NOW),
Mutant("src/Pick.php", 21, "src/Pick.php:21 Ternary", ternary, (b"\t\treturn $count === 1 ? $count . ' items' : 'one item';",)),
])
def test_names_a_mutant_by_the_line_infection_logs_for_it(self):
found = killed_mutants(str(self.top), ["src/Pick.php"], self.infection({"killed": [logged("Foreach_", 11, FOREACH), logged("Ternary", 20, TERNARY)]}), 1)
self.assertEqual([(mutant.line, mutant.name) for mutant in found], [(11, "src/Pick.php:11 Foreach_"), (21, "src/Pick.php:20 Ternary")])
def test_names_a_file_by_its_path_from_the_top_wherever_infection_saw_the_tree(self):
log = {"killed": [logged("GreaterThanOrEqualTo", 12, OPERATOR, path) for path in ("/w/src/Pick.php", "src/Pick.php", "/w/lib/src/Pick.php", "/w/src/Other.php", "/w/src/NotPick.php")]}
found = killed_mutants(str(self.top), ["src/Pick.php", "lib/src/Pick.php", "Pick.php"], self.infection(log), 1)
self.assertEqual([mutant.path for mutant in found], ["src/Pick.php", "src/Pick.php", "lib/src/Pick.php"])
def test_leaves_out_a_mutant_that_changes_no_line(self):
log = {"killed": [logged("GreaterThanOrEqualTo", 12, PICK)]}
self.assertEqual(killed_mutants(str(self.top), ["src/Pick.php"], self.infection(log), 1), [])
def test_leaves_the_tree_as_it_was_whatever_infection_wrote(self):
for code in (0, 1):
killed_mutants(str(self.top), ["src/Pick.php"], self.infection({"killed": []}, code), 1)
self.assertEqual(sorted(str(path.relative_to(self.top)) for path in self.top.rglob("*")), ["src", "src/Pick.php"])
def test_fails_where_infection_exits_nonzero(self):
found = killed_mutants(str(self.top), ["src/Pick.php"], self.infection({"killed": []}, code=1), 1)
self.assertEqual(found, Failure("Infection exited 1:\nthe tool's last words"))
def test_passes_on_a_run_that_could_not_start(self):
failure = Failure("vendor/bin/infection could not start: No such file or directory")
self.assertIs(killed_mutants(str(self.top), ["src/Pick.php"], lambda argv, cwd: failure, 1), failure)
def test_fails_where_infection_wrote_no_log_or_one_it_cannot_read(self):
unreadable = (None, "not json", "{}", '{"killed": [{}]}', '{"killed": [7]}', json.dumps({"killed": [{"mutator": {**logged("Ternary", 21, TERNARY)["mutator"], "mutatedSourceCode": 7}}]}))
for log in unreadable:
with self.subTest(log=log):
found = killed_mutants(str(self.top), ["src/Pick.php"], self.infection(log), 1)
self.assertIsInstance(found, Failure)
self.assertIn("could not read Infection's log, infection-log.json in ", found.reason)
def test_fails_where_the_tree_cannot_be_copied(self):
found = killed_mutants(str(self.top / "missing"), ["src/Pick.php"], self.infection({"killed": []}), 1)
self.assertIsInstance(found, Failure)
self.assertEqual(self.ran, [])
class TaskTextTest(unittest.TestCase):
def test_is_the_first_failed_tests_message_without_the_tests_name_or_file(self):
self.assertEqual(task_text(FAILING), "Failed asserting that 3 is identical to 5.")
def test_is_every_line_of_a_message_up_to_the_file_and_line_that_failed(self):
second = FAILING[FAILING.index("2) "):]
expected = "one is singular\nFailed asserting that two strings are identical.\n--- Expected\n+++ Actual\n@@ @@\n-'one item'\n+''"
self.assertEqual(task_text("There was 1 failure:\n\n" + second), expected)
def test_is_none_on_a_passing_run_or_output_that_lists_no_failure(self):
self.assertIsNone(task_text(PASSING))
self.assertIsNone(task_text("PHP Parse error: syntax error, unexpected token \"}\" in /w/src/Pick.php on line 12\n"))
self.assertIsNone(task_text("1) a line that only looks like a listed test\nits message\n"))
self.assertIsNone(task_text(""))
def test_reads_an_error_as_it_reads_a_failure(self):
output = "E\n\nThere was 1 error:\n\n1) Probe\\Tests\\PickTest::testNamesOne\nTypeError: label(): Argument #1 ($count) must be of type int, string given\n\n/w/src/Pick.php:19\n/w/tests/PickTest.php:17\n\nERRORS!\n"
self.assertEqual(task_text(output), "TypeError: label(): Argument #1 ($count) must be of type int, string given")
def test_leaves_out_each_line_that_names_the_test_its_class_or_its_file(self):
lines = ("testNamesOne went wrong", "PickTest saw it", "see tests/LabelTest.php", "got 3, want 5", "", "/w/tests/PickTest.php:17")
self.assertEqual(task_text(failing("Probe\\Tests\\PickTest::testNamesOne", *lines)), "got 3, want 5")
self.assertEqual(task_text(failing("Probe\\Tests\\PickTest::testNamesOne with data set #0 (1, 'one')", *lines)), "got 3, want 5")
def test_reads_a_listed_test_that_names_no_class(self):
self.assertEqual(task_text(failing("testNamesOne", "got 3, want 5")), "got 3, want 5")
def test_is_none_where_the_message_does_not_say_anything_beyond_the_test(self):
self.assertIsNone(task_text(failing("Probe\\Tests\\PickTest::testNamesOne", "testNamesOne failed", "", "/w/tests/PickTest.php:17")))
def test_reads_no_test_of_another_list_as_a_failed_one(self):
named = failing("Probe\\Tests\\PickTest::testSum", "PickTest failed", "", "/w/tests/PickTest.php:9").partition("FAILURES!")[0]
for heading in ("There was 1 risky test:", "There were 2 risky tests:", "1 test triggered 1 deprecation:", "2 tests triggered 3 PHPUnit warnings:"):
with self.subTest(heading=heading):
output = "\n".join([named, "--", "", heading, "", "1) Probe\\Tests\\LastTest::testLabels", "This test did not perform any assertions", "", "/w/tests/LastTest.php:20", "", "FAILURES!"])
self.assertIsNone(task_text(output))
def test_reads_the_failures_listed_after_another_list(self):
output = "\n".join(["There was 1 risky test:", "", "1) LastTest::testLabels", "This test did not perform any assertions", "", "--", "", "There was 1 failure:", "", "1) PickTest::testSum", "Failed asserting that 3 is identical to 5.", "", "/w/tests/PickTest.php:9", "", "FAILURES!"])
self.assertEqual(task_text(output), "Failed asserting that 3 is identical to 5.")
def test_takes_the_first_failed_test_that_has_a_message(self):
output = "There were 2 failures:\n\n1) PickTest::testAdds\ntestAdds\n\n/w/tests/PickTest.php:12\n\n2) PickTest::testLabels\nno label\n\n/w/tests/PickTest.php:17\n\nFAILURES!\n"
self.assertEqual(task_text(output), "no label")
def test_a_message_without_a_file_and_line_ends_at_the_next_test_or_the_summary(self):
self.assertEqual(task_text("There were 2 failures:\n\n1) PickTest::testAdds\ngot 3\n\n2) PickTest::testLabels\nno label\n"), "got 3")
self.assertEqual(task_text(failing("PickTest::testAdds", "got 3")), "got 3")
self.assertEqual(task_text("There was 1 error:\n\n1) PickTest::testAdds\ngot 3\n\n--\n\nThere was 1 failure:\n\n1) PickTest::testLabels\nno label\n"), "got 3")
if __name__ == "__main__":
unittest.main()
+3 -1
View File
@@ -85,9 +85,11 @@ class LanguagesTest(unittest.TestCase):
class ShippedLanguagesTest(unittest.TestCase):
def test_each_language_reads_its_own_test_runners_output(self):
self.assertEqual([(language.name, language.suffixes) for language in LANGUAGES], [("Go", (".go",)), ("Python", (".py",)), ("Rust", (".rs",))])
self.assertEqual([(language.name, language.suffixes) for language in LANGUAGES], [("Go", (".go",)), ("PHP", (".php",)), ("Python", (".py",)), ("Rust", (".rs",)), ("TypeScript", (".cjs", ".cts", ".js", ".jsx", ".mjs", ".mts", ".ts", ".tsx"))])
self.assertEqual(task_text("calc.go", "--- FAIL: TestPick (0.00s)\n pick_test.go:42: got 3, want 4\nFAIL\n"), "got 3, want 4")
self.assertEqual(task_text("calc.py", "==== FAILURES ====\n___ test_pick ___\nE assert 3 == 4\n"), "assert 3 == 4")
self.assertEqual(task_text("Calc.php", "There was 1 failure:\n\n1) CalcTest::testPicks\ngot 3, want 4\n\n/w/tests/CalcTest.php:9\n"), "got 3, want 4")
self.assertEqual(task_text("calc.ts", "✖ failing tests:\n\ntest at calc.test.ts:5:1\n✖ picks (1.2ms)\n Error: got 3, want 4\n at pick (file:///w/calc.ts:9:5)\n"), "Error: got 3, want 4")
self.assertEqual(task_text("calc.rs", "---- picks stdout ----\nthread 'picks' (7) panicked at src/calc.rs:9:5:\ngot 3, want 4\n"), "got 3, want 4")
+49
View File
@@ -0,0 +1,49 @@
"""The copy of a tree that a mutation tool runs in."""
import os
import pathlib
import socket
import sys
import tempfile
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from failure import Failure
from task_bench.scratch_copy import scratch_copy
class ScratchCopyTest(unittest.TestCase):
def setUp(self):
folder = tempfile.TemporaryDirectory()
self.addCleanup(folder.cleanup)
self.top = pathlib.Path(folder.name)
(self.top / "src").mkdir()
(self.top / "src/pick.ts").write_text("code", encoding="utf-8")
(self.top / ".hidden").write_text("kept", encoding="utf-8")
def test_copies_every_entry_of_the_tree_into_a_scratch_folder_in_it(self):
scratch, copy = scratch_copy(str(self.top))
self.assertRegex(scratch, rf"^{self.top}/\.mutate-changes-[^/]+$")
self.assertEqual(copy, f"{scratch}/copy")
self.assertEqual(sorted(str(path.relative_to(copy)) for path in pathlib.Path(copy).rglob("*")), [".hidden", "src", "src/pick.ts"])
self.assertEqual(pathlib.Path(copy, "src/pick.ts").read_text(encoding="utf-8"), "code")
def test_keeps_a_link_as_a_link(self):
(self.top / "linked").symlink_to("src/missing.ts")
_, copy = scratch_copy(str(self.top))
self.assertEqual(os.readlink(os.path.join(copy, "linked")), "src/missing.ts")
def test_fails_without_a_scratch_folder_left_where_the_tree_cannot_be_copied(self):
# A socket is an entry that no copy can read.
held = socket.socket(socket.AF_UNIX)
self.addCleanup(held.close)
held.bind(str(self.top / "held"))
found = scratch_copy(str(self.top))
self.assertIsInstance(found, Failure)
self.assertRegex(found.reason, rf"^could not copy {self.top} into {self.top}/\.mutate-changes-[^/]+: ")
self.assertEqual(sorted(path.name for path in self.top.iterdir()), [".hidden", "held", "src"])
def test_passes_on_that_no_scratch_folder_could_be_made(self):
found = scratch_copy(str(self.top / "missing"))
self.assertIsInstance(found, Failure)
self.assertIn("could not make a scratch folder in ", found.reason)
+2 -2
View File
@@ -236,7 +236,7 @@ class BenchTest(unittest.TestCase):
def test_the_command_line_fails_with_the_reason_where_the_places_or_the_bench_fail(self):
argv = [part for name, value in self.given.items() for part in (name, value)]
for places, said in ((Failure("no history"), "no history\n"), ("- `gone.go:1` `Gone`: removed\n", "The places the seats found hard don't name any Go, Python or Rust file that the base holds, so there is nowhere to plant a bug.\n")):
for places, said in ((Failure("no history"), "no history\n"), ("- `gone.go:1` `Gone`: removed\n", "The places the seats found hard don't name any file at the base in a language the bench plants bugs in, so there is nowhere to plant a bug.\n")):
with contextlib.redirect_stdout(io.StringIO()) as out, contextlib.redirect_stderr(io.StringIO()) as errors:
self.assertEqual(main.main(argv, self.env, lambda home: places), 1)
self.assertEqual((out.getvalue(), errors.getvalue().splitlines(keepends=True)[-1]), ("", said))
@@ -309,7 +309,7 @@ class BenchTest(unittest.TestCase):
def test_fails_where_the_places_name_no_file_of_the_base_in_a_language_the_bench_plants_in(self):
with contextlib.redirect_stderr(io.StringIO()):
found = main.bench({**self.given, "--base": "main"}, self.env, lambda home: "- `gone.go:1` `Gone`: removed\n- `README.md:1` `Calc`: thin\n", self.home)
self.assertEqual(found, Failure("The places the seats found hard don't name any Go, Python or Rust file that the base holds, so there is nowhere to plant a bug."))
self.assertEqual(found, Failure("The places the seats found hard don't name any file at the base in a language the bench plants bugs in, so there is nowhere to plant a bug."))
self.assertFalse(self.log.exists())
def test_fails_where_the_tests_fail_without_a_bug(self):
+273
View File
@@ -0,0 +1,273 @@
"""task-bench's TypeScript planter: which files Stryker mutates, how its report's mutants become lines and what `node --test`'s
output tells Haiku.
PICK's mutants and FAILING are what Stryker 10.1.1 and Node.js 24.19.0 wrote for a small project, each mutant cut down to the keys
the planter reads. The other mutants and outputs are made up in the same form."""
import json
import pathlib
import sys
import tempfile
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench.typescript_bugs import changed, killed_mutants, task_text
from failure import Failure
from task_bench.planted_mutant import Mutant, mutated
from mutate_changes.tool_process import Ran
PICK = """export function pick(items: number[], floor: number): number {
let sum = 0;
for (const item of items) {
if (item >= floor) {
sum += item;
}
}
return sum;
}
export const tag = (n: number): string => "é😀" + (n > 1 ? "s" : "");
""".encode()
LINES = PICK.split(b"\n")
def reported(mutator: str, replacement: str, start: tuple[int, int], end: tuple[int, int], status: str = "Killed") -> dict:
return {"mutatorName": mutator, "replacement": replacement, "status": status, "location": {"start": {"line": start[0], "column": start[1]}, "end": {"line": end[0], "column": end[1]}}}
OPERATOR = reported("EqualityOperator", "item > floor", (4, 7), (4, 20))
BLOCK = reported("BlockStatement", "{}", (4, 22), (6, 4))
# Stryker counts a column in UTF-16 code units: the string before this condition holds one character of two units.
AFTER_WIDE_TEXT = reported("ConditionalExpression", "true", (11, 52), (11, 57))
# Three failed tests, the last two in a suite.
FAILING = """
> test
> node --test "src/**/*.test.ts"
✖ adds the items at or above the floor (1.654962ms)
▶ label
✖ names one (0.432991ms)
✖ names many (1.398742ms)
✖ label (2.262912ms)
ℹ tests 3
ℹ suites 1
ℹ pass 0
ℹ fail 3
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 164.424758
✖ failing tests:
test at src/pick.test.ts:5:1
✖ adds the items at or above the floor (1.654962ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
3 !== 5
at TestContext.<anonymous> (file:///w/src/pick.test.ts:6:9)
at Test.runInAsyncScope (node:async_hooks:227:14)
at startSubtestAfterBootstrap (node:internal/test_runner/harness:387:17) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: 3,
expected: 5,
operator: 'strictEqual',
diff: 'simple'
}
test at src/pick.test.ts:10:2
✖ names one (0.432991ms)
AssertionError [ERR_ASSERTION]: one is singular
'' !== 'one item'
at TestContext.<anonymous> (file:///w/src/pick.test.ts:11:10)
at Array.map (<anonymous>) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: '',
expected: 'one item',
operator: 'strictEqual',
diff: 'simple'
}
test at src/pick.test.ts:13:2
✖ names many (1.398742ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected
{
+ text: ''
- text: '3 items'
}
at TestContext.<anonymous> (file:///w/src/pick.test.ts:14:10) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: [Object],
expected: [Object],
operator: 'deepStrictEqual',
diff: 'simple'
}
"""
PASSING = "✔ adds the items at or above the floor (1.3494ms)\nℹ tests 1\nℹ pass 1\nℹ fail 0\n"
def failing(test: str, *lines: str) -> str:
return "\n".join([f"✖ {test} (1.2ms)", "ℹ fail 1", "", "✖ failing tests:", "", "test at src/pick.test.ts:5:1", f"✖ {test} (1.2ms)", *lines, ""])
class ChangedTest(unittest.TestCase):
def test_is_the_line_with_the_replacement_between_the_mutants_columns(self):
self.assertEqual(changed(OPERATOR["location"], "item > floor", LINES), (4, (b"\t\tif (item >= floor) {",), (b"\t\tif (item > floor) {",)))
def test_is_every_line_a_mutant_spans(self):
was = (b"\t\tif (item >= floor) {", b"\t\t\tsum += item;", b"\t\t}")
self.assertEqual(changed(BLOCK["location"], "{}", LINES), (4, was, (b"\t\tif (item >= floor) {}",)))
def test_a_replacement_of_more_lines_is_as_many_lines(self):
self.assertEqual(changed(OPERATOR["location"], "item >\n\t\t\tfloor", LINES), (4, (LINES[3],), (b"\t\tif (item >", b"\t\t\tfloor) {")))
def test_reaches_the_files_first_column_and_its_last_line(self):
self.assertEqual(changed(reported("M", "", (1, 1), (1, 8))["location"], "", LINES[:2]), (1, (LINES[0],), (LINES[0][7:],)))
self.assertEqual(changed(reported("M", "0", (2, 12), (2, 13))["location"], "0", LINES[:2]), (2, (LINES[1],), (LINES[1],)))
def test_a_mutant_that_replaces_no_code_adds_its_own(self):
self.assertEqual(changed(reported("M", "!", (4, 7), (4, 7))["location"], "!", LINES), (4, (LINES[3],), (b"\t\tif (!item >= floor) {",)))
def test_counts_a_column_in_utf_16_code_units(self):
now = 'export const tag = (n: number): string => "é😀" + (true ? "s" : "");'.encode()
self.assertEqual(changed(AFTER_WIDE_TEXT["location"], "true", LINES), (11, (LINES[10],), (now,)))
def test_is_none_where_the_file_holds_no_such_line_or_column(self):
for start, end in (((0, 1), (1, 2)), ((12, 1), (13, 1)), ((4, 7), (99, 1)), ((4, 40), (4, 41)), ((4, 0), (4, 3)), ((4, 9), (4, 7)), ((5, 1), (4, 3))):
with self.subTest(start=start, end=end):
self.assertIsNone(changed(reported("M", "x", start, end)["location"], "x", LINES))
def test_what_it_returns_plants_as_the_mutant(self):
line, was, now = changed(BLOCK["location"], "{}", LINES)
planted = mutated(PICK, Mutant("src/pick.ts", line, "a name", was, now))
self.assertEqual(planted, PICK.replace(b" {\n\t\t\tsum += item;\n\t\t}", b" {}"))
class KilledMutantsTest(unittest.TestCase):
def setUp(self):
folder = tempfile.TemporaryDirectory()
self.addCleanup(folder.cleanup)
self.top = pathlib.Path(folder.name)
(self.top / "src").mkdir()
(self.top / "src/pick.ts").write_bytes(PICK)
self.ran: list[tuple[list[str], str, bytes]] = []
def stryker(self, files: dict[str, list[dict]] | None, code: int = 0, text: str | None = None):
"""A run that writes Stryker's report of these files' mutants where it runs, or none where files is None, and Stryker's
incremental file beside it."""
def run(argv: list[str], cwd: str) -> Ran:
self.ran.append((argv, cwd, pathlib.Path(cwd, "src/pick.ts").read_bytes()))
report = pathlib.Path(cwd, "reports/mutation/mutation.json")
report.parent.mkdir(parents=True, exist_ok=True)
pathlib.Path(cwd, "reports/stryker-incremental.json").write_text("every mutant", encoding="utf-8")
if files is not None:
report.write_text(text if text is not None else json.dumps({"files": {path: {"source": PICK.decode(), "mutants": mutants} for path, mutants in files.items()}}), encoding="utf-8")
return Ran(code, "the tool's last words\n")
return run
def test_runs_stryker_over_the_files_in_a_copy_of_the_tree_with_its_json_reporter(self):
killed_mutants(str(self.top), ["src/pick.ts", "src/last.ts"], self.stryker({}), 3)
(argv, cwd, source), = self.ran
self.assertEqual(argv, ["npx", "--no", "--package=@stryker-mutator/core", "stryker", "run", "--mutate", "src/pick.ts,src/last.ts", "--concurrency", "3", "--reporters", "json"])
self.assertRegex(cwd, rf"^{self.top}/\.mutate-changes-[^/]+/copy$")
self.assertEqual(source, PICK)
def test_names_a_file_whose_path_holds_a_globs_characters_by_a_glob_that_matches_it(self):
killed_mutants(str(self.top), ["app/[slug]/page.tsx", "src/pick.ts"], self.stryker({}), 1)
self.assertEqual(self.ran[0][0][6], "app/?slug?/page.tsx,src/pick.ts")
def test_is_each_killed_mutant_as_the_lines_it_changes(self):
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker({"src/pick.ts": [OPERATOR, BLOCK]}), 1)
self.assertEqual(found, [
Mutant("src/pick.ts", 4, "src/pick.ts:4:7 EqualityOperator", (LINES[3],), (b"\t\tif (item > floor) {",)),
Mutant("src/pick.ts", 4, "src/pick.ts:4:22 BlockStatement", tuple(LINES[3:6]), (b"\t\tif (item >= floor) {}",)),
])
def test_leaves_out_a_mutant_no_test_killed(self):
others = [reported("EqualityOperator", "item < floor", (4, 7), (4, 20), status) for status in ("Survived", "NoCoverage", "Timeout", "CompileError", "RuntimeError", "Ignored")]
self.assertEqual(killed_mutants(str(self.top), ["src/pick.ts"], self.stryker({"src/pick.ts": others}), 1), [])
def test_leaves_out_a_mutant_in_another_file_or_at_a_place_the_file_does_not_hold(self):
files = {"src/other.ts": [OPERATOR], "src/pick.ts": [reported("EqualityOperator", "x", (40, 1), (40, 2)), OPERATOR]}
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(files), 1)
self.assertEqual([mutant.name for mutant in found], ["src/pick.ts:4:7 EqualityOperator"])
def test_leaves_the_tree_as_it_was_whatever_stryker_wrote(self):
for files in ({"src/pick.ts": [OPERATOR]}, None):
killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(files, code=1), 1)
self.assertEqual(sorted(str(path.relative_to(self.top)) for path in self.top.rglob("*")), ["src", "src/pick.ts"])
def test_reads_the_report_of_a_run_that_finished_under_the_score_its_config_asks_for(self):
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker({"src/pick.ts": [OPERATOR]}, code=1), 1)
self.assertEqual([mutant.name for mutant in found], ["src/pick.ts:4:7 EqualityOperator"])
def test_fails_where_stryker_exits_nonzero_without_a_report(self):
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(None, code=1), 1)
self.assertEqual(found, Failure("Stryker exited 1:\nthe tool's last words"))
def test_reads_no_report_that_the_tree_held_before_the_run(self):
(self.top / "reports/mutation").mkdir(parents=True)
(self.top / "reports/mutation/mutation.json").write_text(json.dumps({"files": {"src/pick.ts": {"source": PICK.decode(), "mutants": [OPERATOR]}}}), encoding="utf-8")
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(None, code=1), 1)
self.assertEqual(found, Failure("Stryker exited 1:\nthe tool's last words"))
def test_passes_on_a_run_that_could_not_start(self):
failure = Failure("npx could not start: No such file or directory")
self.assertIs(killed_mutants(str(self.top), ["src/pick.ts"], lambda argv, cwd: failure, 1), failure)
def test_fails_where_stryker_wrote_no_report_or_one_it_cannot_read(self):
for files, text in ((None, None), ({}, "not json"), ({}, '{"files": {"src/pick.ts": {"source": ""}}}'), ({}, '{"files": {"src/pick.ts": {"source": "", "mutants": [{"status": "Killed"}]}}}')):
with self.subTest(text=text):
found = killed_mutants(str(self.top), ["src/pick.ts"], self.stryker(files, text=text), 1)
self.assertIsInstance(found, Failure)
self.assertIn("could not read Stryker's report, reports/mutation/mutation.json in ", found.reason)
def test_fails_where_the_tree_cannot_be_copied(self):
found = killed_mutants(str(self.top / "missing"), ["src/pick.ts"], self.stryker({}), 1)
self.assertIsInstance(found, Failure)
self.assertEqual(self.ran, [])
class TaskTextTest(unittest.TestCase):
def test_is_the_first_failed_tests_error_without_the_tests_name_file_or_stack(self):
self.assertEqual(task_text(FAILING), "AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n3 !== 5")
def test_is_none_on_a_passing_run_or_output_that_lists_no_failing_test(self):
self.assertIsNone(task_text(PASSING))
self.assertIsNone(task_text("SyntaxError: Unexpected token\n at node:internal/modules/esm/loader:1:1\n"))
self.assertIsNone(task_text(""))
def test_leaves_out_each_line_that_names_the_test_or_its_file(self):
output = failing("adds the items", " Error: adds the items failed", " got 3 in src/pick.test.ts", " want 5", " at TestContext.<anonymous> (file:///w/src/pick.test.ts:6:9)")
self.assertEqual(task_text(output), "want 5")
def test_is_none_where_the_error_does_not_say_anything_beyond_the_test(self):
self.assertIsNone(task_text(failing("adds the items", " Error: adds the items failed", " at TestContext.<anonymous> (file:///w/src/pick.test.ts:6:9)")))
def test_takes_the_first_failed_test_that_has_an_error(self):
first = failing("adds", " Error: adds", " at TestContext.<anonymous> (file:///w/src/pick.test.ts:6:9)")
second = "\n".join(["test at src/pick.test.ts:9:1", "✖ labels (0.4ms)", " Error: no label", " at label (file:///w/src/pick.ts:12:9)", ""])
self.assertEqual(task_text(first + "\n" + second), "Error: no label")
def test_an_error_without_a_stack_ends_at_its_test(self):
output = failing("adds", " 'a string was thrown'") + "\ntest at src/pick.test.ts:9:1\n✖ labels (0.4ms)\n Error: no label\n"
self.assertEqual(task_text(output), "'a string was thrown'")
def test_an_error_runs_to_the_end_of_the_output(self):
self.assertEqual(task_text("✖ failing tests:\n\ntest at a.test.ts:1:1\n✖ adds (1ms)\n Error: got 3\n want 5"), "Error: got 3\nwant 5")
def test_a_line_before_the_list_of_failing_tests_is_no_error(self):
self.assertIsNone(task_text("✖ adds (1ms)\n Error: printed by the test itself\nℹ fail 1\n\n✖ failing tests:\n\ntest at a.test.ts:1:1\n✖ adds (1ms)\n"))
if __name__ == "__main__":
unittest.main()
+113
View File
@@ -0,0 +1,113 @@
"""The bugs task-bench plants in TypeScript and JavaScript: Stryker's killed mutants, re-applied from its JSON report, and the error
`node --test` prints when a test fails on one."""
import json
import pathlib
import re
from mutate_changes.tool_process import failed, remove, Run
from failure import Failure
from mutate_changes import in_diff_tools
from task_bench.planted_mutant import Mutant
from task_bench.scratch_copy import scratch_copy
# Where Stryker 10.1.1's json reporter writes, from the folder it runs in. Only the project's own Stryker config can set another
# path, so the planter reads this one.
REPORT = "reports/mutation/mutation.json"
# The heading of the list of failed tests that `node --test`'s spec reporter prints. Each test in it has its error.
FAILING_TESTS = "✖ failing tests:"
# Where a listed test stands, the line before its name: `test at src/pick.test.ts:5:1`.
TEST_PLACE = re.compile(r"^test at \S+:\d+:\d+$")
# A listed test's name and how long it ran: `✖ adds the items (1.654962ms)`.
TEST = re.compile(r"^✖ (.+) \(\d+(?:\.\d+)?ms\)$")
# A line of the error's stack, which follows its message: ` at TestContext.<anonymous> (file:///w/src/pick.test.ts:6:9)`.
STACK = re.compile(r"^\s+at ")
TEST_FILE = re.compile(r"\.(?:spec|test)\.[cm]?[jt]sx?\b")
def killed_mutants(top: str, files: list[str], run: Run, jobs: int) -> list[Mutant] | Failure:
"""The mutants in `files` that the tests of the tree at top kill, as Stryker finds them in a copy of that tree. One at a place
its file doesn't hold is left out.
Stryker runs at the copy's top, with the Stryker config and the package.json there."""
copied = scratch_copy(top)
if isinstance(copied, Failure):
return copied
scratch, copy = copied
try:
mutate = ",".join(in_diff_tools.glob_escaped(path) for path in files)
report = pathlib.Path(copy, REPORT)
# A report the project tracks would otherwise stand for this run's.
report.unlink(missing_ok=True)
ran = run([*in_diff_tools.STRYKER_RUN, "--mutate", mutate, "--concurrency", str(jobs), "--reporters", "json"], copy)
# Stryker exits 1 too where it finished under the score the project's config sets as `thresholds.break`, which the files'
# score may be. Only a run that finished writes the report.
if isinstance(ran, Failure) or ran.code and not report.is_file():
return ran if isinstance(ran, Failure) else failed("Stryker", ran)
reported = json.loads(report.read_bytes())["files"]
return [mutant for path in files if path in reported for mutant in file_mutants(path, reported[path])]
except (OSError, ValueError, KeyError, TypeError) as failure:
return Failure(f"could not read Stryker's report, {REPORT} in {copy}: {failure}")
finally:
remove(scratch)
def file_mutants(path: str, reported: dict) -> list[Mutant]:
"""The killed mutants of the file at path, from what Stryker's report holds of it: the source Stryker read, and each mutant."""
lines = reported["source"].encode().split(b"\n")
killed = [mutant for mutant in reported["mutants"] if mutant["status"] == "Killed"]
found = [(mutant, changed(mutant["location"], mutant["replacement"], lines)) for mutant in killed]
return [Mutant(path, lines_changed[0], f"{path}:{mutant['location']['start']['line']}:{mutant['location']['start']['column']} {mutant['mutatorName']}", lines_changed[1], lines_changed[2]) for mutant, lines_changed in found if lines_changed]
def changed(location: dict, replacement: str, lines: list[bytes]) -> tuple[int, tuple[bytes, ...], tuple[bytes, ...]] | None:
"""The lines a mutant changes; `lines` are its file's. Stryker's report gives the code the mutant puts in, and where the code it
replaces starts and ends: each a line and a column, both from 1, the end's column the first one after that code. Returned are
the number of the first line, those lines as the file has them, and what the mutant has in their place. None where the file
holds no such lines or columns."""
start, end = location["start"], location["end"]
if not 1 <= start["line"] <= end["line"] <= len(lines) or (start["line"], start["column"]) > (end["line"], end["column"]):
return None
before, after = cut(lines[start["line"] - 1], start["column"]), cut(lines[end["line"] - 1], end["column"])
if before is None or after is None:
return None
now = before[0] + replacement.encode() + after[1]
return start["line"], tuple(lines[start["line"] - 1:end["line"]]), tuple(now.split(b"\n"))
def cut(line: bytes, column: int) -> tuple[bytes, bytes] | None:
"""A line's bytes before a column and from it on. Stryker counts a column in UTF-16 code units, as JavaScript counts a string's
length, so a character outside the Basic Multilingual Plane is two columns. None where the line holds no such column, or is not
UTF-8."""
try:
units = line.decode().encode("utf-16-le")
at = 2 * (column - 1)
if not 0 <= at <= len(units):
return None
return units[:at].decode("utf-16-le").encode(), units[at:].decode("utf-16-le").encode()
except UnicodeError:
return None
def task_text(output: str) -> str | None:
"""What Haiku is told of a planted bug: the error of the first test that has an error in `node --test`'s list of failing
tests, without the test's name or file and without the stack, so it says what goes wrong and not which test shows it.
None where the output lists no failing test with an error, as on a passing run, a file that fails to load or a reporter other
than spec, or where each error only names its test."""
listed = f"\n{output}".partition(f"\n{FAILING_TESTS}\n")[2]
errors: list[tuple[str, list[str]]] = []
within = False
for line in listed.splitlines():
if test := TEST.match(line):
errors.append((test[1], []))
within = True
elif TEST_PLACE.match(line) or STACK.match(line):
within = False
elif within:
errors[-1][1].append(line.strip())
kept = (kept_lines(test, error) for test, error in errors)
return next(("\n".join(lines) for lines in kept if lines), None)
def kept_lines(test: str, error: list[str]) -> list[str]:
return [text for text in error if text and test not in text and not TEST_FILE.search(text)]
+107
View File
@@ -4372,3 +4372,110 @@ Inherited architect, decided by:
- Navigation, Shape: `bin/do_epic/epic_run.py:21` `EpicRun`: the shared run record has one named place both main.py and parking.py import
- Locality: `bin/claude_code/entries.py:87` `json_objects`: stream parsing done once in one module
- Shape: `bin/task_bench/main.py:199` `on_disk`: sits beside hand-written try/except OSError blocks, two ways for one job; plant.py imports `Side` from the measuring module
## 2026-11-26T15:04:52Z, PR #731 at 68611733
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Junior A | 7 | 5.5 | 6 | 5.5 | 6 |
| Mid A | 7.5 | 6 | 6.5 | 6.5 | 6.5 |
| Maintainability senior | 7.5 | 5.5 | 6.5 | 6 | 6 |
| Inherited architect | 6.5 | 6.5 | 5.5 | 6 | 6 |
| Mean | 7.13 | 5.88 | 6.13 | 6.00 | 6.13 |
Junior A, hardest first:
- Locality, Overall: `bin/chunk_pr/main.py:448` `merged`: a polling loop with approval waits, a flock turn queue and a hidden call to larv-review; the module docstring must stay open beside it
- Self-sufficiency: `bin/project_config/settings.py:205` `load`: some 22 unnamed cross-setting checks in one comprehension, none pointing to its README bullet
- Locality: `bin/agent_cycle/routing.py:115` `unfinished_route`: rung, floor, cap, mark and unfinished count worked through by hand
- Shape: `bin/do_epic/main.py:236` `chunk_run`: threads `news` through `parked_through`, with a nested `Landed` conditional read three times
- Shape: `bin/agent_cycle/run.py:160` `rule`: runs the judge, annotates, steps the route and archives, beside four similarly named archive helpers
- Self-sufficiency: `bin/plan/ranking.py:144` `weigh`: every stage branches on an old and a new item shape, and nothing says which is current
- Self-sufficiency: `bin/rule_hook/rules.py:27` `RULES`: long legal-sounding strings that are slow to check against the code
- Shape: `bin/larv_review/main.py:228` `COMMANDS`: rows hold long nested lambdas, under a 167-line docstring that is the real spec
Mid A, hardest first:
- Locality, Shape, Overall: `bin/do_epic/scheduler.py:172` `start_chunks`: four sets built from tmux window names, a five-way elif over two limits, and a nested flock
- Locality: `bin/chunk_pr/main.py:448` `merged`: one function decides between human merge, waits, parks, the epic and a flock queue whose order lives outside the process
- Locality: `bin/agent_cycle/routing.py:115` `unfinished_route`: five rung notions at once, settled only by the module's verdict table
- Self-sufficiency: `bin/project_config/settings.py:205` `load`: which combinations of settings are legal takes reading all 22 faults
- Locality: `bin/agent_cycle/judge.py:300` `judge_prompt`: budget arithmetic, and a heading that judge_replay parses back
- Shape: `bin/do_epic/main.py:236` `chunk_run`: a long loop mixing parked news, a reopened epic and the Landed choice
- Shape: `bin/chunk_pr/main.py:398` `epic_opened`: a chain of `isinstance(x, Failure)` conditionals, then a truthiness test on what may be a Failure
- Shape: `bin/rule_hook/env_file.py:41` `reaching`: relies on `and` binding tighter than `or`
Maintainability senior, hardest first:
- Locality, Shape, Overall: `bin/do_epic/scheduler.py:172` `start_chunks`: six sets and a five-branch elif, each branch depending on how the sets were built
- Locality: `bin/do_epic/parking.py:18` `parked_through`: parked state lives in a state file, a tmux window name and Jira, and only the docstring states the order
- Locality: `bin/agent_cycle/routing.py:115` `unfinished_route`: five rung notions plus the unfinished count and the mark, read three times beside the table
- Locality, Shape: `bin/chunk_pr/main.py:448` `merged`: each mode is documented alone, and nothing says how they combine
- Locality: `bin/agent_cycle/escalation_mark.py:1` module docstring: the mark is written in judge.py, read in run.py and turned into a rung in routing.py
- Shape: `bin/release_plan/release_standing.py:206` `next_release`: an algebra of tags, dated headings and named releases, decoded through a field comment
- Shape: `bin/do_epic/main.py:236` `chunk_run`: `news` is a `str | Stop` that also stands for parked
- Self-sufficiency: `bin/larv_review/scoring_due.py:23` `Emptied`: a `str` subclass as a type tag, with its reason in the decision log
Inherited architect, would restructure first:
- Shape, Overall: `bin/do_epic/main.py:378` `issue_move`: the 563-line module imports some 30 modules and holds parsing, status, the chunk loop, issue moves and premises
- Locality: `bin/review_rules/round_titles.py:73` `cap`: the round cap is counted twice, restated in SKILL.md and enforced at two of three moments
- Locality: `bin/larv_review/reviewer_header.py:75` `unanswered_round`: counts rounds unguarded, beside rule-hook's guarded count
- Locality: `bin/rule_hook/round_cap.py:28` `earlier_titles`: fails open where git is slow or no default ref exists
- Shape: `bin/chunk_driver/this_loop.py:12` `Loop`: do-epic builds it too, so the name points the wrong way
- Shape: `bin/agent_cycle/hand_over.py:1` module: "hand over" names four different things across loop_claude and do_epic
- Navigation: `README.md:244` "Packages under bin/": the only grouping of 86 flat entries in `bin/`
- Self-sufficiency: `bin/agent_cycle/run.py:33` `Cycle`: the why behind caps and limits sits behind decision-log citations
## 2026-11-26T15:10:22Z, PR #731 rerun at 68611733
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Junior A | 7 | 5.5 | 6 | 5.5 | 6 |
| Mid A | 7 | 6 | 6 | 5.5 | 6 |
| Maintainability senior | 7.5 | 6 | 6.5 | 6 | 6.5 |
| Inherited architect | 7 | 7 | 6 | 6.5 | 6.5 |
| Mean | 7.13 | 6.13 | 6.13 | 5.88 | 6.25 |
Junior A, hardest first:
- Locality, Overall: `bin/do_epic/scheduler.py:172` `start_chunks`: five branches over seven sets and three limits under one lock, with part of the parked state read from tmux window names
- Locality: `bin/do_epic/parking.py:105` `resumed_news`: an endless poll loop whose `awaits`, `stays`, `shown` and `said` mix display state with control state
- Shape: `bin/chunk_pr/main.py:448` `merged`: one merge path carries four flags and two sentinels across a loop of turns and a flock queue
- Shape: `bin/do_epic/main.py:236` `chunk_run`: a loop over `news` that computes `Landed` inline, with a near-twin `handed_on` in loop_claude to compare by hand
- Locality: `bin/agent_cycle/judge.py:300` `judge_prompt`: the prompt's wording is coupled to judge_replay's parsing of archived prompts
- Shape: `bin/project_config/settings.py:205` `load`: about 20 conditional checks in one list, with the table they depend on 175 lines below
- Self-sufficiency: `bin/plan/ranking.py:144` `weigh`: an old and a new item shape branch through the module, and nothing says which is current
- Shape: `bin/rule_hook/folder_search.py:89` `skips`: models the flag clusters of rg and ag, hard because the problem is
Mid A, hardest first:
- Locality, Overall: `bin/chunk_pr/main.py:516` `merge_turn`: four merge settings, the flock queue and the approval wait held at once, with the success path hidden in chained `isinstance` checks
- Self-sufficiency: `skills/larv-review/SKILL.md:102` `Re-entry`: a rule table with exceptions to its own rows, each bullet pointing at another section by name
- Locality: `bin/agent_cycle/routing.py:115` `unfinished_route`: five rungs, a step count, the escalation mark and a cap, with the mark's meaning split over four modules
- Self-sufficiency: `bin/agent_cycle/judge.py:88` `Reply`: the field names don't say what each verdict means to the loop
- Self-sufficiency: `bin/rule_hook/folder_search.py:89` `skips`: flag semantics of rg and ag that can't be checked without the tools' manuals
- Locality: `bin/do_epic/main.py:485` `next_cycle`: picks the prompt by comparing a tmux window name with the epic's key, without saying the name is an identity
- Shape: `bin/agent_cycle/run.py:250` `close`: one long conditional expression decides the archived outcome, beside three similarly named archive helpers
Maintainability senior, hardest first:
- Locality, Overall: `bin/chunk_pr/main.py:448` `merged`: one queue loop holds eight concerns whose order matters, rebuilt only with the 109-line help docstring beside it
- Self-sufficiency: `skills/larv-review/SKILL.md:102` `Re-entry`: exceptions to exceptions, read three times to know which passes a fix reruns
- Shape: `bin/do_epic/main.py:236` `chunk_run`: the loop variable `news` is a `str` or a `Stop`, and a nested conditional picks the `Landed` value
- Self-sufficiency: `bin/do_epic/main.py:402` `handed_on`: retries through an intermediate status and polls with no stated bound
- Shape: `bin/chunk_pr/main.py:398` `epic_opened`: a chain of `x = prev if isinstance(prev, Failure) else f(prev)` hides the success path in the else arms
- Self-sufficiency: `bin/plan/ranking.py:239` `score`: branches on goal term and on an old and a new shape, and the reason sits in a plan item
- Shape: `bin/project_config/settings.py:205` `load`: about twenty conditional entries encode the cross-setting rules
- Shape: `bin/rule_hook/rules.py:27` `RULES`: each rule's prose is one very long string, which hides the table's structure
Inherited architect, would restructure first:
- Shape, Overall: `README.md:244` `Packages under bin/`: one flat list of about 40 bullets carries a level of some 82 entries, with no grouping into families
- Navigation: `bin/agent_cycle/routing.py:115` `unfinished_route`: routing has about nine homes, and no file says which parts make it up
- Self-sufficiency: `bin/review_rules/round_titles.py:39` `named_counts`: the round cap's whole contract lives in SKILL.md prose, and no code counts reviewer launches
- Self-sufficiency: `bin/rule_hook/round_cap.py:28` `earlier_titles`: fails open to an empty list on a slow git, and nothing at the cap says so
- Shape: `bin/chunk_driver/this_loop.py:12` `Loop`: built per chunk and used by do-epic too, as the `loop_`-prefixed packages are
- Shape: `bin/chunk_driver/cycle_start.py:96` `cycle_of`: ten keyword arguments on one line
- Shape: `bin/agent_cycle/run.py:33` `Cycle`: 17 fields, allowed by a decision the reader must open the log to read
- Locality: `bin/loop_claude/loop/reload.py:85` `fingerprint`: an edit to any `.py` under `bin/` reloads the running loop, through a handover format that already carries history
+25
View File
@@ -3661,3 +3661,28 @@ Read most (opens and searches):
- `bin/task_bench/bench_folder.py` 2
- `bin/task_bench/feature_tasks.py` 2
- `docs/decisions.md` 2
## Reading cost, chunk a2b51a47f8f9, finished 2026-11-26T09:29:04Z
51817 new input tokens before the first commit.
Read most (opens and searches):
- `principles/technical-principles.md` 2
## Reading cost, chunk 3ffee0d362c0, finished 2026-11-26T11:46:13Z
140289 new input tokens before the first commit.
Read most (opens and searches):
- `bin/task_bench/main.py` 9
- `README.md` 6
- `bin/mutate_changes/in_diff_tools.py` 3
- `bin/task_bench/planted_mutant.py` 3
- `bin/task_bench/test_rust_bugs.py` 3
- `bin/mutate_changes/changed_lines.py` 2
- `bin/mutate_changes/tool_process.py` 2
- `bin/task_bench/go_bugs.py` 2
- `bin/task_bench/tasks.py` 2
- `bin/task_bench/test_go_bugs.py` 2
+31 -73
View File
@@ -12,10 +12,6 @@
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 544 | 0.16.0 | | | **Make stability-reviewer list every consumer of a shared producer whose yield or return value the diff changes, and state what each does with the new case.** | 1 | 2 | 3 | 4 | 1 | 1.1 by 3 | 1.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 |
| 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 |
| 477 | 0.17.0 | | question | **Rewrite `## Goals` and `## Audience` for a setup others install and run apart from their own `~/.claude`.** | 1 | 1 | 2 | 2 | 2 | | 0.0 |
| 478 | 0.17.0 | | question | **Name the project, its repo and its two commands, today proposed as `do-release` and `do-epic`.** | 1 | 1 | 2 | 2 | 1 | | 0.0 |
| 542 | 0.17.0 | | | **Make chunk-preflight report a project whose code is space-indented with no `.editorconfig` or formatter setting that says so, and narrow the tabs principle to explicit overrides.** | 2 | 2 | 3 | 5 | 4 | 1.1 by 4 | 1.2 |
@@ -24,6 +20,7 @@
| 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 |
| 544 | 0.17.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a PHP or JavaScript test that PHPUnit or `node --test` finds by a name `is_test` does not know.** | 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/<tool>`, 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 |
@@ -55,7 +52,7 @@
| 499 | 0.23.0 | | defect | **Stop `todo-item add` and `edit` from waiting on a stdin that stays open without data, so a call without a heredoc ends at once.** | 2 | 2 | 2 | 4 | 2 | 1.5 by 3, 1.4 by 2 | 1.9 |
| 445 | 0.23.0 | | | **Refuse a plan that holds an item a `Finish item <ID>` commit already removed, so a merge resolution cannot bring a finished item back.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3, 1.1 by 2 | 1.8 |
| 171 | 0.23.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 1.8 |
| 300 | 0.23.0 | | owner | **Reach the comprehension floor: restructure the places the comprehension seats found hardest to follow, so the project reads at 7.0 or above on every dimension, Locality, Shape and Self-sufficiency first; today the second scoring run at 6322c6e1 scored Navigation 6.75, Locality 5.75, Shape 5.75, Self-sufficiency 5.75 and Overall 6.00.** | 4 | 2 | 3 | 7 | 8 | code health by 8 | 1.7 |
| 300 | 0.23.0 | | owner | **Reach the comprehension floor: restructure the places the comprehension seats found hardest to follow, so the project reads at 7.0 or above on every dimension, Self-sufficiency, Locality and Shape first; today the second scoring run at 68611733 scored Navigation 7.13, Locality 6.13, Shape 6.13, Self-sufficiency 5.88 and Overall 6.25.** | 4 | 2 | 3 | 7 | 8 | code health by 8 | 1.7 |
| 264 | 0.23.0 | | | **Report the comprehension seats and the escalated subagents as subagent types of their own in `routing-figures.md`, with their dollars.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 5 | 1.7 |
| 323 | 0.23.0 | | | **Count a release review as landed once its pull request has merged, whatever its commits are titled.** | 3 | 2 | 3 | 6 | 3 | 1.4 by 3, 1.5 by 2 | 1.7 |
| 342 | 0.23.0 | | | **Research the tooling agents read, search and run commands with once more, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 1.7 |
@@ -113,55 +110,6 @@
## Details
### 544. Make stability-reviewer list every consumer of a shared producer whose yield or return value the diff changes, and state what each does with the new case.
An outside reviewer found a defect our stability pass missed. A change made a shared generator yield a special value to signal an over-limit case. Three consumers read that generator: a joiner that checks the limit, a serializer that joins without checking, and a matcher that compares the pieces against a text. Over two rounds the stability pass found the serializer's defect, on an engine whose strings outgrow the limit, but not that the matcher also takes the special value as ordinary text.
Today the reviewer greps callers only of a changed or renamed public symbol. Nothing makes it enumerate the consumers of a producer whose signature stays the same but whose output gains a case. No deterministic tool can find this, so it goes in the reviewer's instructions: where the diff changes what a shared function, generator or iterator yields or returns, such as a new special value, a sentinel, a new error or an early stop, the reviewer lists every caller with `grep` and states, in Coverage & Verification, what each one now does with the new case. A consumer that treats the new case as an ordinary value is a finding.
Touches:
- `agents/stability-reviewer.md`: `## First Steps` (small), `### 1. Backward Compatibility, Blast Radius & Rollout` (small)
### 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.
Touches:
- `bin/task_bench/typescript_bugs.py`
- `bin/task_bench/test_typescript_bugs.py`
- `bin/task_bench/plant.py`: `LANGUAGES`
- `bin/task_bench/test_plant.py`: `ShippedLanguagesTest`
- `bin/mutate_changes/in_diff_tools.py`: `run_stryker`
- `bin/task_bench/main.py`: lines 14-40, lines 100-110, `bugs_planner`
- `README.md`: lines 231-231, lines 281-281
### 528. Plant bugs for `task-bench` in PHP, from the mutants Infection kills.
Infection 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 log. Tell Haiku the failure PHPUnit 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 PHP.
Touches:
- `bin/task_bench/php_bugs.py`
- `bin/task_bench/test_php_bugs.py`
- `bin/task_bench/plant.py`: `LANGUAGES`
- `bin/task_bench/test_plant.py`: `ShippedLanguagesTest`
- `bin/mutate_changes/in_diff_tools.py`: `run_infection`
- `bin/task_bench/main.py`: lines 14-40, lines 100-110, `bugs_planner`
- `README.md`: lines 231-231, lines 281-281
### 525. 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.
The second part of item 505, which says what a source-data task is and when a run counts. The country code of each comes from ISO 3166-1's user-assigned range (AA, QM–QZ, XA–XZ, ZZ), leaving out XK, which the EU and others use for Kosovo, so no task meets real data. Each register has the quirks real ones publish.
Each checker runs a template such as `{/person[QZ]}` with a fixed seed, fejkdata's full test suite with the data-licence tests, and the importer again, which must reproduce the committed data.
- D1: names weighted by frequency, from a semicolon CSV in Latin-1.
- D2: addresses, with postcodes mapped to towns, from nested JSON; values that belong together come from one pick.
- D3: a valid national id, from a spec page giving the checksum; the checker validates every id the template prints.
- D4: companies with legal-form suffixes, from an XML register.
- D5: D1's register in its next edition, with a renamed column and a new code list, so Haiku updates an importer that exists.
Done when `task-bench` counts a run of each. The five land wherever fejkdata's `bench-tasks` setting points, which its config must first set, so the item changes no file of this repo and carries no `Touches:` list. About 1,500 lines of Python, Go, data and specs.
### 477. Rewrite `## Goals` and `## Audience` for a setup others install and run apart from their own `~/.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. Goal 2, "Make my claude setup shareable between computers", and an audience of lilleman, with client teams as readers of what the loop writes, no longer fit. The goals and the audience are the human's to write; propose a wording and ask.
@@ -229,6 +177,12 @@ Touches:
- `bin/task_bench/test_task_bench.py`
- `bin/task_bench/main.py`: lines 30-37
### 544. Leave out of a `task-bench` fix a change Haiku makes to a PHP or JavaScript test that PHPUnit or `node --test` finds by a name `is_test` does not know.
PHPUnit finds a test by `*Test.php`, wherever it stands, and `node --test` also by `*-test.js`, `*_test.js`, `test-*.js` and `test.js`, with `.ts`, `.mjs` and `.cjs` alike. `mutate_changes.changed_lines.is_test` tells a test by a folder named `test`, `tests` or `__tests__`, or by a name such as `*.test.*`, so `src/PickTest.php` and `src/pick-test.js` count as code. `checked_tree` in `bin/task_bench/runs.py` then takes such a file as Haiku left it, so a fix that edits or deletes the failing test passes, at both sides alike, and `place_files` in `bin/task_bench/plant.py` may hand the file to the mutation tool as code. The help's Check paragraph says so.
Recommended: tell these names as tests inside task-bench, for a `.php` file and for the suffixes Stryker covers, and keep `is_test` as it is, since changing it would change what `mutate-changes` skips; item 539 does the same for Rust. A product-owner finding on item 527's chunk raised this.
### 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.
@@ -396,30 +350,34 @@ Have the gate, or `rank_todo.py --check` where it runs in a checkout, refuse a p
Raised by the goals audit of PR #296. `bin/routing_figures/calls.py` groups a chunk's review rounds by the rung its worker started on, and calls for a routing change when a lower rung took more of them. Since PR #296 the reviewers may run above the worker's rung, on the one their item's E + I picks, and no figure groups rounds by it, though the archived worker line names the E + I it follows from. A cheap worker on an item of high E + I gets stronger reviewers, who may raise more rounds, and a call could then blame the worker's rung for them: an interrupt of lilleman that settles nothing (goal 1.2).
### 300. Reach the comprehension floor: restructure the places the comprehension seats found hardest to follow, so the project reads at 7.0 or above on every dimension, Locality, Shape and Self-sufficiency first; today the second scoring run at 6322c6e1 scored Navigation 6.75, Locality 5.75, Shape 5.75, Self-sufficiency 5.75 and Overall 6.00.
### 300. Reach the comprehension floor: restructure the places the comprehension seats found hardest to follow, so the project reads at 7.0 or above on every dimension, Self-sufficiency, Locality and Shape first; today the second scoring run at 68611733 scored Navigation 7.13, Locality 6.13, Shape 6.13, Self-sufficiency 5.88 and Overall 6.25.
Filed by the comprehension check of PR #473 at 13d1550 (`larv-review record-scoring`), which printed `Floor:` and `Next:`, and refreshed from the two runs of item 515's chunk at 6322c6e1. The lowest means are Locality, Shape and Self-sufficiency, all at 5.75 in the second run; the first run put Locality at 5.63 and the other two at 5.88. Locality: do-epic and chunk-pr run order-dependent steps and carry state between loop passes (`handed_on`, `parked_through`, `merged`, `levelled_and_finished`), and no code enforces the order. Shape: `bin/do_epic/main.py` and `bin/chunk_pr/main.py` are hubs of about 700 and 764 lines, `bin/` holds about 95 entries at one level, and the OLD_SHAPE fork in `bin/plan/ranking.py` doubles the paths through ranking. Self-sufficiency: the why behind code sits in `docs/decisions.md`, the README or help prose, not beside the unit. Refresh this item's places and aim from the newest run before the chunk starts; do not file a second floor item.
Filed by the comprehension check of PR #473 at 13d1550 (`larv-review record-scoring`), which printed `Floor:` and `Next:`, and refreshed from the two runs of item 525's chunk at 68611733. The lowest mean of the second run is Self-sufficiency at 5.88, with Locality and Shape at 6.13; the first run put Locality lowest at 5.88, Self-sufficiency at 6.00 and Shape at 6.13. Self-sufficiency: the why behind code sits in `docs/decisions.md`, cited by title from about 120 places, and the review loop's rules live in `skills/larv-review/SKILL.md`, not beside the unit that enforces them. Locality: do-epic and chunk-pr run order-dependent steps and keep state in tmux window names and between loop passes (`start_chunks`, `resumed_news`, `merged`, `merge_turn`), and no code enforces the order. Shape: `bin/` holds about 82 entries at one level, long functions carry several flags at once, and the OLD_SHAPE fork in `bin/plan/ranking.py` doubles the paths through ranking. Refresh this item's places and aim from the newest run before the chunk starts; do not file a second floor item.
Aim: one ambitious refactor of the areas below, sized so every mean reaches 7.0 on the chunk's own scoring run. Where a place is already easier to read when the chunk starts, drop it.
Places the seats named, hardest first (`larv-review places`), Locality first:
Places the seats named in the second run, hardest first (`larv-review places`), Self-sufficiency first:
- Locality, Shape, Self-sufficiency: `bin/do_epic/main.py:538` `handed_on`: five branches over the landing, the automation and two statuses, with no table of the cases; it needs the README's do-epic settings beside it. Seven of eight seats named it over the two runs.
- Locality: `bin/do_epic/main.py:379` `parked_through`, with `:455` `resumed_news`: seven flags to hold over park, resume and a human's merge; park must come before resume, and no code enforces it. Six seats named it.
- Locality: `bin/chunk_pr/main.py:448` `merged`, with `:587` `levelled_and_finished`: one loop interleaves the queue turn, approval waits and parking, and the steps' order is load-bearing and unexplained. Four seats named it.
- Locality: `bin/rule_hook/round_cap.py:28` `earlier_titles`: three callers count rounds from titles fetched three ways.
- Locality: `bin/do_epic/scheduler.py:172` `start_chunks`: chunk state is rebuilt from tmux window names.
- Locality: `bin/agent_cycle/routing.py:115` `unfinished_route`: the route depends on state three modules write.
- Shape: `bin/do_epic/main.py:301` `chunk_run`: argument parsing, status, dry run, windows and parking in one 47 KB module.
- Shape: `bin/plan/ranking.py:239` `score`, with `:144` `weigh`: every change is made twice, for OLD_SHAPE and SHAPE. Two seats named it.
- Navigation, Shape: `README.md:234` "Packages under bin/": about 95 entries at one level, tool and shared packages side by side. Both architects named it.
- Shape: `bin/larv_review/plan.py:1` module: decides whether a scoring run is due, not anything about the plan.
- Self-sufficiency: `skills/larv-review/SKILL.md:94` "Round cap": the review loop's rules live only in the skill's text. Two seats named it.
- Self-sufficiency: `bin/larv_review/main.py:33` module docstring: when a scoring run is due is stated only in help prose.
- Self-sufficiency: `bin/agent_cycle/judge.py:25` `INTERRUPT_RULES`: behaviour lives in prompt text no code shows the effect of.
- Self-sufficiency: `bin/project_config/settings.py:201` `load`: the settings' meaning sits in the help text.
- Self-sufficiency: `bin/agent_cycle/verdicts.py:41` `Verdict`: cites `cycle.judge.re_ask_checked`, which doesn't exist.
- Navigation: `bin/agent_cycle/run.py:103` `archived`: cites a `close.py` that doesn't exist.
- Self-sufficiency: `skills/larv-review/SKILL.md:102` "Re-entry", with `:94` "Round cap": a rule table with exceptions to its own rows, read three times to know which passes a fix reruns. Two seats named it.
- Self-sufficiency: `bin/review_rules/round_titles.py:39` `named_counts`, with `bin/rule_hook/round_cap.py:28` `earlier_titles`: the round cap's whole contract lives in the skill's text, no code counts reviewer launches, and `earlier_titles` fails open to an empty list on a slow git.
- Self-sufficiency: `bin/plan/ranking.py:144` `weigh`, with `:239` `score`: an old and a new item shape branch through the module, and nothing says which is current. Two seats named it.
- Self-sufficiency: `bin/do_epic/main.py:402` `handed_on`: retries through an intermediate status and polls with no stated bound.
- Self-sufficiency: `bin/agent_cycle/judge.py:88` `Reply`: the field names don't say what each verdict means to the loop.
- Self-sufficiency: `bin/rule_hook/folder_search.py:89` `skips`: flag semantics of rg and ag that can't be checked without the tools' manuals. Two seats named it.
- Locality, Shape: `bin/chunk_pr/main.py:448` `merged`, with `:516` `merge_turn` and `:587` `levelled_and_finished`: one queue loop holds the merge settings, the flock queue and the approval wait, in an order that matters and that only the help docstring states. Three seats named it.
- Locality: `bin/do_epic/scheduler.py:172` `start_chunks`: five branches over seven sets and three limits under one lock, with part of the parked state read from tmux window names.
- Locality: `bin/do_epic/parking.py:105` `resumed_news`: an endless poll loop whose `awaits`, `stays`, `shown` and `said` mix display state with control state.
- Locality, Navigation: `bin/agent_cycle/routing.py:115` `unfinished_route`: routing has about nine homes, the escalation mark's meaning is split over four modules, and no file says which parts make routing up. Two seats named it.
- Locality: `bin/agent_cycle/judge.py:300` `judge_prompt`: the prompt's wording is coupled to judge_replay's parsing of archived prompts.
- Locality: `bin/do_epic/main.py:485` `next_cycle`: picks the prompt by comparing a tmux window name with the epic's key.
- Locality: `bin/loop_claude/loop/reload.py:85` `fingerprint`: an edit to any `.py` under `bin/` reloads the running loop, through a handover format that already carries history.
- Shape: `README.md:244` "Packages under bin/": one flat list of about 40 bullets carries a level of some 82 entries, with no grouping into families.
- Shape: `bin/do_epic/main.py:236` `chunk_run`: the loop variable `news` is a `str` or a `Stop`, and a nested conditional picks the `Landed` value. Two seats named it.
- Shape: `bin/project_config/settings.py:205` `load`: about twenty conditional entries encode the cross-setting rules, with the table they depend on 175 lines below. Two seats named it.
- Shape: `bin/chunk_pr/main.py:398` `epic_opened`: a chain of `x = prev if isinstance(prev, Failure) else f(prev)` hides the success path.
- Shape: `bin/agent_cycle/run.py:250` `close`, with `:33` `Cycle`: one long conditional decides the archived outcome, and the dataclass has 17 fields.
- Shape: `bin/chunk_driver/this_loop.py:12` `Loop`, with `bin/chunk_driver/cycle_start.py:96` `cycle_of`: `Loop` is built per chunk and serves do-epic too, as the `loop_`-prefixed packages do; `cycle_of` takes ten keyword arguments.
- Shape: `bin/rule_hook/rules.py:27` `RULES`: each rule's prose is one very long string, which hides the table's structure.
### 264. Report the comprehension seats and the escalated subagents as subagent types of their own in `routing-figures.md`, with their dollars.