Restructure the interrupt so one function owns the ask and loop-inbox imports nothing from cycle/

This commit is contained in:
2026-10-29 13:11:04 +01:00
parent 60cb0dc851
commit 9ebd06e748
13 changed files with 189 additions and 200 deletions
+6 -29
View File
@@ -1,6 +1,5 @@
import dataclasses
from loop_claude.waiting import Ask, OpenInInbox, OpenOnTerminal
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
from loop_claude.escalation_mark import StepUp
@@ -10,7 +9,7 @@ QUOTED_ANSWERS_PER_CYCLE = 3
@dataclasses.dataclass(frozen=True)
class TypedAnswer:
"""The human's answer to an interrupt, typed at loop-claude's terminal."""
"""The human's answer to an interrupt, typed at loop-claude's terminal or in loop-inbox."""
question: str
answer: str
@@ -33,7 +32,7 @@ class Judging:
@dataclasses.dataclass(frozen=True)
class Interrupting:
"""The human answers; a QuotedAnswer reaches here only after the cycle has used up its QUOTED_ANSWERS_PER_CYCLE."""
"""The human answers, by typing or in the worker's claude session; a QuotedAnswer reaches here only after the cycle has used up its QUOTED_ANSWERS_PER_CYCLE."""
transcript_path: str
ruling: Interrupt | QuotedAnswer
quoted_answers: int = 0
@@ -41,20 +40,6 @@ class Interrupting:
step_up: StepUp | None = None
@dataclasses.dataclass(frozen=True)
class Talk:
"""The human answers in the worker's claude session, open on loop-claude's terminal or in loop-inbox, as where says. ask is the question they were asked, which loop-inbox lists as open there."""
ask: Ask
where: OpenOnTerminal | OpenInInbox
@dataclasses.dataclass(frozen=True)
class Talking:
transcript_path: str
talk: Talk
quoted_answers: int = 0
@dataclasses.dataclass(frozen=True)
class Closing:
transcript_path: str
@@ -66,7 +51,7 @@ class Ended:
verdict: Finished | Unfinished
Active = Working | Judging | Interrupting | Talking | Closing
Active = Working | Judging | Interrupting | Closing
State = Active | Ended
@@ -87,15 +72,9 @@ class HumanTyped:
typed: TypedAnswer
@dataclasses.dataclass(frozen=True)
class TalkChosen:
"""The human typed /talk, at loop-claude's terminal or in loop-inbox, or the interrupt is for a release ready to cut."""
talk: Talk
@dataclasses.dataclass(frozen=True)
class HumanTalked:
"""The human typed in the worker's claude session."""
"""The human typed in the worker's claude session, which /talk opens, or a release ready to cut opens at once."""
@dataclasses.dataclass(frozen=True)
@@ -103,7 +82,7 @@ class Archived:
pass
Event = WorkerRan | Ruled | HumanTyped | TalkChosen | HumanTalked | Archived
Event = WorkerRan | Ruled | HumanTyped | HumanTalked | Archived
def transition(state: State, event: Event) -> State:
@@ -120,10 +99,8 @@ def transition(state: State, event: Event) -> State:
return Closing(transcript_path, verdict)
case Interrupting(_, _, quoted_answers, step_up), HumanTyped(typed):
return Working(typed, quoted_answers, step_up)
case Interrupting(transcript_path, _, quoted_answers), TalkChosen(talk):
return Talking(transcript_path, talk, quoted_answers)
# The human worked in the worker's claude session, so the judge rules again on the transcript it leaves.
case Talking(transcript_path, _, quoted_answers), HumanTalked():
case Interrupting(transcript_path, _, quoted_answers), HumanTalked():
return Judging(transcript_path, quoted_answers)
case Closing(_, verdict), Archived():
return Ended(verdict)