diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 841805e1..6b3c8d81 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -40,7 +40,7 @@ import sys from loop_claude.claude_code.session import session_for from loop_claude.cycle.steps import Cycle, run_cycle from loop_claude.effects import Effects -from loop_claude.loop.reload import RELOAD_FLAG, LoopRun, decode_state, exec_if_edited, fingerprint +from loop_claude.loop.reload import RELOAD_FLAG, LoopRun, decode_handed, exec_if_edited, fingerprint from loop_claude.outcome import Stop from loop_claude.project.checkout import checkout_root, project_name from loop_claude.project.models import project_models @@ -86,7 +86,7 @@ def loop_run_from(argv, cwd, effects: Effects) -> LoopRun | Stop: return Stop(0 if task else 1, __doc__.strip()) root = checkout_root(cwd, effects) return root if isinstance(root, Stop) else LoopRun(0, root, task) - loop_run = decode_state(argv[1], LoopRun) if len(argv) == 2 else None + loop_run = decode_handed(argv[1], LoopRun) if len(argv) == 2 else None if not (loop_run and loop_run.root and loop_run.task): - return Stop(1, f"the reload cannot read the loop's state from {argv[1:]}; rerun loop-claude ") + return Stop(1, f"the reload cannot read the loop run from {argv[1:]}; rerun loop-claude ") return loop_run diff --git a/bin/loop_claude/loop/reload.py b/bin/loop_claude/loop/reload.py index a0599203..33ca164f 100644 --- a/bin/loop_claude/loop/reload.py +++ b/bin/loop_claude/loop/reload.py @@ -20,7 +20,7 @@ class LoopRun: task: str -def decode_state(handed, kind: type[T]) -> T | None: +def decode_handed(handed, kind: type[T]) -> T | None: try: fields = json.loads(handed) except ValueError: diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 431c0799..e58d3940 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -317,15 +317,15 @@ class LoopRuns(unittest.TestCase): def test_stops_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, "root": "/r"})], [json.dumps({"cycle_number": 3, "root": "/r", "task": ""})], [json.dumps({"cycle_number": "3", "root": "/r", "task": "do it"})], [json.dumps({"cycle_number": 3, "root": "", "task": "do it"})], [json.dumps({"cycle_number": 3, "root": "/r", "task": "do it", "turns": 1})], [json.dumps({"cycle_number": 3, "failures": 0, "root": "/r", "task": "do it"})]): with self.subTest(handed=handed): - self.assertEqual(main.loop_run_from([main.RELOAD_FLAG, *handed], CWD, FakeEffects().effects()), Stop(1, f"the reload cannot read the loop's state from {handed}; rerun loop-claude ")) + self.assertEqual(main.loop_run_from([main.RELOAD_FLAG, *handed], CWD, FakeEffects().effects()), Stop(1, f"the reload cannot read the loop run from {handed}; rerun loop-claude ")) def test_decodes_a_state_whose_annotations_are_strings(self): @dataclasses.dataclass(frozen=True) class Stringly: count: "int" name: "str" - self.assertEqual(reload.decode_state('{"count": 1, "name": "n"}', Stringly), Stringly(1, "n")) - self.assertIsNone(reload.decode_state('{"count": "1", "name": "n"}', Stringly)) + self.assertEqual(reload.decode_handed('{"count": 1, "name": "n"}', Stringly), Stringly(1, "n")) + self.assertIsNone(reload.decode_handed('{"count": "1", "name": "n"}', Stringly)) def test_stops_when_the_reload_cannot_start_python(self): with tempfile.TemporaryDirectory() as root: diff --git a/docs/decisions.md b/docs/decisions.md index 9680ad4d..dc5b2926 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -106,4 +106,4 @@ ## loop-claude: a cycle's state machine holds the paths that move it on, and a `Stop` leaves it -2026-10-02, larv-review. Applies "Always use explicit state machines". A `Stop` ends the process, so no later state could act on it; a `Stopped` state would add a case every step must pass through and nothing would read. Valid while every failure of a cycle ends the loop. +2026-10-01, larv-review. Applies "Always use explicit state machines". A `Stop` ends the process, so no later state could act on it; a `Stopped` state would add a case every step must pass through and nothing would read. Valid while every failure of a cycle ends the loop.