diff --git a/bin/loop-claude b/bin/loop-claude index abdcd06f..bbc72cf6 100755 --- a/bin/loop-claude +++ b/bin/loop-claude @@ -10,9 +10,10 @@ interrupt: `claude --resume` on the terminal, every worktree first marked truste An unfinished chunk resumes the same session next cycle; a finished one starts a fresh session. Cycles continue until that interrupt or Ctrl-C. Words: ~/.claude/CLAUDE.md → "Vocabulary". -Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, a reload handing -over no task, or the worker or the judge fails three times running. A worker fails when claude exits non-zero, is killed, or ends -without a result event; a judge when its verdict misses a field or quotes nothing in the transcript. +Exit 1: no task, not inside a checkout, no premises, claude leaves no transcript, a reload whose +state it cannot read, or the worker or the judge fails three times running. A worker fails when +claude exits non-zero, is killed, or ends without a result event; a judge when its verdict misses a +field or quotes nothing in the transcript. Exit 2: the human is needed and stdin or stdout is not a terminal, or the interrupt ended without them typing anything. Rerunning resumes any open session. @@ -390,10 +391,10 @@ def main(): state = reloaded_state(argv[1:]) else: state = {"cycle_number": 0, "failures": 0, "root": "", "task": " ".join(argv)} + if state["task"] in ("", "-h", "--help"): + print(__doc__.strip()) + sys.exit(0 if state["task"] else 1) task = state["task"] - if task in ("", "-h", "--help"): - print(__doc__.strip()) - sys.exit(0 if task else 1) root = state["root"] or checkout_root() cycle_number, failures = state["cycle_number"], state["failures"] while True: diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 4473e6f0..84d78aa1 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -348,13 +348,10 @@ class Reload(unittest.TestCase): environment = dict(os.environ) with unittest.mock.patch.object(loop, "__file__", script), unittest.mock.patch("os.execv") as execv: loop.reload_if_edited("/r", "do it", cycle_number=1, failures=2) - execv.assert_called_once_with(sys.executable, [sys.executable, script, loop.RELOAD_FLAG, STATE]) + execv.assert_called_once_with(sys.executable, [sys.executable, script, loop.RELOAD_FLAG, json.dumps({"cycle_number": 1, "failures": 2, "root": "/r", "task": "do it"})]) self.assertEqual(dict(os.environ), environment) -STATE = json.dumps({"cycle_number": 1, "failures": 2, "root": "/r", "task": "do it"}) - - class Main(unittest.TestCase): def test_exits_naming_the_reload_when_it_hands_over_anything_but_the_state_with_a_task(self): for handed in (["3", "2", "/r", "do it"], ["3"], ["[1]"], [json.dumps({"cycle_number": 3, "failures": 0, "root": "/r"})], [json.dumps({"cycle_number": 3, "failures": 0, "root": "/r", "task": ""})]): diff --git a/todo.md b/todo.md index 8c17f21e..e38eb146 100644 --- a/todo.md +++ b/todo.md @@ -2,7 +2,7 @@ ## 0.1.0 -Bar the reload item, ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. +Ordered by how many seats of the 2026-09-25 scoring panel (`docs/decisions.md`) named the place; each is one chunk. - Name `end_session` for what it does, today it deletes the session's transcript files. - Define looping reviewer and round cap under `CLAUDE.md` → "Vocabulary", today inline at `agents/review-protocol.md`.