Answer architecture round 1: 3 🔴, 8 🟡; have the judge quote the worker's record of the trigger word for word, name the worker's rung on resume, give kept and stepped one floor and name stepped's two conditions
This commit is contained in:
+26
-14
@@ -7,7 +7,7 @@ from todo_table import Item, items
|
||||
from model_routing.route import Route
|
||||
|
||||
UNFINISHED_PER_STEP = 2
|
||||
# How many rungs above item_rung the worker may escalate a task without the human's yes: docs/decisions.md → `routing: a worker hands a task one rung up`.
|
||||
# How many rungs above item_rung an escalation trigger takes the worker or a task without the human's yes, as escalation_cap applies it.
|
||||
ESCALATION_CAP = 2
|
||||
# The models `judge-replay` found returning, on their cheapest rung, every verdict the reference judge reproduced: docs/decisions.md → `routing: on a model judge-replay covered`.
|
||||
JUDGE_REPLAYED = ("claude-opus-5-5",)
|
||||
@@ -31,8 +31,13 @@ def first_route(anchor: Rung, item: Item | None) -> Route:
|
||||
|
||||
|
||||
def kept(route: Route, anchor: Rung) -> bool:
|
||||
"""Whether a chunk keeps route: its rung is on the ladder at or above item_rung, the floor stepped keeps too."""
|
||||
return highest(route.rung, item_rung(anchor, route)) == route.rung
|
||||
"""Whether a chunk keeps route: its rung is on the ladder and at or above item_rung."""
|
||||
return floor(anchor, route) == route.rung
|
||||
|
||||
|
||||
def floor(anchor: Rung, route: Route) -> Rung:
|
||||
"""The route's rung, raised to item_rung where it is lower or off the ladder; kept and stepped both hold a route to it."""
|
||||
return highest(route.rung, item_rung(anchor, route))
|
||||
|
||||
|
||||
def item_rung(anchor: Rung, route: Route) -> Rung:
|
||||
@@ -41,34 +46,41 @@ def item_rung(anchor: Rung, route: Route) -> Rung:
|
||||
|
||||
|
||||
def escalation_rungs(anchor: Rung, route: Route) -> tuple[Rung, ...]:
|
||||
"""The rungs an escalation trigger opens to the worker, least competent first: from one above its own up to ESCALATION_CAP above item_rung; none off the ladder.
|
||||
|
||||
A step-up between cycles raises the worker but not that limit, as lilleman set it from the rung the chunk started on.
|
||||
"""
|
||||
"""The rungs an escalation trigger opens to the worker, least competent first: from one above its own up to escalation_cap; none off the ladder."""
|
||||
if route.rung not in LADDER:
|
||||
return ()
|
||||
return LADDER[position(route.rung) + 1:position(escalation_cap(anchor, route)) + 1]
|
||||
|
||||
|
||||
def escalation_cap(anchor: Rung, route: Route) -> Rung:
|
||||
"""The highest rung an escalation trigger takes the worker or a task to without the human's yes."""
|
||||
"""The highest rung an escalation trigger takes the worker or a task to without the human's yes: docs/decisions.md → `routing: a worker hands a task one rung up`.
|
||||
|
||||
It counts from item_rung, the rung the chunk started on, so a step-up between cycles narrows what the worker may climb without a yes, and never widens it.
|
||||
"""
|
||||
return climbed(item_rung(anchor, route), ESCALATION_CAP)
|
||||
|
||||
|
||||
def stepped(anchor: Rung, route: Route, bundled: int, escalated: bool) -> Route:
|
||||
"""The route after one more unfinished verdict, never on a lower rung or below item_rung.
|
||||
"""The route after one more unfinished verdict, never on a lower rung: from taken_in's rung, one rung up when counted_out or escalates, else there.
|
||||
|
||||
bundled is the highest R + C the judge saw the worker take into the chunk, 0 for none; the route climbs to the rung it picks.
|
||||
From there it steps one rung up after every UNFINISHED_PER_STEP unfinished verdicts, or when escalated, as the judge found the escalation trigger the worker cited, up to escalation_cap.
|
||||
bundled and escalated are the verdict's fields, not the verdict, since loop_claude.cycle.judge imports this module through prompts.
|
||||
"""
|
||||
rung = highest(route.rung, item_rung(anchor, route))
|
||||
rung = highest(rung, picked(anchor, bundled)) if bundled else rung
|
||||
rung = taken_in(anchor, route, bundled)
|
||||
unfinished = route.unfinished + 1
|
||||
if unfinished >= UNFINISHED_PER_STEP or escalated and position(rung) < position(escalation_cap(anchor, route)):
|
||||
# Every UNFINISHED_PER_STEP unfinished verdicts.
|
||||
counted_out = unfinished >= UNFINISHED_PER_STEP
|
||||
# The judge found the escalation trigger the worker cited in asking for a higher rung, and escalation_cap leaves room.
|
||||
escalates = escalated and position(rung) < position(escalation_cap(anchor, route))
|
||||
if counted_out or escalates:
|
||||
return dataclasses.replace(route, rung=stepped_up(rung), unfinished=0)
|
||||
return dataclasses.replace(route, rung=rung, unfinished=unfinished)
|
||||
|
||||
|
||||
def taken_in(anchor: Rung, route: Route, bundled: int) -> Rung:
|
||||
"""floor, raised to the rung bundled picks from anchor; bundled is the highest R + C the judge saw the worker take into the chunk, 0 for none."""
|
||||
return highest(floor(anchor, route), picked(anchor, bundled)) if bundled else floor(anchor, route)
|
||||
|
||||
|
||||
def judge_rung(judge_model: str, route: Route) -> Rung:
|
||||
"""The rung the route's item picks from the judge model's cheapest rung, never below that rung, whatever rung the worker stepped to.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user