Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s

This commit is contained in:
2026-12-03 18:56:28 +01:00
parent 20c83f861f
commit 1ca2c8efe0
142 changed files with 1095 additions and 933 deletions
+5 -5
View File
@@ -30,10 +30,10 @@ def gather(env: typing.Mapping[str, str], home: pathlib.Path, claude: Claude) ->
checkout = top(git)
if isinstance(checkout, Failure):
return checkout
rung = project_rung(home, git)
rung = project_rung(home, env, git)
if isinstance(rung, Failure):
return rung
review = made_review_folder(checkout, home)
review = made_review_folder(checkout, home, env)
if isinstance(review, Failure):
return review
with held(review) as folder:
@@ -61,20 +61,20 @@ def run_claude(args: list[str], cwd: str, prompt: str) -> subprocess.CompletedPr
return subprocess.run(["claude", *args], capture_output=True, cwd=cwd, env=with_release_tools(os.environ), input=prompt, text=True)
def project_rung(home: pathlib.Path, git: Git) -> Rung | Failure:
def project_rung(home: pathlib.Path, env: typing.Mapping[str, str], git: Git) -> Rung | Failure:
"""The cheapest rung for the model build-release runs the project on. The routing ladder is that of the project the process runs in."""
common = git("rev-parse", "--path-format=absolute", "--git-common-dir")
if isinstance(common, Failure):
return common
# A worktree's project is its main checkout's, which holds the folder every worktree shares.
key = project_key(os.path.dirname(common.strip()), home)
saved = paths_from(home).models_file
saved = paths_from(home, env).models_file
models = read_models_file(saved)
if isinstance(models, Failure):
return models
if key not in models:
return Failure(f"{saved} names no model for {key}: run build-release in the project once, which asks for it.")
ladder = project_ladder(None, home)
ladder = project_ladder(None, home, env)
if isinstance(ladder, Failure):
return ladder
project = ladder.project_rung(models[key])
+5 -5
View File
@@ -23,23 +23,23 @@ COMMIT_LENGTH = 8
TASKS_NAMED = {f"| {kind.noun.capitalize()} |": f" {tasks}" for tasks, kind in KINDS.items() if kind is not BUG}
def recorded_bench(run: typing.Callable[[], list[str] | Failure], folder: pathlib.Path, git: Git, home: pathlib.Path, now: typing.Callable[[], float]) -> list[str] | Failure:
def recorded_bench(run: typing.Callable[[], list[str] | Failure], folder: pathlib.Path, git: Git, home: pathlib.Path, env: typing.Mapping[str, str], now: typing.Callable[[], float]) -> list[str] | Failure:
"""The report of the bench that run runs in folder, plus the line that says where its figures went. It refuses before the bench where the history cannot be read, since a bench takes hours. A bench that fails or stops records nothing."""
branch = git("rev-parse", "--abbrev-ref", "HEAD")
if isinstance(branch, Failure):
return branch
if isinstance(unreadable := held_history(home), Failure):
if isinstance(unreadable := held_history(home, env), Failure):
return unreadable
report = run()
if isinstance(report, Failure):
return report
recorded = record_figures(folder, branch.strip(), home, now())
recorded = record_figures(folder, branch.strip(), home, env, now())
if isinstance(recorded, Failure):
return Failure(f"the bench finished and {folder} holds its results, but its figures are not recorded: {recorded.reason}")
return [*report, recorded]
def record_figures(folder: pathlib.Path, branch: str, home: pathlib.Path, now: float) -> str | Failure:
def record_figures(folder: pathlib.Path, branch: str, home: pathlib.Path, env: typing.Mapping[str, str], now: float) -> str | Failure:
"""Appends the entry of the bench whose digest folder holds, stamped with now, and returns the line the tool prints."""
try:
digest = (folder / DIGEST).read_text(encoding="utf-8")
@@ -48,7 +48,7 @@ def record_figures(folder: pathlib.Path, branch: str, home: pathlib.Path, now: f
entry = bench_entry(digest, branch, now)
if entry is None:
return Failure(f"{folder / DIGEST} is no task-bench digest: it lacks the line that names its base and head, or the table's three All rows")
read = held_history(home)
read = held_history(home, env)
return read if isinstance(read, Failure) else bench_appended(*read, *entry)
+5 -5
View File
@@ -29,10 +29,10 @@ class GatherTest(unittest.TestCase):
self.env = {**isolated_env(), "HOME": str(self.home)}
self.git("init", "--quiet", "--initial-branch", "main")
self.git("commit", "--quiet", "--allow-empty", "--message", "Base")
self.models = self.home / ".claude/loop-claude-models.json"
self.models.parent.mkdir()
self.models = self.home / ".config/build-release/models.json"
self.models.parent.mkdir(parents=True)
self.models.write_text(json.dumps({"calc": "claude-opus-5-5"}))
self.bench = self.home / ".local/state/larv-review/code/calc/task-bench"
self.bench = self.home / ".local/state/build-release/larv-review/code/calc/task-bench"
(self.bench / "runs").mkdir(parents=True)
(self.bench / "digest.md").write_text("# task-bench digest\n\n## Bug 1: calc.go:4:11 ARITHMETIC_BASE\n")
self.calls: list[tuple[list[str], str, str]] = []
@@ -61,7 +61,7 @@ class GatherTest(unittest.TestCase):
def test_a_worktrees_project_is_its_main_checkouts(self):
worktree = self.home / "code/calc-item-7"
self.git("worktree", "add", "--quiet", str(worktree), "-b", "item-7")
bench = self.home / ".local/state/larv-review/code/calc-item-7/task-bench"
bench = self.home / ".local/state/build-release/larv-review/code/calc-item-7/task-bench"
bench.mkdir(parents=True)
(bench / "digest.md").write_text("worktree's\n")
with contextlib.chdir(worktree):
@@ -77,7 +77,7 @@ class GatherTest(unittest.TestCase):
def test_a_gather_before_any_review_makes_the_review_folders_private(self):
shutil.rmtree(self.home / ".local")
self.assertIsInstance(gather(self.env, self.home, self.claude), Failure)
self.assertEqual((self.home / ".local/state/larv-review").stat().st_mode & 0o777, 0o700)
self.assertEqual((self.home / ".local/state/build-release/larv-review").stat().st_mode & 0o777, 0o700)
def test_a_claude_that_fails_or_hits_a_limit_keeps_the_folder_for_another_try(self):
self.code = 1
@@ -45,10 +45,10 @@ class RecordFiguresTest(unittest.TestCase):
self.repo.mkdir(parents=True)
# The project's config is found from the checkout's top, which git names.
subprocess.run(["git", "init", "--quiet"], cwd=self.repo, env={**isolated_env(), "HOME": str(self.home)}, check=True)
config = self.home / ".claude-projects/calc/config.toml"
config = self.home / ".config/build-release/calc/config.toml"
config.parent.mkdir(parents=True)
config.write_text(PROJECT_CONFIG)
self.bench = self.home / ".local/state/larv-review/code/calc/task-bench"
self.bench = self.home / ".local/state/build-release/larv-review/code/calc/task-bench"
self.bench.mkdir(parents=True)
self.history = self.repo / "docs/comprehension-history.md"
self.ran = 0
@@ -67,7 +67,7 @@ class RecordFiguresTest(unittest.TestCase):
return report
def recorded(self, run=None) -> list[str] | str:
found = recorded_bench(run or self.left, self.bench, self.git, self.home, lambda: NOW)
found = recorded_bench(run or self.left, self.bench, self.git, self.home, {}, lambda: NOW)
return found.reason if isinstance(found, Failure) else found
def unrecorded(self, why: str) -> str:
@@ -95,7 +95,7 @@ class RecordFiguresTest(unittest.TestCase):
self.git = lambda *args: Failure("git failed")
self.assertEqual(self.recorded(), "git failed")
del self.git
(self.home / ".claude-projects/calc/config.toml").unlink()
(self.home / ".config/build-release/calc/config.toml").unlink()
self.assertTrue(self.recorded().startswith(f"no config names the checkout {self.repo}"), self.recorded())
self.assertEqual(self.ran, 0)
@@ -125,7 +125,7 @@ class RecordFiguresTest(unittest.TestCase):
def test_says_why_where_the_history_cannot_be_read_once_the_bench_has_run(self):
def run():
(self.home / ".claude-projects/calc/config.toml").unlink()
(self.home / ".config/build-release/calc/config.toml").unlink()
return self.left()
self.assertTrue(self.recorded(run).startswith(self.unrecorded(f"no config names the checkout {self.repo}")))