Answer architecture round 1: 0 🔴, 2 🟡; rename Step to StepUp and let escalation.py own the judge's step-line sentence

This commit is contained in:
2026-10-23 04:54:45 +02:00
parent f0e14f3fdf
commit bf8b642ead
6 changed files with 62 additions and 59 deletions
+9 -6
View File
@@ -3,8 +3,8 @@
A worker whose run ends asking loop-claude for a higher rung cites the trigger that fired, and the judge quotes the passage where it fired as the verdict's escalation. The mark, Route.escalated_at, is how many transcript entries the session held when an escalation last stepped the worker up, 0 before any. The session's transcript only grows, so the mark holds across cycles, and the archive's Worker: records keep it for a rerun.
- Stamp. stamped records on the judge's verdict how many entries the judge read.
- Step. routing.after_unfinished and routing.after_ruling step the worker up on an escalation and move the mark to mark(verdict). A ruling's Step travels through the cycle's states, so the archive and the worker's next prompt name it.
- Show. transcript puts STEP_LINE after the mark, so the next judge sees that the triggers before it are spent.
- Step. routing.after_unfinished and routing.after_ruling step the worker up on an escalation and move the mark to mark(verdict). A ruling's StepUp travels through the cycle's states, so the archive and the worker's next prompt name it.
- Show. transcript puts STEP_LINE after the mark, and QUOTE_AFTER_STEP, in the judge's schema, tells the next judge that the triggers before it are spent.
- Check. checked keeps an escalation only where it quotes since_step, the worker's own lines after the mark, so a passage that bought one step cannot buy another.
"""
import dataclasses
@@ -15,12 +15,15 @@ from loop_claude.verdicts import Interrupt, QuotedAnswer, Unfinished, Verdict
from claude_code.transcript import render, Typed, verbatim
from model_routing.route import Route
# Reply.escalation's description in cycle/judge.py points at this line. Only the judge reads it, so it is no [loop] line.
STEP_LINE = "[step] loop-claude stepped the worker up a rung here, so the escalation triggers that fired before this line are spent."
# Only the judge reads the step line, so it is no [loop] line.
STEP_TAG = "[step]"
STEP_LINE = f"{STEP_TAG} loop-claude stepped the worker up a rung here, so the escalation triggers that fired before this line are spent."
# Reply.escalation's description in cycle/judge.py carries this sentence, so the judge reads STEP_LINE as the mark.
QUOTE_AFTER_STEP = f"Where a {STEP_TAG} line says loop-claude stepped the worker up a rung, quote only the worker's own words after it, and leave this empty where the trigger fired only before it."
@dataclasses.dataclass(frozen=True)
class Step:
class StepUp:
"""An interrupt's or a quoted answer's escalation stepping the route within a cycle: the route the worker ran on until the ruling, and the one it runs on after."""
before: Route
after: Route
@@ -46,7 +49,7 @@ def since_step(entries: list[dict], at: int, typed_answer: typing.Callable[[str]
return render([entry for entry in entries[at:] if human_text(entry) is None and loop_text(entry) is None], typed_answer)
def checked(verdict: Verdict, since: str, shown: str) -> Verdict:
def checked(verdict: Verdict, *, since: str, shown: str) -> Verdict:
"""The verdict without its escalation unless the escalation quotes both since, since_step's lines, and the transcript the judge was shown. A misquote, or a quote of a passage before the mark, drops the escalation, so the worker's rung holds; it is no failure, which would otherwise exit an unattended loop."""
if isinstance(verdict, Interrupt | QuotedAnswer | Unfinished) and verdict.escalation and not (verbatim(verdict.escalation, since) and verbatim(verdict.escalation, shown)):
return dataclasses.replace(verdict, escalation="")