Pin the judge's rules, the interrupt's checkout root, no name on resume, and a failed replace leaving nothing staged

This commit is contained in:
2026-09-28 19:26:35 +02:00
parent 0e587d75df
commit bbf4636fcc
2 changed files with 18 additions and 4 deletions
+7 -3
View File
@@ -197,7 +197,7 @@ class Checkout:
)
def run_on_terminal(self, command, cwd, typed, stdout_on_terminal, before_typing):
"""Types the input at once, or once stderr shows before_typing's prompt and its callback has run."""
"""Types the input at once, or once stderr shows before_typing's text and its callback has run."""
controller, terminal = pty.openpty()
with tempfile.TemporaryFile() as stderr, tempfile.TemporaryFile() as stdout:
try:
@@ -326,6 +326,7 @@ class Cycles(unittest.TestCase):
self.assertEqual(argument(workers[0], "--name"), "A proj loop-claude")
self.assertEqual(argument(workers[1], "--resume"), session)
self.assertIsNone(argument(workers[1], "--session-id"))
self.assertIsNone(argument(workers[1], "--name"))
self.assertEqual(argument(workers[2], "--session-id"), session)
self.assertTrue(argument(workers[0], "-p").startswith(f"{TASK}\n\nContinue any open draft PR"))
self.assertNotIn(TASK, argument(workers[1], "-p"))
@@ -403,6 +404,7 @@ class Cycles(unittest.TestCase):
run = checkout.run([worker(say="early " * 20000 + "LATE")])
self.assertIn("LATE", run.calls[1]["stdin"])
self.assertLess(run.calls[1]["stdin"].count("early"), 20000)
self.assertTrue(run.calls[1]["stdin"].rstrip().endswith("an open PR, a review not yet run, CI not yet reported."))
def test_skips_a_malformed_transcript_or_stream_line(self):
checkout = Checkout(self)
@@ -464,10 +466,12 @@ class Interrupt(unittest.TestCase):
checkout.claude_json().write_text(json.dumps({"other": 1, "projects": {str(checkout.root): {"kept": True}}}))
checkout.claude_json().chmod(0o644)
asked = [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([*asked, interrupt(type="B"), judge(evidence="B"), worker()], terminal_input="")
(checkout.root / "sub").mkdir()
run = checkout.run([*asked, interrupt(type="B"), judge(evidence="B"), worker()], cwd=checkout.root / "sub", terminal_input="")
self.assertEqual(run.code, 130)
self.assertEqual(run.roles(), ["worker", "judge", "interrupt", "judge", "worker", "judge"])
handed = run.calls[2]["argv"]
self.assertEqual(run.calls[2]["cwd"], str(checkout.root))
self.assertEqual(argument(run.calls[2], "--resume"), argument(run.calls[0], "--session-id"))
self.assertEqual(argument(run.calls[2], "--model"), "worker-model")
self.assertNotIn("-p", handed)
@@ -584,7 +588,7 @@ class Models(unittest.TestCase):
def saved_elsewhere():
checkout.models_file().write_text(json.dumps({"late": "model-y", "other": "model-x"}))
run = checkout.run([worker()], terminal_input="custom-model\n", before_typing=("claude --model takes: ", saved_elsewhere))
run = checkout.run([worker()], terminal_input="custom-model\n", before_typing=("no model catalog cached", saved_elsewhere))
self.assertEqual(run.code, 130)
self.assertIn("no model catalog cached", run.stderr)
self.assertIn("A name claude --model takes: ", run.stderr)