Give the judge's contract one home in cycle/verdicts.py

This commit is contained in:
2026-10-03 17:55:19 +02:00
parent 5f7d34b87d
commit ae7c332ba3
7 changed files with 96 additions and 109 deletions
+4 -6
View File
@@ -1,7 +1,6 @@
import dataclasses
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
from loop_claude.project.records import QUOTE_SOURCES
# A backstop for what the judge misses, such as a reworded repeat, so the worker cannot loop unattended on answers quoted from README.md or the records.
QUOTED_ANSWERS_PER_CYCLE = 3
@@ -23,8 +22,9 @@ class Judging:
@dataclasses.dataclass(frozen=True)
class Interrupting:
"""The human answers; a QuotedAnswer here is one past the cycle's QUOTED_ANSWERS_PER_CYCLE."""
transcript_path: str
question: str
ruling: Interrupt | QuotedAnswer
quoted_answers: int = 0
@@ -72,10 +72,8 @@ def transition(state: State, event: Event) -> State:
return Judging(transcript_path, quoted_answers)
case Judging(_, quoted_answers), Ruled(QuotedAnswer() as answered) if quoted_answers < QUOTED_ANSWERS_PER_CYCLE:
return Working(answered, quoted_answers + 1)
case Judging(transcript_path, quoted_answers), Ruled(QuotedAnswer(question=question, answer=answer)):
return Interrupting(transcript_path, f"{question}\n\n{QUOTE_SOURCES} says:\n{answer}\n\nThose files have answered {quoted_answers} questions this cycle, the most allowed, so this one comes to you.", quoted_answers)
case Judging(transcript_path, quoted_answers), Ruled(Interrupt(question=question)):
return Interrupting(transcript_path, question, quoted_answers)
case Judging(transcript_path, quoted_answers), Ruled(Interrupt() | QuotedAnswer() as ruling):
return Interrupting(transcript_path, ruling, quoted_answers)
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.