Answer architecture round 1: 0 🔴, 6 🟡; show the judge the mark, carry the entries read on the verdict, name the checked texts
This commit is contained in:
@@ -6,8 +6,8 @@ from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, Hu
|
||||
from transcript_archive.write import archive
|
||||
from claude_code.session import delete_session, Session, session_open, transcript_file
|
||||
from loop_claude.effects import Effects
|
||||
from loop_claude.cycle.judge import escalation_mark, Finished, Interrupt, judge, QuotedAnswer, Rejected, Unfinished
|
||||
from failure import Failure
|
||||
from loop_claude.cycle.judge import Finished, Interrupt, judge, QuotedAnswer, Rejected, Unfinished
|
||||
from loop_claude.routing import judge_rung, stepped_by_ruling
|
||||
from transcript_archive import outcomes
|
||||
from loop_claude.paths import Paths
|
||||
@@ -43,16 +43,13 @@ class Cycle:
|
||||
# Only an interrupt's or a quoted answer's escalation changes the route within a cycle. No transition reads the route or the fields below, so they stay out of the states.
|
||||
# The route before that ruling stepped it up, for ask and keep_answer to archive and for worker_start to tell the worker; None unless the latest event is that ruling, or the answer the human typed to it.
|
||||
stepped_from: Route | None = None
|
||||
# How many transcript entries the latest ruling read; 0 before the first.
|
||||
judged: int = 0
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Concluded:
|
||||
"""How a cycle ended: its verdict, the route it ended on, which an interrupt's or a quoted answer's escalation may have stepped up from the route it began on, and how many transcript entries the verdict's judge read, which its escalation marks."""
|
||||
"""How a cycle ended: its verdict, and the route it ended on, which an interrupt's or a quoted answer's escalation may have stepped up from the route it began on."""
|
||||
verdict: Finished | Unfinished
|
||||
route: Route
|
||||
judged: int
|
||||
|
||||
|
||||
def run_cycle(cycle: Cycle) -> Stop | Concluded:
|
||||
@@ -66,7 +63,7 @@ def run_cycle(cycle: Cycle) -> Stop | Concluded:
|
||||
state = transition(state, event)
|
||||
except KeyboardInterrupt:
|
||||
return stopped(cycle, Stop(130, ""), "Ctrl-C")
|
||||
return Concluded(state.verdict, cycle.route, cycle.judged)
|
||||
return Concluded(state.verdict, cycle.route)
|
||||
|
||||
|
||||
def escalated(cycle: Cycle, event: Event) -> Cycle:
|
||||
@@ -74,12 +71,9 @@ def escalated(cycle: Cycle, event: Event) -> Cycle:
|
||||
if isinstance(event, HumanTyped):
|
||||
return cycle
|
||||
cycle = dataclasses.replace(cycle, stepped_from=None)
|
||||
if not isinstance(event, Ruled):
|
||||
if not (isinstance(event, Ruled) and isinstance(event.verdict, Interrupt | QuotedAnswer) and cycle.anchor):
|
||||
return cycle
|
||||
cycle = dataclasses.replace(cycle, judged=event.entries)
|
||||
if not (isinstance(event.verdict, Interrupt | QuotedAnswer) and event.verdict.escalation):
|
||||
return cycle
|
||||
route = stepped_by_ruling(cycle.anchor, cycle.route, event.verdict.bundled, event.entries) if cycle.anchor else cycle.route
|
||||
route = stepped_by_ruling(cycle.anchor, cycle.route, event.verdict.bundled, escalation_mark(event.verdict))
|
||||
return dataclasses.replace(cycle, route=route, stepped_from=cycle.route if route != cycle.route else None)
|
||||
|
||||
|
||||
@@ -154,7 +148,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, entries.reason)
|
||||
verdict = judge(cycle.root, cycle.task, cycle.premises, cycle.records, entries, cycle.route.escalated_at, judge_of(cycle), cycle.effects, lambda rejected: keep_rejection(cycle, transcript_path, rejected))
|
||||
return verdict if isinstance(verdict, Stop) else Ruled(verdict, len(entries))
|
||||
return verdict if isinstance(verdict, Stop) else Ruled(verdict)
|
||||
|
||||
|
||||
def keep_rejection(cycle: Cycle, transcript_path: str, rejected: Rejected) -> Stop | None:
|
||||
|
||||
Reference in New Issue
Block a user