Plant bugs for task-bench in Python from the mutants mutmut kills
CI / tests (pull_request) Failing after 3m46s
CI / tests (pull_request) Failing after 3m46s
This commit is contained in:
+26
-20
@@ -11,11 +11,13 @@ prints. The head is --head, by default HEAD. The base is the merge base of the h
|
||||
origin's as last fetched, else main or master. Where --base names the head's own commit, the bench runs the head against itself.
|
||||
No model judges anything: the bench runs programs, and reads Haiku's own stream.
|
||||
|
||||
- Plant. It copies the tree at the base and runs Gremlins there, as `gremlins unleash`, over the Go files that hold the places
|
||||
`larv-review places` prints, the ones the comprehension seats found hardest. 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 its line stands
|
||||
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.
|
||||
Any other mutant is passed over, so a change to the very line of a bug is not benched. Go is the one language so far.
|
||||
- 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`, and mutmut 3 over
|
||||
the Python files, as `mutmut run`. 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. Any other mutant is passed over,
|
||||
so a change to the very lines of a bug is not benched. The message is the one `go test` prints for a Go file, and pytest for
|
||||
a Python file. Go and Python are the languages so far.
|
||||
- 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
|
||||
@@ -28,13 +30,16 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream.
|
||||
--image is the project's development image, such as golang:1.27.4. The bench adds Claude Code to it, as its installer installs it,
|
||||
so the image needs curl and bash; the result names the version. Haiku works in that image. So does --test: sh runs that text at
|
||||
the copy's top, with no network, so the image must hold what the tests would otherwise download.
|
||||
--prefix is shell text that runs Gremlins, on the host, as mutate-changes' --prefix does: sh runs `<prefix> "$@"` in the copy of the
|
||||
base, which $PWD names, with `gremlins unleash ...` as "$@". Without it, the bench runs the `gremlins` on the host's PATH. For
|
||||
example:
|
||||
--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 ...` or `mutmut run ...`. Gremlins runs in the copy of the base, and mutmut
|
||||
in a copy of the folder there that holds its settings; $PWD names either. Without --prefix, the bench runs the `gremlins` or
|
||||
the `mutmut` on the host's PATH. For example, for Go and then for Python:
|
||||
|
||||
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
|
||||
|
||||
uvx --python "$(command -v python3)" --with pytest==9.2.0 --from "mutmut>=3,<4"
|
||||
|
||||
--tasks features benches features instead of bugs; --tasks bugs is the default. The features are the folders in the folder the
|
||||
project's config names as `bench-tasks`, in the order of their names. Each holds:
|
||||
- `spec.md`, all that Haiku is told of the feature;
|
||||
@@ -46,8 +51,8 @@ works in a copy of the side's tree without the `bench-tasks` folder. A build pas
|
||||
side's tree with each file that is no test as Haiku left it, and the acceptance tests put over that. The reference patch is
|
||||
checked the same way, so a test or a `testdata` file it adds doesn't count either. Keep the folder where the project's own test
|
||||
command doesn't find the acceptance tests, which fail by design: outside the checkout, or in a folder the test runner skips, as Go
|
||||
skips `testdata`. The table then has a row per feature and side, and `-` for the reads. Gremlins
|
||||
doesn't run, so --seed, --bugs and --prefix don't go with it.
|
||||
skips `testdata`. The table then has a row per feature and side, and `-` for the reads. No mutation tool
|
||||
runs, so --seed, --bugs and --prefix don't go with it.
|
||||
|
||||
--tasks data-sources benches adding a data source, for a project that imports what others publish. Each task is a folder in
|
||||
`bench-tasks` that holds a feature's three parts and `generate-register`, an executable script; --tasks features leaves such
|
||||
@@ -97,8 +102,8 @@ Each bench empties its own folder first, and removes the folder every earlier be
|
||||
not, unless a bench or a gather is using it. So gather a bench before the next one starts.
|
||||
|
||||
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 and data-sources, or no token; and where git, docker or Gremlins fails,
|
||||
the seats' places don't name any Go file, the tests fail at a side without a bug, or no mutant becomes a bug. With --tasks
|
||||
number from 1, a --tasks that is none of bugs, features and data-sources, or no token; and where git, docker or the mutation tool
|
||||
fails, the seats' places don't name any Go or Python file, 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. Where the
|
||||
@@ -123,7 +128,8 @@ import typing
|
||||
import uuid
|
||||
|
||||
from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, Task, tests_in_copy
|
||||
from task_bench.plant import bug_at_sides, drawn, killed_mutants, Mutant, place_files, task_text
|
||||
from task_bench.plant import drawn, killed_mutants, place_files, task_text
|
||||
from task_bench.planted_mutant import bug_at_sides, Mutant
|
||||
from claude_code.reply import Claude
|
||||
from task_bench.bench_folder import clear_left, held
|
||||
from task_bench.runs import closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TimedOut, TOKEN, WORK
|
||||
@@ -151,7 +157,7 @@ COUNTS = {"--bugs": "5", "--runs": "5", "--seed": "1"}
|
||||
TASKS = "--tasks"
|
||||
# Opens the report's last line, which names the bench's folder.
|
||||
KEPT = "The digest, and each run's result and stream, until `task-bench gather` files plan items from them or the next bench starts: "
|
||||
# The options only a bench of bugs takes: two choose the bugs to plant, and --prefix runs Gremlins.
|
||||
# The options only a bench of bugs takes: two choose the bugs to plant, and --prefix runs the mutation tool.
|
||||
OF_BUGS = ("--seed", "--bugs", "--prefix")
|
||||
|
||||
|
||||
@@ -162,7 +168,7 @@ class Fixes(typing.NamedTuple):
|
||||
|
||||
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path], str | Failure] = read_places, claude: Claude = run_claude) -> int:
|
||||
"""Runs task-bench with the arguments argv; git, docker and Gremlins run in the environment env, `read` reads what
|
||||
"""Runs task-bench with the arguments argv; git, docker and the mutation tool run in the environment env, `read` reads what
|
||||
`larv-review places` prints for the checkout, and `claude` runs the claude that gathers."""
|
||||
if argv in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
@@ -288,11 +294,11 @@ 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 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: of the mutants the tests kill in the Go and Python files of the tree at base that hold a place
|
||||
in places, those --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 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 Go or Python file that the base holds, 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"]))
|
||||
@@ -438,7 +444,7 @@ def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None:
|
||||
if message is None or isinstance(message, Failure):
|
||||
return message
|
||||
trees[side], messages[side] = str(tree), message
|
||||
return Task(number, f"{mutant.path}:{mutant.line}:{mutant.column} {mutant.mutator}", trees, messages, file=mutant.path)
|
||||
return Task(number, mutant.name, trees, messages, file=mutant.path)
|
||||
|
||||
|
||||
def planted_tree(bench: Bench, side: Side, tree: pathlib.Path, path: str, changed: bytes) -> str | Failure | None:
|
||||
@@ -456,7 +462,7 @@ def planted_tree(bench: Bench, side: Side, tree: pathlib.Path, path: str, change
|
||||
return None
|
||||
if isinstance(ran, Failure):
|
||||
return ran
|
||||
message = task_text(ran.output)
|
||||
message = task_text(path, ran.output)
|
||||
if message is None:
|
||||
return None
|
||||
return committed(bench.git, str(tree)) or message
|
||||
|
||||
Reference in New Issue
Block a user