Record with each archived verdict the setup that ran it, what each model spent by kind, and the human's reversals
CI / tests (pull_request) Failing after 2m12s

This commit is contained in:
2026-11-12 09:57:56 +01:00
parent 8dc82fcf95
commit 3c4cedd389
22 changed files with 587 additions and 114 deletions
+13 -3
View File
@@ -9,11 +9,12 @@ from loop_effects.effects import Effects
from claude_code.entries import Entry, structured_output
from loop_claude import escalation_mark
from failure import Failure
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
from loop_claude.verdicts import Finished, Interrupt, Judged, QuotedAnswer, Unfinished, Verdict
from claude_code.transcript import plain, verbatim
from loop_claude.cycle.retry import retried
from model_routing.ladder import Rung
from loop_claude.stop import Stop
from claude_code.tokens import tokens_of
# At 3 to 4 characters a token, 100,000 to 133,000 tokens, which leaves a 200,000-token context room for the reply; the largest session rendered here was 364,000 characters on 2026-10-03.
JUDGE_PROMPT_CHARS = 400000
@@ -77,6 +78,8 @@ class Reply:
question: str = dataclasses.field(metadata={"description": "With interrupt true, the single question to put to the human. With a quoted answer, the worker's question that the answer field answers. Empty otherwise."})
# True opens claude's session at once, in place of the one-line answer (run.ask). The judge decides it, since loop-claude computes the plan's standing (release_standing.chunk_item) only when it routes a chunk on the ladder afresh: it would miss a release ready to cut in a resumed chunk or off the ladder. A wrong ruling costs the human one typed /talk, or answering in claude, which stops the loop if they leave it with nothing typed.
release_ready: bool = dataclasses.field(metadata={"description": "With interrupt true, whether the question is about a release ready to cut, which only the human may publish. False otherwise."})
# Counts the human's reversals of the worker's own choices, the counter-signal of docs/decisions.md → `loop-claude: a judge decides each interrupt and each quoted answer…`, its entry of 2026-11-08; score-outcomes lists them per chunk.
reversed: str = dataclasses.field(metadata={"description": "The latest [human] line that overrides a choice the worker took itself on its own recommendation and recorded with its reason, quoted verbatim, without elisions. Empty where none does; a line that answers a question the worker left open doesn't override anything."})
REPLY_TYPES = typing.get_type_hints(Reply)
@@ -164,7 +167,8 @@ def run_judge(root: str, args: list[str], prompt: str, grounds: Grounds, effects
reply = claude_reply(effects.claude, args, root, prompt, "the judge")
if isinstance(reply, Failure | Limited):
return reply
verdict = verdict_from(structured_output(reply))
output = structured_output(reply)
verdict = verdict_from(output)
replied = json.dumps(reply, ensure_ascii=False)
cost = cost_of(reply)
if isinstance(verdict, Failure):
@@ -172,7 +176,13 @@ def run_judge(root: str, args: list[str], prompt: str, grounds: Grounds, effects
checked = quotes_checked(verdict, grounds)
if isinstance(checked, Failure):
return Rejected(checked.reason, replied, cost)
return dataclasses.replace(checked, judge_cost=cost)
return dataclasses.replace(checked, judged=Judged(cost, tokens_of(reply.get("usage")), reversal_of(output, grounds.shown)))
def reversal_of(output: object, shown: str) -> str:
"""The reply's reversed quote where the transcript holds it verbatim; empty otherwise. verdict_from has checked the field is a str."""
quote = output.get("reversed") if isinstance(output, dict) else None
return quote if isinstance(quote, str) and verbatim(quote, shown) else ""
def cost_of(reply: dict) -> float: