Answer architecture round 1: 0 🔴, 4 🟡; move verdicts out of cycle, derive RECORDED, type the archived worker as Record, drop stale help names
This commit is contained in:
@@ -7,7 +7,7 @@ from loop_claude.cycle.prompts import ANSWER_DESTINATIONS, ANSWERS_RECORDED, typ
|
||||
from claude_code.reply import claude_reply, Limited
|
||||
from loop_claude.effects import Effects
|
||||
from failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from claude_code.entries import human_text, loop_text
|
||||
from todo_table import LEVELS
|
||||
from model_routing.route import on_its_scale
|
||||
|
||||
@@ -8,7 +8,7 @@ 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 failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.cycle.judge import judge, Rejected
|
||||
from transcript_archive import outcomes
|
||||
from loop_claude.paths import Paths
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import dataclasses
|
||||
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
|
||||
|
||||
# A backstop for what the judge misses, such as a reworded repeat, so the worker cannot loop unattended on answers quoted from README.md or the records.
|
||||
QUOTED_ANSWERS_PER_CYCLE = 3
|
||||
|
||||
@@ -94,26 +94,25 @@ The judge reports the highest L and the highest E + I the worker states for an i
|
||||
next cycle steps the worker up to the rung that L picks, never down, and the reviewers to the rung
|
||||
picked by the higher of two: that E + I, or the routed item's (Route.reviewed_on in
|
||||
bin/model_routing/route.py). A level off its scale counts as none. Every second unfinished verdict
|
||||
on a chunk steps it up one rung (routing.stepped). So does an unfinished verdict on a worker that
|
||||
ended its run asking for a higher rung, once the judge quotes the transcript showing that the
|
||||
escalation trigger it named fired (~/.claude/CLAUDE.md → "Working with the codebase" lists them). An
|
||||
interrupt or a quoted answer with such a quote steps the rung as it comes in, before the human is
|
||||
asked or the worker resumes (routing.stepped_by_ruling). Each such step marks how many transcript
|
||||
entries the session held, and from then on the judge must quote the worker's own lines after that
|
||||
mark, where it reads a [step] line. Each step on an escalation stops two rungs above the rung the
|
||||
chunk's item picks, and the worker's prompts offer it only while the worker is below that limit.
|
||||
on a chunk steps it up one rung (routing.after_unfinished). So does an unfinished verdict on a
|
||||
worker that ended its run asking for a higher rung, once the judge quotes the transcript showing
|
||||
that the escalation trigger it named fired (~/.claude/CLAUDE.md → "Working with the codebase" lists
|
||||
them). An interrupt or a quoted answer with such a quote steps the rung as it comes in, before the
|
||||
human is asked or the worker resumes (routing.after_ruling). Each such step marks how many
|
||||
transcript entries the session held, and from then on the judge must quote the worker's own lines
|
||||
after that mark, where it reads a [step] line. Each step on an escalation stops two rungs above the
|
||||
rung the chunk's item picks, and the worker's prompts offer it only while the worker is below that
|
||||
limit.
|
||||
|
||||
Routing: the archive and reruns
|
||||
|
||||
Each finished or unfinished verdict, interrupt, quoted answer, stop and step-up in the archive ends
|
||||
with a Worker: line, a JSON record of the route: the worker's rung as model and effort, the item, L
|
||||
and E + I that routed the chunk, any taken-in E + I that picks a higher review rung (archived as a
|
||||
step-up too), and the mark. A rerun resumes an open chunk on the latest route named there, and
|
||||
counts its unfinished verdicts afresh; it also reads the prose lines written before the record. A
|
||||
rung no longer on the ladder, or below the one its item's L picks, is dropped, and the chunk is
|
||||
routed afresh from todo.md. So is a chunk whose archived line names an R + C, as loop-claude wrote
|
||||
before it routed on L. A todo.md or an archive that cannot be read or parsed is said on stderr, and
|
||||
the chunk is routed without it.
|
||||
with a Worker: line, the route's JSON record (Route.record in bin/model_routing/route.py). A rerun
|
||||
resumes an open chunk on the latest route named there, and counts its unfinished verdicts afresh; it
|
||||
also reads the prose lines written before the record. A rung no longer on the ladder, or below the
|
||||
one its item's L picks, is dropped, and the chunk is routed afresh from todo.md. So is a chunk whose
|
||||
archived line names an R + C, as loop-claude wrote before it routed on L. A todo.md or an archive
|
||||
that cannot be read or parsed is said on stderr, and the chunk is routed without it.
|
||||
|
||||
Routing: the judge's rung
|
||||
|
||||
@@ -194,7 +193,7 @@ from chunk_pick import default_plan, DefaultPlan
|
||||
from git_repo import default_ref
|
||||
from loop_claude.effects import Effects
|
||||
from failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished
|
||||
from loop_claude.verdicts import Finished
|
||||
from loop_claude.project.model_choice import get_or_ask_models
|
||||
from todo_table import Item
|
||||
from transcript_archive.read import latest_worker
|
||||
|
||||
@@ -3,7 +3,7 @@ import dataclasses
|
||||
|
||||
from chunk_pick import chunk_item, LastCut, Next
|
||||
from model_routing.ladder import climbed, highest, LADDER, position, project_rung, review_floor, Rung, stepped_up, worker_rung
|
||||
from loop_claude.cycle.verdicts import escalation_mark, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.verdicts import escalation_mark, Interrupt, QuotedAnswer, Unfinished
|
||||
from failure import Failure
|
||||
from todo_table import Item, items, NoItemsTable
|
||||
from model_routing.route import Route
|
||||
|
||||
@@ -23,7 +23,7 @@ from chunk_pick import DefaultPlan, LastCut
|
||||
from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python
|
||||
from claude_code import entries, reply, session
|
||||
from failure import Failure
|
||||
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished
|
||||
from loop_claude.cycle import interrupt, judge, prompts, retry, run, states, worker
|
||||
from model_routing import ladder
|
||||
from model_routing.ladder import LADDER, Rung
|
||||
@@ -1329,7 +1329,7 @@ class Verdict(unittest.TestCase):
|
||||
self.assertEqual(verdict_from({"highest_likelihood_taken_in": 0, "highest_escape_and_impact_taken_in": 0, "escalation": "", "answer": "", "interrupt": True, "evidence": "x", "finished": False, "question": " ", "release_ready": False}), Failure("the judge interrupted without a question"))
|
||||
self.assertEqual(verdict_from(None), Failure("the judge returned no reply"))
|
||||
|
||||
def test_takes_a_bundled_l_on_its_scale_and_counts_any_other_as_none(self):
|
||||
def test_takes_the_highest_l_taken_in_on_its_scale_and_counts_any_other_as_none(self):
|
||||
reply = {"answer": "", "highest_escape_and_impact_taken_in": 0, "escalation": "", "interrupt": False, "evidence": "e", "finished": False, "question": "", "release_ready": False}
|
||||
self.assertEqual(verdict_from({**reply, "highest_likelihood_taken_in": 4}), Unfinished("e", 4))
|
||||
self.assertEqual(verdict_from({**reply, "highest_likelihood_taken_in": True}), Failure("the judge's reply has no highest_likelihood_taken_in of type integer"))
|
||||
@@ -1338,14 +1338,14 @@ class Verdict(unittest.TestCase):
|
||||
self.assertEqual(verdict_from({**reply, "highest_likelihood_taken_in": highest_likelihood_taken_in}), Unfinished("e", 0))
|
||||
|
||||
|
||||
def test_takes_a_bundled_e_plus_i_on_its_scale_and_counts_any_other_as_none(self):
|
||||
def test_takes_the_highest_e_plus_i_taken_in_on_its_scale_and_counts_any_other_as_none(self):
|
||||
reply = {"answer": "", "highest_likelihood_taken_in": 0, "escalation": "", "interrupt": False, "evidence": "e", "finished": False, "question": "", "release_ready": False}
|
||||
self.assertEqual(verdict_from({**reply, "highest_escape_and_impact_taken_in": 6}), Unfinished("e", 0, highest_escape_and_impact_taken_in=6))
|
||||
self.assertEqual(verdict_from({**reply, "highest_escape_and_impact_taken_in": 2}), Unfinished("e", 0, highest_escape_and_impact_taken_in=2))
|
||||
self.assertEqual(verdict_from({**reply, "highest_escape_and_impact_taken_in": False}), Failure("the judge's reply has no highest_escape_and_impact_taken_in of type integer"))
|
||||
for highest_likelihood_taken_in in (1, 9, -1):
|
||||
with self.subTest(highest_likelihood_taken_in=highest_likelihood_taken_in):
|
||||
self.assertEqual(verdict_from({**reply, "highest_escape_and_impact_taken_in": highest_likelihood_taken_in}), Unfinished("e", 0))
|
||||
for escape_and_impact in (1, 9, -1):
|
||||
with self.subTest(escape_and_impact=escape_and_impact):
|
||||
self.assertEqual(verdict_from({**reply, "highest_escape_and_impact_taken_in": escape_and_impact}), Unfinished("e", 0))
|
||||
|
||||
def test_takes_an_escalation_quote_on_an_unfinished_verdict(self):
|
||||
reply = {"answer": "", "highest_likelihood_taken_in": 0, "highest_escape_and_impact_taken_in": 0, "escalation": "round 2: 🔴", "interrupt": False, "evidence": "e", "finished": False, "question": "", "release_ready": False}
|
||||
@@ -1365,7 +1365,7 @@ class Verdict(unittest.TestCase):
|
||||
self.assertEqual(judge.quotes_checked(Interrupt("e", "q", "round 2: … 🔴"), judge.Grounds(shown, shown, "")), Interrupt("e", "q"))
|
||||
self.assertEqual(judge.quotes_checked(Unfinished("e", 0, "round 3: 🔴"), judge.Grounds(shown, shown, "")), Unfinished("e"))
|
||||
|
||||
def test_takes_an_escalation_quote_and_a_bundled_l_on_a_quoted_answer(self):
|
||||
def test_takes_an_escalation_quote_and_the_highest_l_taken_in_on_a_quoted_answer(self):
|
||||
reply = {"answer": "A.", "highest_likelihood_taken_in": 4, "highest_escape_and_impact_taken_in": 0, "escalation": "round 2: 🔴", "interrupt": False, "evidence": "e", "finished": False, "question": "Which one?", "release_ready": False}
|
||||
self.assertEqual(verdict_from(reply), QuotedAnswer("e", "Which one?", "A.", "round 2: 🔴", 4))
|
||||
self.assertEqual(verdict_from({**reply, "highest_likelihood_taken_in": 5}), QuotedAnswer("e", "Which one?", "A.", "round 2: 🔴"))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""What the judge rules on a cycle: the verdicts judge.verdict_from builds from its reply."""
|
||||
"""What the judge rules on a cycle: the verdicts cycle.judge.verdict_from builds from its reply, which the cycle, the loop and routing read."""
|
||||
import dataclasses
|
||||
|
||||
|
||||
Reference in New Issue
Block a user