Split review_launches into model_routing's choice of each review's rung and whole prompt sentences that render it
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Where a chunk's reviews run: the choice loop_claude/cycle/prompts.py tells the worker in sentences."""
|
||||
import dataclasses
|
||||
|
||||
from model_routing.ladder import ReviewedPass, review_rungs, reviewers_rung, Rung
|
||||
from model_routing.route import HIGHEST_ESCAPE_AND_IMPACT, Route
|
||||
from review_passes import REVIEWERS
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class ReviewChoice:
|
||||
# The rung of each pass's reviewer that no replay lowered.
|
||||
reviewers: Rung
|
||||
# The passes whose replay chose another rung, with that rung.
|
||||
lowered: dict[ReviewedPass, Rung]
|
||||
seat: Rung
|
||||
security: Rung
|
||||
# Each rung that a higher E + I than the route's picks for the reviewers, with the lowest E + I that picks it, so a worker that takes in such an item reviews it on that rung in the same run.
|
||||
higher: dict[Rung, int]
|
||||
|
||||
|
||||
def chosen(project: Rung, route: Route) -> ReviewChoice:
|
||||
"""The rung each kind of review runs on for a chunk whose route is route, on a project whose rung is project."""
|
||||
rungs = review_rungs(project, route.rung, route.reviewed_on())
|
||||
reviewers = reviewers_rung(project, 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 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(project, route.rung, escape_and_impact) != rungs:
|
||||
higher.setdefault(reviewers_rung(project, route.rung, escape_and_impact), escape_and_impact)
|
||||
return ReviewChoice(reviewers, {kind: rungs[kind] for kind in REVIEWERS if rungs[kind] != reviewers}, rungs["seat"], rungs["security"], higher)
|
||||
@@ -0,0 +1,39 @@
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
from model_routing import ladder
|
||||
from model_routing.ladder import Rung
|
||||
from model_routing.review_choice import chosen, ReviewChoice
|
||||
from model_routing.route import Route
|
||||
|
||||
HAIKU = Rung("claude-haiku-5-5", "low")
|
||||
OPUS = Rung("claude-opus-5-5", "medium")
|
||||
OPUS_HIGH = Rung("claude-opus-5-5", "high")
|
||||
OPUS_XHIGH = Rung("claude-opus-5-5", "xhigh")
|
||||
OPUS_MAX = Rung("claude-opus-5-5", "max")
|
||||
FABLE = Rung("claude-fable-5-1", "max")
|
||||
SONNET = Rung("claude-sonnet-5-5", "high")
|
||||
|
||||
|
||||
class Chosen(unittest.TestCase):
|
||||
def test_runs_the_reviewers_on_the_rung_the_items_e_plus_i_picks_and_seats_and_security_on_the_projects(self):
|
||||
self.assertEqual(chosen(OPUS, Route(SONNET, 3, 2, 5)), ReviewChoice(OPUS_HIGH, {}, OPUS, OPUS, {OPUS_XHIGH: 6, OPUS_MAX: 7, FABLE: 8}))
|
||||
|
||||
def test_runs_the_reviewers_on_the_workers_rung_where_that_is_higher_and_no_e_plus_i_lifts_a_review(self):
|
||||
self.assertEqual(chosen(OPUS, Route(OPUS_HIGH, 3, 4, 4)), ReviewChoice(OPUS_HIGH, {}, OPUS, OPUS, {OPUS_XHIGH: 6, OPUS_MAX: 7, FABLE: 8}))
|
||||
|
||||
def test_runs_the_reviewers_on_the_rung_an_e_plus_i_taken_in_picks_and_names_only_the_rungs_above_it(self):
|
||||
self.assertEqual(chosen(OPUS, Route(OPUS, 3, 3, 5, escape_and_impact_taken_in=7)), ReviewChoice(OPUS_MAX, {}, OPUS, OPUS, {FABLE: 8}))
|
||||
|
||||
def test_names_the_lowest_e_plus_i_that_picks_each_higher_rung(self):
|
||||
self.assertEqual(chosen(OPUS, Route(OPUS, 3, 3, 4)).higher, {OPUS_HIGH: 5, OPUS_XHIGH: 6, OPUS_MAX: 7, FABLE: 8})
|
||||
|
||||
def test_names_no_higher_rung_on_the_top_one(self):
|
||||
self.assertEqual(chosen(OPUS, Route(FABLE, 3, 4, 8)).higher, {})
|
||||
|
||||
def test_puts_a_pass_a_replay_lowered_on_the_rung_the_replay_chose_while_no_e_plus_i_lifts_a_review(self):
|
||||
with unittest.mock.patch.dict(ladder.REPLAYED, {("prose", "claude-opus-5-5"): HAIKU}):
|
||||
lowered = chosen(OPUS, Route(SONNET, 3, 2, 4))
|
||||
lifted = chosen(OPUS, Route(SONNET, 3, 2, 5))
|
||||
self.assertEqual(lowered, ReviewChoice(OPUS, {"prose": HAIKU}, OPUS, OPUS, {OPUS_HIGH: 5, OPUS_XHIGH: 6, OPUS_MAX: 7, FABLE: 8}))
|
||||
self.assertEqual(lifted.lowered, {})
|
||||
Reference in New Issue
Block a user