From a9074901ca623a13a2bf318932350a3c786a7d37 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 18 Nov 2026 17:03:26 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20weigh=20eac?= =?UTF-8?q?h=20chain's=20first=20achieve=20goal=201=20under=20an=20epic=20?= =?UTF-8?q?without=20one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/do_epic/ranking.py | 6 +++--- bin/do_epic/test_ranking.py | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/do_epic/ranking.py b/bin/do_epic/ranking.py index 80cf27fa..6625868e 100644 --- a/bin/do_epic/ranking.py +++ b/bin/do_epic/ranking.py @@ -62,7 +62,7 @@ def ranked(items: list[EpicItem], formula: str, epic_goals: str, repos: dict[str def chain_scoring(formula: ast.Expression, epic_goals: str, repo: str | None, own: RepoRanking | None) -> ranking.Scoring | Failure: """How an item in repo scores: the chain's goals, and what each achieve goal weighs. The bar is 0, since a bar decides what is filed, and the order holds every item that was. - goal_weights scales a chain's weights to sum to 1. Here they are scaled so that the epic's achieve goals sum to 1 instead, in every chain, which makes the scores of items in different repos comparable. + goal_weights scales a chain's weights to sum to 1. Here they are scaled so that the epic's achieve goals sum to 1 instead, in every chain, or the chain's first achieve goal weighs 1 where the epic has none, which makes the scores of items in different repos comparable. Code health and a maintain goal weigh by the rules every project's plan follows, which an epic doesn't change: code health weighs four times its place while its repo is unmeasured or under its readability floor, and plan/ranking.py's weight_of weighs a maintain goal. Either may then outweigh an achieve goal of the epic. "The epic wins" in the decision settles the epic's goals against a repo's, and code health is neither's: it is every project's, and a repo that is hard to read costs each epic item worked in it.""" goals = chain(epic_goals, repo, own) @@ -80,8 +80,8 @@ def chain_scoring(formula: ast.Expression, epic_goals: str, repo: str | None, ow return weights achieve = [goal for goal, mark in goals if mark == "Achieve"] of_epic = len([goal for goal in achieve if goal.startswith(EPIC_GOAL)]) - # An epic without an achieve goal leaves each chain summing to 1. - scale = total(len(achieve)) / total(of_epic) if of_epic else 1 + # Under an epic without an achieve goal, the first achieve goal of each chain weighs 1. + scale = total(len(achieve)) / (total(of_epic) or 1) return ranking.Scoring(SHAPE, formula, 0, 0, dict(goals), {goal: weight * scale for goal, weight in weights.items()}) diff --git a/bin/do_epic/test_ranking.py b/bin/do_epic/test_ranking.py index 06d928b0..f6ab1c08 100644 --- a/bin/do_epic/test_ranking.py +++ b/bin/do_epic/test_ranking.py @@ -90,10 +90,12 @@ class RankedTest(unittest.TestCase): for (_, value), expected in zip(found, (9.7 / TOTAL, 9.7 / TOTAL, 10 * 0.97**2 / TOTAL)): self.assertAlmostEqual(value, expected) - def test_an_epic_without_an_achieve_goal_leaves_each_repos_weights_summing_to_1(self) -> None: - found = ranked([item(1, "repo 1 by 10")], "V", "1. **Maintain:** Leak no customer data.\n", {"billing-api": VOIDED}) + def test_an_epic_without_an_achieve_goal_weighs_each_repos_first_achieve_goal_1(self) -> None: + two = dataclasses.replace(VOIDED, goals_text=VOIDED.goals_text + "2. **Achieve:** Small images.\n") + found = ranked([item(1, "repo 1 by 10"), item(2, "repo 1 by 10", repo="web"), item(3, "repo 2 by 10", repo="web")], "V", "1. **Maintain:** Leak no customer data.\n", {"billing-api": VOIDED, "web": two}) assert not isinstance(found, Failure), found - self.assertAlmostEqual(found[0][1], 10) + for (_, value), expected in zip(found, (10, 10, 9.7)): + self.assertAlmostEqual(value, expected) def test_an_item_without_a_score_fails_naming_it(self) -> None: unscored = EpicItem(dataclasses.replace(item(4, "").item, scores={}), None)