Bench features in task-bench with --tasks features, from the folder the config names as bench-tasks
CI / tests (pull_request) Has been cancelled

This commit is contained in:
2026-11-23 16:31:27 +01:00
parent 28537b5aa3
commit cdeb66bf6e
17 changed files with 735 additions and 199 deletions
+29 -24
View File
@@ -1,5 +1,5 @@
"""What task-bench distils from its runs' streams for the model that gathers plan items: a trace of each run worth reading, and
per bug the decoys, the files that misled the runs that failed. No model reads a whole stream unless the digest leaves a
per bug the decoys, the files that misled the runs that failed. A feature has traces and no decoys. No model reads a whole stream unless the digest leaves a
question open."""
import collections
import re
@@ -22,7 +22,7 @@ AROUND_HITS = re.compile(r"Found \d+ .*|No \w+ found.*|No entries at this offset
class Run(typing.NamedTuple):
"""One run of a bug: the name of its stream's file without the suffix, whether its fix passed, the tokens it spent, None where
"""One run of a task: the name of its stream's file without the suffix, whether its fix passed, the tokens it spent, None where
it didn't finish, and its stream's entries."""
id: str
@@ -31,33 +31,38 @@ class Run(typing.NamedTuple):
entries: typing.Sequence[Entry]
class Bug(typing.NamedTuple):
"""A bug as the digest tells it: its number and name, the file the bug is in, what the failing test printed at the base, and
its runs at both sides in the order they ran."""
class TaskRuns(typing.NamedTuple):
"""A task as the digest tells it: its number and name, what Haiku was told, and its runs at both sides in the order they
ran. For a bug, told is what the failing test printed at the base, and file is the file the bug is in. For a feature, told is
its spec, and file is None."""
named: str
file: str
message: str
file: str | None
told: str
runs: list[Run]
def digest(sides: dict[Side, str], table: list[str], bugs: list[Bug], is_file: typing.Callable[[str], bool]) -> str:
"""The digest of a bench of the commits sides names: where each side's code is, the table of its figures, then each bug.
is_file says whether a path in the project names a file."""
code = f"Base {sides['base']}, head {sides['head']}. A bug's name gives its line at the base. Each side's code without the bugs is in `trees/base` and `trees/head` in the bench's folder."
return "\n".join(["# task-bench digest", "", code, "", *table, *(line for bug in bugs for line in ["", *told(bug, is_file)])]) + "\n"
def digest(sides: dict[Side, str], table: list[str], tasks: list[TaskRuns], is_file: typing.Callable[[str], bool], noun: str = "bug") -> str:
"""The digest of a bench of the commits sides names: where each side's code is, the table of its figures, then each task,
which the digest calls by noun. is_file says whether a path in the project names a file."""
line = " A bug's name gives its line at the base." if noun == "bug" else ""
code = f"Base {sides['base']}, head {sides['head']}.{line} Each side's code without the {noun}s is in `trees/base` and `trees/head` in the bench's folder."
return "\n".join(["# task-bench digest", "", code, "", *table, *(line for task in tasks for line in ["", *told(task, is_file, noun)])]) + "\n"
def told(bug: Bug, is_file: typing.Callable[[str], bool]) -> list[str]:
passing, failing = [run for run in bug.runs if run.passed], [run for run in bug.runs if not run.passed]
passed = f"{len(passing)} of the {len(bug.runs)} runs passed." if failing else f"The {counted(len(bug.runs), 'run')} passed."
misled = decoys([run.entries for run in failing], bug.file, is_file)
if not failing:
found = "No run failed, so the bug has no decoys."
def told(task: TaskRuns, is_file: typing.Callable[[str], bool], noun: str) -> list[str]:
passing, failing = [run for run in task.runs if run.passed], [run for run in task.runs if not run.passed]
passed = f"{len(passing)} of the {len(task.runs)} runs passed." if failing else f"The {counted(len(task.runs), 'run')} passed."
# A feature is in no one file, so no file it read is beside the point.
misled = decoys([run.entries for run in failing], task.file, is_file) if task.file else []
if not task.file:
found = ""
elif not failing:
found = " No run failed, so the bug has no decoys."
elif not misled:
found = f"No decoys: no file but the one the bug is in was read by more than half the {counted(len(failing), 'failing run')}."
found = f" No decoys: no file but the one the bug is in was read by more than half the {counted(len(failing), 'failing run')}."
else:
found = "Decoys, the files more than half the failing runs read that the bug isn't in:"
found = " Decoys, the files more than half the failing runs read that the bug isn't in:"
shown: list[tuple[Run, str]] = []
# A run that didn't finish has no count of its tokens, and searched the longest.
if unfinished := [run for run in failing if run.tokens is None]:
@@ -70,13 +75,13 @@ def told(bug: Bug, is_file: typing.Callable[[str], bool]) -> list[str]:
median = finished[(len(finished) - 1) // 2]
shown.append((median, f"the passing run with the median tokens, {median.tokens} tokens"))
return [
f"## Bug {bug.named}",
f"## {noun.capitalize()} {task.named}",
"",
"The failing test printed, at the base:",
"The failing test printed, at the base:" if task.file else "The spec Haiku was told:",
"",
*(f" {line}" for line in bug.message.splitlines()),
*(f" {line}" for line in task.told.splitlines()),
"",
f"{passed} {found}",
f"{passed}{found}",
*(["", *(f"- {decoy}" for decoy in misled)] if misled else []),
*(line for run, why in shown for line in ["", f"### {run.id}, {why}", "", *trace(run.entries)]),
]