Compare commits

..

3 Commits

Author SHA1 Message Date
lilleman 9f4b663961 Merge remote-tracking branch 'origin/main' into filing-prose-reentry
CI / tests (pull_request) Successful in 4m49s
# Conflicts:
#	todo.md
2026-11-25 23:34:42 +01:00
lilleman 88e94d5980 File item 540: review once more each prose fix that rewrites a checkable claim
CI / tests (pull_request) Has been cancelled
2026-11-25 23:30:01 +01:00
lilleman fc05048180 File item 539: start a fresh session where its transcript is empty
CI / tests (pull_request) Successful in 5m43s
2026-11-25 23:28:09 +01:00
6 changed files with 31 additions and 232 deletions
+3 -6
View File
@@ -29,9 +29,8 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream.
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.
A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. In a Rust file, each
inline `#[cfg(test)]` module stands as the planted file has it, and the rest is as Haiku left it. A Rust mutant is passed over
where its file's modules cannot be told apart, as where two share a name or a brace, string or comment is never closed.
A test Haiku changed, removed or added doesn't count, and neither does a file under a `testdata` folder. A Rust test that
stands in the file of the code it tests is the exception: the bench takes that file whole, so a change to such a test counts.
--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
@@ -174,7 +173,6 @@ import uuid
from task_bench.tasks import Asked, Bench, BUG, check_made, committed, Kind, KINDS, on_disk, Planned, SHIPPED, Task, tests_in_copy
from task_bench.planted_mutant import bug_at_sides, Mutant
from task_bench.rust_test_modules import modules
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
@@ -491,8 +489,7 @@ def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None:
if isinstance(sources, Failure):
return sources
bugs = bug_at_sides(mutant, diff, sources)
# The check keeps a Rust file's test modules as planted, which it can only do where it tells them apart.
if bugs is None or (mutant.path.endswith(".rs") and any(modules(source.decode("utf-8", "surrogateescape")) is None for source in bugs.values())):
if bugs is None:
return None
trees: dict[Side, str] = {}
messages: dict[Side, str] = {}
+1 -16
View File
@@ -11,7 +11,6 @@ import typing
from mutate_changes.tool_process import failed, Ran
from failure import Failure
from mutate_changes.changed_lines import is_test
from task_bench.rust_test_modules import with_tests_of
from task_bench.api_proxy import PORT
MODEL = "claude-haiku-5-5"
@@ -167,7 +166,7 @@ def in_tree(containers: Containers, tree: str) -> list[str]:
def checked_tree(planted: str, copy: str, into: str) -> None:
"""Makes at `into` the tree the tests check a fix in: `planted`, the code with the bug as Haiku got it, with each file that is no
test as `copy` holds it after the fix. So a test Haiku changed, removed or added doesn't count, and neither does a file under
a `testdata` folder, where Go's tests keep the output they expect. A Rust file's `#[cfg(test)]` modules are the planted file's.
a `testdata` folder, where Go's tests keep the output they expect.
Raises OSError where a file cannot be copied."""
shutil.copytree(planted, into, symlinks=True)
@@ -185,20 +184,6 @@ def checked_tree(planted: str, copy: str, into: str) -> None:
with contextlib.suppress(FileNotFoundError):
os.unlink(target)
shutil.copy2(os.path.join(copy, path), target, follow_symlinks=False)
if path.endswith(".rs"):
keep_rust_tests(os.path.join(planted, path), target)
def keep_rust_tests(planted_file: str, target: str) -> None:
"""Puts into the Rust file at target, a copy of Haiku's, the test modules of planted_file; see `with_tests_of`. A file the planted
tree lacks, as a link or as a file, is left as it is, since it has no test to keep.
Raises OSError where a file cannot be read or written."""
if os.path.islink(planted_file) or os.path.islink(target) or not os.path.isfile(planted_file):
return
# A Rust file is UTF-8; a byte that isn't survives the round trip.
planted, copied = (pathlib.Path(file).read_bytes().decode("utf-8", "surrogateescape") for file in (planted_file, target))
pathlib.Path(target).write_bytes(with_tests_of(planted, copied).encode("utf-8", "surrogateescape"))
def of_tests(path: str) -> bool:
-87
View File
@@ -1,87 +0,0 @@
"""The `#[cfg(test)]` modules of a Rust file, which stand in the file of the code they test: where each is, and a file with the modules
of another file put in place of its own."""
import re
# What the scan steps over or stops at, in the order Rust's own lexer tries them. A string, a char and a comment may hold a brace.
SCAN = re.compile(
r"""//[^\n]*"""
r"""|/\*"""
r"""|(?<![A-Za-z0-9_])b?r(?P<hashes>\#*)\""""
r"""|\""""
r"""|'(?:\\(?:u\{[0-9a-fA-F_]+\}|x[0-9a-fA-F]{2}|.)|[^\\'\n])'"""
r"""|[{}]"""
r"""|\#\[cfg\(test\)\]""",
re.DOTALL,
)
COMMENT_EDGE = re.compile(r"/\*|\*/")
# What must follow the attribute for it to start an inline module: other attributes, a visibility, then `mod name {`.
MODULE = re.compile(r"\s*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?mod\s+(?P<name>\w+)\s*\{")
def modules(source: str) -> dict[str, tuple[int, int]] | None:
"""Each inline `#[cfg(test)] mod name { ... }` of source by its name, as the offsets from its attribute to its closing brace. A
module inside another is not listed. None where the modules cannot be told apart: two hold one name, or a brace, string or
comment is never closed. A `#[cfg(test)]` on anything but an inline module is not listed."""
found: dict[str, tuple[int, int]] = {}
depth, open_at, start, name = 0, 0, -1, ""
position = 0
while match := SCAN.search(source, position):
token, position = match.group(), match.end()
if token == "/*":
position = after_comment(source, position)
elif token == '"':
position = after_string(source, position, '"')
elif match.group("hashes") is not None:
position = after_string(source, position, '"' + match.group("hashes"), raw=True)
elif token == "{":
depth += 1
elif token == "}":
depth -= 1
if start >= 0 and depth == open_at:
if name in found:
return None
found[name], start = (start, position), -1
elif start < 0 and (module := MODULE.match(source, position)):
start, name, open_at = match.start(), module.group("name"), depth
position = module.end()
depth += 1
if position < 0:
return None
return found if depth == 0 and start < 0 else None
def after_comment(source: str, position: int) -> int:
"""The offset after the block comment whose `/*` ends at position, -1 where it is never closed. Block comments nest in Rust."""
level = 1
while level and (match := COMMENT_EDGE.search(source, position)):
level += 1 if match.group() == "/*" else -1
position = match.end()
return position if level == 0 else -1
def after_string(source: str, position: int, closing: str, raw: bool = False) -> int:
"""The offset after the string whose opening quote ends at position, -1 where it is never closed. A raw string has no escapes."""
while (found := source.find(closing, position)) >= 0:
backslashes = len(source[position:found]) - len(source[position:found].rstrip("\\"))
if raw or backslashes % 2 == 0:
return found + len(closing)
position = found + 1
return -1
def with_tests_of(planted: str, copy: str) -> str:
"""copy with each test module as planted holds it, and each test module planted lacks left out. So a test a fix changed, removed
or added doesn't count.
Where planted's modules cannot be told apart, copy is returned as it is. Where copy's cannot, or copy lacks one of planted's,
planted is returned: Haiku's file has no module to put them in."""
before, after = modules(planted), modules(copy)
if before is None:
return copy
if after is None or before.keys() - after.keys():
return planted
text = copy
for name, (start, end) in sorted(after.items(), key=lambda item: -item[1][0]):
was = planted[before[name][0]:before[name][1]] if name in before else ""
text = text[:start] + was + text[end:]
return text
-105
View File
@@ -1,105 +0,0 @@
"""The test modules of a Rust file: where they are, and a fixed file with the planted tests put back."""
import pathlib
import sys
import textwrap
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench.rust_test_modules import modules, with_tests_of
LIB = textwrap.dedent("""\
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn adds() {
assert_eq!(add(1, 2), 3);
}
}
""")
def spelt(source: str) -> dict[str, str] | None:
found = modules(source)
return None if found is None else {name: source[start:end] for name, (start, end) in found.items()}
class ModulesTest(unittest.TestCase):
def test_holds_each_test_module_from_its_attribute_to_its_closing_brace(self):
self.assertEqual(spelt(LIB), {"tests": LIB[LIB.index("#[cfg(test)]"):LIB.rindex("}") + 1]})
def test_holds_none_where_the_file_has_no_test_module(self):
self.assertEqual(modules("fn main() {}\n"), {})
def test_takes_a_module_with_a_visibility_and_another_attribute(self):
source = "#[cfg(test)]\n#[allow(dead_code)]\npub(crate) mod checks {\n}\nfn after() {}\n"
self.assertEqual(spelt(source), {"checks": source[:source.index("}") + 1]})
def test_leaves_out_what_the_attribute_is_not_on_an_inline_module(self):
self.assertEqual(modules("#[cfg(test)]\nmod tests;\n#[cfg(test)]\nuse std::fmt;\n#[cfg(test)]\nfn helper() {}\n"), {})
def test_leaves_out_a_module_inside_a_module(self):
source = "#[cfg(test)]\nmod outer {\n #[cfg(test)]\n mod inner {}\n}\n"
self.assertEqual(list(spelt(source)), ["outer"])
def test_reads_past_a_brace_in_a_string_a_char_or_a_comment(self):
source = textwrap.dedent("""\
#[cfg(test)]
mod tests {
// }
/* } /* } */ } */
const A: &str = "}\\"}";
const B: &str = r#"}"}"#;
const C: char = '}';
const D: char = '\\'';
fn lifetime<'a>(x: &'a str) -> &'a str { x }
}
fn after() {}
""")
self.assertEqual(spelt(source), {"tests": source[:source.index("}\nfn after")+1]})
def test_cannot_tell_the_modules_apart_where_two_hold_one_name(self):
self.assertIsNone(modules("#[cfg(test)]\nmod tests {}\nfn a() { #[cfg(test)] mod tests {} }\n"))
def test_cannot_tell_the_modules_apart_where_a_brace_string_or_comment_is_never_closed(self):
for source in ("#[cfg(test)]\nmod tests {\n", "fn a() {\n", "const A: &str = \"\n", "/* open\n", "const A: &str = r#\"\n"):
with self.subTest(source=source):
self.assertIsNone(modules(source))
class WithTestsOfTest(unittest.TestCase):
def test_takes_the_code_as_fixed_and_the_tests_as_planted(self):
planted = LIB.replace("a + b", "a - b")
fixed = LIB.replace("assert_eq!(add(1, 2), 3);", "assert_eq!(add(1, 2), 0);")
self.assertEqual(with_tests_of(planted, fixed), LIB)
def test_takes_the_planted_tests_where_the_fix_deleted_them(self):
planted = LIB.replace("a + b", "a - b")
fixed = "pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n"
self.assertEqual(with_tests_of(planted, fixed), planted)
def test_leaves_out_a_test_module_the_fix_added(self):
planted = "fn a() {}\n"
fixed = "fn a() {}\n#[cfg(test)]\nmod mine {}\nfn b() {}\n"
self.assertEqual(with_tests_of(planted, fixed), "fn a() {}\n\nfn b() {}\n")
def test_puts_each_planted_module_where_the_fixed_module_of_its_name_stands(self):
planted = "fn a() { 1 }\n#[cfg(test)]\nmod x { fn t() {} }\nfn b() {}\n#[cfg(test)]\nmod y { fn u() {} }\n"
fixed = "fn a() { 2 }\n#[cfg(test)]\nmod y { fn changed() {} }\n#[cfg(test)]\nmod x { fn changed() {} }\nfn c() {}\n"
self.assertEqual(with_tests_of(planted, fixed), "fn a() { 2 }\n#[cfg(test)]\nmod y { fn u() {} }\n#[cfg(test)]\nmod x { fn t() {} }\nfn c() {}\n")
def test_takes_the_file_as_fixed_where_the_planted_modules_cannot_be_told_apart(self):
self.assertEqual(with_tests_of("#[cfg(test)]\nmod tests {\n", "fixed {}"), "fixed {}")
def test_takes_the_planted_file_where_the_fixed_modules_cannot_be_told_apart(self):
self.assertEqual(with_tests_of(LIB, "fn broken() {"), LIB)
if __name__ == "__main__":
unittest.main()
-17
View File
@@ -578,11 +578,6 @@ class RunOutcomesTest(unittest.TestCase):
bench = dataclasses.replace(self.bench(), trees={"base": str(self.tree), "head": str(head)})
self.assertIsNone(main.planted(bench, 1, self.MUTANT))
def test_a_rust_mutant_in_a_file_whose_test_module_cannot_be_told_apart_is_passed_over(self):
(self.tree / "lib.rs").write_text("pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n#[cfg(test)]\nmod tests {\n")
mutant = Mutant("lib.rs", 2, "lib.rs:2:7 replace + with -", (b" a + b",), (b" a - b",))
self.assertIsNone(main.planted(self.bench(), 1, mutant))
class ContainersTest(unittest.TestCase):
IN_TREE = ["--memory", "512m", "--memory-swap", "512m", "--user", "1000:1000", "--env", "HOME=/tmp", "--volume", "/tree:/work", "--workdir", "/work"]
@@ -723,18 +718,6 @@ class CheckedTreeTest(unittest.TestCase):
checked_tree(planted, copy, str(self.root / "check"))
self.assertEqual(self.held("check"), {"calc.go": "fixed", "sub/testdata/gone.golden": "4", "testdata.go": "fixed", "testdata/want.golden": "3"})
def test_takes_a_rust_files_test_module_as_planted_and_the_rest_as_fixed(self):
planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 1 }\n"})
copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests {}\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"})
checked_tree(planted, copy, str(self.root / "check"))
self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 2 }\n#[cfg(test)]\nmod tests { fn t() { a() } }\n", "src/other.rs": "fn b() { 2 }\n", "src/new.rs": "#[cfg(test)]\nmod mine {}\nfn c() {}\n"})
def test_takes_the_planted_rust_file_where_the_fix_deleted_its_test_module(self):
planted = self.tree("planted", {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"})
copy = self.tree("copy", {"src/lib.rs": "fn a() { 2 }\n"})
checked_tree(planted, copy, str(self.root / "check"))
self.assertEqual(self.held("check"), {"src/lib.rs": "fn a() { 1 }\n#[cfg(test)]\nmod tests { fn t() {} }\n"})
def test_copies_a_link_as_a_link(self):
planted = self.tree("planted", {"calc.go": "bug"})
copy = self.tree("copy", {"calc.go": "fixed"})
+27 -1
View File
@@ -6,12 +6,14 @@
`Bar = 0.1`
`Next ID = 539`
`Next ID = 541`
## Items
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 540 | 0.16.0 | | | **Review once more each prose fix that rewrites a checkable claim, such as a claim about generated output, a number or a licence term, so no such rewrite reaches the merge unreviewed.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 4 | 1.5 |
| 539 | 0.16.0 | | defect | **Start a chunk's worker on a fresh session where its session's transcript is empty, in place of resuming a session claude cannot find.** | 1 | 2 | 3 | 4 | 2 | 1.5 by 3 | 1.1 |
| 531 | 0.16.0 | | | **Bench the shipped features of a branch that landed by fast-forward: take as the feature the commits from the one after the item finished before it, up to the commit that took its item out of the plan.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 3 | 1.1 |
| 524 | 0.16.0 | | owner | **Write fejkdata's first six bench features, each a spec, acceptance tests in Go and a reference patch that builds it, in the `bench-tasks` folder its config names.** | 3 | 2 | 1 | 4 | 6 | 1.1 by 3 | 0.5 |
| 532 | 0.16.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test that stands in the file of the code it tests.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 |
@@ -112,6 +114,30 @@
## Details
### 540. Review once more each prose fix that rewrites a checkable claim, such as a claim about generated output, a number or a licence term, so no such rewrite reaches the merge unreviewed.
Today the prose pass runs one round per chunk, and a fix for a prose finding reruns no pass ("Re-entry"). So a rewrite of a factual claim merges unchecked. In one chunk the prose reviewer flagged a doc's claim about generated output as false; the rewrite was still false, and only the outside auto-reviewer caught it, after the PR was marked ready. In the same chunk a credit sentence left out parts the project's licence file lists for that source: a licence link and a notice of changes.
Two directions; the implementer picks the cheaper that fits what the rounds cost:
- let the prose pass re-enter once where a round's fix answers a finding that asserts something checkable;
- or have prose-reviewer check each claim a fix rewrites against a concrete counter-example, and against the source it names, such as the licence file's listed credit, before it accepts the rewrite.
Touches:
- `skills/larv-review/SKILL.md`: `## 3. Passes` (small), `### Prose` (small)
- `agents/prose-reviewer.md`: `## Checks, in priority order` (small)
### 539. Start a chunk's worker on a fresh session where its session's transcript is empty, in place of resuming a session claude cannot find.
Today `session_open` in `bin/claude_code/session.py` counts a session as open wherever its `<session id>.jsonl` exists. On 2026-11-24 a run left item-532's transcript as a 0-byte file, with an archive folder whose transcript and outcomes were empty too. On 2026-11-25 every rerun of item-532 called `claude --resume <id>`. Each got "No conversation found with session ID …" and exited 1. The window stopped after three failures and waited for the human, who had to move the file away by hand.
Count an empty transcript as no session. Before the worker starts that session with `--session-id`, remove the empty file, so claude doesn't refuse the id. Leave a non-empty transcript to resume as today. The worker's start, in `bin/agent_cycle/run.py` → `worker_start`, and a chunk's start, in `bin/loop_claude/loop/chunk_start.py`, both read `session_open`, so the fix holds for both.
Touches:
- `bin/claude_code/session.py`: `session_open` (small)
- `bin/claude_code/test_claude_code.py`
### 531. Bench the shipped features of a branch that landed by fast-forward: take as the feature the commits from the one after the item finished before it, up to the commit that took its item out of the plan.
Today `task-bench --tasks shipped-features` passes such a feature over. A fast-forwarded branch's commits keep a commit time each, so `branch_chunks` cuts each commit into a chunk of its own, and the chunk that took the item out of the plan holds only the feature's last commit. This project landed 114 of its 260 shipped features that way, and none of those can be benched. A squash-merged feature whose one commit was authored and committed at the same time would be passed over too; whether a forge writes such commits is not checked.