From 7b1ee20c7c3b3d5be23bd2f9af338ab55f3e4ae6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 16:48:46 +0200 Subject: [PATCH] Pin a reason per incomplete verdict, the rerun hint off a terminal, and which claude could not start --- bin/test_loop_claude.py | 15 +++++++-------- bin/test_loop_claude_black_box.py | 11 ++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index a42fc5b1..432645f9 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -271,7 +271,7 @@ class Interrupt(unittest.TestCase): transcript = os.path.join(root, "session.jsonl") pathlib.Path(transcript).write_text("{}\n") with unittest.mock.patch("sys.stdin.isatty", return_value=False): - self.assertEqual(interrupt.interrupt(root, SESSION_ID, "m", transcript, "q?", paths_from(pathlib.Path(root), {})), Stop(2, "the human is needed to answer the question above, but stdin or stdout is not a terminal")) + self.assertEqual(interrupt.interrupt(root, SESSION_ID, "m", transcript, "q?", paths_from(pathlib.Path(root), {})), Stop(2, "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal")) with ( unittest.mock.patch("sys.stdin.isatty", return_value=True), unittest.mock.patch("sys.stdout.isatty", return_value=True), @@ -348,12 +348,11 @@ class Grounded(unittest.TestCase): class Verdict(unittest.TestCase): def test_needs_every_field_the_schema_requires(self): - self.assertTrue(judge.complete({"interrupt": False, "evidence": "", "finished": True, "question": ""})) - self.assertFalse(judge.complete({"interrupt": "no", "evidence": "", "finished": True, "question": ""})) - self.assertFalse(judge.complete({"interrupt": False, "evidence": None, "finished": True, "question": ""})) - self.assertFalse(judge.complete({"interrupt": False})) - self.assertFalse(judge.complete({"interrupt": True, "evidence": "x", "finished": False, "question": " "})) - self.assertFalse(judge.complete(None)) + self.assertIsNone(judge.incomplete({"interrupt": False, "evidence": "", "finished": True, "question": ""})) + self.assertEqual(judge.incomplete({"interrupt": "no", "evidence": "", "finished": True, "question": ""}), "the judge's verdict has no interrupt of type boolean") + self.assertEqual(judge.incomplete({"interrupt": False, "evidence": None, "finished": True, "question": ""}), "the judge's verdict has no evidence of type string") + self.assertEqual(judge.incomplete({"interrupt": True, "evidence": "x", "finished": False, "question": " "}), "the judge interrupted without a question") + self.assertEqual(judge.incomplete(None), "the judge returned no verdict") STUB_CLAUDE = """#!/usr/bin/env python3 @@ -411,7 +410,7 @@ class RunCycle(unittest.TestCase): self.assertEqual(cycle.run_cycle(home, "task", "premises", OPUS, paths), Continue()) pathlib.Path(verdicts).write_text("interrupt") with unittest.mock.patch("sys.stderr") as stderr: - self.assertEqual(cycle.run_cycle(home, "task", "premises", OPUS, paths), Stop(2, "the human is needed to answer the question above, but stdin or stdout is not a terminal")) + self.assertEqual(cycle.run_cycle(home, "task", "premises", OPUS, paths), Stop(2, "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal")) self.assertIn(f"transcript: {paths.archive}", "".join(str(call.args[0]) for call in stderr.write.call_args_list)) pathlib.Path(verdicts).write_text("interrupt fail fail fail") with unittest.mock.patch("sys.stderr"), unittest.mock.patch.object(cycle, "interrupt", return_value=None): diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index c46572a0..51f84aff 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -315,7 +315,8 @@ class Cycles(unittest.TestCase): self.assertEqual(run.roles(), ["worker", "judge", "judge", "judge"]) self.assertEqual(run.sleeps, [60, 60]) self.assertIn("retrying the judge in a minute: judge down", run.stderr) - self.assertEqual(run.stderr.strip().splitlines()[-1], "the judge failed three times running: the judge returned no verdict") + self.assertIn("retrying the judge in a minute: the judge returned no verdict", run.stderr) + self.assertEqual(run.stderr.strip().splitlines()[-1], "the judge failed three times running: the judge's verdict has no evidence of type string") def test_retries_the_judge_alone_when_its_verdict_quotes_nothing_in_the_transcript(self): checkout = Checkout(self) @@ -375,13 +376,13 @@ class Interrupt(unittest.TestCase): steps = [worker(say="Shall I use A or B?"), judge(interrupt=True, evidence="Shall I use A or B?", question="A or B?")] run = checkout.run(steps) self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"])) - self.assertEqual(run.stderr.strip().splitlines()[-2:], ["A or B?", "the human is needed to answer the question above, but stdin or stdout is not a terminal"]) + self.assertEqual(run.stderr.strip().splitlines()[-2:], ["A or B?", "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal"]) self.assertTrue(checkout.archived()) session = argument(run.calls[0], "--session-id") run = checkout.run(steps, terminal_input="", stdout_on_terminal=False) self.assertEqual((run.code, run.roles()), (2, ["worker", "judge"])) self.assertEqual(argument(run.calls[0], "--resume"), session) - self.assertEqual(run.stderr.strip().splitlines()[-1], "the human is needed to answer the question above, but stdin or stdout is not a terminal") + self.assertEqual(run.stderr.strip().splitlines()[-1], "the human is needed to answer the question above, but stdin or stdout is not a terminal; rerun loop-claude on a terminal") def test_hands_the_terminal_over_and_exits_2_when_nothing_is_typed(self): checkout = Checkout(self) @@ -412,7 +413,7 @@ class Interrupt(unittest.TestCase): run = checkout.run([worker(say="A or B?"), judge(interrupt=True, evidence="A or B?", question="A or B?", vanish=True)], terminal_input="") self.assertEqual((run.code, run.roles()), (1, ["worker", "judge"])) - self.assertEqual(run.stderr.strip().splitlines()[-1], "could not start claude: No such file or directory") + self.assertEqual(run.stderr.strip().splitlines()[-1], "could not start claude for the interrupt: No such file or directory") @unittest.skipIf(os.geteuid() == 0, "root reads an unreadable file") def test_exits_1_when_the_transcript_cannot_be_read_after_the_interrupt(self): @@ -435,7 +436,7 @@ class Models(unittest.TestCase): self.catalog(checkout) run = checkout.run([worker()]) self.assertEqual((run.code, run.calls), (2, [])) - self.assertEqual(run.stderr.strip(), f'the human is needed to pick proj\'s model, or merge {{"proj": ""}} into {checkout.models_file()}, but stdin or stdout is not a terminal') + self.assertEqual(run.stderr.strip(), f'the human is needed to pick proj\'s model, or merge {{"proj": ""}} into {checkout.models_file()}, but stdin or stdout is not a terminal; rerun loop-claude on a terminal') run = checkout.run([worker()], terminal_input="\x04") self.assertEqual((run.code, run.calls), (2, []))