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:
2026-10-03 01:32:22 +02:00
parent 387c22087c
commit 1839c8a19e
9 changed files with 46 additions and 35 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ JUDGE_RULES = (
"where a note goes - is not on its own a reason to interrupt. The human may have replied inside the transcript, on a [human] line: judge only what "
"is still open, never a question they already answered there. A [loop] line is what loop-claude told "
"the agent, such as an answer quoted from README.md or the project's records; a question it answered "
"is no longer open.\n"
"is no longer open, unless the agent asks it again: then it is the human's, with answer empty.\n"
"Where the agent asked or flagged something itself, the question is that one, in the agent's own "
"wording; never construct another from facts it stated.\n"
"Where README.md or the project's records answer that question, quote the passage that answers it "
+1 -1
View File
@@ -52,7 +52,7 @@ def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop:
def step(cycle: Cycle, state: Active) -> Event | Stop:
match state:
case Working(answer):
case Working(answer, _):
return work(cycle, answer)
case Judging(transcript_path, _):
return rule(cycle, transcript_path)
+17 -14
View File
@@ -2,25 +2,29 @@ import dataclasses
from loop_claude.cycle.verdicts import AnsweredFromRecords, Finished, Interrupt, Unfinished, Verdict
# A backstop, so a worker the records' answers do not satisfy cannot loop unattended; the judge sends a repeated question to the human.
RECORDS_ANSWERS_PER_CYCLE = 3
@dataclasses.dataclass(frozen=True)
class Working:
"""The worker runs, resumed with the records' answer when there is one."""
answer: str | None = None
records_answers: int = 0
@dataclasses.dataclass(frozen=True)
class Judging:
"""The judge rules; answered_from_records holds once the records answered a question this cycle."""
"""The judge rules; records_answers counts the questions the records answered this cycle."""
transcript_path: str
answered_from_records: bool = False
records_answers: int = 0
@dataclasses.dataclass(frozen=True)
class Interrupting:
transcript_path: str
question: str
answered_from_records: bool = False
records_answers: int = 0
@dataclasses.dataclass(frozen=True)
@@ -63,20 +67,19 @@ 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(AnsweredFromRecords(answer=answer)):
return Working(answer)
# 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 Working(_, records_answers), WorkerRan(transcript_path):
return Judging(transcript_path, records_answers)
case Judging(_, records_answers), Ruled(AnsweredFromRecords(answer=answer)) if records_answers < RECORDS_ANSWERS_PER_CYCLE:
return Working(answer, records_answers + 1)
case Judging(transcript_path, records_answers), Ruled(AnsweredFromRecords(question=question, answer=answer)):
return Interrupting(transcript_path, f"{question}\n\nREADME.md or the project's records say:\n{answer}", records_answers)
case Judging(transcript_path, records_answers), Ruled(Interrupt(question=question)):
return Interrupting(transcript_path, question, records_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.
case Interrupting(transcript_path, _, answered_from_records), HumanAnswered():
return Judging(transcript_path, answered_from_records)
case Interrupting(transcript_path, _, records_answers), HumanAnswered():
return Judging(transcript_path, records_answers)
case Closing(), Archived():
return Ended()
raise ValueError(f"no transition from {state} on {event}")