Release review of 0.17.0 #778

Merged
lilleman merged 12 commits from release-review-0.17.0 into main 2026-12-02 00:14:22 +01:00
27 changed files with 283 additions and 206 deletions
+1
View File
@@ -15,6 +15,7 @@
- stability-reviewer checks the neighbours of each input shape a change starts to handle against what the base made of them.
- stability-reviewer lists every caller of a shared function, generator or iterator whose output the diff changes, and states what each does with the new case.
- task-bench leaves out of a fix a change Haiku makes to a PHP test named `*Test.php` or a JavaScript or TypeScript test that `node --test` finds by a name such as `*-test.js`, and plants no bug in such a file.
- mutate-changes takes a PHP file named `*Test.php`, and a JavaScript or TypeScript file that `node --test` finds by a name such as `*-test.js`, as a test, and no longer mutates it.
- `chunk-preflight` names the next release's items that have no `Touches:` list, where the release holds other items, and the worker of the next item's chunk has one subagent write the lists before its chunk, so other chunks can start beside it. `rank_todo.py --check` warns of such items, still exiting 0.
- Technical principles: a function keeps a copy of an argument it retains, and a size limit counts every cell the code allocates, empty ones too.
- larv-review's security pass and stability-reviewer now check that the doc beside a new secret or token names what the credential can reach, such as the other repositories its owning account can use, not only what the change uses it for.
+1 -1
View File
@@ -311,7 +311,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
- `judge_replay` imports `agent_cycle`'s judge and verdicts, and `chunk_driver`'s premises, records and `ANSWER_DESTINATIONS`.
- `routing_figures/` measures loop-claude's archive, and each of its projects' default branches, for loop-claude's routing calls.
- `rung_replay/` holds what `judge_replay` and `review_replay` share: the parallel replay runner, the argument reader, the candidate rungs and the exits, and `judge_replay`'s rung search. It reads `agent_cycle`'s retry count and `chunk_driver`'s models file, and finds that file through `loop_state`'s paths. Its `archive.py` keeps each replay's runs and its report in a `replays/` folder of loop-claude's archive.
- `task_bench/` holds `task-bench`, which has Haiku fix, build or add a task in containers: a bug planted in a project's Go, PHP, Python, Rust, TypeScript and JavaScript files (`bugs/`), or one of the project's bench features, its data sources or the features its history shipped (`features/`). `figures/` measures the runs and holds `task-bench gather`.
- `task_bench/` holds `task-bench`, which has Haiku fix, build or add a task in containers: a bug planted in a project's Go, PHP, Python, Rust, TypeScript and JavaScript files (`bugs/`), or one of the project's bench features, its data sources or the features its history shipped (`features/`). `figures/` measures the runs and holds `task-bench gather`. `task_bench` imports three things from `mutate_changes`: the rule for which files are tests (`changed_lines.is_test`), the runners of the mutation tools, and the process runner (`tool_process`).
#### The shell, the machine and text
+10 -34
View File
@@ -122,7 +122,7 @@ import time
import typing
from chunk_pr.approval import approval, approved, awaited, left_to_a_person, left_to_park, PARKS, unanswered
from forge.pulls import checks_passed, merged_pull, open_pull, other_base, pull_from, required_checks
from forge.pulls import checks_passed, merged_pull, open_pull, other_base, required_checks, shown_pull, StaleHead
from git_cli.git_repo import CHUNK_BASE, Git
from git_cli import epic_branch
from failure import Failure
@@ -141,9 +141,6 @@ QUEUE = "chunk-pr-merge-queue"
# A turn lasts as long as its checks, which chunk-pr waits half an hour for on Gitea, so a queue still held after that is reported, not waited out.
QUEUE_SECONDS = 30 * 60
QUEUE_POLL_SECONDS = 10
# How long push waits for the forge to show the pushed commit as the head of the branch's open pull request, polling every PUSH_POLL_SECONDS: GitHub may list the old head for a while after a push.
PUSH_SECONDS = 60
PUSH_POLL_SECONDS = 5
# The line record-ruling writes into the comprehension history, as git's -G reads it.
RULING = "^Ruling: "
# The project's config, loaded once per step, on the first call that needs it.
@@ -161,7 +158,7 @@ def main(argv: list[str]) -> int:
if argv[:1] in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
done = step(argv, runner(os.getcwd()), functools.cache(lambda: located(os.getcwd(), pathlib.Path.home())), os.environ.get(PARKS) == "1")
done = step(argv, runner(os.getcwd()), functools.cache(lambda: located(os.getcwd(), pathlib.Path.home())), os.environ.get(PARKS) == "1", time.sleep)
if isinstance(done, Failure):
print(f"chunk-pr: {done.reason}", file=sys.stderr)
return 1
@@ -169,7 +166,7 @@ def main(argv: list[str]) -> int:
return 0
def step(argv: list[str], run: Run, config: Config, parks: bool = False, sleep: typing.Callable[[float], None] = time.sleep) -> str | Failure:
def step(argv: list[str], run: Run, config: Config, parks: bool, sleep: typing.Callable[[float], None]) -> str | Failure:
"""Run the step argv names: the line to print, or a Failure. A malformed argv doesn't run anything. parks is whether a merge fails at once where it would wait for an approval (`merged`). sleep is how push and merge wait."""
match argv:
case ["open", title, *body] if len(body) <= 1 and not title.startswith("-"):
@@ -341,15 +338,16 @@ def levelled(run: Run, branch: str, base: str, resolve: str = "resolve them and
def readied(run: Run, title: str | None, config: Config) -> str | Failure:
"""Mark the branch's pull request ready, then ask for a review of it as `review_asked` does."""
"""Mark the branch's pull request ready, then comment on it as `review_comment` says, to ask for a review."""
found = pull(run)
marked = found if isinstance(found, Failure) else marked_ready(run, title)
if isinstance(found, Failure) or isinstance(marked, Failure):
return marked
asked = review_asked(found[0], found[1], run, config)
comment = review_comment(run, config)
asked = comment_on(found[0], found[1], comment, run) if isinstance(comment, str) else comment
if isinstance(asked, Failure):
return Failure(f"marked pull request #{found[1]} ready, but could not ask for a review: {asked.reason}")
return f"{marked[:-1]}, and asked for a review with “{asked}”." if asked else marked
return f"{marked[:-1]}, and asked for a review with “{comment}”." if comment else marked
def marked_ready(run: Run, title: str | None) -> str | Failure:
@@ -370,7 +368,7 @@ def marked_ready(run: Run, title: str | None) -> str | Failure:
def pushed(run: Run, config: Config, sleep: typing.Callable[[float], None]) -> str | Failure:
"""Push the branch checked out, and ask for a review of its open pull request as `review_asked` does, once the forge shows the pushed commit as that pull request's head."""
"""Push the branch checked out, and comment on its open pull request as `review_comment` says, to ask for a review, once the forge shows the pushed commit as that pull request's head."""
found = checkout(run)
if isinstance(found, Failure):
return found
@@ -386,36 +384,14 @@ def pushed(run: Run, config: Config, sleep: typing.Callable[[float], None]) -> s
number = shown_pull(forge, branch, head, run, sleep)
if number is None:
return f"Pushed {branch}."
if isinstance(number, StaleHead):
return Failure(f"pushed {branch}, but {number.reason}, so no review was asked for; once it does, run chunk-pr push again")
if isinstance(number, Failure):
return number
made = comment_on(forge, number, comment, run)
return Failure(f"pushed {branch}, but could not ask for a review: {made.reason}") if isinstance(made, Failure) else f"Pushed {branch}, and asked for a review of pull request #{number} with “{comment}”."
def shown_pull(forge: Forge, branch: str, head: str, run: Run, sleep: typing.Callable[[float], None]) -> str | None | Failure:
"""The number of branch's open pull request at head, just pushed. Right after a push the forge may still list that pull request at an older head. While it does, this polls for up to PUSH_SECONDS, then returns a Failure naming the pull request. None where no pull request from branch is open: `push` before `open` is normal."""
other = None
for waited in range(0, PUSH_SECONDS + 1, PUSH_POLL_SECONDS):
number = open_pull(forge, branch, head, run)
if number is not None:
return number
other = pull_from(forge, branch, run)
if not isinstance(other, str):
return other
if waited < PUSH_SECONDS:
sleep(PUSH_POLL_SECONDS)
return Failure(f"pushed {branch}, but pull request #{other} still doesn't show {head[:12]} as its head after {PUSH_SECONDS} seconds, so no review was asked for; once it does, run chunk-pr push again")
def review_asked(forge: Forge, number: str, run: Run, config: Config) -> str | None | Failure:
"""Comment on the pull request numbered number as `review_comment` says. The comment made; None where it says none."""
comment = review_comment(run, config)
if comment is None or isinstance(comment, Failure):
return comment
made = comment_on(forge, number, comment, run)
return made if isinstance(made, Failure) else comment
def comment_on(forge: Forge, number: str, comment: str, run: Run) -> str | Failure:
return run(["gh", "pr", "comment", number, "--body", comment] if forge == "gh" else ["tea", "comment", number, comment])
+11 -1
View File
@@ -7,12 +7,13 @@ import shutil
import subprocess
import sys
import tempfile
import typing
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from chunk_pr.approval import awaited
from chunk_pr.main import Base, base_of, cleaned, merged, QUEUE, step, turn, USAGE
from chunk_pr.main import Base, base_of, cleaned, Config, merged, QUEUE, step as step_of_main, turn, USAGE
from failure import Failure
from test_env import isolated_env
from project_config.settings import ProjectConfig
@@ -325,6 +326,15 @@ class Sync(unittest.TestCase):
self.assertEqual(step(["sync"], checkout, checkout.config), Failure("git fetch --quiet: could not read from remote"))
def no_wait(seconds: float) -> None:
raise AssertionError(f"this test should not wait, and its step slept {seconds} seconds")
def step(argv: list[str], run: Run, config: Config, parks: bool = False, sleep: typing.Callable[[float], None] = no_wait) -> str | Failure:
"""chunk-pr's step, failing the test where it waits, unless the test hands it a sleep."""
return step_of_main(argv, run, config, parks, sleep)
def changes(checkout: Checkout) -> list[list[str]]:
"""What a merge ran, leaving out what it read, the project's config included, and the fetch each turn opens with."""
return [command for command in checkout.acted() if command != FETCH and not command[0].endswith("/project-config")]
+2 -2
View File
@@ -8,7 +8,7 @@ from forge.commands import Forge
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran
from text_files.markdown_text import listed, quoted
from chunk_preflight.choices import PULLS_LIST
from chunk_preflight.indentation import SpaceIndented
from chunk_preflight.indentation import SAMPLE, SpaceIndented
from plan.touches import unpredicted, without_a_list
from plan.release import version
@@ -46,7 +46,7 @@ def indentation_lines(found: SpaceIndented | Failure | None) -> list[str]:
return [f"- Whether the project's code is space-indented cannot be read: {found.reason}"]
if found is None:
return []
return [f"- The project's code is space-indented ({found.spaced} lines against {found.tabbed} with tabs), and neither an `.editorconfig` with `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the indent. The technical principles indent with hard tabs unless a setting a tool reads, plus a decision in the project's decision log that names the reason, overrides that. Don't reindent in a chunk with another purpose. Where the plan holds no item for either way out, file one: convert the code to tabs, or record the override in `.editorconfig` and a decision."]
return [f"- The project's code is space-indented ({found.spaced} lines against {found.tabbed} with tabs, in the first {SAMPLE} code files git lists), and neither an `.editorconfig` with `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the indent. The technical principles, under “Indent with hard tabs by default”, say which settings override the tabs. Don't reindent in a chunk with another purpose. Where the plan holds no item for either way out, file one: convert the code to tabs, or record the override in `.editorconfig` and a decision."]
def last_release(default: str, release: LastCut) -> str:
+14 -14
View File
@@ -23,6 +23,9 @@ SETTINGS = (
# Two spaces is the narrowest space indent; a lone leading space aligns a comment's continuation.
SPACED_LINE = re.compile(r"^ {2,}\S", re.MULTILINE)
TABBED_LINE = re.compile(r"^\t+\S", re.MULTILINE)
# How many code files are counted. chunk-preflight runs for every chunk, and a client's repo may hold tens of thousands of files; the first that git lists
# tell which indent most of the code uses.
SAMPLE = 200
@dataclasses.dataclass(frozen=True)
@@ -33,26 +36,23 @@ class SpaceIndented:
def space_indented(base: pathlib.Path, timeout: float | None = None) -> SpaceIndented | Failure | None:
"""The line counts of the tracked code under base, where it has more space-indented than tab-indented lines and no tracked file holds an indent key; else None. A Failure where git cannot list the files or a file cannot be read."""
"""The line counts of the first SAMPLE files of tracked code under base, in git's order, where they have more space-indented than tab-indented lines and no tracked file holds an indent key; else None. A Failure where git cannot list the files or a file cannot be read."""
tracked = git("ls-files", "-z", cwd=str(base), timeout=timeout, errors="replace")
if isinstance(tracked, Failure):
return tracked
spaced = tabbed = 0
for name in filter(None, tracked.split("\0")):
if VENDORED.search(name):
continue
code = CODE.fullmatch(name)
key = next((key for pattern, key in SETTINGS if pattern.fullmatch(name.rsplit("/", 1)[-1])), None)
path = base / name
if not (code or key) or not os.path.isfile(path):
continue
names = [name for name in filter(None, tracked.split("\0")) if not VENDORED.search(name) and os.path.isfile(base / name)]
keyed = [(name, key) for name in names for pattern, key in SETTINGS if pattern.fullmatch(name.rsplit("/", 1)[-1])]
code = [name for name in names if CODE.fullmatch(name)][:SAMPLE]
texts = []
# The settings files are few, so each is read before any code is counted.
for name, key in [*keyed, *((name, None) for name in code)]:
try:
text = path.read_text(encoding="utf-8", errors="replace")
text = (base / name).read_text(encoding="utf-8", errors="replace")
except OSError as failure:
return Failure(f"{name}: {failure}")
if key and key in text:
return None
if code:
spaced += len(SPACED_LINE.findall(text))
tabbed += len(TABBED_LINE.findall(text))
texts += [] if key else [text]
spaced = sum(len(SPACED_LINE.findall(text)) for text in texts)
tabbed = sum(len(TABBED_LINE.findall(text)) for text in texts)
return SpaceIndented(spaced, tabbed) if spaced > tabbed else None
+9 -4
View File
@@ -21,8 +21,8 @@ and prints that the release reviews and the cuts are the human's to call. It pri
finished on the branch of an open pull request that is not a draft, where the checkout holds
the plan. Where no item of the release can start and one awaits such a merge, it names those
pull requests and says the working loop stops there;
- where the project's tracked code (files of common programming languages, by extension; not
Markdown, JSON or YAML, nor anything under vendor/, node_modules/ or third_party/) has more
- where the first 200 files git lists of the project's tracked code (files of common programming languages, by extension; not
Markdown, JSON or YAML, nor anything under vendor/, node_modules/ or third_party/) hold more
space-indented than tab-indented lines, and neither an `.editorconfig` with `indent_style` nor a
formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the
indent, one line naming the technical principles' hard-tabs default and the two ways out. It
@@ -174,9 +174,14 @@ def preflight(root: pathlib.Path, timeout: float, make: bool, item_id: int | Non
held = project_plan(config, ref, str(root), forge_run=forge_run)
plan = planned(held.plan, held.cut, ref, config.branch, outside, item_id)
item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout, make, epic_branch_of(config))
# The folder the chunk works in: the item's worktree where one was made or found, else the checkout.
worktree = item.worktree.path if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else None
# A `checkout:` path lands in the worktree the chunk works in.
made = located(str(item.worktree.path), pathlib.Path.home()) if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else config
return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts, merges_unread=held.merges_unread, left=left_worktrees(root, forge_run) if config.merge == "human" else (), indentation=space_indented(item.worktree.path if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else root, timeout)))
made = located(str(worktree), pathlib.Path.home()) if worktree else config
places = (config if isinstance(made, Failure) else made).places
left = left_worktrees(root, forge_run) if config.merge == "human" else ()
indentation = space_indented(worktree or root, timeout)
return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), places, outside is not None, config.texts, merges_unread=held.merges_unread, left=left, indentation=indentation))
def epic_branch_of(config: ProjectConfig) -> str | None | Failure:
+3 -3
View File
@@ -810,8 +810,8 @@ class IndentationFact(unittest.TestCase):
def test_names_the_counts_the_principle_and_the_two_ways_out(self):
(line,) = self.said(SpaceIndented(spaced=120, tabbed=3))
self.assertIn("space-indented (120 lines against 3 with tabs)", line)
self.assertIn("The technical principles indent with hard tabs", line)
self.assertIn("space-indented (120 lines against 3 with tabs, in the first 200 code files git lists)", line)
self.assertIn("under “Indent with hard tabs by default”", line)
self.assertIn("file one: convert the code to tabs, or record the override in `.editorconfig` and a decision", line)
def test_says_nothing_where_the_code_is_not_space_indented_and_why_where_it_cannot_be_read(self):
@@ -826,7 +826,7 @@ class IndentationFact(unittest.TestCase):
spaced.commit(spaced.root, "spaces")
done = spaced.preflight()
self.assertEqual(done.returncode, 0, done.stderr)
self.assertIn("- The project's code is space-indented (2 lines against 0 with tabs)", done.stdout)
self.assertIn("- The project's code is space-indented (2 lines against 0 with tabs, in the first 200 code files git lists)", done.stdout)
spaced.write(spaced.root, ".editorconfig", "[*]\nindent_style = space\n")
spaced.commit(spaced.root, "setting")
self.assertNotIn("space-indented", spaced.preflight().stdout)
+9 -1
View File
@@ -9,7 +9,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from test_env import assert_not_root, isolated_env
from failure import Failure
from chunk_preflight.indentation import space_indented, SpaceIndented
from chunk_preflight.indentation import SAMPLE, space_indented, SpaceIndented
TABBED = "def run():\n\tif True:\n\t\treturn 1\n"
SPACED = "def run():\n if True:\n return 1\n"
@@ -56,6 +56,14 @@ class SpaceIndentation(unittest.TestCase):
with self.subTest(name):
self.assertIsInstance(space_indented(self.checkout(**{"app.py": SPACED, name: text})), SpaceIndented)
def test_counts_no_line_of_a_settings_file(self):
self.assertIsNone(space_indented(self.checkout(**{"app.py": TABBED, "package.json": '{\n "name": "x",\n "version": "1",\n "private": true\n}\n'})))
def test_counts_only_the_first_code_files_git_lists(self):
first = {f"a{number:03}.py": TABBED for number in range(SAMPLE)}
self.assertIsNone(space_indented(self.checkout(**first, **{"b1.py": SPACED * 400})))
self.assertIsNone(space_indented(self.checkout(**{f"a{number:03}.py": SPACED for number in range(SAMPLE + 1)}, **{"z__.editorconfig": "indent_style = space\n"})))
def test_stays_silent_for_a_repo_without_code(self):
self.assertIsNone(space_indented(self.checkout(**{"README.md": SPACED, "data.json": SPACED, "ci.yml": SPACED})))
+27 -2
View File
@@ -15,7 +15,11 @@ POLL_SECONDS = 10
WAIT_SECONDS = 30 * 60
# How many pull requests pull_at asks Gitea for in a page; Gitea's default cap is 50.
PAGE_SIZE = 50
# What gh says of a pull request whose head has no check.
# How long shown_pull waits for the forge to show the pushed commit as the head of the branch's open pull request, polling every PUSH_POLL_SECONDS: GitHub may list the old head for a while after a push.
PUSH_SECONDS = 60
PUSH_POLL_SECONDS = 5
# What gh says of a pull request whose head has no check. gh exits 1 for it, as for a failed check, so only the text tells the two apart. gh
# doesn't document the text; gh 2.102.0's `pr checks` prints "no checks reported on the '<branch>' branch".
NO_CHECKS = "no checks reported"
@@ -29,6 +33,26 @@ def pull_from(forge: Forge, branch: str, run: Run) -> str | None | Failure:
return pull_at(forge, branch, None, "open", run)
@dataclasses.dataclass(frozen=True)
class StaleHead(Failure):
"""The forge still lists a pull request at an older head than the one pushed."""
def shown_pull(forge: Forge, branch: str, head: str, run: Run, sleep: typing.Callable[[float], None]) -> str | None | StaleHead | Failure:
"""The number of branch's open pull request at head, just pushed; None where the branch has no open pull request. Right after a push the forge may still list that pull request at an older head. While it does, this polls for up to PUSH_SECONDS, and is then a StaleHead that names the pull request."""
other = None
for waited in range(0, PUSH_SECONDS + 1, PUSH_POLL_SECONDS):
number = open_pull(forge, branch, head, run)
if number is not None:
return number
other = pull_from(forge, branch, run)
if not isinstance(other, str):
return other
if waited < PUSH_SECONDS:
sleep(PUSH_POLL_SECONDS)
return StaleHead(f"pull request #{other} still doesn't show {head[:12]} as its head after {PUSH_SECONDS} seconds")
def merged_pull(forge: Forge, branch: str, head: str, run: Run) -> str | None | Failure:
"""The number of the merged pull request from origin's own branch whose head was head; None where there is none. A rebase or a squash merge counts: the pull request keeps the head it had."""
return pull_at(forge, branch, head, "merged", run)
@@ -79,7 +103,8 @@ def ready_pulls(forge: Forge, run: Run) -> list[ReadyPull] | Failure:
rows = [line.split("\t") for line in listed.splitlines()]
found = [ReadyPull(*row[:3]) for row in rows if row[3:] == ["false", "false"]]
else:
pulls = gitea(run, "repos/{owner}/{repo}/pulls?state=open&limit=50")
# A limit: this reads one page of the open pull requests, drafts and forks counted, so an awaited one past that page is not seen.
pulls = gitea(run, f"repos/{{owner}}/{{repo}}/pulls?state=open&limit={PAGE_SIZE}")
if isinstance(pulls, Failure):
return pulls
try:
+9 -1
View File
@@ -9,7 +9,14 @@ HUNK = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@", re.MULTILINE)
STRYKER = (".cjs", ".cts", ".js", ".jsx", ".mjs", ".mts", ".ts", ".tsx")
TOOLS = {".go": "gremlins", ".php": "infection", ".py": "mutmut", ".rs": "cargo-mutants", **dict.fromkeys(STRYKER, "stryker")}
TEST_FOLDERS = frozenset({"__tests__", "test", "tests"})
TEST_NAME = re.compile(r"test_.*\.py|.*_test\.py|conftest\.py|.*_test\.go|.*\.(?:spec|test)\.[^.]+")
# The suffixes `node --test` runs: JavaScript, and TypeScript where Node strips the types; not `.jsx` or `.tsx`, which it doesn't find.
NODE_SUFFIXES = (".cjs", ".cts", ".js", ".mjs", ".mts", ".ts")
# pytest's and Go's names and `*.spec.*` and `*.test.*`; PHPUnit's default suffix; node --test's `*-test`, `*_test`, `test-*` and `test`
# stems, in each of its suffixes.
TEST_NAME = re.compile(
r"test_.*\.py|.*_test\.py|conftest\.py|.*_test\.go|.*\.(?:spec|test)\.[^.]+"
rf"|.*Test\.php|(?:.*[-_]test|test|test-.*)(?:{'|'.join(re.escape(suffix) for suffix in NODE_SUFFIXES)})"
)
def added_lines(diff: str) -> frozenset[int]:
@@ -34,6 +41,7 @@ def tool_for(path: str) -> str | None:
def is_test(path: str) -> bool:
"""Whether path is a test by its name or folder alone, as pytest, Go, PHPUnit or `node --test` finds one, or by a folder in TEST_FOLDERS."""
folders, name = posixpath.split(path)
return bool(TEST_FOLDERS & set(folders.split("/")) or TEST_NAME.fullmatch(name))
+3 -2
View File
@@ -4,8 +4,9 @@ usage: mutate-changes [--base <ref>] [--prefix <shell text>] [--jobs <n>]
Run it in a checkout, under ~/.claude/bin/run-heavy. It diffs the working tree's tracked files against the merge base of HEAD and
--base, by default the default branch: origin's as last fetched, else main or master. It picks the tool by each changed file's
extension, and leaves out test files: test_*.py, *_test.py, *_test.go, conftest.py, *.test.* and *.spec.*, and any file under a tests/, test/
or __tests__/ folder.
extension, and leaves out test files: test_*.py, *_test.py, *_test.go, conftest.py, *.test.*, *.spec.* and *Test.php; the names
`node --test` runs, *-test, *_test, test-* and test with a JavaScript or TypeScript suffix other than .jsx and .tsx; and any file under
a tests/, test/ or __tests__/ folder.
- .py: mutmut 3, in a scratch copy of the nearest folder above the file that holds a setup.cfg or a pyproject.toml, else of the
checkout's top. The exception is a file that a test beside it imports by its file name, as `import run_harness`, where the
@@ -1,25 +1,25 @@
import unittest
from task_bench.framework_tests import is_test_file
from mutate_changes.changed_lines import is_test
class IsTestFileTest(unittest.TestCase):
class IsTestTest(unittest.TestCase):
def test_tells_a_php_file_ending_in_Test_wherever_it_stands(self):
for path in ("src/PickTest.php", "PickTest.php", "app/Models/UserTest.php"):
with self.subTest(path=path):
self.assertTrue(is_test_file(path))
self.assertTrue(is_test(path))
def test_tells_the_names_node_test_finds_in_each_suffix_it_runs(self):
for path in ("src/pick-test.js", "pick_test.mjs", "src/test-pick.cjs", "src/test.ts", "a/b/pick-test.ts", "test.js", "x_test.mts", "test-x.cts"):
with self.subTest(path=path):
self.assertTrue(is_test_file(path))
self.assertTrue(is_test(path))
def test_tells_what_is_test_tells(self):
def test_tells_a_test_by_its_folder_or_its_spec_test_or_pytest_or_go_name(self):
for path in ("src/pick.test.js", "src/pick.spec.ts", "tests/pick.php", "a/__tests__/pick.js", "pick_test.go", "test_pick.py"):
with self.subTest(path=path):
self.assertTrue(is_test_file(path))
self.assertTrue(is_test(path))
def test_takes_other_code_as_code(self):
for path in ("src/Pick.php", "src/Tester.php", "src/PickTest.phps", "src/pick.js", "src/latest.js", "src/pick-tests.js", "src/pickTest.js", "src/test-pick.json", "src/pick-test.jsx", "src/pick-test.tsx", "src/contest.ts", "src/Test.php.bak"):
with self.subTest(path=path):
self.assertFalse(is_test_file(path))
self.assertFalse(is_test(path))
+1
View File
@@ -99,6 +99,7 @@ class FilePlan:
"""What `rank_todo.py --check` says of the file without failing on it: which items of its earliest release hold no `Touches:` list.
The line states that, with no instruction to its reader: `chunk-preflight` quotes it into every chunk's facts, and only the fact of `chunk_preflight.facts.unpredicted_lines` has a subagent write the lists."""
# The warning is for a person who runs `rank_todo.py --check` by hand, whom chunk-preflight's facts don't reach.
plan = self.read()
if isinstance(plan, Failure):
return []
+2 -3
View File
@@ -7,10 +7,9 @@ import typing
from failure import Failure
from task_bench.bugs import go_bugs, php_bugs, python_bugs, rust_bugs, typescript_bugs
from task_bench.framework_tests import is_test_file
from mutate_changes.changed_lines import is_test, STRYKER
from task_bench.bugs.planted_mutant import Mutant
from mutate_changes.tool_process import Run
from mutate_changes.changed_lines import STRYKER
# A place as `larv-review places` prints it: `<path>:<line>` in backticks.
PLACE = re.compile(r"`([^`\s:]+):\d+`")
@@ -44,7 +43,7 @@ def language_of(path: str, languages: tuple[Language, ...] = LANGUAGES) -> Langu
def place_files(places: str) -> list[str]:
"""The files that hold a place in what `larv-review places` prints and are in a language of LANGUAGES, test files left out, in
the order of their paths."""
return sorted({path for path in PLACE.findall(places) if language_of(path) and not is_test_file(path)})
return sorted({path for path in PLACE.findall(places) if language_of(path) and not is_test(path)})
def killed_mutants(top: str, files: list[str], run: Run, jobs: int, languages: tuple[Language, ...] = LANGUAGES) -> list[Mutant] | Failure:
+2 -1
View File
@@ -6,7 +6,8 @@ import pathlib
import shutil
from task_bench.tasks import Bench, committed, on_disk, Side, SIDES
from task_bench.runs import Containers, entries, in_tree, NotStarted, run_in_image, TimedOut
from task_bench.runs import Containers, in_tree, NotStarted, run_in_image, TimedOut
from task_bench.tree_tests import entries
from failure import Failure
# A panel of three readers, seated as the README's audience, picked the name on 2026-11-23: each had it first or second, over
+1 -1
View File
@@ -16,7 +16,7 @@ from failure import Failure
from git_cli.git_repo import Git
from plan.todo_table import Item, tagline_text
from project_config.main import located
from task_bench.runs import of_tests
from task_bench.tree_tests import of_tests
from project_config.settings import RECORDS
# Why a feature that landed by fast-forward is passed over: no earlier chunk says where its commits start, or its branch merged
-17
View File
@@ -1,17 +0,0 @@
"""Which files PHPUnit and `node --test` find as tests by their names, beyond the ones `mutate_changes.changed_lines.is_test` tells.
`is_test` stays as it is: changing it would change what `mutate-changes` skips."""
import posixpath
import re
from mutate_changes.changed_lines import is_test
# The suffixes `node --test` runs: JavaScript, and TypeScript where Node strips the types; not `.jsx` or `.tsx`, which it doesn't find.
NODE_SUFFIXES = (".cjs", ".cts", ".js", ".mjs", ".mts", ".ts")
# PHPUnit's default suffix, wherever the file stands; node --test's `*-test`, `*_test`, `test-*` and `test` stems, in each of its
# suffixes. node --test's `*.test.*` is `is_test`'s already.
FRAMEWORK_NAME = re.compile(rf".*Test\.php|(?:.*[-_]test|test|test-.*)(?:{'|'.join(re.escape(suffix) for suffix in NODE_SUFFIXES)})")
def is_test_file(path: str) -> bool:
"""Whether path is a test by its name or folder alone, as `is_test`, PHPUnit or `node --test` tells it."""
return is_test(path) or bool(FRAMEWORK_NAME.fullmatch(posixpath.basename(path)))
+16 -5
View File
@@ -204,7 +204,7 @@ from task_bench.tasks import Asked, Bench, BUG, check_made, committed, DATA_SOUR
from task_bench.bugs.planted_mutant import bug_at_sides, Mutant
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, rust_test_files, TimedOut, TOKEN, WORK
from task_bench.runs import closed, Containers, docker_cli, fix_attempted, MEMORY_MIB, opened, ran_tests, TimedOut, TOKEN, WORK
from task_bench.figures.digest import counted, digest, Run, TaskRuns
from machine_load.slots import CPUS_PER_SLOT
from git_cli.git_repo import default_ref, Git, top
@@ -220,6 +220,7 @@ from review_rules.review_folder import made_review_folder, REPORTS
from larv_review.history_commands import read_places
from task_bench.features.shipped_features import read_shipped, shipped_tasks
from task_bench.figures.record_figures import recorded_bench
from task_bench.tree_tests import rust_test_files
from run_heavy.capped_docker import SHARE_VARIABLE
from task_bench.rust_test_modules import tells_apart
@@ -523,10 +524,12 @@ def planted_tasks(bench: Bench, mutants: list[Mutant], seed: int, bugs: int) ->
"""The mutants that become bugs, in the order seed draws them, until the bench has as many as bugs; with a line that says so
where it has fewer."""
tasks: list[Task] = []
# The trees stand as they are while the bugs are planted, so their Rust test files are read once, and only where a Rust mutant is drawn.
rust_tests = functools.cache(functools.partial(rust_tests_of, bench))
for mutant in drawn(mutants, seed):
if len(tasks) == bugs:
break
task = planted(bench, len(tasks) + 1, mutant)
task = planted(bench, len(tasks) + 1, mutant, rust_tests)
if isinstance(task, Failure):
return task
tasks += [task] if task else []
@@ -580,8 +583,16 @@ def stopped_report(stopped: Failure, results: list[Result], total: int, names: d
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, kind.noun)]))
def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None:
"""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."""
RustTests = list[set[str] | None] | Failure
def rust_tests_of(bench: Bench) -> RustTests:
"""What `rust_test_files` finds in each side's tree."""
return on_disk("read the Rust files", lambda: [rust_test_files(tree) for tree in bench.trees.values()])
def planted(bench: Bench, number: int, mutant: Mutant, rust_tests: typing.Callable[[], RustTests]) -> Task | Failure | None:
"""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. rust_tests reads what `rust_tests_of` finds for bench."""
diff = bench.git("diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", bench.sides["base"], bench.sides["head"], "--", mutant.path, cwd=bench.checkout, errors="replace")
if isinstance(diff, Failure):
return diff
@@ -594,7 +605,7 @@ def planted(bench: Bench, number: int, mutant: Mutant) -> Task | Failure | None:
return None
# ... and the Rust test files of each side's tree, which it keeps only where it finds every one. A mutant in one of them is no bug.
if mutant.path.endswith(".rs"):
standing = on_disk(f"read the Rust files for the mutant in {mutant.path}", lambda: [rust_test_files(tree) for tree in bench.trees.values()])
standing = rust_tests()
if isinstance(standing, Failure):
return standing
if any(tests is None or mutant.path in tests for tests in standing):
-82
View File
@@ -1,17 +1,12 @@
"""Run task-bench's containers: the image that adds Claude Code to the project's, the network that reaches only the API, one task
done by Haiku in a copy of the code, and the project's tests over what it changed."""
import contextlib
import dataclasses
import os
import pathlib
import shutil
import subprocess
import typing
from task_bench.rust_test_modules import declared, homes, with_tests_of
from mutate_changes.tool_process import failed, Ran
from failure import Failure
from task_bench.framework_tests import is_test_file
from task_bench.api_proxy import PORT
MODEL = "claude-haiku-5-5"
@@ -162,80 +157,3 @@ def run_in_image(containers: Containers, args: list[str], stdout: typing.IO[byte
def in_tree(containers: Containers, tree: str) -> list[str]:
"""The options that run a container in tree, mounted at WORK on every run so no path tells the sides apart, as the caller's user."""
return [*containers.limits(), "--user", containers.user, "--env", f"HOME={HOME}", "--volume", f"{tree}:{WORK}", "--workdir", WORK]
def checked_tree(planted: str, copy: str, into: str, rust_tests_planted: bool = True) -> 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. Where rust_tests_planted, a Rust file's inline `#[cfg(test)]`
modules stand as the planted file has them too, as `with_tests_of` says, and so does each file that `rust_test_files` finds in
the planted tree.
Raises OSError where a file cannot be copied."""
shutil.copytree(planted, into, symlinks=True)
# `rust_test_files` is None for a tree with a declaration whose file it can't find, and the bench plants no bug in such a tree.
rust_tests = (rust_test_files(planted) or set()) if rust_tests_planted else set()
before, after = set(entries(planted)), set(entries(copy))
for path in before - after:
if not of_tests(path, rust_tests):
with contextlib.suppress(FileNotFoundError):
os.unlink(os.path.join(into, path))
for path in sorted(after):
target = os.path.join(into, path)
# A link is copied as a link, never followed; and one that would stand in for a folder of the planted tree is left out.
if of_tests(path, rust_tests) or (os.path.isdir(target) and not os.path.islink(target)):
continue
os.makedirs(os.path.dirname(target), exist_ok=True)
with contextlib.suppress(FileNotFoundError):
os.unlink(target)
shutil.copy2(os.path.join(copy, path), target, follow_symlinks=False)
if rust_tests_planted and 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, as `with_tests_of` says. A planted tree
without the file has no test module, so a file Haiku added keeps none. A link, planted's or Haiku's, is left as it is.
Raises OSError where a file cannot be read or written."""
if os.path.islink(planted_file) or os.path.islink(target):
return
planted = pathlib.Path(planted_file).read_bytes() if os.path.isfile(planted_file) else b""
pathlib.Path(target).write_bytes(with_tests_of(planted, pathlib.Path(target).read_bytes()))
def of_tests(path: str, rust_tests: typing.AbstractSet[str] = frozenset()) -> bool:
"""Whether path is a test by its path alone, or one of rust_tests."""
return is_test_file(path) or "testdata" in pathlib.PurePath(path).parts or path in rust_tests
def rust_test_files(tree: str) -> set[str] | None:
"""The Rust files under tree that a `#[cfg(test)] mod name;` declaration names, by their paths from tree. None where a declaration
names no file there, or a string or comment of a Rust file is never closed: the tree may hold a test file this can't find.
Raises OSError where a file cannot be read."""
files = set(entries(tree))
found = set()
for path in sorted(files):
if not path.endswith(".rs") or os.path.islink(os.path.join(tree, path)):
continue
declarations = declared(pathlib.Path(tree, path).read_bytes())
if declarations is None:
return None
for name, _ in declarations:
standing = files.intersection(homes(path, name))
if not standing:
return None
found |= standing
return found
def entries(top: str) -> list[str]:
"""Each file and link under top, by its path from top, without git's own under `.git`."""
found = []
for folder, folders, names in os.walk(top):
if folder == top and ".git" in folders:
folders.remove(".git")
links = [name for name in folders if os.path.islink(os.path.join(folder, name))]
found += [os.path.relpath(os.path.join(folder, name), top) for name in (*names, *links)]
return found
+2 -1
View File
@@ -5,7 +5,8 @@ import pathlib
import shutil
import typing
from task_bench.runs import checked_tree, Containers, ran_tests
from task_bench.tree_tests import checked_tree
from task_bench.runs import Containers, ran_tests
from failure import Failure
from git_cli.git_repo import Git
from mutate_changes.tool_process import Ran
+17 -10
View File
@@ -3,6 +3,7 @@ fix is checked in, and the proxy that reaches only the API."""
import asyncio
import contextlib
import dataclasses
import functools
import io
import json
import os
@@ -17,7 +18,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench import api_proxy, bench_folder, main, runs
from test_env import assert_not_root, isolated_env
from task_bench.runs import checked_tree, closed, Containers, docker_cli, fix_attempted, opened, ran_tests, rust_test_files, TimedOut
from task_bench.tree_tests import checked_tree, rust_test_files
from task_bench.runs import closed, Containers, docker_cli, fix_attempted, opened, ran_tests, TimedOut
from task_bench.bugs.plant import drawn
from claude_code.entries import Entry, entry_from
from failure import Failure
@@ -95,6 +97,10 @@ NAME, USER = "task-bench-0123456789ab", "1234:5678"
PLACES = "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `calc.go:3` `Add`: long\n- `gone.go:1` `Gone`: removed since\n- `README.md:1` `Calc`: thin\n"
def planted(bench, mutant):
return main.planted(bench, 1, mutant, functools.partial(main.rust_tests_of, bench))
class BenchTest(unittest.TestCase):
def setUp(self):
folder = tempfile.TemporaryDirectory()
@@ -546,11 +552,11 @@ class RunOutcomesTest(unittest.TestCase):
def test_a_mutant_whose_tests_run_out_of_time_is_passed_over(self):
late = TimedOut("docker run still ran after 30 min")
self.assertIsNone(main.planted(self.bench(late), 1, self.MUTANT))
self.assertIsNone(planted(self.bench(late), self.MUTANT))
def test_a_mutant_whose_tests_docker_could_not_run_fails_the_bench(self):
broke = Failure("docker could not start: No such file or directory")
self.assertEqual(main.planted(self.bench(broke), 1, self.MUTANT), broke)
self.assertEqual(planted(self.bench(broke), self.MUTANT), broke)
def assertFailsWith(self, found, start: str):
self.assertIsInstance(found, Failure)
@@ -594,7 +600,7 @@ class RunOutcomesTest(unittest.TestCase):
assert_not_root(self)
(self.tree / "calc.go").chmod(0)
self.addCleanup((self.tree / "calc.go").chmod, 0o644)
self.assertFailsWith(main.planted(self.bench(), 1, self.MUTANT), "could not read calc.go: ")
self.assertFailsWith(planted(self.bench(), self.MUTANT), "could not read calc.go: ")
def test_a_digest_quoting_half_of_a_surrogate_pair_is_written_with_a_question_mark_in_its_place(self):
# Claude Code may cut a string between the halves of an emoji's pair, and JSON parses the half it keeps into a lone surrogate.
@@ -606,12 +612,12 @@ class RunOutcomesTest(unittest.TestCase):
head = self.folder / "head"
head.mkdir()
bench = dataclasses.replace(self.bench(), trees={"base": str(self.tree), "head": str(head)})
self.assertIsNone(main.planted(bench, 1, self.MUTANT))
self.assertIsNone(planted(bench, 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))
self.assertIsNone(planted(self.bench(), mutant))
def rust_bench(self, files: dict[str, str], *runs: Ran | Failure) -> main.Bench:
for path, text in files.items():
@@ -625,21 +631,22 @@ class RunOutcomesTest(unittest.TestCase):
def test_a_rust_mutant_in_a_test_file_of_its_own_is_passed_over(self):
bench = self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": "fn t() { assert!(1 + 1 == 2); }\n"})
mutant = Mutant("src/tests.rs", 1, "src/tests.rs:1:20 replace + with -", (b"fn t() { assert!(1 + 1 == 2); }",), (b"fn t() { assert!(1 - 1 == 2); }",))
self.assertIsNone(main.planted(bench, 1, mutant))
self.assertIsNone(planted(bench, mutant))
def test_a_rust_mutant_in_a_tree_whose_declared_test_file_is_not_found_is_passed_over(self):
self.assertIsNone(main.planted(self.rust_bench({"src/lib.rs": self.ADD}), 1, self.ADDING))
self.assertIsNone(planted(self.rust_bench({"src/lib.rs": self.ADD}), self.ADDING))
def test_a_rust_mutant_in_code_beside_a_test_file_goes_on_to_the_tests(self):
broke = Failure("docker could not start: No such file or directory")
self.assertEqual(main.planted(self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": ""}, broke), 1, self.ADDING), broke)
self.assertEqual(planted(self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": ""}, broke), self.ADDING), broke)
def test_a_rust_mutant_in_a_tree_whose_rust_file_cannot_be_read_fails_the_bench_naming_the_file(self):
assert_not_root(self)
bench = self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": "", "src/other.rs": ""})
(self.tree / "src/other.rs").chmod(0)
self.addCleanup((self.tree / "src/other.rs").chmod, 0o644)
self.assertFailsWith(main.planted(bench, 1, self.ADDING), "could not read the Rust files for the mutant in src/lib.rs: ")
self.assertFailsWith(planted(bench, self.ADDING), "could not read the Rust files: ")
self.assertFailsWith(main.planted_tasks(bench, [self.ADDING], 1, 1), "could not read the Rust files: ")
class ContainersTest(unittest.TestCase):
+86
View File
@@ -0,0 +1,86 @@
"""Which files of a tree are its tests, and the tree the tests check a fix in: the planted tests over the code as fixed."""
import contextlib
import os
import pathlib
import shutil
import typing
from task_bench.rust_test_modules import declared, homes, with_tests_of
from mutate_changes.changed_lines import is_test
def checked_tree(planted: str, copy: str, into: str, rust_tests_planted: bool = True) -> 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. Where rust_tests_planted, a Rust file's inline `#[cfg(test)]`
modules stand as the planted file has them too, as `with_tests_of` says, and so does each file that `rust_test_files` finds in
the planted tree.
Raises OSError where a file cannot be copied."""
shutil.copytree(planted, into, symlinks=True)
# `rust_test_files` is None for a tree with a declaration whose file it can't find, and the bench plants no bug in such a tree.
rust_tests = (rust_test_files(planted) or set()) if rust_tests_planted else set()
before, after = set(entries(planted)), set(entries(copy))
for path in before - after:
if not of_tests(path, rust_tests):
with contextlib.suppress(FileNotFoundError):
os.unlink(os.path.join(into, path))
for path in sorted(after):
target = os.path.join(into, path)
# A link is copied as a link, never followed; and one that would stand in for a folder of the planted tree is left out.
if of_tests(path, rust_tests) or (os.path.isdir(target) and not os.path.islink(target)):
continue
os.makedirs(os.path.dirname(target), exist_ok=True)
with contextlib.suppress(FileNotFoundError):
os.unlink(target)
shutil.copy2(os.path.join(copy, path), target, follow_symlinks=False)
if rust_tests_planted and 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, as `with_tests_of` says. A planted tree
without the file has no test module, so a file Haiku added keeps none. A link, planted's or Haiku's, is left as it is.
Raises OSError where a file cannot be read or written."""
if os.path.islink(planted_file) or os.path.islink(target):
return
planted = pathlib.Path(planted_file).read_bytes() if os.path.isfile(planted_file) else b""
pathlib.Path(target).write_bytes(with_tests_of(planted, pathlib.Path(target).read_bytes()))
def of_tests(path: str, rust_tests: typing.AbstractSet[str] = frozenset()) -> bool:
"""Whether path is a test by its path alone, or one of rust_tests."""
return is_test(path) or "testdata" in pathlib.PurePath(path).parts or path in rust_tests
def rust_test_files(tree: str) -> set[str] | None:
"""The Rust files under tree that a `#[cfg(test)] mod name;` declaration names, by their paths from tree. None where a declaration
names no file there, or a string or comment of a Rust file is never closed: the tree may hold a test file this can't find.
Raises OSError where a file cannot be read."""
files = set(entries(tree))
found = set()
for path in sorted(files):
if not path.endswith(".rs") or os.path.islink(os.path.join(tree, path)):
continue
declarations = declared(pathlib.Path(tree, path).read_bytes())
if declarations is None:
return None
for name, _ in declarations:
standing = files.intersection(homes(path, name))
if not standing:
return None
found |= standing
return found
def entries(top: str) -> list[str]:
"""Each file and link under top, by its path from top, without git's own under `.git`."""
found = []
for folder, folders, names in os.walk(top):
if folder == top and ".git" in folders:
folders.remove(".git")
links = [name for name in folders if os.path.islink(os.path.join(folder, name))]
found += [os.path.relpath(os.path.join(folder, name), top) for name in (*names, *links)]
return found
+30
View File
@@ -4678,3 +4678,33 @@ Inherited architect, would restructure first:
- Navigation: `bin/do_epic/__init__.py:1` `do_epic`: an empty package header over about 25 modules, mapped only in README prose
- Shape, Navigation: `bin/chunk_pr/main.py:485` `merged`: one of three 37 to 46 KB mains that bundle several concerns
- Shape: `bin/agent_cycle/run.py:33` `Cycle`: 17 fields
## 2026-12-01T23:09:55Z, PR #778 at c79dc43, against 3315d9f
Ruling: better
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|---|---|---|---|---|---|
| Mid A | better | better | better | same | better |
| Inherited architect | better | better | better | same | better |
Mid A, decided by:
- Navigation, Locality: `bin/task_bench/tree_tests.py:52` `of_tests`: every caller imports the one `is_test`, where the base had two answers to which file is a test
- Navigation, Shape: `bin/task_bench/tree_tests.py:12` `checked_tree`: the tree work sits in a module named for it, and `runs.py` only runs containers
- Navigation, Shape: `bin/forge/pulls.py:41` `shown_pull`: the poll for a pushed head sits beside the lookups it calls and returns a typed `StaleHead`
- Shape: `bin/chunk_pr/main.py:341` `readied`: the docstrings name `review_comment`, which the code calls, where the base named a function `pushed` never called
- Locality: `bin/chunk_pr/main.py:169` `step`: `parks` and `sleep` are passed, so no caller sleeps for real unseen
- Locality, Shape: `bin/chunk_preflight/main.py:163` `preflight`: named locals replace one long line that repeated the worktree test
- Locality: `bin/task_bench/main.py:523` `planted_tasks`: a cached reader passed down adds hidden memoisation the base's inline read did not have
Inherited architect, decided by:
- Locality, Shape: `bin/mutate_changes/changed_lines.py:43` `is_test`: one rule for which files are tests, used by mutate-changes and task-bench, where the base had two
- Navigation, Shape: `bin/task_bench/tree_tests.py:12` `checked_tree`: a symptom about which test a fix keeps leads to the file by its name
- Shape, Locality: `bin/forge/pulls.py:41` `shown_pull`: the lookup no longer carries its caller's wording
- Locality: `bin/chunk_pr/main.py:169` `step`: the base defaulted to `time.sleep` with nothing at the call site showing it
- Shape: `bin/chunk_pr/main.py:340` `readied`: the single-use `review_asked` is gone, and with it a pointer to the wrong function
- Locality: `bin/task_bench/main.py:528` `planted_tasks`: the cached thunk is one more step of indirection than the base's inline read
- Locality: `bin/chunk_preflight/indentation.py:48` `space_indented`: one loop with a key-or-None marker is denser than the base's per-file loop
- Navigation: `README.md:314` task_bench entry: says what `task_bench` imports from `mutate_changes`
+9
View File
@@ -3910,3 +3910,12 @@ Read most (opens and searches):
- `agents/prose-reviewer.md` 2
- `agents/product-owner-reviewer.md` 1
## Reading cost, chunk 20d6ca33e337, finished 2026-12-01T17:43:12Z
55863 new input tokens before the first commit.
Read most (opens and searches):
- `docs/decisions.md` 8
- `skills/larv-review/SKILL.md` 3
+5 -3
View File
@@ -111,10 +111,12 @@ Give a reviewer without Bash `git ls-files`'s output in its prompt, since some h
| a 🔴 of a pass other than prose | opens an untrusted-input boundary or touches authn/authz, secrets or crypto | Security, unless the full scan reruns on it |
| a 🔴 of a pass other than prose | made rule-hook log an override | Overrides |
| a 🔴 of a pass other than prose | changes behaviour: what the code or its tests do | Stability |
| a 🟡 of a pass other than prose | removes or loosens an assertion, changes an expected value, or skips, deletes or guards a test or assertion with a condition or a catch | that pass |
| a 🟡 of a pass other than prose | adds a type, a function, a guard, a counter or shared state to code, or any other new unit of behaviour, whether in new lines or inside existing ones; a test, or a change that only edits what existing lines do, adds none | Stability |
| a 🟡 of a pass other than prose | weakens a test: removes or loosens an assertion, changes an expected value, or skips, deletes or guards a test or assertion with a condition or a catch | that pass |
| a 🟡 of a pass other than prose | adds a unit of behaviour: a type, a function, a guard, a counter or shared state in code, or any other, whether in new lines or inside existing ones | Stability |
| a prose finding, of any severity | rewrites what a claim says, where a command or a source file can check the claim, such as what generated output holds, a number or a licence term | Prose, as its second and last round |
A test doesn't add a unit of behaviour, and neither does a change that only edits what existing lines do.
Example: in the release review, a fix for a stability 🔴 that changes code and a comment reruns Stability and Principles.
A fix that fits no row doesn't rerun any pass. So none of these does:
@@ -125,7 +127,7 @@ A fix that fits no row doesn't rerun any pass. So none of these does:
A comment or doc edit inside a fix for another pass's finding adds no pass: no row reruns Prose for it.
One fix fits the first 🟡 row and still doesn't rerun the pass: a fix that only kills a named mutant or makes a named failing test pass, once §2's tests and mutation command run clean on it and the named failing test is unedited ("Mechanical answers"). A skipped test kills no mutant.
One fix doesn't rerun the pass, though the row "weakens a test" names its kind: a fix that only kills a named mutant or makes a named failing test pass, once §2's tests and mutation command run clean on it and the named failing test is unedited ("Mechanical answers"). A skipped test kills no mutant.
A round's fixes re-enter together: run every pass the table names for any of them, a done pass included, in the waves of "Waves", then §4. "Mechanical answers" below names the one case where the fixes for a 🔴 don't rerun its pass. A pass at its cap doesn't run again ("Round cap" → "Cap").
+6 -11
View File
@@ -52,11 +52,11 @@
| 471 | 0.23.0 | | | **Ship `jira-rest METHOD PATH [BODY]`, which makes one Jira Cloud REST call with the credentials of the project's config, or do-epic's, reading the env file itself, so an agent calls Jira without naming a file rule-hook guards.** | 2 | 2 | 4 | 6 | 3 | 1.6 by 3, 1.4 by 2 | 1.3 |
| 149 | 0.23.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 1.3 |
| 165 | 0.23.0 | | | **Make this repo's tests assert the facts a prompt or help text carries in place of its sentences, and drop the tests that scan source or assert a constant.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4, 1.4 by 3 | 1.3 |
| 392 | 0.23.0 | | owner | **Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, forge and host), so a newcomer finds a tool's neighbours in one place.** | 3 | 1 | 3 | 5 | 7 | code health by 4 | 1.3 |
| 392 | 0.23.0 | | owner | **Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, ship and host), so a newcomer finds a tool's neighbours in one place.** | 3 | 1 | 3 | 5 | 7 | code health by 4 | 1.3 |
| 456 | 0.23.0 | | | **Make the child-shell stop test pass under load, so a full test run doesn't fail on a race.** | 2 | 2 | 2 | 4 | 2 | 1.1 by 2, 1.5 by 2 | 1.3 |
| 151 | 0.23.0 | | decision | **Keep 10 to 20 settled decisions per project as its goals' test set, and rerun them after a goal changes.** | 3 | 2 | 2 | 5 | 5 | 1.2 by 7 | 1.2 |
| 68 | 0.23.0 | | principle | **Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.** | 2 | 1 | 1 | 2 | 4 | 1.1 by 5 | 1.2 |
| 102 | 0.23.0 | | | **Give loop-claude's retry delay, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 1.2 |
| 102 | 0.23.0 | | | **Give loop-claude's retry delay, its wall clock, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep`, `time.time` and `machine_load.memory.MEMINFO` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 3 | 1.1 by 4 | 1.2 |
| 135 | 0.23.0 | | | **Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 4 | 1.2 |
| 443 | 0.23.0 | | | **Measure whether compacting a waiting worker's session cut the cost of 20 chunks with an interrupt, with quality holding.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4 | 1.1 |
| 5 | 0.23.0 | | decision | **Key a project on its checkout's full path, and refuse to start while another session uses that key.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 6 | 1.1 |
@@ -83,7 +83,6 @@
| 518 | 0.23.0 | | | **Refuse `nothing`, `no one` and `nobody` after a verb or a preposition in everything Claude writes: files, commit messages, pull requests and Jira text before they are written, and chat replies by sending them back to be reworded.** | 3 | 2 | 3 | 6 | 5 | 1.1 by 4 | 0.7 |
| 181 | 0.23.0 | | principle | **Have the test of a quoted answer's step-up assert the stepped rung's facts as literals, not through `prompts.rungs_held`.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.7 |
| 193 | 0.23.0 | | | **Narrow `numbered`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.** | 1 | 1 | 3 | 3 | 1 | 1.1 by 2 | 0.7 |
| 194 | 0.23.0 | | | **Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 0.7 |
| 519 | 0.23.0 | | | **Make stability-reviewer check that a test which runs git, or a script that runs git on another repository, isolates it from the caller's git environment.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.7 |
| 534 | 0.23.0 | | | **Have the stability and product-owner reviewers follow three paths an outside reviewer found unchecked: the loser of a create race, a stored null reaching a typed parameter, and each documented outcome against the order of the code's branches.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.7 |
| 535 | 0.23.0 | | | **Have stability-reviewer check four things an outside reviewer and two failed gate runs found unchecked: that a timeout bounds the I/O it wraps, that no early error hides an outcome's class, that a test takes its timestamps where the events happen, and that it waits for every state it depends on before it disrupts the system.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.7 |
@@ -374,7 +373,7 @@ A release's capacity is a sum of its items' cost, as the formula counts it. Each
A test audit across lilleman's projects on 2026-10-16 found 10 of 33 sampled tests in this repo pinning wording that is not the contract. Examples of these and other weak tests: many tests under `bin/loop_claude/`, `bin/chunk_driver/` and `bin/agent_cycle/` pin whole sentences of the question, archive, prompt or help text, up to about 750 characters. `test_every_exit_1_stop_has_its_clause_in_help` and `test_every_failed_judge_run_has_its_clause_in_help` parse the source with `ast` and list each `Stop(...)` and `Failure(...)` call by function name. `bin/model_routing/test_ladder.py` asserts `len(LADDER) == 6`. Rewrite each to the technical principles' test bullet: assert the facts the text must carry, such as an item ID, a rung or a model argument, and delete a test no real bug could fail. Before and after rewriting a test, run the mutation tool on the code it covers: every mutant the old test killed, the new one kills.
### 392. Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, forge and host), so a newcomer finds a tool's neighbours in one place.
### 392. Group bin/'s packages by concern into seven folders (plan, records, integrations, loop, review, ship and host), so a newcomer finds a tool's neighbours in one place.
The 0.11.0 release review's architecture pass, round 1, finding 9: `bin/` holds 43 packages, about 20 launchers and 10 root files at one level, and the README's two lists are its only index. lilleman chose, during that review, to file this regrouping for a later release instead of doing it in 0.11.0, since it moves every package and no defect lies behind it.
@@ -385,7 +384,7 @@ Group `bin/` by concern, one package level per group, with the launchers left at
- `integrations/`: `atlassian`, `adf_codec`, `rest_client` and `notifier`.
- `loop/`: `loop_claude`, `loop_effects`, `loop_state`, `model_routing`, `transcript_archive` and `routing_figures`.
- `review/`: `larv_review`, `branch_chunks`, `review_rules`, `judge_replay`, `review_replay`, `rung_replay`, `score_outcomes`, `metric_bench`, `reading_cost`, `command_patterns` and `mutate_changes`.
- `forge/`: `chunk_pr`, `chunk_preflight` and `deploy_release`, where item 287's shared forge module lands.
- `ship/`: `chunk_pr`, `chunk_preflight` and `deploy_release`. The shared forge module `bin/forge/` stays at the root of `bin/`, since packages outside `ship/` import it.
- `host/`: `git_cli`, `command_lines`, `claude_code`, `machine_load`, `run_heavy`, `run_tests`, `text_files`, `wait_for`, `rule_hook` and `subagent_rung`.
`repo_checks` stays at the root, since it tests the repo, not a tool. The README's `bin/` list then becomes seven short groups. That list is a place the comprehension seats found hard (`README.md` → the `bin/` package list): make it easier to read.
@@ -413,9 +412,9 @@ Each case is a question the project settled and the answer it chose. A fresh-con
The tests also cover `workflow-bench/bench.py`'s `permission_flags`, with a probe of a headless claude given its flags. It is denied a read outside the granted trees, a bare `git status`, and wrapper calls with `--output`, `--no-index`, a glued `-aF/abs`, `--fil=/abs` or a path outside the clone. A `cd <elsewhere> && python3 <wrapper> …` acts on the clone only. It is allowed the wrapper's `log`, `diff`, `show`, `status`, `ls-files`, `add` and `commit -m`. `workflow-bench/test_review_git.py` tests the wrapper's refusals directly.
### 102. Give loop-claude's retry delay, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep` and `machine_load.memory.MEMINFO` through `sitecustomize`.
### 102. Give loop-claude's retry delay, its wall clock, and the file it reads the machine's memory from, environment overrides, so the black-box test stops replacing `time.sleep`, `time.time` and `machine_load.memory.MEMINFO` through `sitecustomize`.
Found by the principles audit of PR #242. The `SITECUSTOMIZE` block in `bin/loop_claude/test_black_box.py` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans, and the audit of PR #376 found the same block swapping `machine_load.memory.MEMINFO`, the constant in `bin/machine_load/memory.py`. An override of each lets the test run the code as production runs it.
Found by the principles audit of PR #242. The `SITECUSTOMIZE` block in `bin/loop_claude/test_black_box.py` swaps the global `time.sleep`, the shape "Functional core, imperative shell" bans, and the audit of PR #376 found the same block swapping `machine_load.memory.MEMINFO`, the constant in `bin/machine_load/memory.py`. An override of each lets the test run the code as production runs it. Release 0.17.0 added a third swap to the block: `LOOP_TEST_NOW` replaces `time.time`, so the test of a usage limit's wait doesn't depend on the wall clock. The override of the wall clock replaces that swap too.
### 135. Fingerprint only the modules loop-claude imports, so editing another tool's code no longer reloads a running loop.
@@ -609,10 +608,6 @@ The form is the word after another word inside a clause: `<word> nothing`, `<wor
Found by review of PR #317. `bin/plan/goals_file.py`'s `numbered` writes `typing.cast(Mark, mark or None)`, which asserts the type `goal_weights` branches on without checking it: a mark added to the regex reaches `goal_weights` as a value `Mark` lacks. mypy does not read the regex, so no lookup lets it catch that. Replace the cast with a lookup typed `dict[str, Mark]`, from each mark the regex captures, and `""` for none, to its `Mark` value. A mark added to the regex but not the lookup then raises `KeyError` at run time, and a value added to the lookup but not `Mark` fails mypy.
### 194. Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.
Found by review of PR #317. The black-box test, `bin/loop_claude/test_black_box.py:609`, not the unit test of the same name in `bin/agent_cycle/test_retry.py`, which runs on a fake clock, sets `resets_at` from the test's `time.time()` and expects the wait, rounded to tens, to be 3720. When more than about 5 s pass between that read and the loop's, the wait rounds to 3710 and the test fails with no bug. Item 102 covers only replacing the `time.sleep` swap; this item changes the expected value, for example by asserting the wait against `resets_at + 120` minus the time the loop read, or a bound on it.
### 519. Make stability-reviewer check that a test which runs git, or a script that runs git on another repository, isolates it from the caller's git environment.
An outside reviewer caught what our review missed, twice in one day: