Answer principles round 1: 0 🔴, 1 🟡 (0 misread); chunk-pr's step takes its sleep and the tests fail on a wait; Rust test files read once per bench, the indent count bounded, and six nits
CI / tests (pull_request) Successful in 4m38s
CI / tests (pull_request) Successful in 4m38s
This commit is contained in:
@@ -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`. It imports `mutate_changes`' rule for which files are tests (`changed_lines.is_test`), its list of mutation tools and its process runner.
|
||||
|
||||
#### The shell, the machine and text
|
||||
|
||||
|
||||
@@ -158,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
|
||||
@@ -166,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("-"):
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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 200
|
||||
# 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,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,11 @@ class SpaceIndentation(unittest.TestCase):
|
||||
with self.subTest(name):
|
||||
self.assertIsInstance(space_indented(self.checkout(**{"app.py": SPACED, name: text})), SpaceIndented)
|
||||
|
||||
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)}, **{".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})))
|
||||
|
||||
|
||||
+6
-3
@@ -18,7 +18,8 @@ PAGE_SIZE = 50
|
||||
# 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.
|
||||
# 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; it is read from gh 2.102.0's `pr checks`, whose source words it "no checks reported on the '<branch>' branch".
|
||||
NO_CHECKS = "no checks reported"
|
||||
|
||||
|
||||
@@ -32,11 +33,12 @@ 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 | Failure:
|
||||
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):
|
||||
@@ -101,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: an awaited pull request past the first page of open ones, drafts and forks counted, is not seen.
|
||||
pulls = gitea(run, f"repos/{{owner}}/{{repo}}/pulls?state=open&limit={PAGE_SIZE}")
|
||||
if isinstance(pulls, Failure):
|
||||
return pulls
|
||||
try:
|
||||
|
||||
@@ -99,9 +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 0.17.0 release review's architect asked to drop this warning as a second copy of that fact. It stays: the plan item that added both
|
||||
# asked for a warning a person sees when running `rank_todo.py --check` by hand, and which lists count as missing has one home,
|
||||
# `plan.touches.unpredicted`.
|
||||
# A person who runs `rank_todo.py --check` by hand sees this warning. Which lists count as missing has one home, `plan.touches.unpredicted`.
|
||||
plan = self.read()
|
||||
if isinstance(plan, Failure):
|
||||
return []
|
||||
|
||||
@@ -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 mutate_changes.changed_lines import is_test
|
||||
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+`")
|
||||
|
||||
+14
-4
@@ -524,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 []
|
||||
@@ -581,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] | None = None) -> 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 is what `rust_tests_of` finds for bench, read from the trees where the caller hands none."""
|
||||
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
|
||||
@@ -595,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 or functools.partial(rust_tests_of, bench))()
|
||||
if isinstance(standing, Failure):
|
||||
return standing
|
||||
if any(tests is None or mutant.path in tests for tests in standing):
|
||||
|
||||
@@ -640,7 +640,7 @@ class RunOutcomesTest(unittest.TestCase):
|
||||
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(main.planted(bench, 1, self.ADDING), "could not read the Rust files: ")
|
||||
|
||||
|
||||
class ContainersTest(unittest.TestCase):
|
||||
|
||||
@@ -5,8 +5,8 @@ import pathlib
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
from mutate_changes.changed_lines import is_test
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user