Answer architecture round 1: 0 🔴, 8 🟡; read old routes' rungs, write R in rank_todo, route reviews through review_rungs, file item 168
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from model_routing.ladder import climbed, LADDER, position, review_rung, reviewers_rung, ReviewKind, Rung
|
||||
from model_routing.ladder import climbed, LADDER, position, review_rungs, ReviewKind, Rung
|
||||
from model_routing.route import ESCALATION_MARKER, Route
|
||||
from loop_claude.routing import escalation_rungs
|
||||
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
||||
@@ -14,6 +14,8 @@ QUOTE_SOURCES = either(("README.md's Goals and Audience", *RECORD_FILES, *HUMAN_
|
||||
# Where the worker may write an answer the human typed, so it counts as recorded.
|
||||
ANSWER_DESTINATIONS = "README.md's Goals or Audience, " + ", ".join(RECORD_FILES) + ", todo.md or a comment"
|
||||
ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could need is recorded in {ANSWER_DESTINATIONS} at the one place it governs"
|
||||
# Each kind of review, as review_launches names those it launches.
|
||||
REVIEWS: tuple[tuple[str, ReviewKind], ...] = (("each reviewer", "reviewer"), ("each comprehension seat", "seat"), ("the security pass's subagent", "security"))
|
||||
|
||||
|
||||
def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str:
|
||||
@@ -27,24 +29,33 @@ def routed_by(route: Route, anchor: Rung | None) -> str:
|
||||
|
||||
|
||||
def review_launches(route: Route, anchor: Rung | None) -> str:
|
||||
"""Which reviews to launch on a rung other than the worker's, and on which; below the project's rung, anchor, also where to launch a subagent that plans. Empty off the ladder, and where every review runs on the worker's rung."""
|
||||
"""Which reviews to launch on a rung other than the worker's, and on which; below the project's rung, anchor, also where to launch a subagent that plans. Empty off the ladder, and where every review runs on the worker's rung.
|
||||
|
||||
For a worker on Sonnet 5.5 at high, on an Opus 5.5 project, routed by item 3 of E + I 5, it opens: ` Launch each reviewer with the Agent tool set to model opus, effort high, the rung item 3's E + I of 5 picks. Launch each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung.`
|
||||
"""
|
||||
if anchor is None:
|
||||
return ""
|
||||
reviewers = reviewers_rung(anchor, route.rung, route.escape_and_impact)
|
||||
# The seats score every chunk on one rung, and the security pass spends no more than the project chose. Where the reviewers' rung is anchor too, anchor's name wins.
|
||||
named = {reviewers: f"the rung item {route.item}'s E + I of {route.escape_and_impact} picks", anchor: "the project's rung"}
|
||||
rungs = review_rungs(anchor, route.rung, route.escape_and_impact)
|
||||
launched: dict[Rung, list[str]] = {}
|
||||
kinds: tuple[tuple[str, ReviewKind], ...] = (("each reviewer", "reviewer"), ("each comprehension seat and the security pass's subagent", "seat"))
|
||||
for reviews, kind in kinds:
|
||||
rung = review_rung(kind, anchor, reviewers)
|
||||
if rung != route.rung:
|
||||
launched.setdefault(rung, []).append(reviews)
|
||||
launches = "".join(f" Launch {', '.join(reviews)} with the Agent tool set to {rung.agent_args()}, {named[rung]}." for rung, reviews in launched.items())
|
||||
scan = " Run a full scan only from such a subagent, since the scan's agents run on the model that starts them." if anchor != route.rung else ""
|
||||
for reviews, kind in REVIEWS:
|
||||
if rungs[kind] != route.rung:
|
||||
launched.setdefault(rungs[kind], []).append(reviews)
|
||||
launches = "".join(f" Launch {listed(reviews)} with the Agent tool set to {rung.agent_args()}, {rung_named(rung, route, anchor)}." for rung, reviews in launched.items())
|
||||
scan = " Run a full scan only from such a subagent, since the scan's agents run on the model that starts them." if rungs["security"] != route.rung else ""
|
||||
planning = f" Your rung is below the project's: launch each subagent that files or scores todo.md items on the rung `~/.claude/bin/subagent-rung --plan {anchor.model} <L>` prints." if position(route.rung) < position(anchor) else ""
|
||||
return f"{launches}{scan}{planning}"
|
||||
|
||||
|
||||
def listed(names: list[str]) -> str:
|
||||
"""The names as `a, b and c`."""
|
||||
return names[0] if len(names) == 1 else f"{', '.join(names[:-1])} and {names[-1]}"
|
||||
|
||||
|
||||
def rung_named(rung: Rung, route: Route, anchor: Rung) -> str:
|
||||
"""Why a review runs on rung: it is the project's, anchor, or the one the route's item's E + I picks."""
|
||||
return "the project's rung" if rung == anchor else f"the rung item {route.item}'s E + I of {route.escape_and_impact} picks"
|
||||
|
||||
|
||||
def escalation(route: Route, anchor: Rung | None) -> str:
|
||||
"""The prompt's escalation sentences, the marker's among them. Empty off the ladder or on its top rung. Where escalation_rungs opens none, the worker escalates only with the human's yes.
|
||||
Else they name the rungs escalation_rungs opens to a subagent, and offer to resume the worker one rung up for the rest of the chunk, up to the highest of those rungs."""
|
||||
@@ -63,9 +74,8 @@ def reruns(route: Route, anchor: Rung | None) -> str:
|
||||
"""The prompt's sentence naming the rung one above a reviewer's and a seat's, on which each reruns when it asks; empty off the ladder, and leaving out one already on the top rung."""
|
||||
if anchor is None or route.rung not in LADDER:
|
||||
return ""
|
||||
# The rungs review_launches launches them on.
|
||||
reviewers = reviewers_rung(anchor, route.rung, route.escape_and_impact)
|
||||
launched = (("reviewer", review_rung("reviewer", anchor, reviewers)), ("comprehension seat", review_rung("seat", anchor, reviewers)))
|
||||
rungs = review_rungs(anchor, route.rung, route.escape_and_impact)
|
||||
launched = (("reviewer", rungs["reviewer"]), ("comprehension seat", rungs["seat"]))
|
||||
rerun = {name: climbed(rung, 1) for name, rung in launched if rung != LADDER[-1]}
|
||||
if not rerun:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user