Answer the fourth round: a repeated question goes to the human, three records answers a cycle as the backstop, the quote in the interrupt, the cycle redefined
This commit is contained in:
+16
-13
@@ -127,26 +127,28 @@ class Streamed:
|
||||
|
||||
class Transitions(unittest.TestCase):
|
||||
def test_each_state_moves_on_its_events_and_only_on_them(self):
|
||||
answered = states.Ruled(AnsweredFromRecords("e", "Which one?", "A."))
|
||||
legal = (
|
||||
(states.Working(), states.WorkerRan("/t"), states.Judging("/t")),
|
||||
(states.Working("A."), states.WorkerRan("/t"), states.Judging("/t", True)),
|
||||
(states.Working("A.", 3), states.WorkerRan("/t"), states.Judging("/t", 3)),
|
||||
(states.Judging("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?")),
|
||||
(states.Judging("/t", True), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?", True)),
|
||||
(states.Judging("/t"), states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")), states.Working("A.")),
|
||||
(states.Judging("/t", True), states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")), states.Interrupting("/t", "Which one?", True)),
|
||||
(states.Judging("/t", True), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
|
||||
(states.Judging("/t", True), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))),
|
||||
(states.Judging("/t", 3), states.Ruled(Interrupt("e", "Which one?")), states.Interrupting("/t", "Which one?", 3)),
|
||||
(states.Judging("/t"), answered, states.Working("A.", 1)),
|
||||
(states.Judging("/t", 2), answered, states.Working("A.", 3)),
|
||||
(states.Judging("/t", 3), answered, states.Interrupting("/t", "Which one?\n\nREADME.md or the project's records say:\nA.", 3)),
|
||||
(states.Judging("/t"), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
|
||||
(states.Judging("/t", 3), states.Ruled(Finished("e")), states.Closing("/t", Finished("e"))),
|
||||
(states.Judging("/t"), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))),
|
||||
(states.Judging("/t", 3), states.Ruled(Unfinished("e")), states.Closing("/t", Unfinished("e"))),
|
||||
(states.Interrupting("/t", "q"), states.HumanAnswered(), states.Judging("/t")),
|
||||
(states.Interrupting("/t", "q", True), states.HumanAnswered(), states.Judging("/t", True)),
|
||||
(states.Interrupting("/t", "q", 3), states.HumanAnswered(), states.Judging("/t", 3)),
|
||||
(states.Closing("/t", Finished("e")), states.Archived(), states.Ended()),
|
||||
)
|
||||
for state, event, after in legal:
|
||||
with self.subTest(state=state, event=event):
|
||||
self.assertEqual(states.transition(state, event), after)
|
||||
every_state = (states.Working(), states.Working("A."), states.Judging("/t"), states.Judging("/t", True), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", True), states.Closing("/t", Finished("e")), states.Ended())
|
||||
every_event = (states.WorkerRan("/t"), states.Ruled(Interrupt("e", "Which one?")), states.Ruled(AnsweredFromRecords("e", "Which one?", "A.")), states.Ruled(Finished("e")), states.Ruled(Unfinished("e")), states.HumanAnswered(), states.Archived())
|
||||
every_state = (states.Working(), states.Working("A.", 3), states.Judging("/t"), states.Judging("/t", 3), states.Interrupting("/t", "q"), states.Interrupting("/t", "q", 3), states.Closing("/t", Finished("e")), states.Ended())
|
||||
every_event = (states.WorkerRan("/t"), states.Ruled(Interrupt("e", "Which one?")), answered, states.Ruled(Finished("e")), states.Ruled(Unfinished("e")), states.HumanAnswered(), states.Archived())
|
||||
for state in every_state:
|
||||
for event in every_event:
|
||||
if (state, event) not in [(state, event) for state, event, _ in legal]:
|
||||
@@ -242,14 +244,15 @@ class Cycles(unittest.TestCase):
|
||||
self.assertNotIn("the second", prompts[0])
|
||||
self.assertIn("[human] the second", prompts[1])
|
||||
|
||||
def test_a_question_the_records_answer_resumes_the_worker_with_the_answer_once_per_cycle(self):
|
||||
def test_a_question_the_records_answer_resumes_the_worker_with_the_answer_three_times_a_cycle(self):
|
||||
answered = judged("interrupt", answer="Use *A*.")
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)] * 2, claude=[answered, answered, judged("unfinished")], on_terminal_claude=[0], git=[ran()])
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)] * 4, claude=[answered] * 4, on_terminal_claude=[0], git=[ran()])
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake, records="From AGENTS.md:\nUse A.")), Stop(2, "the human is needed to answer the question above, but the interrupt ended with nothing typed"))
|
||||
resumed = fake.made("stream_claude")[1]
|
||||
self.assertEqual(resumed[resumed.index("-p") + 1], "README.md or the project's records answer your question:\n\nUse *A*.\n\nContinue the task.")
|
||||
self.assertEqual(len(fake.made("claude_on_terminal")), 1)
|
||||
self.assertEqual(len(fake.made("stream_claude")), 4)
|
||||
self.assertIn("Which one?\n\nREADME.md or the project's records say:\nUse *A*.", said.getvalue())
|
||||
|
||||
def test_the_judge_fails_on_an_answer_the_records_do_not_hold(self):
|
||||
invented = judged("interrupt", answer="Use B.")
|
||||
|
||||
Reference in New Issue
Block a user