Hold the escalation mark in one module, and carry a ruling's step through the cycle's states
This commit is contained in:
@@ -22,6 +22,7 @@ from loop_claude.project import checkout, model_choice, records
|
||||
from chunk_pick import DefaultPlan, LastCut
|
||||
from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python
|
||||
from claude_code import entries, reply, session
|
||||
from loop_claude import escalation, paths, routing
|
||||
from failure import Failure
|
||||
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.cycle import interrupt, judge, prompts, retry, run, states, worker
|
||||
@@ -30,11 +31,11 @@ from model_routing.ladder import LADDER, Rung
|
||||
from claude_code.reply import Limited
|
||||
from loop_claude.loop import main, reload, routing_check
|
||||
from transcript_archive import outcomes, write
|
||||
from loop_claude import paths, routing
|
||||
from transcript_archive.location import project_archive
|
||||
from model_routing.route import Record, Route, route_from
|
||||
from loop_claude.stop import Stop
|
||||
from utc_stamp import utc
|
||||
from claude_code.transcript import verbatim
|
||||
from loop_claude.cycle.judge import verdict_from
|
||||
|
||||
# How the archive records a worker that runs off the ladder.
|
||||
@@ -194,6 +195,20 @@ class Transitions(unittest.TestCase):
|
||||
states.transition(state, event)
|
||||
|
||||
|
||||
def test_a_rulings_step_up_reaches_the_worker_it_resumes_through_the_answer_the_human_types_and_no_further(self):
|
||||
step = escalation.Step(Route(Rung("claude-opus-5-5", "medium")), Route(Rung("claude-opus-5-5", "high"), escalated_at=3))
|
||||
interrupt, quoted = Interrupt("e", "q", "round 2: 🔴"), QuotedAnswer("e", "q", "A.", "round 2: 🔴")
|
||||
for state, event, after in (
|
||||
(states.Judging("/t"), states.Ruled(quoted, step), states.Working(quoted, 1, step)),
|
||||
(states.Judging("/t", 3), states.Ruled(quoted, step), states.Interrupting("/t", quoted, 3, step)),
|
||||
(states.Judging("/t"), states.Ruled(interrupt, step), states.Interrupting("/t", interrupt, 0, step)),
|
||||
(states.Interrupting("/t", interrupt, 0, step), states.HumanTyped(TYPED), states.Working(TYPED, 0, step)),
|
||||
(states.Interrupting("/t", interrupt, 0, step), states.TalkChosen(), states.Talking("/t")),
|
||||
(states.Working(TYPED, 0, step), states.WorkerRan("/t"), states.Judging("/t")),
|
||||
):
|
||||
with self.subTest(state=state, event=event):
|
||||
self.assertEqual(states.transition(state, event), after)
|
||||
|
||||
class QuestionFor(unittest.TestCase):
|
||||
def test_puts_an_interrupts_question_as_asked_and_a_quoted_answer_past_the_cap_with_its_quote(self):
|
||||
self.assertEqual(run.question_for(Interrupt("e", "Which one?")), "Which one?")
|
||||
@@ -392,9 +407,8 @@ class Cycles(unittest.TestCase):
|
||||
cycle = dataclasses.replace(self.cycle(FakeEffects()), project=Routing.OPUS, route=Route(Routing.OPUS, 3, 3, 4))
|
||||
for ruling in (Interrupt("e", "q", entries_read=3), QuotedAnswer("e", "q", "A.", entries_read=3)):
|
||||
with self.subTest(ruling=ruling):
|
||||
self.assertEqual(run.escalated(cycle, states.Ruled(ruling)), cycle)
|
||||
stepped = run.escalated(cycle, states.Ruled(Interrupt("e", "q", "round 2: 🔴", 4, entries_read=3)))
|
||||
self.assertEqual((stepped.route, stepped.stepped_from), (Route(Routing.XHIGH, 3, 3, 4, escalated_at=3), cycle.route))
|
||||
self.assertIsNone(run.stepped(cycle, ruling))
|
||||
self.assertEqual(run.stepped(cycle, Interrupt("e", "q", "round 2: 🔴", 4, entries_read=3)), escalation.Step(cycle.route, Route(Routing.XHIGH, 3, 3, 4, escalated_at=3)))
|
||||
|
||||
def test_an_escalation_after_an_interrupt_stepped_the_worker_steps_it_again_in_the_same_cycle(self):
|
||||
streams = [Worker(self.paths.claude_code_transcripts.parent, text="round 2: 🔴"), Worker(self.paths.claude_code_transcripts.parent), Worker(self.paths.claude_code_transcripts.parent)]
|
||||
@@ -1327,9 +1341,9 @@ class Grounded(unittest.TestCase):
|
||||
self.assertFalse(judge.grounded("... …", transcript))
|
||||
|
||||
def test_an_answer_holds_only_word_for_word(self):
|
||||
self.assertTrue(judge.verbatim("Merge **ff-only**.", "Merge ff-only.\nNever squash."))
|
||||
self.assertFalse(judge.verbatim("Merge ... squash.", "Merge ff-only.\nNever squash."))
|
||||
self.assertFalse(judge.verbatim("", "Merge ff-only."))
|
||||
self.assertTrue(verbatim("Merge **ff-only**.", "Merge ff-only.\nNever squash."))
|
||||
self.assertFalse(verbatim("Merge ... squash.", "Merge ff-only.\nNever squash."))
|
||||
self.assertFalse(verbatim("", "Merge ff-only."))
|
||||
|
||||
|
||||
class Verdict(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user