Files
claude-config/bin/loop_claude/verdicts.py
T

75 lines
3.0 KiB
Python

"""The verdicts cycle.judge.verdict_from builds from the judge's reply; cycle.run.rule then stamps every verdict but Finished with the items the chunk takes. They sit outside cycle/, since routing reads them and cycle imports routing."""
import dataclasses
from claude_code.tokens import Tokens
@dataclasses.dataclass(frozen=True)
class TakenIn:
"""The levels of the plan items the worker names on its latest `Chunk items:` line, as cycle.chunk_items reads them. The item the chunk was routed on counts only where the worker names it."""
# The highest L among them, 0 for none: an escalation steps up from the rung that L picks, and an unfinished verdict also raises the worker to it.
highest_likelihood: int = 0
# The highest E + I among them, 0 for none: after an unfinished verdict, it routes the next cycle's reviewers.
highest_escape_and_impact: int = 0
@dataclasses.dataclass(frozen=True)
class Judged:
"""What the judge run that gave a verdict found beside it, which the cycle archives with the verdict."""
# In dollars, as its reply records; 0 where it records none.
cost: float = 0.0
# Its reply's usage, on the judge's model.
tokens: Tokens = Tokens()
# The human's whole typed answer that holds the judge's quote of a reversal of a choice the worker took on its own recommendation; empty for none, and where no typed answer holds the quote.
reversed: str = ""
@dataclasses.dataclass(frozen=True)
class Interrupt:
evidence: str
question: str
# The judge's quote showing that the worker's cited escalation trigger fired; empty for none.
escalation: str = ""
taken_in: TakenIn = TakenIn()
release_ready: bool = False
# How many transcript entries the judge read, which escalation_mark.stamped stamps. An escalation the verdict carries moves the route's mark there. None means it was never stamped, and then its escalation doesn't step the worker.
entries_read: int | None = None
judged: Judged = Judged()
# The [human] line from earlier in the chunk that answered the same question, and the words of it that leave the question open; empty for none. cycle.judge.re_ask_checked turns the Interrupt into an Unfinished where the question doesn't quote them.
answered_before: str = ""
left_open: str = ""
@dataclasses.dataclass(frozen=True)
class QuotedAnswer:
"""The worker asked a question that the premises or the records answer. The answer field quotes the passage."""
evidence: str
question: str
answer: str
# As on Interrupt.
escalation: str = ""
taken_in: TakenIn = TakenIn()
entries_read: int | None = None
judged: Judged = Judged()
@dataclasses.dataclass(frozen=True)
class Finished:
evidence: str
judged: Judged = Judged()
@dataclasses.dataclass(frozen=True)
class Unfinished:
evidence: str
# As on Interrupt.
escalation: str = ""
taken_in: TakenIn = TakenIn()
entries_read: int | None = None
judged: Judged = Judged()
Verdict = Interrupt | QuotedAnswer | Finished | Unfinished
# The verdicts that may carry an escalation.
Escalating = Interrupt | QuotedAnswer | Unfinished