diff --git a/bin/chunk_preflight/choices.py b/bin/chunk_preflight/choices.py index 0e0e0f21..db531dff 100644 --- a/bin/chunk_preflight/choices.py +++ b/bin/chunk_preflight/choices.py @@ -5,7 +5,7 @@ import re from chunk_pick import chunk_item, Cut, Finished, LastCut, Unknown, Unplanned from failure import Failure from chunk_preflight.gathered import Forge, NoItem, Plan -from todo_table import item_details, items, version +from todo_table import item_details, items, NoItemsTable, version # The command each forge's CLI lists pull requests with; pulls_command adds the flags that pick their rows and fields. PULLS_LIST: dict[Forge, tuple[str, ...]] = {"gh": ("gh", "pr", "list"), "tea": ("tea", "pulls", "list")} @@ -17,10 +17,10 @@ def planned(todo: str | Failure, cut: LastCut, default: str) -> Plan | NoItem: if isinstance(todo, Failure): return NoItem(f"{where} cannot be read: {todo.reason}.") found = items(todo) + if isinstance(found, NoItemsTable): + return NoItem(f"{where} holds no items table.") if isinstance(found, Failure): return NoItem(f"{where} cannot be read: {found.reason}.") - if found is None: - return NoItem(f"{where} holds no items table.") pick = chunk_item(found, cut) if isinstance(pick, Cut): return NoItem(f"{where} files items under release {version(pick.release)}, which is not after the last cut, {cut.tag}; ask the human which release they belong to.") diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index 2c6d3830..9aa3a59f 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -417,6 +417,7 @@ class Plans(unittest.TestCase): without = planned("", CUT, "origin/main").why self.assertIn("origin/main", without) self.assertIn("no items table", without) + self.assertNotIn("cannot be read", without) empty = planned(EMPTY, LastCut(None, "", 4, []), "origin/main").why self.assertIn("holds no item", empty) self.assertNotIn("no items table", empty) diff --git a/bin/larv_review/plan.py b/bin/larv_review/plan.py index b8e69753..7f2e070c 100644 --- a/bin/larv_review/plan.py +++ b/bin/larv_review/plan.py @@ -3,7 +3,7 @@ import pathlib from larv_review.git import committed_since_release from failure import Failure from git_repo import file_at, top -from todo_table import Item, items, renames, version +from todo_table import Item, items, NoItemsTable, renames, version def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], landed: bool, renamed: set[tuple[int, int, int]]) -> list[str] | Failure: @@ -44,11 +44,13 @@ def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure: except (OSError, UnicodeDecodeError) as failure: return Failure(f"could not read todo.md: {failure}") # While a chunk reshapes todo.md into one table, the default branch's todo.md has no items table. - planned = items(before) or [] + planned = items(before) + if isinstance(planned, NoItemsTable): + planned = [] if isinstance(planned, Failure): return Failure(f"{default}'s todo.md: {planned.reason}") chunk = items(after) - if chunk is None: + if isinstance(chunk, NoItemsTable): return Failure("the checkout's todo.md has no items table; rank_todo.py --help shows one") if isinstance(chunk, Failure): return Failure(f"the checkout's todo.md: {chunk.reason}") diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 01312543..a0ff2aa3 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -16,7 +16,7 @@ import comprehension_history from larv_review.ruling import counted, ruling, split, votes from failure import Failure from test_env import isolated_env -from todo_table import Item, items +from todo_table import Item, items, NoItemsTable from larv_review.scoring import means, under_floor from larv_review.ruling_base import measured_commit from larv_review.seats import score_line, scores, seats_file @@ -260,7 +260,8 @@ class Base(unittest.TestCase): class ScoringRunDue(unittest.TestCase): def test_reads_each_rows_id_release_and_tagline(self): self.assertEqual(items(todo("| 3 | 0.1.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |")), [item(3, (0, 1, 0))]) - self.assertIsNone(items("# todo\n")) + self.assertEqual(items("# todo\n"), NoItemsTable("todo.md holds no items table")) + self.assertIsInstance(items("# todo\n"), Failure) self.assertIsInstance(items(todo("| 0 | 0.1.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |")), Failure) def test_is_due_for_an_item_naming_the_floor(self): diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index c4ef6aaf..d790377c 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -4,7 +4,7 @@ import dataclasses from chunk_pick import chunk_item, LastCut, Next from model_routing.ladder import climbed, highest, LADDER, position, project_rung, review_floor, Rung, stepped_up, worker_rung from failure import Failure -from todo_table import Item, items +from todo_table import Item, items, NoItemsTable from model_routing.route import Route UNFINISHED_PER_STEP = 2 @@ -17,9 +17,11 @@ JUDGE_REPLAYED = ("claude-opus-5-5",) def routed_item(todo: str, cut: LastCut) -> Item | Failure | None: """The item chunk_pick.chunk_item picks from todo.md, weighed against the last cut; None when there is none, or it lacks L, E or I.""" found = items(todo) + if isinstance(found, NoItemsTable): + return None if isinstance(found, Failure): return found - pick = chunk_item(found or [], cut) + pick = chunk_item(found, cut) takes = pick.item if isinstance(pick, Next) else None return takes if takes and takes.likelihood and takes.escape_and_impact else None diff --git a/bin/todo_table.py b/bin/todo_table.py index 60359791..b70513d3 100644 --- a/bin/todo_table.py +++ b/bin/todo_table.py @@ -133,10 +133,17 @@ def shape_of(columns: tuple[str, ...]) -> Shape: return OLD_SHAPE if MOVES not in columns and {"A", "G", OLD_SHAPE.goals_column}.intersection(columns) else SHAPE -def items(todo: str) -> list[Item] | None | Failure: - """Each row of a todo.md's items table; None where todo.md holds no items table.""" +@dataclasses.dataclass(frozen=True) +class NoItemsTable(Failure): + """todo.md holds no items table. A table with no rows is not a NoItemsTable: items returns an empty list for it.""" + + +def items(todo: str) -> list[Item] | Failure: + """Each row of a todo.md's items table; a NoItemsTable where todo.md holds none.""" table = items_table(todo.splitlines()) - if table is None or isinstance(table, Failure): + if table is None: + return NoItemsTable("todo.md holds no items table") + if isinstance(table, Failure): return table found = [] for row in table.rows: diff --git a/docs/reading-cost.md b/docs/reading-cost.md index f450faad..48593fc8 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -721,3 +721,16 @@ Read most (opens and searches): Read most (opens and searches): - `rules/todo-items.md` 1 + +## Reading cost, chunk b4afdc174f9a, finished 2026-10-21T22:28:38Z + +151079 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/model_routing/ladder.py` 2 +- `bin/score_outcomes/main.py` 2 +- `todo.md` 2 +- `bin/routing_figures/measure.py` 1 +- `bin/score_outcomes/outcomes.py` 1 +- `docs/decisions.md` 1 diff --git a/todo.md b/todo.md index e1b0524b..47d6b893 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 117 | 0.4.0 | | | **Give `todo_table.items` one way to say a plan has no items table, so no caller tells it from an empty plan by truthiness.** | 1 | 1 | 3 | 3 | 2 | code health by 4, 1.4 by 4 | 29.2 | | 126 | 0.4.0 | | | **State when work has landed towards a release once, in `bin/larv_review/plan.py`, and have larv-review's help point to it.** | 1 | 2 | 1 | 2 | 2 | code health by 4, 1.4 by 4 | 29.2 | | 131 | 0.4.0 | | | **Describe the transcript archive's layout in `bin/transcript_archive/`, which owns it, and have loop-claude's help point there.** | 1 | 2 | 1 | 2 | 2 | code health by 4, 1.4 by 4 | 29.2 | | 133 | 0.4.0 | | | **Show, beside `bin/rule_hook/override_log.py`'s `this_chunks`, one example per case it decides: an amended or rebased commit, a renamed branch, and a commit on the default branch.** | 1 | 2 | 1 | 2 | 2 | code health by 4, 1.4 by 4 | 29.2 | @@ -88,10 +87,6 @@ ## Details -### 117. Give `todo_table.items` one way to say a plan has no items table, so no caller tells it from an empty plan by truthiness. - -The comprehension seats on PR #254 found `items` returning a list, None or a Failure, and `larv_review/plan.py` `plan_reasons` reading None through `items(before) or []`, which works only because a Failure is truthy. - ### 126. State when work has landed towards a release once, in `bin/larv_review/plan.py`, and have larv-review's help point to it. Two seats of PR #257's scoring run named `bin/larv_review/plan.py:9` `scoring_run_due`. It reads the default branch's plan and the chunk's together, and the landed rule is written twice: in its docstring and in `bin/larv_review/main.py`'s help. Make `scoring_run_due` easier to read.