diff --git a/bin/model_routing/review_choice.py b/bin/model_routing/review_choice.py index e28b21c3..d1226387 100644 --- a/bin/model_routing/review_choice.py +++ b/bin/model_routing/review_choice.py @@ -24,7 +24,8 @@ def chosen(project: Rung, route: Route) -> ReviewChoice: 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) + # A higher E + I changes a review only by moving the reviewers' rung: a replay lowers a pass only where the worker runs no higher than the project and the E + I steps no review up, and the first E + I that steps one up moves the reviewers too. + rung = reviewers_rung(project, route.rung, escape_and_impact) + if rung != reviewers: + higher.setdefault(rung, escape_and_impact) return ReviewChoice(reviewers, {kind: rungs[kind] for kind in REVIEWERS if rungs[kind] != reviewers}, rungs["seat"], rungs["security"], higher) diff --git a/bin/model_routing/test_review_choice.py b/bin/model_routing/test_review_choice.py index 8bf89f58..43488556 100644 --- a/bin/model_routing/test_review_choice.py +++ b/bin/model_routing/test_review_choice.py @@ -13,27 +13,17 @@ 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") +HIGHER = {OPUS_HIGH: 5, OPUS_XHIGH: 6, OPUS_MAX: 7, FABLE: 8} 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, 5)).higher, {}) - def test_puts_a_pass_a_replay_lowered_on_the_rung_the_replay_chose_while_no_e_plus_i_lifts_a_review(self): + def test_puts_a_pass_a_replay_lowered_on_the_rung_the_replay_chose_while_no_e_plus_i_steps_a_review_up(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, {}) + self.assertEqual(chosen(OPUS, Route(SONNET, 3, 2, 4)), ReviewChoice(OPUS, {"prose": HAIKU}, OPUS, OPUS, HIGHER)) + + def test_puts_every_pass_on_the_reviewers_rung_once_an_e_plus_i_steps_a_review_up(self): + with unittest.mock.patch.dict(ladder.REPLAYED, {("prose", "claude-opus-5-5"): HAIKU}): + self.assertEqual(chosen(OPUS, Route(SONNET, 3, 2, 5)).lowered, {})