Answer the third round: show the judge loop-claude's prompts, one records answer per cycle through an interrupt, name the answer's two sources apart
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import dataclasses
|
||||
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, Recorded, Unfinished, Verdict
|
||||
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished, Verdict
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -11,6 +11,7 @@ class Working:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Judging:
|
||||
"""The judge rules; answered_from_records holds once the records answered a question this cycle."""
|
||||
transcript_path: str
|
||||
answered_from_records: bool = False
|
||||
|
||||
@@ -19,6 +20,7 @@ class Judging:
|
||||
class Interrupting:
|
||||
transcript_path: str
|
||||
question: str
|
||||
answered_from_records: bool = False
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -47,7 +49,7 @@ class Ruled:
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Answered:
|
||||
class HumanAnswered:
|
||||
pass
|
||||
|
||||
|
||||
@@ -56,25 +58,25 @@ class Archived:
|
||||
pass
|
||||
|
||||
|
||||
Event = WorkerRan | Ruled | Answered | Archived
|
||||
Event = WorkerRan | Ruled | HumanAnswered | Archived
|
||||
|
||||
|
||||
def transition(state: State, event: Event) -> State:
|
||||
match state, event:
|
||||
case Working(answer), WorkerRan(transcript_path):
|
||||
return Judging(transcript_path, answer is not None)
|
||||
case Judging(_, False), Ruled(Recorded(answer=answer)):
|
||||
case Judging(_, False), Ruled(AnsweredFromRecords(answer=answer)):
|
||||
return Working(answer)
|
||||
# The worker asked again after the records' answer, so the answer did not settle it.
|
||||
case Judging(transcript_path, True), Ruled(Recorded(question=question)):
|
||||
return Interrupting(transcript_path, question)
|
||||
case Judging(transcript_path, _), Ruled(Interrupt(question=question)):
|
||||
return Interrupting(transcript_path, question)
|
||||
# One records answer per cycle, so a worker the answer did not satisfy cannot loop unattended.
|
||||
case Judging(transcript_path, True), Ruled(AnsweredFromRecords(question=question)):
|
||||
return Interrupting(transcript_path, question, True)
|
||||
case Judging(transcript_path, answered_from_records), Ruled(Interrupt(question=question)):
|
||||
return Interrupting(transcript_path, question, answered_from_records)
|
||||
case Judging(transcript_path, _), Ruled(Finished() | Unfinished() as verdict):
|
||||
return Closing(transcript_path, verdict)
|
||||
# The human works in the interrupt's claude session, so the judge rules again on the transcript it leaves.
|
||||
case Interrupting(transcript_path), Answered():
|
||||
return Judging(transcript_path)
|
||||
case Interrupting(transcript_path, _, answered_from_records), HumanAnswered():
|
||||
return Judging(transcript_path, answered_from_records)
|
||||
case Closing(), Archived():
|
||||
return Ended()
|
||||
raise ValueError(f"no transition from {state} on {event}")
|
||||
|
||||
Reference in New Issue
Block a user