diff --git a/README.md b/README.md index d99cc059..4bbeac0c 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read, and the list prices, which `routing_figures` and `transcript_archive` read. - `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them. - `records/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, stamps times in UTC, and replaces a file in one step, private where it is new. -- `release_plan/` reads `todo.md`'s items table and release versions, says which release is next and whether it is ready to cut (`release_standing.py`), and ranks the plan (`ranking.py`, with its score formula in `formula.py` and its blocker order in `blockers.py`). `plan_file.py` reads, ranks, checks and writes a `todo.md`, for `larv_review`, `rank_todo.py`, `rule_hook` and `todo_item`. +- `release_plan/` reads `todo.md`'s items table and release versions, says which release is next and whether it is ready to cut (`release_standing.py`), and ranks the plan (`ranking.py`, with its score formula in `formula.py` and its blocker order in `blockers.py`). `goals_file.py` reads the goals file's sections, goals and goal weights, for the ranking and for `loop_claude`'s premises, and `citations.py` holds `todo.md` and `docs/decisions.md` to each other. `plan_file.py` reads, ranks, checks and writes a `todo.md`, for `larv_review`, `rank_todo.py`, `rule_hook` and `todo_item`. - `repo_checks/` tests the repo itself. - `review_rules/` holds the larv-review rules that several tools apply: its passes, its review folder, its round commit titles and the comprehension history's format. - `routing_figures/` measures loop-claude's archive, and each of its projects' default branches, for loop-claude's routing calls. diff --git a/bin/larv_review/plan.py b/bin/larv_review/plan.py index 486eca81..f3b3f599 100644 --- a/bin/larv_review/plan.py +++ b/bin/larv_review/plan.py @@ -4,7 +4,7 @@ from release_plan.release_standing import Cut, default_plan, held_at, LastCut, n from failure import Failure from larv_review.scoring import is_floor_item from release_plan.todo_table import Item, items, NoItemsTable, renames -from release_plan.ranking import OPTED_OUT +from release_plan.goals_file import OPTED_OUT from project_config.main import project from release_plan.release import Release, version from larv_review.unmeasured import unmeasured_cut diff --git a/bin/loop_claude/project/premises.py b/bin/loop_claude/project/premises.py index 35e9b976..15f9c3b4 100644 --- a/bin/loop_claude/project/premises.py +++ b/bin/loop_claude/project/premises.py @@ -3,7 +3,7 @@ import pathlib from failure import Failure from project_config.main import goals_file from loop_claude.project.text_file import read_utf8 -from records.markdown_text import sections +from release_plan.goals_file import section def read_premises(root: str, home: pathlib.Path) -> str | Failure: @@ -14,13 +14,10 @@ def read_premises(root: str, home: pathlib.Path) -> str | Failure: text = read_utf8(str(path.parent), path.name, "no premises") if isinstance(text, Failure): return text - found = sections(text) + bodies: list[str] = [] for name in ("Goals", "Audience"): - bodies = found.get(name, []) - if not bodies: - return Failure(f"{path} has no ## {name} heading - no premises.") - if len(bodies) > 1: - return Failure(f"{path} has ## {name} more than once - no premises.") - if not bodies[0]: - return Failure(f"{path} has no text under ## {name} - no premises.") - return f"{path}:\n## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}" + body = section(text, name) + if isinstance(body, Failure): + return Failure(f"{path} {body.reason} - no premises.") + bodies.append(body) + return f"{path}:\n## Goals\n{bodies[0]}\n\n## Audience\n{bodies[1]}" diff --git a/bin/release_plan/citations.py b/bin/release_plan/citations.py new file mode 100644 index 00000000..acd6d6e7 --- /dev/null +++ b/bin/release_plan/citations.py @@ -0,0 +1,23 @@ +"""Holds todo.md and docs/decisions.md to each other: every item a decision cites is in the plan and exempt from the bar, and every item marked decision is cited.""" + +import re + +from failure import Failure +from release_plan.todo_table import Item + + +def check_citations(items: list[Item], decisions: str) -> Failure | None: + """Holds todo.md and docs/decisions.md to each other: a cited item is exempt, a decision row is cited.""" + cited = set(cited_items(decisions)) + if gone := sorted(cited - {item.id for item in items}): + return Failure(f"docs/decisions.md cites \"`todo.md` item {gone[0]}\", which todo.md no longer holds; revise that decision to say what holds now") + for item in sorted(items, key=lambda item: item.id): + if item.id in cited and not item.exempt: + return Failure(f"docs/decisions.md cites \"`todo.md` item {item.id}\"; mark it decision, or another reason the bar does not apply") + if item.exempt == "decision" and item.id not in cited: + return Failure(f"item {item.id} is marked decision, but docs/decisions.md does not cite \"`todo.md` item {item.id}\"; cite it there, or mark it with another reason the bar does not apply") + return None + + +def cited_items(decisions: str) -> list[int]: + return [int(id_) for cited in re.findall(r"`todo\.md` items? (\d+(?:(?:, | and )\d+)*)", decisions) for id_ in re.findall(r"\d+", cited)] diff --git a/bin/release_plan/goals_file.py b/bin/release_plan/goals_file.py new file mode 100644 index 00000000..9ca09ae6 --- /dev/null +++ b/bin/release_plan/goals_file.py @@ -0,0 +1,90 @@ +"""The goals file, read once for everyone: its ## Goals and ## Audience sections, the goals ## Goals numbers and marks, and what each goal weighs.""" + +import decimal +import re +import typing + +from release_plan.todo_table import CODE_HEALTH +from failure import Failure +from review_rules.comprehension_history import FLOOR +from records.markdown_text import sections + +# What each achieve goal weighs of the one above it; docs/decisions.md records the choice. +GOAL_STEP = 0.97 +# Code health weighs this many times its weight by position while the comprehension panel's overall is under FLOOR, or unmeasured; lilleman's choice, which docs/decisions.md records. +UNDER_FLOOR = 4 +# Any **Void:** line of the goals file's ## Goals; ranked_goals accepts only `**Void:** code health, since .`, as ~/.claude/CLAUDE.md → "Shared goal" spells it. +VOID = re.compile(r"^\*\*Void:\*\* (.*)$", re.M) +# A docs/decisions.md title opting the project out of the comprehension check, as larv-review's SKILL.md → "Opt-out" spells it. +OPTED_OUT = re.compile(r"^## review opt-out:.*\bcomprehension check\b", re.M) +# How the goals file marks a goal; None where it marks it neither way. +Mark = typing.Literal["Maintain", "Achieve"] | None + + +def section(goals_text: str, name: str) -> str | Failure: + """The text under the goals file's one ## name heading. A Failure whose reason completes "the goals file ..." where the heading is missing or repeated, or holds no text.""" + bodies = sections(goals_text).get(name, []) + if not bodies: + return Failure(f"has no ## {name} heading") + if len(bodies) > 1: + return Failure(f"has ## {name} more than once") + return bodies[0] or Failure(f"has no text under ## {name}") + + +def ranked_goals(goals_text: str, decisions: str) -> list[tuple[str, Mark]] | Failure: + """Every goal in rank order, each with its mark: code health first, unless the goals file voids it, then the goals file's goals in reading order. A **Void:** line other than `**Void:** code health, since .` fails, and so does a docs/decisions.md that opts out of the comprehension check where the goals file keeps code health, since the goal then has no signal.""" + body = goals_section(goals_text) + if isinstance(body, Failure): + return body + goals = numbered(body) + if isinstance(goals, Failure): + return goals + voids = VOID.findall(body) + if other := [void for void in voids if not void.startswith(f"{CODE_HEALTH}, since ")]: + if other[0].lower().startswith(CODE_HEALTH): + return Failure(f"the goals file's ## Goals voids code health as `{other[0]}`; spell the void exactly `**Void:** {CODE_HEALTH}, since .`") + return Failure(f"the goals file's ## Goals voids `{other[0]}`; only code health may be voided, as `**Void:** {CODE_HEALTH}, since .`") + if voids: + return goals + if OPTED_OUT.search(decisions): + return Failure(f"docs/decisions.md opts out of the comprehension check, so code health has no signal; void it in the goals file's ## Goals with `**Void:** {CODE_HEALTH}, since .`, as ~/.claude/CLAUDE.md → 'Shared goal' says") + return [(CODE_HEALTH, "Achieve"), *goals] + + +def numbered_goals(goals_text: str) -> list[tuple[str, Mark]] | Failure: + """The goals file's goals in reading order: each one's number, a sub-goal as 4.1, and its mark, Maintain, Achieve or None.""" + body = goals_section(goals_text) + return body if isinstance(body, Failure) else numbered(body) + + +def goals_section(goals_text: str) -> str | Failure: + body = section(goals_text, "Goals") + return Failure(f"the goals file {body.reason}") if isinstance(body, Failure) else body + + +def numbered(body: str) -> list[tuple[str, Mark]] | Failure: + goals: list[tuple[str, Mark]] = [] + path: list[tuple[int, str]] = [] + for indent, position, mark in re.findall(r"^([ \t]*)(\d+)\. (?:\*\*(Maintain|Achieve):\*\*)?", body.expandtabs(4), re.M): + while path and path[-1][0] >= len(indent): + path.pop() + path.append((len(indent), position)) + goals.append((".".join(part for _, part in path), typing.cast(Mark, mark or None))) + numbers = [number for number, _ in goals] + if not goals: + return Failure("the goals file's ## Goals has no numbered goal") + if len(set(numbers)) < len(numbers): + return Failure(f"the goals file's ## Goals numbers {', '.join(numbers)}; number each goal by its position") + return goals + + +def goal_weights(goals: list[tuple[str, Mark]], overall: decimal.Decimal | None) -> dict[str, float] | Failure: + """Each achieve goal's weight: the one ranked k of n weighs GOAL_STEP ** (k - 1) / (1 + GOAL_STEP + ... + GOAL_STEP ** (n - 1)), so the weights sum to 1. Code health, where goals holds it, then weighs UNDER_FLOOR times that while the overall is under FLOOR or None, and the other goals keep their weights. Every weight is 0 where goals holds no achieve goal, as where the goals file voids code health and marks no goal **Achieve:**; an item then scores V 0 unless it names a maintain goal, and only an exempt one passes the bar. A maintain goal has no weight here: weight_of weighs it per item.""" + if unmarked := [number for number, mark in goals if mark is None]: + return Failure(f"the goals file's goal {unmarked[0]} is marked neither **Maintain:** nor **Achieve:**; mark it, as ~/.claude/rules/goals-and-audience.md says, so rank_todo.py knows which goals score") + achieve = [number for number, mark in goals if mark == "Achieve"] + total = sum(GOAL_STEP**rank for rank in range(len(achieve))) + weights = {number: GOAL_STEP**rank / total for rank, number in enumerate(achieve)} + if CODE_HEALTH in weights and (overall is None or overall < FLOOR): + weights[CODE_HEALTH] *= UNDER_FLOOR + return weights diff --git a/bin/release_plan/ranking.py b/bin/release_plan/ranking.py index bf5adab8..c9604c67 100644 --- a/bin/release_plan/ranking.py +++ b/bin/release_plan/ranking.py @@ -1,35 +1,26 @@ -"""Rank todo.md's items by the formula it states, weighing code health first and then the goals file's achieve goals by their position, and hold them to its bar; rank_todo.py --help states the rules. +"""Rank todo.md's items by the formula it states, weighing the goals as goals_file.py weighs them, and hold them to its bar; rank_todo.py --help states the rules. """ import ast import dataclasses -import decimal import math import re import typing from release_plan.todo_table import BLOCKED_BY, cells, CODE_HEALTH, DETAILS, Exempt, HEADER_START, Item, item_details, items_table, MOVES, OLD_SHAPE, parse_row, renames, risk, Shape, SHAPE, shape_of, Table, table_rows from release_plan.blockers import blocked_through, blockers_first +from release_plan.citations import check_citations from release_plan.formula import evaluate, parse_formula from failure import Failure -from review_rules.comprehension_history import FLOOR, latest_overall -from records.markdown_text import listed, sections +from release_plan.goals_file import goal_weights, Mark, ranked_goals +from review_rules.comprehension_history import latest_overall +from records.markdown_text import listed from release_plan.release import version -# What each achieve goal weighs of the one above it; docs/decisions.md records the choice. -GOAL_STEP = 0.97 -# Code health weighs this many times its weight by position while the comprehension panel's overall is under FLOOR, or unmeasured; lilleman's choice, which docs/decisions.md records. -UNDER_FLOOR = 4 # What a point of an item's move on a maintain goal is worth. A defect that restores the goal weighs it at least this much per point. docs/decisions.md records the choice and its data. MAINTAIN_WEIGHT = 0.5 -# Any **Void:** line of the goals file's ## Goals; ranked_goals accepts only `**Void:** code health, since .`, as ~/.claude/CLAUDE.md → "Shared goal" spells it. -VOID = re.compile(r"^\*\*Void:\*\* (.*)$", re.M) -# A docs/decisions.md title opting the project out of the comprehension check, as larv-review's SKILL.md → "Opt-out" spells it. -OPTED_OUT = re.compile(r"^## review opt-out:.*\bcomprehension check\b", re.M) WEIGHTS_HEADER = "| Goal | W |" # The Exempt reasons that rank ahead of the rest of their release, in this order: a question first, since its answer may change other items, then a security finding. FIRST: dict[Exempt, int] = {"question": 0, "security": 1} -# How the goals file marks a goal; None where it marks it neither way. -Mark = typing.Literal["Maintain", "Achieve"] | None RESHAPE = f"todo.md's items table is in the old shape, scoring A and G against goal weights todo.md states. Until todo.md has the shape rank_todo.py --help shows, reshaping it is the project's only work, as ~/.claude/CLAUDE.md → 'Working loop' says: mark the goals file's goals **Maintain:** or **Achieve:**, name each item's {MOVES}, score its L, E and I in place of C, and set the bar below the score of every item to keep" @@ -140,23 +131,6 @@ def read_scoring(text: str, lines: list[str], goals_text: str, decisions: str, h return Scoring(shape, formula, bar, int(next_id), dict(goals), weights) -def ranked_goals(goals_text: str, decisions: str) -> list[tuple[str, Mark]] | Failure: - """Every goal in rank order, each with its mark: code health first, unless the goals file voids it, then the goals file's goals in reading order. A **Void:** line other than `**Void:** code health, since .` fails, and so does a docs/decisions.md that opts out of the comprehension check where the goals file keeps code health, since the goal then has no signal.""" - goals = numbered_goals(goals_text) - if isinstance(goals, Failure): - return goals - voids = VOID.findall("".join(sections(goals_text).get("Goals", []))) - if other := [void for void in voids if not void.startswith(f"{CODE_HEALTH}, since ")]: - if other[0].lower().startswith(CODE_HEALTH): - return Failure(f"the goals file's ## Goals voids code health as `{other[0]}`; spell the void exactly `**Void:** {CODE_HEALTH}, since .`") - return Failure(f"the goals file's ## Goals voids `{other[0]}`; only code health may be voided, as `**Void:** {CODE_HEALTH}, since .`") - if voids: - return goals - if OPTED_OUT.search(decisions): - return Failure(f"docs/decisions.md opts out of the comprehension check, so code health has no signal; void it in the goals file's ## Goals with `**Void:** {CODE_HEALTH}, since .`, as ~/.claude/CLAUDE.md → 'Shared goal' says") - return [(CODE_HEALTH, "Achieve"), *goals] - - def weigh(lines: list[str], history: str, goals: list[tuple[str, Mark]], shape: Shape) -> dict[str, float] | Failure: """Each goal's weight. In OLD_SHAPE, the goals file's goals weigh what todo.md states, and code health has no weight, so no item may name it. Otherwise goal_weights gives each its weight, at the overall latest_overall reads where the goals hold code health.""" if shape is OLD_SHAPE: @@ -235,55 +209,6 @@ def outside_items(lines: list[str], table: Table) -> Failure | None: return None -def check_citations(items: list[Item], decisions: str) -> Failure | None: - """Holds todo.md and docs/decisions.md to each other: a cited item is exempt, a decision row is cited.""" - cited = set(cited_items(decisions)) - if gone := sorted(cited - {item.id for item in items}): - return Failure(f"docs/decisions.md cites \"`todo.md` item {gone[0]}\", which todo.md no longer holds; revise that decision to say what holds now") - for item in sorted(items, key=lambda item: item.id): - if item.id in cited and not item.exempt: - return Failure(f"docs/decisions.md cites \"`todo.md` item {item.id}\"; mark it decision, or another reason the bar does not apply") - if item.exempt == "decision" and item.id not in cited: - return Failure(f"item {item.id} is marked decision, but docs/decisions.md does not cite \"`todo.md` item {item.id}\"; cite it there, or mark it with another reason the bar does not apply") - return None - - -def numbered_goals(goals_text: str) -> list[tuple[str, Mark]] | Failure: - """The goals file's goals in reading order: each one's number, a sub-goal as 4.1, and its mark, Maintain, Achieve or None.""" - found = sections(goals_text).get("Goals", []) - if len(found) != 1: - return Failure(f"the goals file has ## Goals {len(found)} times; it needs it once") - goals: list[tuple[str, Mark]] = [] - path: list[tuple[int, str]] = [] - for indent, position, mark in re.findall(r"^([ \t]*)(\d+)\. (?:\*\*(Maintain|Achieve):\*\*)?", found[0].expandtabs(4), re.M): - while path and path[-1][0] >= len(indent): - path.pop() - path.append((len(indent), position)) - goals.append((".".join(part for _, part in path), typing.cast(Mark, mark or None))) - numbers = [number for number, _ in goals] - if not goals: - return Failure("the goals file's ## Goals has no numbered goal") - if len(set(numbers)) < len(numbers): - return Failure(f"the goals file's ## Goals numbers {', '.join(numbers)}; number each goal by its position") - return goals - - -def goal_weights(goals: list[tuple[str, Mark]], overall: decimal.Decimal | None) -> dict[str, float] | Failure: - """Each achieve goal's weight: the one ranked k of n weighs GOAL_STEP ** (k - 1) / (1 + GOAL_STEP + ... + GOAL_STEP ** (n - 1)), so the weights sum to 1. Code health, where goals holds it, then weighs UNDER_FLOOR times that while the overall is under FLOOR or None, and the other goals keep their weights. Every weight is 0 where goals holds no achieve goal, as where the goals file voids code health and marks no goal **Achieve:**; an item then scores V 0 unless it names a maintain goal, and only an exempt one passes the bar. A maintain goal has no weight here: weight_of weighs it per item.""" - if unmarked := [number for number, mark in goals if mark is None]: - return Failure(f"the goals file's goal {unmarked[0]} is marked neither **Maintain:** nor **Achieve:**; mark it, as ~/.claude/rules/goals-and-audience.md says, so rank_todo.py knows which goals score") - achieve = [number for number, mark in goals if mark == "Achieve"] - total = sum(GOAL_STEP**rank for rank in range(len(achieve))) - weights = {number: GOAL_STEP**rank / total for rank, number in enumerate(achieve)} - if CODE_HEALTH in weights and (overall is None or overall < FLOOR): - weights[CODE_HEALTH] *= UNDER_FLOOR - return weights - - -def cited_items(decisions: str) -> list[int]: - return [int(id_) for cited in re.findall(r"`todo\.md` items? (\d+(?:(?:, | and )\d+)*)", decisions) for id_ in re.findall(r"\d+", cited)] - - def stated(text: str, name: str) -> str | Failure: found = re.findall(rf"^`{name} = ([^`]+)`$", text, re.M) if len(found) != 1: diff --git a/bin/release_plan/test_ranking.py b/bin/release_plan/test_ranking.py index 5129408c..7247fb30 100644 --- a/bin/release_plan/test_ranking.py +++ b/bin/release_plan/test_ranking.py @@ -10,8 +10,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from project_config.test_project_config import configured from failure import Failure +from release_plan import goals_file, plan_file, ranking from project_config.main import located -from release_plan import plan_file, ranking from repo_checks import ROOT from release_plan import todo_table @@ -122,13 +122,13 @@ class Rank(unittest.TestCase): def test_weighs_each_achieve_goal_97_percent_of_the_one_above_and_no_maintain_goal(self): readme = "## Goals\n\n1. **Achieve:** A.\n 1. **Maintain:** B.\n 2. **Achieve:** C.\n2. **Achieve:** D.\n" - self.assertEqual({goal: round(weight, 4) for goal, weight in ranking.goal_weights(ranking.numbered_goals(readme), None).items()}, {"1": 0.3435, "1.2": 0.3332, "2": 0.3232}) + self.assertEqual({goal: round(weight, 4) for goal, weight in goals_file.goal_weights(goals_file.numbered_goals(readme), None).items()}, {"1": 0.3435, "1.2": 0.3332, "2": 0.3232}) def test_weighs_5_achieve_goals_from_0212_to_0188_and_15_from_0082_to_0053(self): for count, first, last in ((5, 0.212, 0.188), (15, 0.082, 0.053)): with self.subTest(count=count): - goals = ranking.numbered_goals("## Goals\n\n" + "".join(f"{number}. **Achieve:** G.\n" for number in range(1, count + 1))) - weights = list(ranking.goal_weights(goals, None).values()) + goals = goals_file.numbered_goals("## Goals\n\n" + "".join(f"{number}. **Achieve:** G.\n" for number in range(1, count + 1))) + weights = list(goals_file.goal_weights(goals, None).values()) self.assertEqual((round(weights[0], 3), round(weights[-1], 3), round(sum(weights), 6)), (first, last, 1)) def test_scores_an_item_by_the_weights_of_the_goals_it_moves(self): @@ -156,15 +156,15 @@ class Rank(unittest.TestCase): self.assertEqual(self.ranked(ranked.text.replace("| 2 | 0.1.0 | | |", "| 2 | 0.1.0 | | owner |")).under_bar, []) def test_reads_goals_and_sub_goals_in_reading_order(self): - self.assertEqual(ranking.numbered_goals(README), [("1", "Achieve"), ("2", "Maintain"), ("2.1", "Achieve")]) - self.assertEqual(ranking.numbered_goals(README.replace(" 1.", "\t1.")), [("1", "Achieve"), ("2", "Maintain"), ("2.1", "Achieve")]) - self.assertEqual(ranking.numbered_goals(README.replace("2. **Maintain:** Correct.", "```\n## Goals\n```\n2. Correct.")), [("1", "Achieve"), ("2", None), ("2.1", "Achieve")]) - self.assertEqual(ranking.numbered_goals(README.replace("2. **Maintain:**", "1. **Maintain:**")), Failure("the goals file's ## Goals numbers 1, 1, 1.1; number each goal by its position")) + self.assertEqual(goals_file.numbered_goals(README), [("1", "Achieve"), ("2", "Maintain"), ("2.1", "Achieve")]) + self.assertEqual(goals_file.numbered_goals(README.replace(" 1.", "\t1.")), [("1", "Achieve"), ("2", "Maintain"), ("2.1", "Achieve")]) + self.assertEqual(goals_file.numbered_goals(README.replace("2. **Maintain:** Correct.", "```\n## Goals\n```\n2. Correct.")), [("1", "Achieve"), ("2", None), ("2.1", "Achieve")]) + self.assertEqual(goals_file.numbered_goals(README.replace("2. **Maintain:**", "1. **Maintain:**")), Failure("the goals file's ## Goals numbers 1, 1, 1.1; number each goal by its position")) self.assertEqual(ranking.parse_weights(["| Goal | W |", "|---|---|"], ["1"]), Failure("the goal weights list no goal, but the goals file's goals are 1; by position they weigh:\n| Goal | W |\n|---|---|\n| 1 | 1.00 |")) - self.assertEqual(ranking.numbered_goals("# P\n"), Failure("the goals file has ## Goals 0 times; it needs it once")) - self.assertEqual(ranking.numbered_goals("## Goals\n\nFast.\n"), Failure("the goals file's ## Goals has no numbered goal")) + self.assertEqual(goals_file.numbered_goals("# P\n"), Failure("the goals file has no ## Goals heading")) + self.assertEqual(goals_file.numbered_goals("## Goals\n\nFast.\n"), Failure("the goals file's ## Goals has no numbered goal")) self.assertEqual(ranking.parse_weights(["| Goal | W |", "|---|---|", "| 1 | 0.5 |", "| 3 | 0.5 |"], ["1", "2"]), Failure("the goal weights list 1, 3, but the goals file's goals are 1, 2; by position they weigh:\n| Goal | W |\n|---|---|\n| 1 | 1.00 |\n| 2 | 0.50 |")) - self.assertEqual(ranking.numbered_goals("## Goals\n\n1. **Achieve:** A.\n 1. **Achieve:** B.\n\t2. **Achieve:** C.\n"), [("1", "Achieve"), ("1.1", "Achieve"), ("1.2", "Achieve")]) + self.assertEqual(goals_file.numbered_goals("## Goals\n\n1. **Achieve:** A.\n 1. **Achieve:** B.\n\t2. **Achieve:** C.\n"), [("1", "Achieve"), ("1.1", "Achieve"), ("1.2", "Achieve")]) def test_refuses_a_goal_it_cannot_weigh(self): cases = { diff --git a/bin/test_rank_todo.py b/bin/test_rank_todo.py index c1022dee..9a542673 100644 --- a/bin/test_rank_todo.py +++ b/bin/test_rank_todo.py @@ -9,8 +9,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) from project_config.test_project_config import configured from release_plan.test_ranking import DECISIONS, OLD_SHAPE, README, TODO +from release_plan import goals_file, ranking import rank_todo -from release_plan import ranking class Main(unittest.TestCase): @@ -109,6 +109,6 @@ class Main(unittest.TestCase): self.assertEqual(self.run_main("--fix"), (1, "rank_todo.py: cannot read the arguments --fix; usage: rank_todo.py [--check] [todo.md]\n")) def test_states_the_goal_weights_the_ranking_computes(self): - for figure in (ranking.GOAL_STEP, 0.212, 0.188, 0.082, 0.053): + for figure in (goals_file.GOAL_STEP, 0.212, 0.188, 0.082, 0.053): self.assertIn(str(figure), rank_todo.__doc__) - self.assertIn(f"While it is under {ranking.FLOOR}, or the history holds no scoring run, code health weighs {ranking.UNDER_FLOOR} times its weight by position, and the other goals keep theirs.", " ".join(rank_todo.__doc__.split())) + self.assertIn(f"While it is under {goals_file.FLOOR}, or the history holds no scoring run, code health weighs {goals_file.UNDER_FLOOR} times its weight by position, and the other goals keep theirs.", " ".join(rank_todo.__doc__.split()))