Weigh each achieve goal 0.97 times the one above it, so a goal far down a project's list counts almost as much as its first

This commit is contained in:
2026-10-18 11:17:32 +02:00
parent 0462980bd4
commit 80a90a803e
6 changed files with 221 additions and 214 deletions
+9 -6
View File
@@ -38,9 +38,10 @@ A valid todo.md; ## Details and each item's detail are optional:
- The formula holds numbers, + - * / ** and parentheses over L, E, I, R, S and V.
- V sums, over the goals in an item's Moves cell, each goal's weight times how far the item moves it.
README.md marks each goal **Maintain:** or **Achieve:**. The one ranked k of n achieve goals, in
reading order, a sub-goal such as 1.1 included, weighs (1/k) / (1 + 1/2 + ... + 1/n). Only an item
marked defect may name a maintain goal, the one it restores, which weighs as the heaviest achieve
goal.
reading order, a sub-goal such as 1.1 included, weighs 0.97 times the one ranked k - 1, and the
weights sum to 1: with 5 achieve goals the first weighs 0.212 and the last 0.188, with 15, 0.082
and 0.053. Only an item marked defect may name a maintain goal, the one it restores, which weighs
as the heaviest achieve goal.
- The bar is judged on the Score as shown, to one decimal.
- A new item takes Next ID, and Next ID then goes up by one; every ID stays below it.
- An item's L, E and I are levels that ~/.claude/rules/todo-items.md defines: L from 1 to 4, E from 1
@@ -86,6 +87,8 @@ from failure import Failure
from markdown_text import listed, sections
from file_writes import replace_file
# Each achieve goal weighs this much of the one above it, so a goal far down the list still counts almost as much as the first (lilleman, 2026-10-18).
GOAL_STEP = 0.97
LARGEST_FORMULA = 200
LONGEST_FORMULA = 4 * LARGEST_FORMULA
OPERATORS = (ast.Add, ast.BinOp, ast.Div, ast.Expression, ast.Load, ast.Mult, ast.Pow, ast.Sub, ast.UAdd, ast.UnaryOp, ast.USub)
@@ -430,12 +433,12 @@ def readme_goals(readme: str) -> list[tuple[str, Mark]] | Failure:
def goal_weights(goals: list[tuple[str, Mark]]) -> dict[str, float] | Failure:
"""Each achieve goal's sum-reciprocal weight: the one ranked k of n in reading order weighs (1/k) / (1 + 1/2 + ... + 1/n). Each maintain goal weighs as the heaviest achieve goal, since a broken one outranks any achieve goal; only a defect that restores it may name it. Every weight is 0 where README.md marks no goal **Achieve:**, so every item scores V 0 and only an exempt one passes the bar."""
"""Each achieve goal's weight: the one ranked k of n in reading order weighs GOAL_STEP ** (k - 1) / (1 + GOAL_STEP + ... + GOAL_STEP ** (n - 1)), so the weights sum to 1. Each maintain goal weighs as the heaviest achieve goal, since a broken one outranks any achieve goal; only a defect that restores it may name it. Every weight is 0 where README.md marks no goal **Achieve:**, so every item scores V 0 and only an exempt one passes the bar."""
if unmarked := [number for number, mark in goals if mark is None]:
return Failure(f"README.md'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"]
harmonic = sum(1 / rank for rank in range(1, len(achieve) + 1))
weights = {number: 1 / rank / harmonic for rank, number in enumerate(achieve, 1)}
total = sum(GOAL_STEP**rank for rank in range(len(achieve)))
weights = {number: GOAL_STEP**rank / total for rank, number in enumerate(achieve)}
heaviest = max(weights.values(), default=0.0)
return weights | {number: heaviest for number, mark in goals if mark == "Maintain"}