Answer principles round 1: 0 🔴, 1 🟡 (0 misread); test the trials' imports from bin, pass one loop value through loop/, type the Exempt reasons
CI / tests (pull_request) Successful in 2m20s

This commit is contained in:
2026-11-10 22:20:48 +01:00
parent ce941388a2
commit 12d70586ed
21 changed files with 216 additions and 116 deletions
+16 -9
View File
@@ -13,7 +13,9 @@ LEVELS = {"L": 4, "E": 3, "I": 5}
RISK_FLOOR = {4: 5, 5: 7}
# The highest R an item may have and still share a chunk; `docs/decisions.md` → `chunks:` says why 5.
BUNDLE_MAX_R = 5
EXEMPTIONS = ("", "decision", "defect", "owner", "principle", "question", "security")
# What an Exempt cell may hold: empty, or a reason ~/.claude/rules/todo-items.md defines.
Exempt = typing.Literal["", "decision", "defect", "owner", "principle", "question", "security"]
EXEMPTIONS: tuple[Exempt, ...] = typing.get_args(Exempt)
# The column naming the items that block an item: each must be done before the item starts.
BLOCKED_BY = "Blocked by"
# The column naming each achieve goal an item moves and how far, such as `1.1 by 8, 1.2 by 5`.
@@ -94,7 +96,7 @@ OLD_SHAPE = Shape(("R", "S", "C", "A", "G"), (BLOCKED_BY, "C", "Score"), (), (),
class Item:
id: int
release: Release
exempt: str
exempt: Exempt
tagline: str
scores: dict[str, int]
moves: Moves
@@ -263,8 +265,9 @@ def parse_row(row: str, table: Table) -> Item | Failure:
if isinstance(found, Failure):
return found
named = dict(zip(table.columns, found))
if misformed := check_cells(row, named):
return misformed
exempt = check_cells(row, named)
if isinstance(exempt, Failure):
return exempt
shape = shape_of(table.columns)
scores = parse_scores(named["ID"], {name: cell for name, cell in named.items() if cell or name not in shape.derived}, shape.score_columns)
if isinstance(scores, Failure):
@@ -275,21 +278,25 @@ def parse_row(row: str, table: Table) -> Item | Failure:
moves = shape.read_goals(named["ID"], named[shape.goals_column])
if isinstance(moves, Failure):
return moves
return Item(int(named["ID"]), release_of(named["Release"]), named["Exempt"], named["Item"], scores, moves, blocked_by)
return Item(int(named["ID"]), release_of(named["Release"]), exempt, named["Item"], scores, moves, blocked_by)
def check_cells(row: str, named: dict[str, str]) -> Failure | None:
"""Holds the row's ID, Release, Exempt and Item cells to the format: why one breaks it, None when none does."""
def is_exempt(cell: str) -> typing.TypeGuard[Exempt]:
return cell in EXEMPTIONS
def check_cells(row: str, named: dict[str, str]) -> Exempt | Failure:
"""Holds the row's ID, Release, Exempt and Item cells to the format: the row's Exempt cell, or why a cell breaks it."""
id_, release, exempt, tagline = named["ID"], named["Release"], named["Exempt"], named["Item"]
if not re.fullmatch(r"[0-9]+", id_) or int(id_) < 1:
return Failure(f"the ID {id_!r} is not a positive whole number: {row}")
if parsed(release) is None:
return Failure(f"item {id_}'s release {release!r} is not a semver version")
if exempt not in EXEMPTIONS:
if not is_exempt(exempt):
return Failure(f"item {id_}'s Exempt {exempt!r} is not empty or one of {', '.join(EXEMPTIONS[1:])}")
if not re.fullmatch(r"\*\*[^*].*[^*]\*\*", tagline):
return Failure(f"item {id_}'s Item cell is not one bold tagline: {tagline}")
return None
return exempt
def parse_scores(id_: str, named: dict[str, str], names: tuple[str, ...]) -> dict[str, int] | Failure: