From 11aad9b72c88b9d03168868708705752fd303f30 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 17:35:24 +0200 Subject: [PATCH 1/3] Carry the reload counters on argv, off the LOOP_CLAUDE_ names --help documents --- CHANGELOG.md | 1 + bin/loop-claude | 19 +++++++++---------- bin/test_loop_claude.py | 29 +++++++++++++++++++++++------ todo.md | 1 - 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf28c8b..9738a4b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - `loop-claude` says why when it cannot read `~/.claude.json` before an interrupt, and the interrupt then lands in Claude Code's trust dialog. - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. This repo runs on Fable 5.1. +- `loop-claude` reads only the `LOOP_CLAUDE_` variables `--help` names; a reload after an edit carries its counters on its own command line. - Reviewers share one protocol for verdicts, severities, rounds and declines: `agents/review-protocol.md`. - Skills and agents cite `CLAUDE.md` by heading, and a test resolves each citation; the comment and documentation bar lives there alone. - Update a main checkout with `git pull --ff-only`, never `--autostash`. diff --git a/bin/loop-claude b/bin/loop-claude index 50748e4f..6d06abc1 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -45,8 +45,7 @@ import uuid ARCHIVE = os.path.expanduser(os.environ.get("LOOP_CLAUDE_TRANSCRIPTS", "~/.claude/loop-claude-transcripts")) RELOAD_BASELINE = open(__file__, encoding="utf-8").read() -RELOAD_CYCLE = "LOOP_CLAUDE_CYCLE" -RELOAD_FAILURES = "LOOP_CLAUDE_FAILURES" +RELOAD_FLAG = "--reloaded" SESSION_NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec") JUDGE_RULES = ( @@ -346,7 +345,7 @@ def run_cycle(task, premises, name, session_id): return True -def reload_if_edited(cycle_number, failures): +def reload_if_edited(task, cycle_number, failures): try: source = open(__file__, encoding="utf-8").read() except OSError as failure: @@ -358,21 +357,21 @@ def reload_if_edited(cycle_number, failures): if trial.returncode != 0: print(f"keeping the running script: {trial.stderr.strip() or f'exit {trial.returncode}'}", file=sys.stderr) return - os.environ[RELOAD_CYCLE] = str(cycle_number) - os.environ[RELOAD_FAILURES] = str(failures) - os.execv(sys.executable, [sys.executable, __file__, *sys.argv[1:]]) + os.execv(sys.executable, [sys.executable, __file__, RELOAD_FLAG, str(cycle_number), str(failures), task]) def main(): - task = " ".join(sys.argv[1:]) + argv = sys.argv[1:] + cycle_number, failures = 0, 0 + if argv[:1] == [RELOAD_FLAG]: + cycle_number, failures, argv = int(argv[1]), int(argv[2]), argv[3:] + task = " ".join(argv) if task in ("", "-h", "--help"): print(__doc__.strip()) sys.exit(0 if task else 1) os.chdir(checkout_root()) - cycle_number = int(os.environ.pop(RELOAD_CYCLE, 0)) - failures = int(os.environ.pop(RELOAD_FAILURES, 0)) while True: - reload_if_edited(cycle_number, failures) + reload_if_edited(task, cycle_number, failures) cycle_number += 1 premises = read_premises() name = session_name() diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index ee984536..05f1a469 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -8,6 +8,7 @@ import os import pathlib import stat import subprocess +import sys import tempfile import unittest import unittest.mock @@ -309,18 +310,34 @@ class RunCycle(unittest.TestCase): class Reload(unittest.TestCase): - def test_runs_the_edited_file_before_trusting_it(self): + def test_runs_the_edited_file_before_trusting_it_and_hands_it_the_counters_on_argv(self): with tempfile.TemporaryDirectory() as root: script = os.path.join(root, "loop-claude") open(script, "w").write(loop.RELOAD_BASELINE.replace("import glob\n", "import glob\nimport no_such_module\n")) with unittest.mock.patch.object(loop, "__file__", script), unittest.mock.patch("os.execv") as execv: - loop.reload_if_edited(cycle_number=1, failures=0) + loop.reload_if_edited("do it", cycle_number=1, failures=0) execv.assert_not_called() - open(script, "w").write(loop.RELOAD_BASELINE.replace("RELOAD_CYCLE = ", "RELOAD_CYCLE = \"x\" or ")) + open(script, "w").write(loop.RELOAD_BASELINE.replace("RELOAD_FLAG = ", "RELOAD_FLAG = \"x\" or ")) + environment = dict(os.environ) with unittest.mock.patch.object(loop, "__file__", script), unittest.mock.patch("os.execv") as execv: - loop.reload_if_edited(cycle_number=1, failures=2) - execv.assert_called_once() - self.assertEqual((os.environ.pop(loop.RELOAD_CYCLE), os.environ.pop(loop.RELOAD_FAILURES)), ("1", "2")) + loop.reload_if_edited("do it", cycle_number=1, failures=2) + execv.assert_called_once_with(sys.executable, [sys.executable, script, loop.RELOAD_FLAG, "1", "2", "do it"]) + self.assertEqual(dict(os.environ), environment) + + +class Main(unittest.TestCase): + def test_resumes_the_counters_a_reload_handed_over(self): + patches = [unittest.mock.patch.object(loop, name) for name in ("checkout_root", "read_premises", "reload_if_edited", "run_cycle")] + with contextlib.ExitStack() as stack: + mocks = [stack.enter_context(patch) for patch in patches] + stack.enter_context(unittest.mock.patch.object(sys, "argv", ["loop-claude", loop.RELOAD_FLAG, "3", "2", "do it"])) + stack.enter_context(unittest.mock.patch.object(sys, "stdout", io.StringIO())) + mocks[0].return_value = os.getcwd() + mocks[3].side_effect = SystemExit(0) + with self.assertRaises(SystemExit): + loop.main() + mocks[2].assert_called_once_with("do it", 3, 2) + self.assertIn("=== cycle 4 ===", sys.stdout.getvalue()) if __name__ == "__main__": diff --git a/todo.md b/todo.md index 5b7bb780..4fad0218 100644 --- a/todo.md +++ b/todo.md @@ -4,7 +4,6 @@ Ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- Hand the counters `reload_if_edited` carries across `os.execv` outside the `LOOP_CLAUDE_` prefix `--help` documents, today `LOOP_CLAUDE_CYCLE` and `LOOP_CLAUDE_FAILURES` a user can set by mistake. - Define a human turn at `typed` in one line and name what it tests, today the definition sits in the docstring 150 lines above. - Place `larv-review`'s Re-entry section after the passes it cites, today five forward references before ยง0. - State the fits-in-your-head thresholds once in `agents/systems-architect.md`, cited by heading, today echoed at seven places and cited as "step 4" by number at nine; fold the Quality Bar into the sections it restates. -- 2.52.0 From 5eef82d7a48971be91d683e7d66575f1b0859b0c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 17:39:16 +0200 Subject: [PATCH 2/3] Keep the changelog line to the contract --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9738a4b8..e86ffd0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ - `loop-claude` says why when it cannot read `~/.claude.json` before an interrupt, and the interrupt then lands in Claude Code's trust dialog. - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. This repo runs on Fable 5.1. -- `loop-claude` reads only the `LOOP_CLAUDE_` variables `--help` names; a reload after an edit carries its counters on its own command line. +- `loop-claude` reads only the `LOOP_CLAUDE_` variables `--help` names. - Reviewers share one protocol for verdicts, severities, rounds and declines: `agents/review-protocol.md`. - Skills and agents cite `CLAUDE.md` by heading, and a test resolves each citation; the comment and documentation bar lives there alone. - Update a main checkout with `git pull --ff-only`, never `--autostash`. -- 2.52.0 From 75bc4885fd12db0a72f36e62351050629f441931 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 17:40:48 +0200 Subject: [PATCH 3/3] Drop the changelog line: the carriers it removed never shipped --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e86ffd0a..cbf28c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,6 @@ - `loop-claude` says why when it cannot read `~/.claude.json` before an interrupt, and the interrupt then lands in Claude Code's trust dialog. - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. This repo runs on Fable 5.1. -- `loop-claude` reads only the `LOOP_CLAUDE_` variables `--help` names. - Reviewers share one protocol for verdicts, severities, rounds and declines: `agents/review-protocol.md`. - Skills and agents cite `CLAUDE.md` by heading, and a test resolves each citation; the comment and documentation bar lives there alone. - Update a main checkout with `git pull --ff-only`, never `--autostash`. -- 2.52.0