Refuse a register entry that is no regular file, and say data source in what task-bench prints

This commit is contained in:
2026-11-23 19:49:22 +01:00
parent c798278406
commit 44c0f13883
11 changed files with 94 additions and 63 deletions
+31 -29
View File
@@ -50,16 +50,18 @@ skips `testdata`. The table then has a row per feature and side, and `-` for the
doesn't run, 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 file; --tasks features leaves such a
folder out. Before Haiku starts, the bench runs the script at the top of a copy of each side's tree, in the image with no
network, and the files it adds are the register: a made-up dataset in the format a real publisher would use. The script is
seeded, so it writes the same bytes at both sides; the bench passes over a task whose script fails, adds no file, writes a
`.git`, or writes one register at the base and another at the head. `spec.md` tells Haiku where the register is and what to add: say, the importer,
the data it imports and the licence entry. The reference patch adds them, and the acceptance tests check them, as by running
the importer again and comparing what it writes with the committed data. A task counts, and a run passes, as for a feature; the
tree that is checked holds the register as Haiku left it. Make up a publisher no real data could come from: a country code
ISO 3166-1 leaves to its users, such as QZ, and never XK, which is Kosovo's in practice. The table has a row per data source
and side.
`bench-tasks` that holds a feature's three parts and `generate-register`, an executable script; --tasks features leaves such
a folder out. Before Haiku starts, the bench runs the script at the top of a copy of each side's tree, in the image with no
network, and the files it adds are the register: a made-up dataset in the format a real publisher would use. The container
holds that tree and the script alone, so the script can't read another file of the task's folder. Seed the script, so that it
writes the same bytes at both sides. The bench passes over a task whose script doesn't exit 0, runs for 30 minutes, adds no
file, adds a link or anything else that is no regular file, writes a `.git`, or writes one register at the base and another at
the head; the report says which, with the last line a failing script printed. `spec.md` tells Haiku where the register is and
what to add: say, the importer, the data it imports and the licence entry. The reference patch adds them, and the acceptance
tests check them, as by running the importer again and comparing what it writes with the committed data. A task counts, and a
run passes, as for a feature; the tree that is checked holds the register as Haiku left it. Name the made-up publisher's
country by a code no real data could carry: one ISO 3166-1 leaves to its users, such as QZ, and never XK, which is Kosovo's in
practice. The table has a row per data source and side.
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
@@ -84,8 +86,7 @@ With --record-figures, a bench that finishes appends its figures to the project'
table's header and its three All rows. The entry's heading gives the current UTC time, then `task-bench of <branch>: head
<commit> against base <commit>`, where <branch> is the branch checked out, whatever --head names. For a bench of
features the heading reads `task-bench features of <branch>: ...` instead, and for one of data sources `task-bench data-sources
of <branch>: ...`. No tool reads the entry as a
ruling or a scoring run. The bench's last line says where the entry went. A bench that fails or stops doesn't record anything.
of <branch>: ...`. No tool reads the entry as a ruling or a scoring run. The bench's last line says where the entry went. A bench that fails or stops doesn't record anything.
`task-bench gather`, run in the same checkout, turns the digest into plan items. It starts a claude on the project's rung, the
cheapest rung of the model loop-claude runs the project on, with the digest and the prompt in gather-prompt.md beside this file.
@@ -96,11 +97,12 @@ 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 neither bugs nor features, 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 features 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 feature or one that lacks a part,
each before docker runs; and where the tests fail at a side without the acceptance tests, or no feature counts. Where the API refuses a run, the bench stops there and exits 1 too, after the table of
the runs that finished.
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
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
API refuses a run, the bench stops there and exits 1 too, after the table of the runs that finished.
With --record-figures it also exits 1, saying why: before it plants a bug, where no config names the checkout or the history
cannot be read; and after the bench, where the history already holds that branch's bench of those two commits or cannot be
written. The folder then still holds the bench's results.
@@ -387,9 +389,9 @@ def ran_fixes(bench: Bench, tasks: list[Task], total: int) -> Fixes:
def kept(bench: Bench, plan: Planned, names: dict[int, str], results: list[Result]) -> Failure | None:
"""Writes results.json and the digest of the plan's tasks into the bench's folder. names holds each task's name by its number."""
in_a_tree = lambda path: any(pathlib.Path(tree, path).is_file() for tree in bench.trees.values())
noun = bench.asked.kind.noun
recorded_runs = json.dumps({"sides": bench.sides, **plan.drawn_by, f"{noun}s": names, "runs": [recorded(result, noun) for result in results]}, indent="\t") + "\n"
digest_text = digest(bench.sides, table(results, names, noun), [digested(task, results, bench.folder, noun) for task in plan.tasks], in_a_tree, noun)
noun, key = bench.asked.kind.noun, bench.asked.kind.key
recorded_runs = json.dumps({"sides": bench.sides, **plan.drawn_by, f"{key}s": names, "runs": [recorded(result, key) for result in results]}, indent="\t") + "\n"
digest_text = digest(bench.sides, table(results, names, noun), [digested(task, results, bench.folder, key) for task in plan.tasks], in_a_tree, noun)
try:
(bench.folder / "results.json").write_text(recorded_runs, encoding="utf-8")
(bench.folder / DIGEST).write_text(digest_text, encoding="utf-8", errors="replace")
@@ -463,7 +465,7 @@ def planted_tree(bench: Bench, side: Side, tree: pathlib.Path, path: str, change
def fixed(task: Task, side: Side, number: int, containers: Containers, folder: pathlib.Path, kind: Kind) -> Result | Failure:
"""One run: Haiku's work on task at side in a copy of its tree, then the tests over what it changed, with a feature's
acceptance tests among them. The stream stays in folder; the copy is removed. Tests that run out of time don't pass."""
stream = stream_of(Result(task.number, side, number, False, None), folder, kind.noun)
stream = stream_of(Result(task.number, side, number, False, None), folder, kind.key)
copy, check = folder / "copy", folder / "check"
try:
try:
@@ -494,21 +496,21 @@ def fixed(task: Task, side: Side, number: int, containers: Containers, folder: p
shutil.rmtree(check, ignore_errors=True)
def stream_of(result: Result, folder: pathlib.Path, noun: str) -> pathlib.Path:
"""The file that holds the stream of the run result names, of a task the bench calls by noun. Its name without the suffix is
def stream_of(result: Result, folder: pathlib.Path, key: str) -> pathlib.Path:
"""The file that holds the stream of the run result names, of a task whose kind has that key. Its name without the suffix is
the run's id in the digest."""
return folder / "runs" / f"{noun}-{result.task}-{result.side}-{result.run}.jsonl"
return folder / "runs" / f"{key}-{result.task}-{result.side}-{result.run}.jsonl"
def digested(task: Task, results: list[Result], folder: pathlib.Path, noun: str) -> TaskRuns:
def digested(task: Task, results: list[Result], folder: pathlib.Path, key: str) -> TaskRuns:
"""The task as the digest tells it, with each of its runs in results. A run that didn't finish has no tokens."""
runs = [Run(stream_of(result, folder, noun).stem, result.passed, found.tokens.context() + found.tokens.output if (found := result.figures) else None, result.entries) for result in results if result.task == task.number]
runs = [Run(stream_of(result, folder, key).stem, result.passed, found.tokens.context() + found.tokens.output if (found := result.figures) else None, result.entries) for result in results if result.task == task.number]
return TaskRuns(f"{task.number}: {task.name}", task.file, task.told["base"], runs)
def recorded(result: Result, noun: str) -> dict:
"""A run as results.json holds it, of a task the bench calls by noun."""
run = {noun: result.task, "side": result.side, "run": result.run, "passed": result.passed, "finished": result.figures is not None}
def recorded(result: Result, key: str) -> dict:
"""A run as results.json holds it, of a task whose kind has that key."""
run = {key: result.task, "side": result.side, "run": result.run, "passed": result.passed, "finished": result.figures is not None}
if not (found := result.figures):
return run
return {**run, "claude_code": found.version, "model": found.model, "tokens": dataclasses.asdict(found.tokens), "turns": found.turns, "seconds": found.seconds, "reads": found.reads}