Answer stability round 1: 0 🔴, 4 🟡; test a move of ten, a variable base and each new message, keep a nan through **, score V 0 without an achieve goal

This commit is contained in:
2026-10-16 00:53:09 +02:00
parent 11f4c5ab17
commit c184c7f650
2 changed files with 22 additions and 9 deletions
+8 -6
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Score todo.md's items by the formula it states, weighing each goal by its rank in README.md, and hold them to its bar.
"""Score todo.md's items by the formula it states, weighing each achieve goal by its rank in README.md, and hold them to its bar.
usage: rank_todo.py [--check] [todo.md]
@@ -83,7 +83,7 @@ OPERATORS = (ast.Add, ast.BinOp, ast.Div, ast.Expression, ast.Load, ast.Mult, as
WEIGHTS_HEADER = "| Goal | W |"
# How README.md marks a goal; None where it marks it neither way.
Mark = typing.Literal["Maintain", "Achieve"] | None
RESHAPE = f"the items table scores A and G against goal weights todo.md states, the shape before {MOVES}; reshaping it to the shape rank_todo.py --help shows, after marking README.md's goals **Maintain:** or **Achieve:**, is a chunk of its own"
RESHAPE = f"the items table scores A and G against goal weights todo.md states, the shape before {MOVES}; reshaping it to the shape rank_todo.py --help shows, after marking README.md's goals **Maintain:** or **Achieve:** and setting the bar on the new scale under every item to keep, is a chunk of its own"
@dataclasses.dataclass(frozen=True)
@@ -403,12 +403,10 @@ def readme_goals(readme: str) -> list[tuple[str, Mark]] | Failure:
def achieve_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 achieve goal's sum-reciprocal weight: the one ranked k of n in reading order weighs (1/k) / (1 + 1/2 + ... + 1/n). None 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"]
if not achieve:
return Failure("README.md marks no goal **Achieve:**, so no item can score; ~/.claude/rules/goals-and-audience.md says how to mark the goals to pursue")
harmonic = sum(1 / rank for rank in range(1, len(achieve) + 1))
return {number: 1 / rank / harmonic for rank, number in enumerate(achieve, 1)}
@@ -468,8 +466,12 @@ def evaluate(node: ast.AST, values: dict[str, float]) -> float:
return evaluate(left, values) / divisor if divisor else math.nan
case ast.BinOp(left, ast.Pow(), right):
# Caught in place of checking first: a negative base with a fractional exponent, zero to a negative power and an overflow each raise, and three checks would read worse than one catch.
base, exponent = evaluate(left, values), evaluate(right, values)
# A nan from a zero divisor stays nan, though math.pow(1, nan) and math.pow(nan, 0) give 1.
if math.isnan(base) or math.isnan(exponent):
return math.nan
try:
return math.pow(evaluate(left, values), evaluate(right, values))
return math.pow(base, exponent)
except (OverflowError, ValueError):
return math.nan
return math.nan