Answer architecture round 1: 2 🔴, 8 🟡 (0 misread); split task-bench's benched into phases and its table into one column list, parse each stream once, move do-epic's parking out with pure move and news decisions, share the round summaries, rename scoring_due, and file the version question as item 517
CI / tests (pull_request) Successful in 5m2s

This commit is contained in:
2026-11-23 01:20:55 +01:00
parent 21200cb698
commit 0bf87b736e
29 changed files with 678 additions and 368 deletions
+11 -13
View File
@@ -5,8 +5,8 @@ import collections
import re
import typing
from claude_code.entries import AssistantTurn, parse_entry, Text, tool_calls, ToolCall, ToolResult, ToolResults
from task_bench.figures import HOME, WORK
from claude_code.entries import AssistantTurn, Entry, Text, tool_calls, ToolCall, ToolResult, ToolResults
from task_bench.runs import HOME, WORK
from reading_cost.measure import reads_of
# A trace keeps the first TEXT_LINES lines of the model's text between two calls, and the first TEXT_WIDTH characters of each.
@@ -22,12 +22,12 @@ 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
it didn't finish, and its stream."""
it didn't finish, and its stream's entries."""
id: str
passed: bool
tokens: int | None
stream: bytes
entries: typing.Sequence[Entry]
class Bug(typing.NamedTuple):
@@ -50,7 +50,7 @@ def digest(sides: dict[str, str], table: list[str], bugs: list[Bug], is_file: ty
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.stream for run in failing], bug.file, is_file)
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."
elif not misled:
@@ -77,27 +77,25 @@ def told(bug: Bug, is_file: typing.Callable[[str], bool]) -> list[str]:
"",
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.stream)]),
*(line for run, why in shown for line in ["", f"### {run.id}, {why}", "", *trace(run.entries)]),
]
def decoys(failing: list[bytes], fixed: str, is_file: typing.Callable[[str], bool]) -> list[str]:
"""The files of the project that more than half of the failing runs' streams read, but for fixed, the file the bug is in:
def decoys(failing: list[typing.Sequence[Entry]], fixed: str, is_file: typing.Callable[[str], bool]) -> list[str]:
"""The files of the project that more than half of the failing runs read, but for fixed, the file the bug is in:
each with how many runs read it, sorted by name."""
read_by = collections.Counter(path for stream in failing for path in files_read(stream))
read_by = collections.Counter(path for entries in failing for path in files_read(entries))
by = lambda count: "the one failing run" if len(failing) == 1 else f"{count} of the {len(failing)} failing runs"
return [f"`{path}`, read by {by(count)}" for path, count in sorted(read_by.items()) if count * 2 > len(failing) and path != fixed and is_file(path)]
def files_read(stream: bytes) -> set[str]:
def files_read(entries: typing.Sequence[Entry]) -> set[str]:
"""The paths in the project that the run opened or searched, a folder it searched among them."""
entries = [entry for line in stream.splitlines() if (entry := parse_entry(line))]
return {path.removeprefix(WORK + "/") for _, call in tool_calls(entries) for path in reads_of(call, WORK, HOME).read if path.startswith(WORK + "/")}
def trace(stream: bytes) -> list[str]:
def trace(entries: typing.Sequence[Entry]) -> list[str]:
"""The run in short: a line per tool call, and between calls the first TEXT_LINES lines of what the model wrote, each after `> `."""
entries = [entry for line in stream.splitlines() if (entry := parse_entry(line))]
results = {result.tool_use_id: result for entry in entries if isinstance(entry, ToolResults) for result in entry.results}
return [line for entry in entries if isinstance(entry, AssistantTurn) for part in entry.parts for line in (written(part.text) if isinstance(part, Text) else [called(part, results.get(part.id))])]