Answer stability round 1: 0 🔴, 10 🟡 (0 misread); take the failed test's last message, fail on a docker run that never started, keep testdata as planted, show finished runs when the API refuses one, and test five survivors
This commit is contained in:
+60
-45
@@ -5,44 +5,47 @@ usage: task-bench --image <image> --test <shell text> [--base <ref>] [--head <re
|
||||
|
||||
Run it in a checkout, under ~/.claude/bin/run-heavy, with a long-lived token in CLAUDE_CODE_OAUTH_TOKEN, which `claude setup-token`
|
||||
prints. The head is --head, by default HEAD. The base is the merge base of the head and --base, by default the default branch:
|
||||
origin's as last fetched, else main or master. `--base HEAD` benches the head against itself. No model judges anything: the bench
|
||||
runs programs, and reads Haiku's own stream.
|
||||
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. Of the mutants the tests kill, it draws --bugs, 5 by
|
||||
default, in the order --seed sets, 1 by default. A drawn mutant becomes a bug where its line stands unchanged at the head, and
|
||||
where, planted at each side, the tests fail on an assertion whose message says something. Others are passed over, so a change to
|
||||
the very line of a bug is not benched. Go is the one language so far.
|
||||
- Run. Per bug and side, --runs times, 5 by default, sides in turn: a copy of that side's tree with the bug in it, committed once,
|
||||
so git shows nothing of the bug. In it, in a container, `claude -p --strict-mcp-config --disable-slash-commands
|
||||
--no-session-persistence --model claude-haiku-5-5 --effort low` works with every tool, told the failing assertion's message at that
|
||||
side, without the test's name, file or line. The container's 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.
|
||||
`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.
|
||||
- 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
|
||||
tool. It is told the message the failing test printed at that side, without the test's name, file or line. The container's
|
||||
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.
|
||||
Tests Haiku changed, removed or added count for nothing.
|
||||
A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder.
|
||||
|
||||
--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, and --test runs in it, as sh runs it at
|
||||
the copy's top, with no network: the image must hold what the tests download otherwise.
|
||||
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 "$@". For example:
|
||||
base, which $PWD names, with `gremlins unleash ...` as "$@". Without it, the bench runs the `gremlins` on the host's PATH. For
|
||||
example:
|
||||
|
||||
docker run --rm --memory 8g --memory-swap 8g -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
|
||||
|
||||
It prints the base and the head, then a table: a row per bug and side with how many fixes passed and the medians, over the runs
|
||||
that finished, of the input, cache-write, cache-read and output tokens, the turns, the wall time, and the reads and searches before
|
||||
the run first opened the file the bug is in; then a row per side over every bug, and the head's change against the base. Each
|
||||
run's result and stream are in the folder its last line names, `task-bench` in the chunk's review folder, which each bench empties
|
||||
first.
|
||||
the run first opened the file the bug is in. The median of the reads leaves out a run that never opened that file. Then come a row
|
||||
per side over every bug, and the head's change against the base. The last line names the folder that holds each run's result and
|
||||
stream: `task-bench` in the chunk's review folder. Each bench empties that `task-bench` folder first.
|
||||
|
||||
Exit 1, saying why, on an unknown or repeated argument, a missing --image or --test, a count that is no whole number from 1, or
|
||||
no token; and where git, docker or Gremlins fails, the seats' places name no Go file, the tests fail at a side without a bug, no
|
||||
mutant becomes a bug, or the API refuses a run.
|
||||
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, or no token; and where git, docker or Gremlins fails, the seats' places name no Go file, the tests fail at a side
|
||||
without a bug, or no mutant becomes a bug. Where the API refuses a run, the bench stops there and exits 1 too, after the table of
|
||||
the runs that finished.
|
||||
"""
|
||||
import dataclasses
|
||||
import functools
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
@@ -52,7 +55,7 @@ import tarfile
|
||||
import typing
|
||||
import uuid
|
||||
|
||||
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TOKEN
|
||||
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TimedOut, TOKEN
|
||||
from machine_load.slots import CPUS_PER_SLOT
|
||||
from git_cli.git_repo import default_ref, Git, top
|
||||
from task_bench.plant import drawn, killed_mutants, line_at_head, Mutant, mutated, place_files, task_text
|
||||
@@ -68,7 +71,7 @@ USAGE = "usage: task-bench --image <image> --test <shell text> [--base <ref>] [-
|
||||
# A panel of three readers, seated as the README's audience, picked these options on 2026-11-21, each 3 to 0.
|
||||
OPTIONS = ("--base", "--bugs", "--head", "--image", "--prefix", "--runs", "--seed", "--test")
|
||||
COUNTS = {"--bugs": "5", "--runs": "5", "--seed": "1"}
|
||||
# The planted commit names no one, and no hook or signing key of the caller's reaches it.
|
||||
# The planted commit doesn't name anyone, and neither a hook nor a signing key of the caller's reaches it.
|
||||
COMMIT = ["-c", "user.name=task-bench", "-c", "user.email=task-bench@localhost", "-c", "commit.gpgsign=false", "-c", "core.hooksPath=/dev/null", "commit", "--quiet", "--message", "Import"]
|
||||
|
||||
|
||||
@@ -109,8 +112,10 @@ def options(argv: list[str], env: typing.Mapping[str, str]) -> dict[str, str] |
|
||||
rest = list(argv)
|
||||
while rest:
|
||||
name, equals, value = rest.pop(0).partition("=")
|
||||
if name not in OPTIONS or name in given:
|
||||
return Failure(f"unknown or repeated argument {name}")
|
||||
if name not in OPTIONS:
|
||||
return Failure(f"unknown argument {name}")
|
||||
if name in given:
|
||||
return Failure(f"{name} is given twice")
|
||||
if not equals and not rest:
|
||||
return Failure(f"{name} needs a value")
|
||||
given[name] = value if equals else rest.pop(0)
|
||||
@@ -177,7 +182,8 @@ def commits(given: dict[str, str], checkout: str, git: Git) -> dict[str, str] |
|
||||
|
||||
|
||||
def archived(commit: str, into: pathlib.Path, checkout: str, git: Git) -> str | Failure:
|
||||
"""Makes `into` the tree at commit, without git's own data, and returns its path."""
|
||||
"""Makes `into` the tree at commit, as `git archive` holds it, and returns its path: without git's own data, and without a
|
||||
path the project marks `export-ignore`."""
|
||||
into.mkdir(parents=True)
|
||||
archive = into.with_suffix(".tar")
|
||||
wrote = git("archive", "--format=tar", "--output", str(archive), commit, cwd=checkout)
|
||||
@@ -207,31 +213,37 @@ def benched(given: dict[str, str], checkout: str, sides: dict[str, str], trees:
|
||||
return task
|
||||
tasks += [task] if task else []
|
||||
if not tasks:
|
||||
return Failure(f"None of the {len(mutants)} mutants the tests kill becomes a bug: each is on a line the head changed, or fails no assertion with a message.")
|
||||
return Failure(f"None of the {len(mutants)} mutants the tests kill becomes a bug: each is on a line the head changed, or the test it fails doesn't print a message.")
|
||||
results: list[Result] = []
|
||||
stopped = None
|
||||
total = int(given["--runs"]) * len(tasks) * len(SIDES)
|
||||
for number in range(1, int(given["--runs"]) + 1):
|
||||
for task in tasks:
|
||||
for side in SIDES:
|
||||
result = fixed(task, side, number, containers, folder)
|
||||
if isinstance(result, Failure):
|
||||
return result
|
||||
results.append(result)
|
||||
print(f"task-bench: run {len(results)} of {total}, bug {task.number} at the {side}: {'passed' if result.passed else 'not passed'}.", file=sys.stderr)
|
||||
(folder / "results.json").write_text(json.dumps({"sides": sides, "seed": int(given["--seed"]), "bugs": {task.number: task.named() for task in tasks}, "runs": [recorded(result) for result in results]}, indent="\t") + "\n", encoding="utf-8")
|
||||
for number, task, side in itertools.product(range(1, int(given["--runs"]) + 1), tasks, SIDES):
|
||||
result = fixed(task, side, number, containers, folder)
|
||||
if isinstance(result, Failure):
|
||||
stopped = result
|
||||
break
|
||||
results.append(result)
|
||||
print(f"task-bench: run {len(results)} of {total}, bug {task.number} at the {side}: {'passed' if result.passed else 'not passed'}.", file=sys.stderr)
|
||||
if stopped and not results:
|
||||
return stopped
|
||||
names = {task.number: task.named() for task in tasks}
|
||||
(folder / "results.json").write_text(json.dumps({"sides": sides, "seed": int(given["--seed"]), "bugs": names, "runs": [recorded(result) for result in results]}, indent="\t") + "\n", encoding="utf-8")
|
||||
if stopped:
|
||||
# The runs that finished took hours and tokens, so the bench shows them before it fails.
|
||||
return Failure("\n".join([stopped.reason, f"task-bench stopped after {len(results)} of {total} runs, which results.json holds in {folder}:", "", *table(results, names)]))
|
||||
ran_on = sorted({f"{found.model} in Claude Code {found.version}" for result in results if (found := result.figures)})
|
||||
short = [] if len(tasks) == int(given["--bugs"]) else [f"Planted {len(tasks)} of the {given['--bugs']} bugs asked for: no other mutant the tests kill becomes one."]
|
||||
return [
|
||||
f"task-bench: base {sides['base'][:12]}, head {sides['head'][:12]}. {counted(len(tasks), 'bug')}, fixed {counted(int(given['--runs']), 'time')} at each side by {' and '.join(ran_on) or 'no run that finished'}.",
|
||||
f"task-bench: base {sides['base'][:12]}, head {sides['head'][:12]}. {counted(len(tasks), 'bug')}, each run {counted(int(given['--runs']), 'time')} at each side by {' and '.join(ran_on) or 'no run that finished'}.",
|
||||
*short,
|
||||
"",
|
||||
*table(results, {task.number: task.named() for task in tasks}),
|
||||
*table(results, names),
|
||||
"",
|
||||
]
|
||||
|
||||
|
||||
def planted(number: int, mutant: Mutant, checkout: str, sides: dict[str, str], trees: dict[str, str], containers: Containers, folder: pathlib.Path, git: Git) -> Task | Failure | None:
|
||||
"""The task of fixing mutant, with its planted tree at each side; None where the mutant is no bug at both sides.
|
||||
"""The task of fixing mutant, with its planted tree at each side; None where the mutant doesn't become a bug at one side or the other.
|
||||
|
||||
The bug is the same change to the same line at both sides, so only the code around it differs between them."""
|
||||
diff = git("diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", sides["base"], sides["head"], "--", mutant.path, cwd=checkout, errors="replace")
|
||||
@@ -251,9 +263,10 @@ def planted(number: int, mutant: Mutant, checkout: str, sides: dict[str, str], t
|
||||
shutil.copytree(trees[side], tree, symlinks=True)
|
||||
(tree / mutant.path).write_bytes(changed)
|
||||
ran = tests_in_copy(containers, str(tree), folder)
|
||||
if isinstance(ran, Failure):
|
||||
if isinstance(ran, Failure) and not isinstance(ran, TimedOut):
|
||||
return ran
|
||||
message = task_text(ran.output) if ran.code else None
|
||||
# Tests that never end under the bug have no message to tell Haiku.
|
||||
message = None if isinstance(ran, TimedOut) else task_text(ran.output)
|
||||
if message is None:
|
||||
return None
|
||||
for args in (["init", "--quiet"], ["add", "--all", "--force"], COMMIT):
|
||||
@@ -265,7 +278,7 @@ def planted(number: int, mutant: Mutant, checkout: str, sides: dict[str, str], t
|
||||
|
||||
|
||||
def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path) -> Ran | Failure:
|
||||
"""The test command's run in a copy of tree that goes afterwards, so what the tests write stays out of tree."""
|
||||
"""The test command's run in a copy of tree, removed afterwards, so what the tests write stays out of tree."""
|
||||
copy = folder / "tested"
|
||||
shutil.copytree(tree, copy, symlinks=True)
|
||||
try:
|
||||
@@ -276,7 +289,7 @@ def tests_in_copy(containers: Containers, tree: str, folder: pathlib.Path) -> Ra
|
||||
|
||||
def fixed(task: Task, side: str, number: int, containers: Containers, folder: pathlib.Path) -> Result | Failure:
|
||||
"""One run: Haiku's fix of task at side in a copy of its planted tree, then the tests over what it changed. The stream stays in
|
||||
folder; the copy goes."""
|
||||
folder; the copy is removed. Tests that run out of time don't pass."""
|
||||
stream = folder / "runs" / f"bug-{task.number}-{side}-{number}.jsonl"
|
||||
stream.parent.mkdir(exist_ok=True)
|
||||
copy, check = folder / "copy", folder / "check"
|
||||
@@ -290,7 +303,9 @@ def fixed(task: Task, side: str, number: int, containers: Containers, folder: pa
|
||||
return found
|
||||
checked_tree(task.trees[side], str(copy), str(check))
|
||||
ran = ran_tests(containers, str(check))
|
||||
return Result(task.number, side, number, not isinstance(ran, Failure) and ran.code == 0, found)
|
||||
if isinstance(ran, Failure) and not isinstance(ran, TimedOut):
|
||||
return ran
|
||||
return Result(task.number, side, number, isinstance(ran, Ran) and ran.code == 0, found)
|
||||
finally:
|
||||
shutil.rmtree(copy, ignore_errors=True)
|
||||
shutil.rmtree(check, ignore_errors=True)
|
||||
|
||||
Reference in New Issue
Block a user