diff --git a/bin/rank_todo.py b/bin/rank_todo.py index 9bcb1197..8622c29b 100755 --- a/bin/rank_todo.py +++ b/bin/rank_todo.py @@ -53,8 +53,8 @@ A valid todo.md; ## Details and each item's detail are optional: loop. An ID at or above Next ID fails; one below it that the table no longer holds was finished or deleted, and is dropped. - ## Items holds the table and nothing else: an order goes in the scores or the Blocked by column. -- The table holds the columns above, a table from before Blocked by or C joined read by column name; - a column this version does not know fails, rather than be dropped. +- The table holds the columns above. A table without Blocked by gains it; one without C fails, and so + does a column this version does not know, rather than be dropped. Exit 1, saying why, on bad arguments, a file that cannot be read or written, a todo.md, README.md or docs/decisions.md that breaks the rules above, an item that is not exempt scoring under the bar, or @@ -191,6 +191,16 @@ def rank(text: str, readme: str, decisions: str) -> Ranked | Failure: return Ranked(ranked, under_bar) +def blocked_through(id_: int, items: list[Item]) -> set[int]: + """The IDs of the items id_ blocks, and of those they block in turn.""" + found: set[int] = set() + reached = {id_} + while reached: + reached = {other.id for other in items if reached.intersection(other.blocked_by)} - found + found |= reached + return found + + def ordered(items: list[Item], scoring: Scoring) -> list[tuple[Item, float]] | Failure: """Each item with its score, by release, then security first, then by score from highest, then by ID; then each blocker just above the first item it blocks.""" by_score = [] @@ -204,8 +214,8 @@ def ordered(items: list[Item], scoring: Scoring) -> list[tuple[Item, float]] | F def under_the_bar(item: Item, value: float, bar: float, items: list[Item]) -> str: - blocks = [str(other.id) for other in items if item.id in other.blocked_by] - blocked = f" and the items it blocks, {', '.join(blocks)}" if blocks else "" + blocks = [str(id_) for id_ in sorted(blocked_through(item.id, items))] + blocked = f" and the items it blocks, directly or through another, {', '.join(blocks)}" if blocks else "" return f"item {item.id} scores {value:.1f}, under the bar {bar:g}; delete it{blocked}, or mark it with a reason the bar does not apply" diff --git a/bin/test_rank_todo.py b/bin/test_rank_todo.py index 52dece8a..c9cf12bb 100644 --- a/bin/test_rank_todo.py +++ b/bin/test_rank_todo.py @@ -83,8 +83,8 @@ class Rank(unittest.TestCase): def test_names_each_item_under_the_bar_that_is_not_exempt(self): ranked = self.ranked(TODO.replace("`Bar = 9`", "`Bar = 11`")) self.assertEqual(ranked.under_bar, ["item 2 scores 10.3, under the bar 11; delete it, or mark it with a reason the bar does not apply"]) - blocking = self.ranked(TODO.replace("`Bar = 9`", "`Bar = 11`").replace("| 3 | 0.1.0 | |", "| 3 | 0.1.0 | 2 |")) - self.assertEqual(blocking.under_bar, ["item 2 scores 10.3, under the bar 11; delete it and the items it blocks, 3, or mark it with a reason the bar does not apply"]) + blocking = self.ranked(TODO.replace("`Bar = 9`", "`Bar = 11`").replace("| 3 | 0.1.0 | |", "| 3 | 0.1.0 | 2 |").replace("| 5 | 0.1.0 | |", "| 5 | 0.1.0 | 3 |")) + self.assertEqual(blocking.under_bar, ["item 2 scores 10.3, under the bar 11; delete it and the items it blocks, directly or through another, 3, 5, or mark it with a reason the bar does not apply"]) self.assertEqual(self.ranked(ranked.text.replace("| 2 | 0.1.0 | | |", "| 2 | 0.1.0 | | principle |")).under_bar, []) self.assertEqual(self.ranked(ranked.text.replace("| 2 | 0.1.0 | | |", "| 2 | 0.1.0 | | owner |")).under_bar, []) diff --git a/bin/todo_table.py b/bin/todo_table.py index 98fd93b5..173955de 100644 --- a/bin/todo_table.py +++ b/bin/todo_table.py @@ -103,7 +103,7 @@ def cells(row: str, count: int) -> list[str] | Failure: return found if len(found) == count else Failure(f"this row needs {count} cells: {row}") -def parse_row(row: str, columns: tuple[str, ...] = COLUMNS) -> Item | Failure: +def parse_row(row: str, columns: tuple[str, ...]) -> Item | Failure: """An item row under columns, every cell checked but the goals it cites.""" found = cells(row, len(columns)) if isinstance(found, Failure): diff --git a/docs/decisions.md b/docs/decisions.md index c4ce3f16..1c64659b 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -204,7 +204,7 @@ A model off the ladder routes nothing: claude runs it at the effort its settings The worker delegates a task only when it needs just the task's conclusion: a search or read across many files, or work independent enough to run in parallel. Edits, and whatever it must check line by line, stay in its own thread, since it would read a delegated diff again to check it. Measured over archived worker transcripts, subagent reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegated searches save the most context. It scores each delegated task's R and C as for an item, and `bin/subagent-rung` turns them into the Agent tool's model and effort, counted from the project's rung. The rule names both, because the Agent tool sets a subagent's effort only when instructions ask. `CLAUDE.md` states the rule, since it holds in every session. A task that proves too hard for the worker's rung goes one rung up instead: `routing: a worker hands a task one rung up`. -Because a model switch inside a session discards its prompt cache, the worker changes rung only as the chunk starts, after every second unfinished verdict, when the judge reports a taken-in item whose R + C picks a higher rung, or when the judge finds the escalation trigger a worker cites in asking for a higher rung (`routing: a worker whose run ends asking for a higher rung`). loop-claude routes on the first row of the next release in `todo.md`'s table that waits on nothing: on no question, and on no blocker that waits. Since the table holds each blocker above the items it blocks, and `todo.md` no other order (`todo.md: one table`), that row is the item the worker takes. An item it takes in besides lifts it once the judge reports that item, after the first cycle. +Because a model switch inside a session discards its prompt cache, the worker changes rung only as the chunk starts, after every second unfinished verdict, when the judge reports a taken-in item whose R + C picks a higher rung, or when the judge finds the escalation trigger a worker cites in asking for a higher rung (`routing: a worker whose run ends asking for a higher rung`). loop-claude routes on the first row of the next release in `todo.md`'s table that does not wait: an item waits while it is marked `question` or a blocker of it is still in the table. Since `todo.md` holds no order but its table's (`todo.md: one table`), that row is the item the worker takes. An item it takes in besides lifts it once the judge reports that item, after the first cycle. Valid while the index ranks these models, and while no newer model joins the catalog.