From 81bd8e6705aecb51e622af4af85f96223ddff785 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 16 Oct 2026 13:24:15 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=209=20=F0=9F=9F=A1;=20test=20the=20levels'=20boun?= =?UTF-8?q?ds,=20the=20reviewers'=20rung=20above=20the=20floor,=20a=20lone?= =?UTF-8?q?=20missing=20level,=20the=20hook's=20fallback=20below=20the=20p?= =?UTF-8?q?roject,=20ties,=20every=20level's=20line,=20rendering,=20?= =?UTF-8?q?=F0=9F=94=B4=20medians=20and=20each=20scale's=20top?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/test_loop_claude.py | 3 ++- bin/model_routing/test_worker_rungs.py | 1 + bin/rule_hook/test_rule_hook.py | 2 ++ bin/score_outcomes/test_score_outcomes.py | 23 +++++++++++++++++++---- bin/test_rank_todo.py | 5 +++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index ee9dc3b6..a7244ca6 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -599,10 +599,11 @@ class Routing(unittest.TestCase): self.assertEqual(routing.judge_rung("claude-sonnet-5-5", Route(self.HIGH, 3, 4, 5)), Rung("claude-sonnet-5-5")) def test_refuses_a_route_whose_item_has_levels_off_their_scales_or_levels_without_an_item(self): - for item, likelihood, escape_and_impact in ((3, 0, 5), (3, 5, 5), (3, 4, 1), (3, 4, 9), (0, 4, 5)): + for item, likelihood, escape_and_impact in ((3, 0, 5), (3, 5, 5), (3, 4, 1), (3, 4, 9), (0, 4, 5), (0, 4, 0), (0, 0, 5)): with self.subTest(item=item, likelihood=likelihood, escape_and_impact=escape_and_impact): with self.assertRaises(ValueError): Route(self.HIGH, item, likelihood, escape_and_impact) + self.assertEqual(Route(self.HIGH, 3, 1, 2).escape_and_impact, 2) def test_routes_nothing_on_an_item_without_e_or_i(self): without_i = TODO.replace("| E | I | R |", "| E | R |").replace("|---|---|---|---|---|---|---|---|---|---|---|", "|---|---|---|---|---|---|---|---|---|---|").replace("| 4 | 3 | 5 | 10 |", "| 4 | 3 | 10 |").replace("| 4 | 2 | 3 | 7 |", "| 4 | 2 | 7 |").replace("| 1 | 1 | 1 | 1 |", "| 1 | 1 | 1 |") diff --git a/bin/model_routing/test_worker_rungs.py b/bin/model_routing/test_worker_rungs.py index f3320883..32c88f97 100644 --- a/bin/model_routing/test_worker_rungs.py +++ b/bin/model_routing/test_worker_rungs.py @@ -12,6 +12,7 @@ class Environment(unittest.TestCase): def test_the_project_the_worker_and_the_reviewers_rungs_are_named_in_the_environment(self): self.assertEqual(environment(self.PROJECT, Route(self.WORKER, 3, 1, 5)), {"LOOP_CLAUDE_PROJECT_RUNG": "claude-opus-5-5 at medium effort", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort", "LOOP_CLAUDE_REVIEWER_RUNG": "claude-opus-5-5 at high effort"}) self.assertEqual(environment(self.PROJECT, Route(self.WORKER))["LOOP_CLAUDE_REVIEWER_RUNG"], "claude-opus-5-5 at medium effort") + self.assertEqual(environment(self.PROJECT, Route(Rung("claude-opus-5-5", "xhigh"), 3, 4, 2))["LOOP_CLAUDE_REVIEWER_RUNG"], "claude-opus-5-5 at xhigh effort") def test_a_project_off_the_ladder_is_handed_empty_rungs_so_none_is_inherited(self): self.assertEqual(environment(None, Route(self.WORKER)), {"LOOP_CLAUDE_PROJECT_RUNG": "", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort", "LOOP_CLAUDE_REVIEWER_RUNG": ""}) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 42eacb10..ab0e9eec 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -210,6 +210,8 @@ class ReviewerRung(unittest.TestCase): def test_holds_a_reviewer_to_the_higher_of_the_workers_and_the_projects_rung_where_loop_claude_handed_no_reviewers_rung(self): without = {name: rung for name, rung in self.ABOVE.items() if name != "LOOP_CLAUDE_REVIEWER_RUNG"} self.assertEqual(self.refused({"subagent_type": "stability-reviewer", "model": "opus", "effort": "medium"}, without), ["reviewer-rung"]) + below = {name: rung for name, rung in self.ENVIRON.items() if name != "LOOP_CLAUDE_REVIEWER_RUNG"} + self.assertEqual(self.refused({"subagent_type": "stability-reviewer", "model": "sonnet", "effort": "high"}, below), ["reviewer-rung"]) self.assertEqual(self.refused({"prompt": "You are one seat of a comprehension panel.", "model": "sonnet", "effort": "high"}, without), ["reviewer-rung"]) def test_a_seat_or_a_security_launch_is_held_to_the_project_rung_alone(self): diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 9f137614..bdbee077 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -9,7 +9,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from test_env import isolated_env from todo_table import Item -from score_outcomes.outcomes import nearest, Outcome, outcomes_of, render, report, shipped +from score_outcomes.outcomes import nearest, Outcome, outcomes_of, rank_correlation, render, report, shipped TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes" HEADER = "| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n" @@ -79,15 +79,22 @@ class Nearest(unittest.TestCase): class Report(unittest.TestCase): def test_gives_each_guessed_values_median_outcome_once_ten_single_item_chunks_hold_it(self): - found = [outcome(id_, 2, 1 + id_ % 2, 4, lines=10 * id_, rounds=id_) for id_ in range(1, 11)] + found = [outcome(id_, 2, 1 + id_ % 2, 4, lines=10 * id_, rounds=id_, findings=(1, 3)) for id_ in range(1, 11)] lines = report(found + [outcome(11, 2, 2, None, lines=1000, findings=None, shipped_with=(12,))]) - self.assertIn("- R, 🔴 findings: 2 → 0 (10 chunks)", lines) + self.assertIn("- R, 🔴 findings: 2 → 1 (10 chunks)", lines) self.assertIn("- S, lines changed: 1 → 60 (5 chunks), 2 → 50 (5 chunks)", lines) self.assertFalse([line for line in lines if line.startswith("- C")]) def test_says_how_many_chunks_it_has_under_ten(self): self.assertIn("- S, lines changed: 1 chunk that shipped one item records S and its outcome; the report needs 10.", report([outcome(1, 2, 2, 4), outcome(2, 2, 2, None, shipped_with=(1,))])) - self.assertIn("- L, by review rounds past each pass's first and 🔴 findings: 1 chunk that shipped one item records L and both outcomes; the report needs 10.", report([outcome(1, 2, 2, None, levels={"L": 2}), outcome(2, 2, 2, None, levels={"L": 2}, findings=None)])) + too_few = report([outcome(1, 2, 2, None, levels={"L": 2, "E": 1, "I": 1}), outcome(2, 2, 2, None, levels={"L": 2}, findings=None)]) + for name in "LEI": + with self.subTest(name=name): + self.assertIn(f"- {name}, by review rounds past each pass's first and 🔴 findings: 1 chunk that shipped one item records {name} and both outcomes; the report needs 10.", too_few) + + def test_ranks_ties_by_their_mean_rank(self): + self.assertAlmostEqual(rank_correlation([1, 1, 2, 2, 2], [1, 2, 3, 4, 5]), 0.866, places=3) + self.assertAlmostEqual(rank_correlation([1, 1, 2, 3], [1, 2, 3, 4]), 0.949, places=3) def test_gives_how_well_l_e_and_i_each_order_chunks_by_review_rounds_and_red_findings(self): levels = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4] @@ -99,6 +106,9 @@ class Report(unittest.TestCase): class Render(unittest.TestCase): + def test_shows_an_items_l_e_and_i_before_its_r_and_s(self): + self.assertTrue(render(outcome(4, 3, 3, None, levels={"L": 2, "E": 2, "I": 1})).startswith("- Item 4, L 2, E 2, I 1, R 3, S 3:")) + def test_names_the_items_shipped_together_and_unknown_findings(self): self.assertEqual(render(outcome(4, 2, 3, None, lines=1, rounds=2, findings=None, shipped_with=(5, 6))), "- Item 4, R 2, S 3: 1 line in 1 file, 2 rounds past each pass's first, findings unknown; merged 2026-10-13T10:00:00Z in aaaaaaa, with items 5, 6. **Item 4.**") self.assertEqual(render(outcome(4, 2, 3, 4, findings=(1, 2))), "- Item 4, R 2, S 3, C 4: 10 lines in 1 file, 1 round past each pass's first, 1 🔴, 2 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 4.**") @@ -141,6 +151,11 @@ class ScoreOutcomesTool(unittest.TestCase): self.assertIn("- Item 4, R 2, S 3, C 10: 3 lines in 1 file, 0 rounds past each pass's first, 1 🔴, 2 🟡; merged ", ran.stdout) self.assertNotIn("Item 5", ran.stdout) + def test_takes_each_score_at_the_top_of_its_scale(self): + ran = self.run_tool("4", "3", "5", "10") + self.assertEqual(ran.returncode, 0, ran.stderr) + self.assertIn("Finished items nearest L 4, E 3, I 5, so R 10, and S 10, closest first:", ran.stdout) + def test_refuses_a_score_off_its_scale_or_a_missing_score(self): for args in (("5", "2", "3", "4"), ("2", "4", "3", "4"), ("2", "2", "6", "4"), ("2", "2", "3", "11"), ("0", "2", "3", "4"), ("2", "2", "3")): with self.subTest(args): diff --git a/bin/test_rank_todo.py b/bin/test_rank_todo.py index 12c06fe7..94af948c 100644 --- a/bin/test_rank_todo.py +++ b/bin/test_rank_todo.py @@ -261,6 +261,11 @@ class Risk(unittest.TestCase): item = next(item for item in todo_table.items(TODO) if item.id == 4) self.assertEqual((item.likelihood, item.escape_and_impact), (3, 8)) + def test_names_the_one_level_column_a_table_lacks(self): + without_i = TODO.replace("| E | I | R |", "| E | R |").replace("|---|---|---|---|---|---|---|---|---|---|---|---|", "|---|---|---|---|---|---|---|---|---|---|---|") + without_i = re.sub(r"(\*\* \| \d+ \| \d+) \| \d+ \|", r"\1 |", without_i) + self.assertEqual(self.ranked(without_i), Failure("todo.md's items table has no I column; add it, scoring each item's L, E and I as rank_todo.py --help shows")) + def test_asks_a_table_from_before_l_e_and_i_for_them_yet_reads_its_rows(self): before = TODO.replace("| L | E | I | R | S | Moves |", "| R | S | C | Moves |").replace("|---|---|---|---|---|---|---|---|---|---|---|---|", "|---|---|---|---|---|---|---|---|---|---|") before = re.sub(r"(\*\* \|) \d+ \| \d+ \| \d+ \| (\d+) \| (\d+) \|", r"\1 \2 | \3 | 3 |", before)