From 37d31b9ab117ae0db1df575489f95e18ceabb8d9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 27 Sep 2026 22:48:36 +0200 Subject: [PATCH 1/2] Rename granted, model and project for what they hold and return --- bin/loop-claude | 26 +++++++++++++------------- bin/test_loop_claude.py | 6 +++--- todo.md | 1 - 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index 356268e3..0ca0f78e 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -201,19 +201,19 @@ def sections(text): def session_name(root): # "A " is the human's cue in the session picker that the session is the loop's. - return f"A {project(root)} loop-claude" + return f"A {project_name(root)} loop-claude" def archive(root, path, note): # Stamped by mtime, so a transcript unchanged since its last archive maps to the file already written. - folder = os.path.join(ARCHIVE, project(root)) + folder = os.path.join(ARCHIVE, project_name(root)) try: stamp = time.strftime("%Y-%m-%dT%H-%M-%SZ", time.gmtime(os.path.getmtime(path))) make_private(folder) dest = os.path.join(folder, f"{stamp}.md") if not os.path.exists(dest): with open(os.open(dest, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600), "w", encoding="utf-8") as copy: - copy.write(f"# {stamp} {project(root)}\n\n{note}\n\n{render(entries(path))}\n") + copy.write(f"# {stamp} {project_name(root)}\n\n{note}\n\n{render(entries(path))}\n") print(f"transcript: {dest}", file=sys.stderr) except OSError as failure: print(f"could not archive the transcript: {failure}", file=sys.stderr) @@ -242,11 +242,11 @@ def replace_json(path, data, **dump): return None -def model(variable, chosen): +def model_flags(variable, chosen): return ["--model", os.environ.get(variable) or chosen] -def project(root): +def project_name(root): return root.removeprefix(os.path.expanduser("~/code/")).lstrip("/") @@ -297,7 +297,7 @@ def project_model(root): if os.environ.get("LOOP_CLAUDE_JUDGE_MODEL") and os.environ.get("LOOP_CLAUDE_WORKER_MODEL"): return "" saved = os.path.expanduser("~/.claude/loop-claude-models.json") - name = project(root) + name = project_name(root) models = read_models(saved) if isinstance(models, Stop): return models @@ -456,7 +456,7 @@ def worker_args(task, name, session_id, chosen, resuming): "--output-format", "stream-json", "--permission-mode", "bypassPermissions", "--verbose", - *model("LOOP_CLAUDE_WORKER_MODEL", chosen), + *model_flags("LOOP_CLAUDE_WORKER_MODEL", chosen), ] @@ -488,7 +488,7 @@ def judge(root, task, premises, transcript, chosen): args = [ "-p", "--json-schema", json.dumps(JUDGE_SCHEMA), - *model("LOOP_CLAUDE_JUDGE_MODEL", chosen), + *model_flags("LOOP_CLAUDE_JUDGE_MODEL", chosen), "--no-session-persistence", "--output-format", "json", "--permission-mode", "bypassPermissions", @@ -538,7 +538,7 @@ def interrupt(root, session_id, chosen, path, question): return "stdin or stdout is not a terminal" trust(checkouts(root)) before = human_turns(entries(path)) - subprocess.run(["claude", *model("LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root) + subprocess.run(["claude", *model_flags("LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root) return "" if human_turns(entries(path)) > before else "the interrupt ended without the human typing anything" @@ -562,15 +562,15 @@ def trust(paths): if not isinstance(projects, dict) or not all(isinstance(record, dict) for record in projects.values()): print(f"could not read {config}: not an object whose \"projects\" maps paths to objects", file=sys.stderr) return - granted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")] - if not granted: + untrusted = [path for path in paths if not projects.get(path, {}).get("hasTrustDialogAccepted")] + if not untrusted: return - for path in granted: + for path in untrusted: projects.setdefault(path, {})["hasTrustDialogAccepted"] = True if failure := replace_json(config, data, indent=2): print(f"could not write {config}: {failure.strerror}", file=sys.stderr) return - print("trusted for the interrupt: " + ", ".join(granted), file=sys.stderr) + print("trusted for the interrupt: " + ", ".join(untrusted), file=sys.stderr) if __name__ == "__main__": diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 4d656561..b69d24f1 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -122,10 +122,10 @@ class CheckoutRoot(unittest.TestCase): class Project(unittest.TestCase): def test_names_a_checkout_relative_to_code_and_any_other_relative_to_root(self): with unittest.mock.patch.dict(os.environ, {"HOME": "/h"}): - self.assertEqual(loop.project("/h/code/a/b"), "a/b") + self.assertEqual(loop.project_name("/h/code/a/b"), "a/b") self.assertEqual(loop.session_name("/h/code/a/b"), "A a/b loop-claude") - self.assertEqual(loop.project("/h/code"), "h/code") - self.assertEqual(loop.project("/srv/x"), "srv/x") + self.assertEqual(loop.project_name("/h/code"), "h/code") + self.assertEqual(loop.project_name("/srv/x"), "srv/x") self.assertEqual(loop.session_name("/srv/x"), "A srv/x loop-claude") diff --git a/todo.md b/todo.md index c40b7d75..8b31a66e 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,6 @@ Ships when a four-seat scoring run puts every dimension and the overall at 7.0 o Shape, 7.0: -- Rename `granted` in `trust` for the paths it holds before the write, and `model` and `project` for what they return. - Move `agents/review-protocol.md` out of `agents/`, beside what binds to it. - Split `larv-review` ยง7 so a fix's re-entry reads without the whole skill open. - Keep the fits-in-a-head thresholds in one place in `agents/systems-architect.md`, today four. -- 2.52.0 From 53b6ffdff1536a9437fcc2ad10d20658597e501c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 27 Sep 2026 22:49:43 +0200 Subject: [PATCH 2/2] Name the test class ProjectName and the argv helper model_args --- bin/loop-claude | 8 ++++---- bin/test_loop_claude.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/loop-claude b/bin/loop-claude index 0ca0f78e..21021d5f 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -242,7 +242,7 @@ def replace_json(path, data, **dump): return None -def model_flags(variable, chosen): +def model_args(variable, chosen): return ["--model", os.environ.get(variable) or chosen] @@ -456,7 +456,7 @@ def worker_args(task, name, session_id, chosen, resuming): "--output-format", "stream-json", "--permission-mode", "bypassPermissions", "--verbose", - *model_flags("LOOP_CLAUDE_WORKER_MODEL", chosen), + *model_args("LOOP_CLAUDE_WORKER_MODEL", chosen), ] @@ -488,7 +488,7 @@ def judge(root, task, premises, transcript, chosen): args = [ "-p", "--json-schema", json.dumps(JUDGE_SCHEMA), - *model_flags("LOOP_CLAUDE_JUDGE_MODEL", chosen), + *model_args("LOOP_CLAUDE_JUDGE_MODEL", chosen), "--no-session-persistence", "--output-format", "json", "--permission-mode", "bypassPermissions", @@ -538,7 +538,7 @@ def interrupt(root, session_id, chosen, path, question): return "stdin or stdout is not a terminal" trust(checkouts(root)) before = human_turns(entries(path)) - subprocess.run(["claude", *model_flags("LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root) + subprocess.run(["claude", *model_args("LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root) return "" if human_turns(entries(path)) > before else "the interrupt ended without the human typing anything" diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index b69d24f1..f828e2f3 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -119,7 +119,7 @@ class CheckoutRoot(unittest.TestCase): self.assertEqual(loop.checkouts(root), [root]) -class Project(unittest.TestCase): +class ProjectName(unittest.TestCase): def test_names_a_checkout_relative_to_code_and_any_other_relative_to_root(self): with unittest.mock.patch.dict(os.environ, {"HOME": "/h"}): self.assertEqual(loop.project_name("/h/code/a/b"), "a/b") -- 2.52.0