Name each file of the setup as the setup's, and a config's as setup:<path>
CI / tests (pull_request) Successful in 4m42s
CI / tests (pull_request) Successful in 4m42s
This commit is contained in:
@@ -13,11 +13,12 @@ from git_cli.git_repo import Git, top
|
||||
from git_cli import git_repo
|
||||
from task_bench.bench_folder import held
|
||||
from review_rules.review_folder import made_review_folder
|
||||
from loop_state.paths import paths_from, with_release_tools
|
||||
from loop_state.paths import paths_from
|
||||
from transcript_archive.project_key import project_key
|
||||
from model_routing.ladder_file import project_ladder
|
||||
from chunk_driver.project.model_choice import read_models_file
|
||||
from model_routing.ladder import Rung
|
||||
from loop_effects.effects import system_effects
|
||||
|
||||
DIGEST = "digest.md"
|
||||
PROMPT = pathlib.Path(__file__).with_name("gather-prompt.md")
|
||||
@@ -58,7 +59,17 @@ def gather(env: typing.Mapping[str, str], home: pathlib.Path, claude: Claude) ->
|
||||
|
||||
|
||||
def run_claude(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(os.environ), input=prompt, text=True)
|
||||
"""Runs the gathering claude as the loop runs each of its own: in the loop's Claude home, built or refreshed first, with the release's tools first on its `PATH`."""
|
||||
effects = system_effects(pathlib.Path.home(), os.environ)
|
||||
return once_ready(effects.claude_home, effects.claude)(args, cwd, prompt)
|
||||
|
||||
|
||||
def once_ready(unready: typing.Callable[[], str | None], claude: Claude) -> Claude:
|
||||
"""claude, started only where unready gives no reason why it cannot run yet; else a failed run that says the reason."""
|
||||
def run(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedProcess[str]:
|
||||
reason = unready()
|
||||
return subprocess.CompletedProcess(args, 1, "", reason) if reason else claude(args, cwd, prompt)
|
||||
return run
|
||||
|
||||
|
||||
def project_rung(home: pathlib.Path, env: typing.Mapping[str, str], git: Git) -> Rung | Failure:
|
||||
|
||||
@@ -14,7 +14,7 @@ BIN = pathlib.Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(BIN))
|
||||
|
||||
from failure import Failure
|
||||
from task_bench.figures.gather import gather, PROMPT
|
||||
from task_bench.figures.gather import gather, once_ready, PROMPT
|
||||
from test_env import isolated_env
|
||||
from task_bench import main
|
||||
|
||||
@@ -69,6 +69,12 @@ class GatherTest(unittest.TestCase):
|
||||
self.assertEqual((self.calls[0][0][2], self.calls[0][1], self.calls[0][2].endswith("\n\nworktree's\n")), ("claude-opus-5-5", str(worktree), True))
|
||||
self.assertEqual((bench.exists(), self.bench.exists()), (False, True))
|
||||
|
||||
def test_the_claude_starts_only_once_the_loops_claude_home_is_ready_and_a_home_that_is_not_keeps_the_folder(self):
|
||||
found = gather(self.env, self.home, once_ready(lambda: "nobody is signed in to the loop's Claude home", self.claude))
|
||||
self.assertEqual((found.reason if isinstance(found, Failure) else found, self.calls), (f"nobody is signed in to the loop's Claude home\nThe digest stays in {self.bench} until the next bench: run `task-bench gather` again.", []))
|
||||
self.assertNotIsInstance(gather(self.env, self.home, once_ready(lambda: None, self.claude)), Failure)
|
||||
self.assertEqual(len(self.calls), 1)
|
||||
|
||||
def test_refuses_without_a_digest_and_starts_no_claude(self):
|
||||
(self.bench / "digest.md").unlink()
|
||||
found = gather(self.env, self.home, self.claude)
|
||||
@@ -143,15 +149,23 @@ class GatherTest(unittest.TestCase):
|
||||
|
||||
|
||||
class RunClaude(unittest.TestCase):
|
||||
def test_runs_claude_in_the_folder_with_the_prompt_and_the_releases_tools_first_on_its_path(self):
|
||||
def test_runs_claude_in_the_loops_claude_home_once_it_is_built_with_the_prompt_and_the_releases_tools_first_on_its_path(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
claude = pathlib.Path(folder, "claude")
|
||||
claude.write_text('#!/bin/sh\necho "$PWD $* $(cat) $PATH"\n')
|
||||
claude.write_text("""#!/bin/sh
|
||||
case "$*" in
|
||||
"auth status") echo '{"loggedIn": true}' ;;
|
||||
plugin*) ;;
|
||||
*) echo "$PWD $* $(cat) $PATH $CLAUDE_CONFIG_DIR" ;;
|
||||
esac
|
||||
""")
|
||||
claude.chmod(0o755)
|
||||
# A process of its own, so the test changes no PATH but that process's.
|
||||
# A process of its own, so the test changes no PATH and no home but that process's.
|
||||
call = f"import sys; sys.path.insert(0, {str(BIN)!r}); from task_bench.figures.gather import run_claude; print(run_claude(['-p'], {folder!r}, 'asked').stdout, end='')"
|
||||
done = subprocess.run([sys.executable, "-c", call], capture_output=True, env={"PATH": f"{folder}:/usr/bin:/bin"}, text=True)
|
||||
self.assertEqual(done.stdout, f"{os.path.realpath(folder)} -p asked {BIN}:{folder}:/usr/bin:/bin\n", done.stderr)
|
||||
done = subprocess.run([sys.executable, "-c", call], capture_output=True, env={"HOME": folder, "PATH": f"{folder}:/usr/bin:/bin"}, text=True)
|
||||
home = pathlib.Path(folder, ".local/share/build-release/claude-home")
|
||||
self.assertEqual(done.stdout, f"{os.path.realpath(folder)} -p asked {BIN}:{folder}:/usr/bin:/bin {home}\n", done.stderr)
|
||||
self.assertTrue((home / "CLAUDE.md").is_symlink())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -162,7 +162,7 @@ table's header and its three All rows. The entry's heading gives the current UTC
|
||||
features the heading reads `task-bench features of <branch>: ...` instead, for one of data sources `task-bench data-sources
|
||||
of <branch>: ...`, and for one of shipped features `task-bench shipped-features of <branch>: ...`. No tool reads the entry as a ruling or a scoring run. The bench's last line says where the entry went. A bench that fails or stops doesn't record anything.
|
||||
|
||||
`task-bench gather`, run in the same checkout, turns the digest into plan items. It starts a claude on the project's rung, the
|
||||
`task-bench gather`, run in the same checkout, turns the digest into plan items. It starts a claude in the loop's Claude home, on the project's rung, the
|
||||
cheapest rung of the model build-release runs the project on, with the digest and the prompt in bin/task_bench/figures/gather-prompt.md.
|
||||
That claude files an item with `todo-item add` for each place the runs show to be hard, and leaves the plan's file uncommitted.
|
||||
gather prints that claude's answer and removes the bench's folder. Where claude fails, the folder stays, for another try.
|
||||
@@ -185,7 +185,7 @@ With --record-figures it also exits 1, saying why: before it plants a bug, where
|
||||
cannot be read; and after the bench, where the history already holds that branch's bench of those two commits or cannot be
|
||||
written. The folder then still holds the bench's results.
|
||||
gather exits 1, saying why, outside a checkout, without a digest, where build-release has saved no model for the project or the
|
||||
model is not on its routing ladder, and where its claude fails or hits a usage limit.
|
||||
model is not on its routing ladder, and where the loop's Claude home is not ready or its claude fails or hits a usage limit.
|
||||
"""
|
||||
import dataclasses
|
||||
import functools
|
||||
|
||||
Reference in New Issue
Block a user