27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""Where a chunk's reviews run, chosen from its route and the project's rung."""
|
|
import dataclasses
|
|
|
|
from model_routing.route import HIGHEST_ESCAPE_AND_IMPACT, Route
|
|
from model_routing.ladder import reviewers_rung, Rung
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class ReviewChoice:
|
|
# The rung of each pass's reviewer.
|
|
reviewers: Rung
|
|
seat: Rung
|
|
security: Rung
|
|
# Each rung a higher E + I than the route's picks for the reviewers, with the lowest E + I that picks it, in rising order.
|
|
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."""
|
|
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):
|
|
if (rung := reviewers_rung(project, route.rung, escape_and_impact)) != reviewers:
|
|
higher.setdefault(rung, escape_and_impact)
|
|
# A seat and the security pass run on the project's rung, as ladder.review_rung says.
|
|
return ReviewChoice(reviewers, project, project, higher)
|