Answer stability round 1: 0 🔴, 7 🟡 (0 misread); parse the formula on load, require the scoring, share the bar rule and split add

This commit is contained in:
2026-11-16 03:07:39 +01:00
parent 727ed70ecb
commit cf1180734c
12 changed files with 109 additions and 71 deletions
+6 -1
View File
@@ -70,7 +70,7 @@ def rank(text: str, goals_text: str, decisions: str, history: str, floor: decima
ranked = rank_details(rewrite_table(lines, table, shape, scored), [item for item, _ in scored])
if isinstance(ranked, Failure):
return ranked
under_bar = [under_the_bar(item, value, scoring.bar, items) for item, value in scored if not item.exempt and round(value, 1) < scoring.bar]
under_bar = [under_the_bar(item, value, scoring.bar, items) for item, value in scored if falls_under(item, value, scoring.bar)]
return Ranked(ranked, under_bar, notes(items, scoring))
@@ -302,6 +302,11 @@ def with_risk(item: Item) -> Item:
return dataclasses.replace(item, scores=item.scores | {"R": risk(item.scores["L"], item.scores["E"], item.scores["I"])})
def falls_under(item: Item, value: float, bar: float) -> bool:
"""Whether the item, which scores value, may not be planned: it scores under the bar, rounded as todo.md shows a Score, and isn't exempt."""
return not item.exempt and round(value, 1) < bar
def item_score(item: Item, scoring: Scoring, name: str) -> float | Failure:
"""The score of an item that holds no R, such as an issue in Jira; refused where it names a goal it may not. name is what a message calls the item."""
if broken := cited_goals_failure(item, scoring, name):
+11 -6
View File
@@ -272,12 +272,17 @@ class CodeHealth(unittest.TestCase):
return SCORED.format(overall=overall).removeprefix("# Comprehension history\n\n").replace("2026-10-08T12", at).replace("PR #1 at aaaaaaa", read)
def test_a_plan_in_jira_weighs_the_goals_as_todo_md_does(self):
opted_out = "## review opt-out: the comprehension check\n\nCosts rounds.\n"
for decisions, history, floor in (("", SCORED.format(overall="6.99"), DEFAULT_FLOOR), ("", SCORED.format(overall="6.99"), decimal.Decimal("6.0")), (opted_out, "", DEFAULT_FLOOR)):
with self.subTest(decisions=decisions, history=history, floor=floor):
stated = ranking.config_scoring("V", 1, self.readme, decisions, history, floor)
read = ranking.read_scoring(self.todo, self.todo.split("\n"), self.readme, decisions, history, ranking.SHAPE, floor)
self.assertEqual(stated if isinstance(stated, Failure) else stated.weights, read if isinstance(read, Failure) else read.weights)
# As the two tests below: code health weighs 1 / 1.97 at or over the floor and four times that under it, goal 1 0.97 / 1.97.
for floor, code_health in ((DEFAULT_FLOOR, 4 / 1.97), (decimal.Decimal("6.0"), 1 / 1.97)):
with self.subTest(floor=floor):
stated = ranking.config_scoring("V", 1, self.readme, "", SCORED.format(overall="6.99"), floor)
assert not isinstance(stated, Failure), stated
self.assertEqual(set(stated.weights), {"code health", "1"})
self.assertAlmostEqual(stated.weights["code health"], code_health)
self.assertAlmostEqual(stated.weights["1"], 0.97 / 1.97)
opted_out = ranking.config_scoring("V", 1, self.readme, "## review opt-out: the comprehension check\n\nCosts rounds.\n", "", DEFAULT_FLOOR)
assert isinstance(opted_out, Failure), opted_out
self.assertTrue(opted_out.reason.startswith("docs/decisions.md opts out of the comprehension check"), opted_out.reason)
def test_ranks_code_health_first_among_the_achieve_goals_at_an_overall_of_7_or_above(self):
# Code health, then goal 1: weights 1 / 1.97 and 0.97 / 1.97, an item moving one by 1 at S 1 scoring 50 times its weight.