Answer architecture round 1: 3 🔴, 3 🟡; restore the reviewer-table check tied to SKILL.md and the round titles, render each lowered pass as an exception sentence, move review-replay's argument parsing into the shared reader, split reviewed_in, and rename the package in item 114
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from model_routing.ladder import climbed, LADDER, position, review_rungs, REVIEWERS, ReviewKind, Rung
|
||||
from model_routing.ladder import climbed, LADDER, position, review_rungs, REVIEWERS, reviewers_rung, ReviewKind, Rung
|
||||
from model_routing.route import ESCALATION_MARKER, HIGHEST_ESCAPE_AND_IMPACT, Route
|
||||
from loop_claude.routing import escalation_rungs
|
||||
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
||||
@@ -10,7 +10,7 @@ QUOTE_SOURCES = listed(("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: a row per pass, since a replay may lower one pass alone.
|
||||
# Each kind of review, as review_launches names those it launches: a row per pass, since a replay may lower one pass alone, while "each reviewer" names the passes it left.
|
||||
REVIEWS: tuple[tuple[str, ReviewKind], ...] = (*((f"each {agent}", kind) for kind, agent in REVIEWERS.items()), ("each comprehension seat", "seat"), ("the security pass's subagent", "security"))
|
||||
|
||||
|
||||
@@ -41,21 +41,35 @@ def preflight_failed(reason: str) -> 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 files or scores todo.md items; then taken_in_launches, the reviewers' rung each higher E + I picks. Empty off the ladder.
|
||||
"""Which reviews to launch on a rung other than the worker's, and on which, then the rung of each pass a replay lowered; below the project's rung, anchor, also where to launch a subagent that files or scores todo.md items; then taken_in_launches, the reviewers' rung each higher E + I picks. Empty off the ladder.
|
||||
|
||||
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.`
|
||||
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.` Where a replay lowered the prose pass to Haiku 5.5 at low, and the E + I steps no review up, a sentence follows: ` Launch each prose-reviewer instead with the Agent tool set to model haiku, effort low, the rung the replay of its pass chose.`
|
||||
"""
|
||||
if anchor is None:
|
||||
return ""
|
||||
rungs = review_rungs(anchor, route.rung, route.reviewed_on())
|
||||
launched: dict[Rung, list[ReviewKind]] = {}
|
||||
for _, kind in REVIEWS:
|
||||
if rungs[kind] != route.rung:
|
||||
launched.setdefault(rungs[kind], []).append(kind)
|
||||
launches = "".join(f" Launch {listed(named(kinds), 'and')} with the Agent tool set to {rung.agent_args()}, {rung_named(rung, route, anchor)}." for rung, kinds in launched.items())
|
||||
lowered_launches = "".join(f" Launch {reviews} instead with the Agent tool set to {rung.agent_args()}, the rung the replay of its pass chose." for reviews, rung in lowered(route, anchor))
|
||||
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}{taken_in_launches(route, anchor)}"
|
||||
return f"{shared_launches(route, anchor)}{lowered_launches}{scan}{planning}{taken_in_launches(route, anchor)}"
|
||||
|
||||
|
||||
def shared_launches(route: Route, anchor: Rung) -> str:
|
||||
"""A sentence for each rung other than the worker's that a review runs on, naming the passes no replay lowered "each reviewer"."""
|
||||
rungs = review_rungs(anchor, route.rung, route.reviewed_on())
|
||||
together = {"each reviewer": reviewers_rung(anchor, route.rung, route.reviewed_on())} | {reviews: rungs[kind] for reviews, kind in REVIEWS if kind not in REVIEWERS}
|
||||
launched: dict[Rung, list[str]] = {}
|
||||
for reviews, rung in together.items():
|
||||
if rung != route.rung:
|
||||
launched.setdefault(rung, []).append(reviews)
|
||||
return "".join(f" Launch {listed(reviews, 'and')} with the Agent tool set to {rung.agent_args()}, {rung_named(rung, route, anchor)}." for rung, reviews in launched.items())
|
||||
|
||||
|
||||
def lowered(route: Route, anchor: Rung) -> list[tuple[str, Rung]]:
|
||||
"""How REVIEWS names each pass a replay lowered below reviewers_rung, and the rung the replay chose."""
|
||||
rungs = review_rungs(anchor, route.rung, route.reviewed_on())
|
||||
reviewers = reviewers_rung(anchor, route.rung, route.reviewed_on())
|
||||
return [(reviews, rungs[kind]) for reviews, kind in REVIEWS if kind in REVIEWERS and rungs[kind] != reviewers]
|
||||
|
||||
|
||||
def taken_in_launches(route: Route, anchor: Rung) -> str:
|
||||
@@ -63,31 +77,22 @@ def taken_in_launches(route: Route, anchor: Rung) -> str:
|
||||
|
||||
For a worker on Opus 5.5 at medium, routed by an item of E + I 6, it reads: ` Where an item you take into the chunk has an E + I of 7 or more, launch each reviewer with the Agent tool set to `model opus, effort max` from 7 and `model fable, effort max` from 8.`
|
||||
"""
|
||||
lowest = min(position(review_rungs(anchor, route.rung, route.reviewed_on())[kind]) for kind in REVIEWERS)
|
||||
now = review_rungs(anchor, route.rung, route.reviewed_on())
|
||||
higher: dict[Rung, int] = {}
|
||||
for escape_and_impact in range(route.reviewed_on() + 1, HIGHEST_ESCAPE_AND_IMPACT + 1):
|
||||
# An E + I that steps reviews up puts every pass on one rung; one that does not leaves each pass where it is.
|
||||
rungs = {review_rungs(anchor, route.rung, escape_and_impact)[kind] for kind in REVIEWERS}
|
||||
if len(rungs) == 1 and position(rung := rungs.pop()) > lowest:
|
||||
higher.setdefault(rung, escape_and_impact)
|
||||
# An E + I that lifts any pass puts every pass on reviewers_rung, since a replay lowers a pass only where the E + I steps no review up.
|
||||
if review_rungs(anchor, route.rung, escape_and_impact) != now:
|
||||
higher.setdefault(reviewers_rung(anchor, route.rung, escape_and_impact), escape_and_impact)
|
||||
if not higher:
|
||||
return ""
|
||||
picks = [f"`{rung.agent_args()}` from {escape_and_impact}" for rung, escape_and_impact in higher.items()]
|
||||
return f" Where an item you take into the chunk has an E + I of {min(higher.values())} or more, launch each reviewer with the Agent tool set to {listed(picks, 'and')}."
|
||||
|
||||
|
||||
def named(kinds: list[ReviewKind]) -> list[str]:
|
||||
"""How review_launches names kinds: by their rows in REVIEWS, with "each reviewer" for every pass where all are among them."""
|
||||
every = all(kind in kinds for kind in REVIEWERS)
|
||||
return [*(["each reviewer"] if every else []), *(name for name, kind in REVIEWS if kind in kinds and not (every and kind in REVIEWERS))]
|
||||
|
||||
|
||||
def rung_named(rung: Rung, route: Route, anchor: Rung) -> str:
|
||||
"""Why a review runs on rung: it is the project's, anchor, the one a pass's replay chose, which alone lies below anchor, or the one the route's reviewed_on E + I picks, the item's or one taken in."""
|
||||
"""Why a review runs on rung: it is the project's, anchor, or the one the route's reviewed_on E + I picks, the item's or one taken in."""
|
||||
if rung == anchor:
|
||||
return "the project's rung"
|
||||
if position(rung) < position(anchor):
|
||||
return "the rung the replay of its pass chose"
|
||||
if route.escape_and_impact_taken_in:
|
||||
return f"the rung picked by an item of E + I {route.escape_and_impact_taken_in} taken into the chunk"
|
||||
return f"the rung item {route.item}'s E + I of {route.escape_and_impact} picks"
|
||||
@@ -117,25 +122,26 @@ def escalation(route: Route, anchor: Rung | None) -> str:
|
||||
|
||||
|
||||
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."""
|
||||
"""The prompt's sentences naming the rung one above a review's, on which it reruns when it asks: shared_reruns' for a reviewer and a seat, then one for each pass a replay lowered. Empty off the ladder.
|
||||
|
||||
For a worker on Sonnet 5.5 at high, on an Opus 5.5 project whose prose pass a replay lowered to Haiku 5.5 at low, routed by an item of E + I 4, they read: ` A reviewer or comprehension seat that asks for a rerun one rung up reruns with the Agent tool set to `model opus, effort high`. Rerun each prose-reviewer that asks with the Agent tool set to `model haiku, effort medium` instead.`
|
||||
"""
|
||||
if anchor is None or route.rung not in LADDER:
|
||||
return ""
|
||||
rungs = review_rungs(anchor, route.rung, route.reviewed_on())
|
||||
rerun: dict[Rung, list[ReviewKind]] = {}
|
||||
for _, kind in REVIEWS:
|
||||
if kind != "security" and rungs[kind] != LADDER[-1]:
|
||||
rerun.setdefault(climbed(rungs[kind], 1), []).append(kind)
|
||||
seats = review_rungs(anchor, route.rung, route.reviewed_on())["seat"]
|
||||
lowered_reruns = "".join(f" Rerun {reviews} that asks with the Agent tool set to `{climbed(rung, 1).agent_args()}` instead." for reviews, rung in lowered(route, anchor))
|
||||
return f"{shared_reruns(reviewers_rung(anchor, route.rung, route.reviewed_on()), seats)}{lowered_reruns}"
|
||||
|
||||
|
||||
def shared_reruns(reviewers: Rung, seats: Rung) -> str:
|
||||
"""The sentence naming the rung one above reviewers, the rung of each pass no replay lowered, and one above seats, leaving out one already on the top rung."""
|
||||
launched = (("reviewer", reviewers), ("comprehension seat", seats))
|
||||
rerun = {name: climbed(rung, 1) for name, rung in launched if rung != LADDER[-1]}
|
||||
if not rerun:
|
||||
return ""
|
||||
(first, kinds), *others = rerun.items()
|
||||
withs = [f"a {listed(nouns(more), 'or')} with `{rung.agent_args()}`" for rung, more in others]
|
||||
rest = f", {'and ' if len(withs) == 1 else ''}{listed(withs, 'and')}" if withs else ""
|
||||
return f" A {listed(nouns(kinds), 'or')} that asks for a rerun one rung up reruns with the Agent tool set to `{first.agent_args()}`{rest}."
|
||||
|
||||
|
||||
def nouns(kinds: list[ReviewKind]) -> list[str]:
|
||||
"""named's names without their "each"."""
|
||||
return [name.removeprefix("each ") for name in named(kinds)]
|
||||
if len(set(rerun.values())) == 1:
|
||||
return f" A {listed(list(rerun), 'or')} that asks for a rerun one rung up reruns with the Agent tool set to `{next(iter(rerun.values())).agent_args()}`."
|
||||
return f" A reviewer that asks for a rerun one rung up reruns with the Agent tool set to `{rerun['reviewer'].agent_args()}`, and a comprehension seat with `{rerun['comprehension seat'].agent_args()}`."
|
||||
|
||||
|
||||
def resumed(unfinished_evidence: str, route: Route, anchor: Rung | None) -> str:
|
||||
|
||||
@@ -1150,11 +1150,14 @@ class WorkerArgs(unittest.TestCase):
|
||||
with unittest.mock.patch.dict(ladder.REPLAYED, {("prose", "claude-opus-5-5"): haiku}):
|
||||
below = prompts.fresh("Do it.", "## Goals", Route(Rung("claude-sonnet-5-5", "high"), 3, 2, 4), opus, self.FACTS)
|
||||
on_it = prompts.resumed("", Route(haiku, 3, 1, 4), opus)
|
||||
self.assertIn("whether or not it is item 3. Launch each systems-architect, each principles-auditor, each override-reviewer, each stability-reviewer, each product-owner-reviewer, each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung. Launch each prose-reviewer with the Agent tool set to model haiku, effort low, the rung the replay of its pass chose.", below)
|
||||
launched = " Launch each reviewer, each comprehension seat and the security pass's subagent with the Agent tool set to model opus, effort medium, the project's rung. Launch each prose-reviewer instead with the Agent tool set to model haiku, effort low, the rung the replay of its pass chose."
|
||||
rerun = " A reviewer or comprehension seat that asks for a rerun one rung up reruns with the Agent tool set to `model opus, effort high`. Rerun each prose-reviewer that asks with the Agent tool set to `model haiku, effort medium` instead."
|
||||
self.assertIn(f"whether or not it is item 3.{launched}", below)
|
||||
self.assertIn(" Where an item you take into the chunk has an E + I of 5 or more, launch each reviewer with the Agent tool set to `model opus, effort high` from 5,", below)
|
||||
self.assertIn(" A systems-architect, principles-auditor, override-reviewer, stability-reviewer, product-owner-reviewer or comprehension seat that asks for a rerun one rung up reruns with the Agent tool set to `model opus, effort high`, and a prose-reviewer with `model haiku, effort medium`.", below)
|
||||
self.assertNotIn("each prose-reviewer", on_it)
|
||||
self.assertIn(f"{rerun} After your first read", below)
|
||||
self.assertIn(f"loop-claude runs you on claude-haiku-5-5 at low effort.{launched}", on_it)
|
||||
self.assertIn(" Where an item you take into the chunk has an E + I of 5 or more,", on_it)
|
||||
self.assertTrue(on_it.endswith(rerun))
|
||||
|
||||
def test_names_the_rung_a_reviewer_or_seat_reruns_on_one_above_its_own(self):
|
||||
opus = Rung("claude-opus-5-5", "medium")
|
||||
|
||||
Reference in New Issue
Block a user