diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d761d7..20c94658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ - `rule-hook` refuses an Agent call that launches a reviewer, a comprehension seat or the security pass on a rung below the one `loop-claude` names for it, and takes no override: pass the model and effort the refusal names. - `score-outcomes` lists a project's score anchors: the shipped items its `docs/score-anchors.md` names for each level of L, E and I, each with what its chunk measured. `rules/todo-items.md` has a scorer compare a new item with them, and says how to choose two or three per level. Add the file to each project that merges with merge commits; elsewhere, score by the level descriptions in `rules/todo-items.md`. - `loop-claude` archives each judge reply it rejects in the chunk's `.outcomes.md`, with the reason and the reply as json. Before, such a reply reached only stderr, so a run that exited 1 overnight could not say what the judge had returned. stderr now prints only the reason; the reply is in outcomes.md. If archiving fails, `loop-claude` exits 1. -- The new `bin/chunk-preflight` finds a chunk's mechanical facts and makes its worktree, `-item-` beside the checkout on the branch `item-`, or continues the one already there. Before it routes each chunk, `loop-claude` runs it and quotes what it printed in the worker's first prompt. The preflight fetches origin and reads `todo.md` from its default branch, leaving the checkout as it is, and `loop-claude` routes on that same `todo.md`, so an edit to `todo.md` routes a chunk only once the default branch holds it. Its facts name the last release and the unreleased changes, the next item with its L, E + I and detail, the items that may join its chunk, the files the item names, the open pull requests, and what `rank_todo.py --check`, `larv-review needs-scoring-run`, `reading-cost` and `larv-review places` print. Where `todo.md` holds no item for the release after the newest tag, it names no item, and says that release is finished and ready to cut, or is to be planned first. It stops a fetch, forge CLI or tool still running after 60 seconds, or after the seconds `CHUNK_PREFLIGHT_TIMEOUT` sets. Expect the worker to start editing sooner, and `docs/reading-cost.md` to hold an uncommitted figure in the new worktree for the chunk to commit. The prompt also asks the worker to count the item's size again once it has read the code, and to have the item re-scored where its L would change. +- The new `bin/chunk-preflight` finds a chunk's mechanical facts and makes its worktree, `-item-` beside the checkout on the branch `item-`, or continues the one already there. Before it routes each chunk, `loop-claude` runs it and quotes what it printed in the worker's first prompt. The preflight fetches origin and reads `todo.md` from its default branch, leaving the checkout as it is, and `loop-claude` routes on that same `todo.md`, so an edit to `todo.md` routes a chunk only once the default branch holds it. Its facts name the last release and the unreleased changes, the next item with its L, E + I and detail, the items that may join its chunk, the files the item names, the open pull requests, and what `rank_todo.py --check`, `larv-review needs-scoring-run`, `reading-cost` and `larv-review places` print. Where `todo.md` holds no item for the next release, the earliest it has named since the newest tag, it names no item and `loop-claude` routes on none; it says that release is finished and ready to cut where work has landed since the tag, or else is to be planned first. It stops a fetch, forge CLI or tool still running after 60 seconds, or after the seconds `CHUNK_PREFLIGHT_TIMEOUT` sets. Expect the worker to start editing sooner, and `docs/reading-cost.md` to hold an uncommitted figure in the new worktree for the chunk to commit. The prompt also asks the worker to count the item's size again once it has read the code, and to have the item re-scored where its L would change. ## 0.1.0 diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index 76ad7d95..8a6af2aa 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -1,20 +1,20 @@ """The lines the preflight prints, stated from what it gathered.""" -from todo_table import bundle_candidates, Item +from todo_table import bundle_candidates, Item, LastCut, unreleased_entries from failure import Failure -from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, PULLS_LIST, Ran, Release, version -from markdown_text import quoted, sections +from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, PULLS_LIST, Ran, version +from markdown_text import quoted def render(found: Gathered) -> list[str]: """One `- ` line per fact, then the item's tagline and detail, and what each tool printed.""" note = [f"- {found.note}"] if found.note else [] - head = [*note, f"- {last_release(found.default, found.release)}"] + head = [*note, f"- {last_release(found.default, found.cut)}"] if isinstance(found.item, NoItem): return [*head, f"- No plan item: {found.item.why} No worktree was made."] return [*head, *item_lines(found.default, found.item)] -def last_release(default: str, release: Release) -> str: +def last_release(default: str, release: LastCut) -> str: if isinstance(release.tag, Failure): return f"Last version cut: cannot be read: {release.tag.reason}" cut = f"Last version cut: {release.tag or 'none'}." @@ -27,12 +27,6 @@ def last_release(default: str, release: Release) -> str: return f"{cut} Unreleased: {commits}; {changelog}." -def unreleased_entries(changelog: str) -> int | None: - """How many top-level `- ` entries CHANGELOG.md holds under ## Unreleased; None without that section.""" - found = sections(changelog).get("Unreleased") - return None if found is None else sum(line.startswith("- ") for line in found[0].splitlines()) - - def item_lines(default: str, item: ItemFacts) -> list[str]: first = item.plan.first worktree = item.worktree.reason if isinstance(item.worktree, Failure) else f"{item.worktree.path}, {item.worktree.how}" diff --git a/bin/chunk_preflight/gathered.py b/bin/chunk_preflight/gathered.py index f7bc8786..2b582b66 100644 --- a/bin/chunk_preflight/gathered.py +++ b/bin/chunk_preflight/gathered.py @@ -4,7 +4,7 @@ import pathlib import re import typing -from todo_table import chunk_item, Item, item_details, items +from todo_table import chunk_item, Item, item_details, items, LastCut from failure import Failure # The CLI that lists a forge's pull requests: gh for a github.com origin, tea for any other. @@ -21,15 +21,6 @@ class Ran: stderr: str -@dataclasses.dataclass(frozen=True) -class Release: - """What the last release fact rests on, each read from the default branch.""" - tag: str | None | Failure - changelog: str | Failure - # How many commits follow the tag, or make up the branch where it has none. - commits: int | Failure - - @dataclasses.dataclass(frozen=True) class Plan: """The default branch's todo.md items, and first, the item the next chunk takes first.""" @@ -85,12 +76,12 @@ class Gathered: default: str # Why origin reads as last fetched; None after a fetch. note: str | None - release: Release + cut: LastCut # What was found or made for the plan's first item; else why the plan names none. item: ItemFacts | NoItem -def planned(todo: str | Failure, release: Release, default: str) -> Plan | NoItem: +def planned(todo: str | Failure, cut: LastCut, default: str) -> Plan | NoItem: """The plan in todo, the default branch's todo.md, with the item the next chunk takes first, todo_table.chunk_item's pick, which routing makes too; else why there is none.""" where = f"{default}'s todo.md" if isinstance(todo, Failure): @@ -101,16 +92,16 @@ def planned(todo: str | Failure, release: Release, default: str) -> Plan | NoIte if found is None: return NoItem(f"{where} holds no items table.") earliest = min((item.release for item in found), default=None) - stands, first = chunk_item(found, release.tag, release.commits) + stands, first = chunk_item(found, cut) if earliest is not None and stands == "cut": - return NoItem(f"{where} files items under release {version(earliest)}, which is not after the last cut, {release.tag}.") - gap = f"{where} holds no item for the release after the last cut, {release.tag}, and" + return NoItem(f"{where} files items under release {version(earliest)}, which is not after the last cut, {cut.tag}.") + gap = f"{where} holds no item for the next release after the last cut, {cut.tag}, and" if stands == "finished": - return NoItem(f"{gap} commits have landed since, so that release is finished and ready to cut, and the working loop stops here.") + return NoItem(f"{gap} work has landed since, so that release is finished and ready to cut, and the working loop stops here.") if stands == "unplanned": - return NoItem(f"{gap} no commit has landed since, so that release is to be planned first.") + return NoItem(f"{gap} no work has landed since, so that release is to be planned first.") if stands == "unknown": - return NoItem(f"{gap} the commits since it cannot be counted.") + return NoItem(f"{gap} the work landed since it cannot be counted.") if first is None: return NoItem(f"every item of release {version(earliest)} in {where} waits." if earliest is not None else f"{where}'s items table holds no item.") details = item_details(todo) diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index cc0bc3ee..844ff872 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -12,10 +12,11 @@ that branch holds it, the plan loop-claude routes on, and prints: holds under ## Unreleased, or else how many commits followed the tag; - the earliest release in todo.md, and that release's first item that does not wait, the item loop-claude routes on, with its L and E + I. It names that item only where the tag names no - version x.y.z, or the release is x.y.z+1, x.y+1.0 or x+1.0.0. For a later release, or a todo.md - that holds no item, it says the release after the tag holds none: finished and ready to cut where - commits followed the tag, and else to be planned first. For x.y.z or an earlier release, it says - todo.md files items under a release already cut; + version x.y.z, or the release is the earliest after x.y.z that todo.md has named at the tag or + since: the next release. Where the next release holds no item, it says so: finished and ready to + cut where work landed since the tag, counted as the ## Unreleased entries or else the commits, and + else to be planned first. For x.y.z or an earlier release, it says todo.md files items under a + release already cut; - the item's worktree: a sibling of the checkout named -item-, on the branch item-. It continues a worktree already on that branch; else it adds one on the local branch, else on a new branch tracking origin's, else on a new branch off the default branch; @@ -46,7 +47,7 @@ import typing from git_repo import commit_exists, default_branch, default_plan, file_at, git, top from failure import Failure -from chunk_preflight.gathered import Forge, forge_of, Gathered, ItemFacts, named_paths, NamedPath, NoItem, Plan, planned, pulls_command, Ran, Release, Worktree, worktree_add, worktree_on +from chunk_preflight.gathered import Forge, forge_of, Gathered, ItemFacts, named_paths, NamedPath, NoItem, Plan, planned, pulls_command, Ran, Worktree, worktree_add, worktree_on from chunk_preflight.facts import render BIN = pathlib.Path(__file__).resolve().parents[1] @@ -96,13 +97,10 @@ def preflight(root: pathlib.Path, timeout: float) -> list[str] | Failure: if isinstance(default, Failure): return default ref, note = default - held = default_plan(str(root), timeout) - if isinstance(held, Failure): - return held - cut = Release(held.tag, file_at(ref, "CHANGELOG.md", str(root)), held.commits) - plan = planned(held.todo, cut, ref) + held = default_plan(str(root), ref) + plan = planned(held.todo, held.cut, ref) item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout) - return render(Gathered(ref, note, cut, item)) + return render(Gathered(ref, note, held.cut, item)) def item_facts(root: pathlib.Path, default: str, plan: Plan, timeout: float) -> ItemFacts: diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index 48a641a6..dc785be4 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -9,10 +9,11 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure -from chunk_preflight.gathered import forge_of, Gathered, ItemFacts, named_paths, NamedPath, NoItem, planned, Ran, Release, Worktree, worktree_add +from chunk_preflight.gathered import forge_of, Gathered, ItemFacts, named_paths, NamedPath, NoItem, planned, Ran, Worktree, worktree_add from test_env import isolated_env +from todo_table import LastCut, unreleased_entries from chunk_preflight.main import line_count, ran, seconds, TIMEOUT -from chunk_preflight.facts import open_pulls, render, unreleased_entries +from chunk_preflight.facts import open_pulls, render BIN = pathlib.Path(__file__).resolve().parents[1] README = "# Project\n\n## Goals\n\n1. **Achieve:** Work.\n\n## Audience\n\nMe.\n" @@ -51,7 +52,7 @@ LATER = TODO[:TODO.index("| 5 |")] + "| 9 | 0.3.0 | | | **Do a later thing.** EMPTY = TODO[:TODO.index("| 5 |")] CHANGELOG = "# Changelog\n\n## Unreleased\n\n- One.\n - A nested line.\n- Two.\n\n## 0.1.0\n\n- Old.\n" # What the preflight reads of the last release: tag v0.1.0, two entries under ## Unreleased, and 4 commits since the tag. -CUT = Release("v0.1.0", CHANGELOG, 4) +CUT = LastCut("v0.1.0", CHANGELOG, 4, []) # Two open pull requests, as `tea pulls list --fields index,head,url --output tsv` prints them; anything else exits 1. FAKE_TEA = "#!/bin/sh\n[ \"$*\" = 'pulls list --fields index,head,url --output tsv' ] || exit 1\nprintf 'index\\thead\\turl\\n12\\titem-7\\thttps://forge/pulls/12\\n13\\tother\\thttps://forge/pulls/13\\n'\n" # Item 3's open pull request, as `gh pr list` prints it through the preflight's template; any other arguments exit 1. @@ -66,7 +67,7 @@ print("12\\thttps://github.com/o/r/pull/12") class Repo: """An origin with a tagged release, a clone of it at /proj, and a fake tea and gh on PATH.""" - def __init__(self, test, todo=TODO, origin="origin.git"): + def __init__(self, test, todo=TODO, origin="origin.git", changelog=CHANGELOG): temp = tempfile.TemporaryDirectory() test.addCleanup(temp.cleanup) self.temp = pathlib.Path(os.path.realpath(temp.name)) @@ -85,7 +86,7 @@ class Repo: self.write(self.root, "src/app.py", "def run():\n\treturn 1\n\n") self.commit(self.root, "start") self.git(self.root, "tag", "v0.1.0") - self.write(self.root, "CHANGELOG.md", CHANGELOG) + self.write(self.root, "CHANGELOG.md", changelog) if todo: self.write(self.root, "todo.md", todo) self.commit(self.root, "plan") @@ -152,6 +153,19 @@ class ChunkPreflightTool(unittest.TestCase): self.assertNotIn("#13", done.stdout) self.assertNotIn("`gone.py`:", done.stdout) + def test_names_no_item_and_makes_no_worktree_where_the_release_after_the_last_cut_has_emptied(self): + for changelog, fact in ((CHANGELOG, "finished and ready to cut"), ("# Changelog\n\n## Unreleased\n\n## 0.1.0\n\n- Old.\n", "planned first")): + with self.subTest(fact=fact): + repo = Repo(self, changelog=changelog) + repo.write(repo.root, "todo.md", LATER) + repo.commit(repo.root, "ship 0.2.0") + repo.git(repo.root, "push", "--quiet", "origin", "main") + done = repo.preflight() + self.assertEqual(done.returncode, 0, done.stderr) + self.assertIn(fact, done.stdout) + self.assertNotIn("item 9", done.stdout) + self.assertFalse((repo.temp / "proj-item-9").exists()) + def test_continues_the_items_worktree_and_else_its_pushed_branch(self): repo = Repo(self) repo.preflight() @@ -277,16 +291,16 @@ class Render(unittest.TestCase): def test_states_the_unreleased_entries_and_else_the_commits_since_the_last_cut(self): self.assertIn("v0.1.0. Unreleased: 2 entries", rendered(NoItem("x."))) - self.assertIn("1 entry", rendered(NoItem("x."), Release("v0.1.0", "## Unreleased\n\n- One.\n", 4))) - without = rendered(NoItem("x."), Release("v0.1.0", "# Changelog\n", 4)) + self.assertIn("1 entry", rendered(NoItem("x."), LastCut("v0.1.0", "## Unreleased\n\n- One.\n", 4, []))) + without = rendered(NoItem("x."), LastCut("v0.1.0", "# Changelog\n", 4, [])) self.assertIn("4 commits since v0.1.0", without) self.assertIn("no ## Unreleased", without) - untagged = rendered(NoItem("x."), Release(None, "", 1)) + untagged = rendered(NoItem("x."), LastCut(None, "", 1, [])) self.assertIn("cut: none", untagged) self.assertIn("1 commit on origin/main", untagged) def test_states_why_the_changelog_and_the_commits_since_the_last_cut_cannot_be_read(self): - said = rendered(NoItem("x."), Release("v0.1.0", Failure("changelog unreadable"), Failure("count unreadable"))) + said = rendered(NoItem("x."), LastCut("v0.1.0", Failure("changelog unreadable"), Failure("count unreadable"), [])) self.assertIn("changelog unreadable", said) self.assertIn("cannot be counted: count unreadable", said) self.assertNotIn("no ## Unreleased", said) @@ -359,7 +373,7 @@ class Plans(unittest.TestCase): without = planned("", CUT, "origin/main").why self.assertIn("origin/main", without) self.assertIn("no items table", without) - empty = planned(EMPTY, Release(None, "", 4), "origin/main").why + empty = planned(EMPTY, LastCut(None, "", 4, []), "origin/main").why self.assertIn("holds no item", empty) self.assertNotIn("no items table", empty) @@ -373,12 +387,15 @@ class Plans(unittest.TestCase): ) for todo, commits, fact in cases: with self.subTest(todo=todo, commits=commits): - why = planned(todo, Release("v0.1.0", "", commits), "origin/main").why + why = planned(todo, LastCut("v0.1.0", "", commits, [TODO]), "origin/main").why self.assertIn(fact, why) self.assertIn("v0.1.0", why) + def test_takes_the_earliest_release_where_no_earlier_one_was_named_since_the_last_cut(self): + self.assertEqual(planned(LATER, LastCut("v0.1.0", "", 4, [LATER]), "origin/main").first.id, 9) + def test_says_the_plan_files_items_under_a_release_already_cut(self): - why = planned(TODO, Release("v0.2.0", "", 4), "origin/main").why + why = planned(TODO, LastCut("v0.2.0", "", 4, []), "origin/main").why self.assertIn("release 0.2.0", why) self.assertIn("v0.2.0", why) self.assertIn("not after", why) diff --git a/bin/git_repo.py b/bin/git_repo.py index 85e5605e..d776eb9f 100644 --- a/bin/git_repo.py +++ b/bin/git_repo.py @@ -4,6 +4,7 @@ import re import subprocess from failure import Failure +from todo_table import LastCut def git(*args: str, cwd: str | None = None, timeout: float | None = None) -> str | Failure: @@ -67,19 +68,30 @@ class DefaultPlan: ref: str # todo.md's text, empty where the branch holds none. todo: str | Failure - # The newest v* tag on the branch, None where it has none. - tag: str | None | Failure - # How many commits follow the tag, or make up the branch where it has none. - commits: int | Failure + cut: LastCut -def default_plan(root: str, timeout: float) -> DefaultPlan | Failure: - """What the default branch as last fetched holds for the pick, read in the checkout at root. Asking origin, where the checkout records no default branch for it, fails after timeout seconds.""" - ref = default_ref(root, timeout) - if isinstance(ref, Failure): - return ref +def default_plan(root: str, ref: str) -> DefaultPlan: + """What ref, the default branch as last fetched, holds for the pick, read in the checkout at root.""" tag = newest_release_tag(ref, root) - return DefaultPlan(ref, file_at(ref, "todo.md", root), tag, tag if isinstance(tag, Failure) else commits_since(tag, ref, root)) + commits = tag if isinstance(tag, Failure) else commits_since(tag, ref, root) + return DefaultPlan(ref, file_at(ref, "todo.md", root), LastCut(tag, file_at(ref, "CHANGELOG.md", root), commits, todos_since(tag, ref, root))) + + +def todos_since(tag: str | None | Failure, ref: str, cwd: str) -> list[str] | Failure: + """todo.md's text at tag and at each later commit on ref that changed it, read in cwd; empty where there is no tag.""" + if not isinstance(tag, str): + return [] + changed = git("log", "--format=%H", f"{tag}..{ref}", "--", "todo.md", cwd=cwd) + if isinstance(changed, Failure): + return changed + texts = [] + for commit in [tag, *changed.split()]: + text = file_at(commit, "todo.md", cwd) + if isinstance(text, Failure): + return text + texts.append(text) + return texts def newest_release_tag(branch: str, cwd: str | None = None) -> str | None | Failure: diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index a8919d2b..d47a3cba 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -52,7 +52,8 @@ Where that model is on the routing ladder (bin/model_routing/ladder.py), the wor interrupt run on one of the ladder's rungs: a model at an effort. As a chunk starts, todo.md on the default branch, as chunk-preflight has just fetched it, routes it on the item the preflight names (todo_table.chunk_item): the earliest release's top item that does not wait, where that release is -the one after the newest v* tag, or there is no such tag. An item waits while it is marked +the next, the earliest after the newest v* tag that todo.md has named since that tag, or there is no +such tag; else no item routes it. An item waits while it is marked question, or while an item that blocks it is still in the table. The item's L picks the worker's rung, stepping from the model's cheapest rung by WORKER_STEPS in bin/model_routing/ladder.py, below it for a low L; without such an item, or with its L, E or I @@ -155,7 +156,7 @@ from loop_claude.loop.routing_check import check_routing from loop_claude.project.checkout import checkout_root from loop_claude.cycle.run import Cycle, run_cycle from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG -from git_repo import default_plan, DefaultPlan +from git_repo import default_plan, default_ref, DefaultPlan from loop_claude.effects import Effects from failure import Failure from loop_claude.cycle.judge import Finished, Unfinished @@ -214,7 +215,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc facts = "" if session_open(session) else chunk_facts(launcher.with_name("chunk-preflight"), loop_run.root, effects) anchor = project_rung(models.worker) root = loop_run.root - loop_run = routed(loop_run, anchor, lambda: archived_route(archive_folder, session), lambda: plan_item(default_plan(root, ORIGIN_TIMEOUT))) + loop_run = routed(loop_run, anchor, lambda: archived_route(archive_folder, session), lambda: plan_item(fetched_plan(root))) route = loop_run.route or Route(Rung(models.worker)) print(f"\n=== cycle {loop_run.cycle_number}, worker on {route.rung} ===", flush=True) verdict = run_cycle(Cycle(anchor=anchor, effects=effects, facts=facts, judge_model=models.judge, paths=paths, premises=premises, project_archive=archive_folder, records=records, root=loop_run.root, route=route, session=session, task=loop_run.task, unfinished_evidence=loop_run.unfinished_evidence)) @@ -270,6 +271,12 @@ def chunk_facts(preflight: pathlib.Path, root: str, effects: Effects) -> str: return prompts.preflight_facts(done.stdout.strip()) +def fetched_plan(root: str) -> DefaultPlan | Failure: + """What the default branch, as chunk-preflight's fetch left it, holds for routing.""" + ref = default_ref(root, ORIGIN_TIMEOUT) + return ref if isinstance(ref, Failure) else default_plan(root, ref) + + def plan_item(plan: DefaultPlan | Failure) -> Item | None: """The item that routes a chunk, from the default branch as git_repo.default_plan reads it, as chunk-preflight does, so both take todo_table.chunk_item's pick. None without one, so the chunk runs on the project's rung.""" if isinstance(plan, Failure): @@ -277,7 +284,7 @@ def plan_item(plan: DefaultPlan | Failure) -> Item | None: elif isinstance(plan.todo, Failure): item = plan.todo else: - item = routed_item(plan.todo, plan.tag, plan.commits) + item = routed_item(plan.todo, plan.cut) if isinstance(item, Failure): print(f"routing on the project's rung: {item.reason}", file=sys.stderr) return None diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index 06224c2f..09e5ec49 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -1,7 +1,7 @@ """Which ladder rung a chunk's worker and judge run on: docs/decisions.md → `routing:`.""" import dataclasses -from todo_table import chunk_item, Item, items +from todo_table import chunk_item, Item, items, LastCut from model_routing.ladder import climbed, highest, LADDER, position, project_rung, review_floor, Rung, stepped_up, worker_rung from failure import Failure from model_routing.route import Route @@ -13,12 +13,12 @@ ESCALATION_CAP = 2 JUDGE_REPLAYED = ("claude-opus-5-5",) -def routed_item(todo: str, tag: str | None | Failure, commits: int | Failure) -> Item | Failure | None: - """The item todo_table.chunk_item picks from todo.md, given the newest v* tag and the commits since it; None when there is none, or it lacks L, E or I.""" +def routed_item(todo: str, cut: LastCut) -> Item | Failure | None: + """The item todo_table.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, Failure): return found - _, takes = chunk_item(found or [], tag, commits) + _, takes = chunk_item(found or [], cut) return takes if takes and takes.likelihood and takes.escape_and_impact else None diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 0c546bdc..bf23d212 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -25,6 +25,7 @@ from failure import Failure from loop_claude.cycle.judge import Finished, Interrupt, QuotedAnswer, Unfinished, verdict_from from loop_claude.cycle import interrupt, judge, prompts, retry, run, states, worker from model_routing.ladder import LADDER, Rung +from todo_table import LastCut from claude_code.reply import Limited from loop_claude.loop import main, reload, routing_check from transcript_archive import outcomes, write @@ -568,6 +569,8 @@ class ModelPrompt(unittest.TestCase): self.assertEqual(model_choice.ask_for_model("proj", pathlib.Path("/m.json"), pathlib.Path(empty), fake.effects()), Stop(2, "the human is needed to pick proj's model, but the input ended")) +# A plan read with no release cut yet. +NO_CUT = LastCut(None, "", 0, []) TODO = """# todo ## Items @@ -588,32 +591,32 @@ class Routing(unittest.TestCase): SONNET = Rung("claude-sonnet-5-5", "high") def test_routes_on_the_next_releases_top_item_that_waits_on_no_question(self): - self.assertEqual(routing.routed_item(TODO, None, 0).id, 3) - self.assertIsNone(routing.routed_item(TODO.replace("| | **Do", "| question | **Do"), None, 0)) - self.assertIsNone(routing.routed_item("# todo\n", None, 0)) - self.assertIsNone(routing.routed_item(TODO[:TODO.index("| 7 |")], None, 0)) + self.assertEqual(routing.routed_item(TODO, NO_CUT).id, 3) + self.assertIsNone(routing.routed_item(TODO.replace("| | **Do", "| question | **Do"), NO_CUT)) + self.assertIsNone(routing.routed_item("# todo\n", NO_CUT)) + self.assertIsNone(routing.routed_item(TODO[:TODO.index("| 7 |")], NO_CUT)) old_shape = "## Items\n\n| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n| 3 | 0.2.0 | | **Do the next thing.** | 5 | 3 | 6 | 8 | 9 | 1 | 25 |\n" - self.assertIsNone(routing.routed_item(old_shape, None, 0)) - self.assertEqual(routing.routed_item(TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |"), None, 0), Failure("item 3's L 'x' is not a whole number from 1 to 4")) + self.assertIsNone(routing.routed_item(old_shape, NO_CUT)) + self.assertEqual(routing.routed_item(TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |"), NO_CUT), Failure("item 3's L 'x' is not a whole number from 1 to 4")) def test_routes_on_no_item_where_the_release_after_the_last_cut_has_none(self): - self.assertEqual(routing.routed_item(TODO, "v0.1.0", 3).id, 3) - self.assertIsNone(routing.routed_item(TODO, "v0.2.0", 3)) + self.assertEqual(routing.routed_item(TODO, LastCut("v0.1.0", "", 3, [TODO])).id, 3) + self.assertIsNone(routing.routed_item(TODO, LastCut("v0.2.0", "", 3, [TODO]))) later_only = TODO[:TODO.index("| 7 |")] + TODO[TODO.index("| 1 | 0.3.0 |"):] - self.assertIsNone(routing.routed_item(later_only, "v0.1.0", 3)) - self.assertIsNone(routing.routed_item(later_only, "v0.1.0", 0)) - self.assertEqual(routing.routed_item(later_only, "v0.2.0", 3).id, 1) + self.assertIsNone(routing.routed_item(later_only, LastCut("v0.1.0", "", 3, [TODO]))) + self.assertIsNone(routing.routed_item(later_only, LastCut("v0.1.0", "", 0, [TODO]))) + self.assertEqual(routing.routed_item(later_only, LastCut("v0.2.0", "", 3, [later_only])).id, 1) def test_routes_past_an_item_a_waiting_item_blocks(self): todo = "## Items\n\n| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |\n|---|---|---|---|---|---|---|---|---|---|---|---|\n| 7 | 0.2.0 | | question | **Ask first.** | 4 | 3 | 5 | 10 | 1 | 1 by 9 | 30 |\n| 8 | 0.2.0 | 7 | | **Use the answer.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 | 30 |\n| 9 | 0.2.0 | 8 | | **Build on it.** | 1 | 1 | 1 | 1 | 1 | 1 by 9 | 30 |\n| 3 | 0.2.0 | | | **Do the next thing.** | 4 | 2 | 3 | 7 | 3 | 1 by 9 | 25 |\n" - self.assertEqual(routing.routed_item(todo, None, 0).id, 3) - self.assertEqual(routing.routed_item(todo.replace("| question |", "| |"), None, 0).id, 7) + self.assertEqual(routing.routed_item(todo, NO_CUT).id, 3) + self.assertEqual(routing.routed_item(todo.replace("| question |", "| |"), NO_CUT).id, 7) first = "| 7 | 0.2.0 | | question | **Ask first.** | 4 | 3 | 5 | 10 | 1 | 1 by 9 | 30 |\n" - self.assertEqual(routing.routed_item(todo.replace(first, "") + first, None, 0).id, 3) + self.assertEqual(routing.routed_item(todo.replace(first, "") + first, NO_CUT).id, 3) def test_starts_a_chunk_on_the_rung_its_items_l_picks_below_the_projects_too(self): - self.assertEqual(routing.first_route(self.OPUS, routing.routed_item(TODO, None, 0)), Route(self.HIGH, 3, 4, 5)) - cheap = routing.routed_item(TODO.replace("| 4 | 2 | 3 |", "| 1 | 2 | 3 |"), None, 0) + self.assertEqual(routing.first_route(self.OPUS, routing.routed_item(TODO, NO_CUT)), Route(self.HIGH, 3, 4, 5)) + cheap = routing.routed_item(TODO.replace("| 4 | 2 | 3 |", "| 1 | 2 | 3 |"), NO_CUT) self.assertEqual(routing.first_route(self.OPUS, cheap), Route(Rung("claude-haiku-5-5", "max"), 3, 1, 5)) self.assertEqual(routing.first_route(self.OPUS, None), Route(self.OPUS)) @@ -688,7 +691,7 @@ class Routing(unittest.TestCase): def test_routes_nothing_on_an_item_without_e_or_i(self): without_i = TODO.replace("| E | I | R |", "| E | R |").replace("|---|---|---|---|---|---|---|---|---|---|---|", "|---|---|---|---|---|---|---|---|---|---|").replace("| 4 | 3 | 5 | 10 |", "| 4 | 3 | 10 |").replace("| 4 | 2 | 3 | 7 |", "| 4 | 2 | 7 |").replace("| 1 | 1 | 1 | 1 |", "| 1 | 1 | 1 |") - self.assertIsNone(routing.routed_item(without_i, None, 0)) + self.assertIsNone(routing.routed_item(without_i, NO_CUT)) def test_archives_the_route_in_a_line_it_reads_back(self): route = Route(self.HIGH, 3, 4, 5) @@ -714,7 +717,7 @@ class Routing(unittest.TestCase): def test_keeps_a_chunks_route_or_its_archived_one_at_or_above_the_rung_its_item_picks_and_else_routes_afresh(self): def run_with(route=None): return main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=route) - item = routing.routed_item(TODO, None, 0) + item = routing.routed_item(TODO, NO_CUT) archived = Route(self.XHIGH, 3, 4, 5) def never(): raise AssertionError("not asked") @@ -730,11 +733,11 @@ class Routing(unittest.TestCase): class RouteSources(unittest.TestCase): def test_routes_on_the_plan_item_and_says_why_it_routes_on_the_projects_rung(self): - self.assertIsNone(main.plan_item(DefaultPlan("origin/main", "", None, 0))) - self.assertEqual(main.plan_item(DefaultPlan("origin/main", TODO, "v0.1.0", 3)).id, 3) - self.assertIsNone(main.plan_item(DefaultPlan("origin/main", TODO, "v0.2.0", 3))) + self.assertIsNone(main.plan_item(DefaultPlan("origin/main", "", NO_CUT))) + self.assertEqual(main.plan_item(DefaultPlan("origin/main", TODO, LastCut("v0.1.0", "", 3, [TODO]))).id, 3) + self.assertIsNone(main.plan_item(DefaultPlan("origin/main", TODO, LastCut("v0.2.0", "", 3, [TODO])))) unreadable = Failure("git show origin/main:todo.md printed text that is not UTF-8") - for plan, said in ((DefaultPlan("origin/main", TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |"), None, 0), "routing on the project's rung: item 3's L 'x' is not a whole number from 1 to 4\n"), (DefaultPlan("origin/main", unreadable, None, 0), f"routing on the project's rung: {unreadable.reason}\n"), (Failure("no origin remote"), "routing on the project's rung: no origin remote\n")): + for plan, said in ((DefaultPlan("origin/main", TODO.replace("| 4 | 2 | 3 |", "| x | 2 | 3 |"), NO_CUT), "routing on the project's rung: item 3's L 'x' is not a whole number from 1 to 4\n"), (DefaultPlan("origin/main", unreadable, NO_CUT), f"routing on the project's rung: {unreadable.reason}\n"), (Failure("no origin remote"), "routing on the project's rung: no origin remote\n")): with self.subTest(said=said): with contextlib.redirect_stderr(io.StringIO()) as stderr: self.assertIsNone(main.plan_item(plan)) diff --git a/bin/test_git_repo.py b/bin/test_git_repo.py index 45c55c1e..0d32f6f7 100644 --- a/bin/test_git_repo.py +++ b/bin/test_git_repo.py @@ -1,27 +1,41 @@ +import contextlib import pathlib +import subprocess import sys +import tempfile +import time import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) from failure import Failure -from git_repo import git +import git_repo -class Git(unittest.TestCase): - # Each command is a shell alias, so it touches no repository, whatever GIT_DIR the test runs under. +class StalledOrigin(unittest.TestCase): + """A checkout whose origin, run through git's ext transport, answers nothing for 10 s, and which records no default branch for it.""" - def test_stops_git_still_running_after_the_timeout_and_says_so(self): - done = git("-c", "alias.hang=!sleep 5", "hang", timeout=0.2) - self.assertIsInstance(done, Failure) - self.assertIn("hang", done.reason) - self.assertIn("0.2 s", done.reason) + def setUp(self): + temp = tempfile.TemporaryDirectory() + self.addCleanup(temp.cleanup) + self.root = temp.name + for args in (("init", "--quiet"), ("config", "protocol.ext.allow", "always"), ("remote", "add", "origin", "ext::sleep 10")): + subprocess.run(["git", *args], capture_output=True, check=True, cwd=self.root) - def test_says_git_printed_text_that_is_not_utf_8(self): - done = git("-c", "alias.latin=!printf 'caf\\351'", "latin") - self.assertIsInstance(done, Failure) - self.assertIn("latin", done.reason) - self.assertIn("UTF-8", done.reason) + def test_reading_the_default_branch_fails_after_the_timeout(self): + started = time.monotonic() + ref = git_repo.default_ref(self.root, 0.5) + self.assertLess(time.monotonic() - started, 5) + self.assertIsInstance(ref, Failure) + self.assertIn("stopped after 0.5 s", ref.reason) + + def test_fetching_the_default_branch_fails_after_the_timeout(self): + started = time.monotonic() + with contextlib.chdir(self.root): + found = git_repo.default_branch(stale_ok=True, timeout=0.5) + self.assertLess(time.monotonic() - started, 5) + self.assertIsInstance(found, Failure) + self.assertIn("stopped after 0.5 s", found.reason) if __name__ == "__main__": diff --git a/bin/test_rank_todo.py b/bin/test_rank_todo.py index f01c1e3c..f81255e6 100644 --- a/bin/test_rank_todo.py +++ b/bin/test_rank_todo.py @@ -416,28 +416,43 @@ class Blockers(unittest.TestCase): class Standing(unittest.TestCase): - def test_takes_the_earliest_release_where_it_is_the_next_patch_minor_or_major_or_no_tag_names_a_version(self): + def test_takes_the_earliest_release_where_it_is_the_earliest_named_since_the_last_cut(self): cases = ( - ("v1.2.3", 4, (1, 2, 4), "next"), - ("v1.2.3", 4, (1, 3, 0), "next"), - ("v1.2.3", 4, (2, 0, 0), "next"), - (None, 4, (0, 2, 0), "next"), - (None, 4, None, "next"), - ("v1.2.3-rc.1", 4, (1, 2, 3), "next"), - (Failure("tags unreadable"), 4, (0, 2, 0), "next"), - ("v1.2.3", 4, (1, 2, 3), "cut"), - ("v1.2.3", 4, (1, 2, 2), "cut"), - ("v1.2.3", 4, (1, 2, 5), "finished"), - ("v1.2.3", 4, (1, 3, 1), "finished"), - ("v1.2.3", 4, (2, 0, 1), "finished"), - ("v1.2.3", 4, None, "finished"), - ("v1.2.3", 0, (1, 4, 0), "unplanned"), - ("v1.2.3", 0, None, "unplanned"), - ("v1.2.3", Failure("count unreadable"), (1, 4, 0), "unknown"), + ("v1.2.3", 4, (1, 2, 4), set(), "next"), + ("v1.2.3", 4, (1, 3, 0), {(1, 3, 0)}, "next"), + ("v0.2.0", 4, (0, 4, 0), set(), "next"), + (None, 4, (0, 2, 0), set(), "next"), + (None, 4, None, set(), "next"), + ("v1.2.3-rc.1", 4, (1, 2, 3), set(), "next"), + (Failure("tags unreadable"), 4, (0, 2, 0), set(), "next"), + ("v1.2.3", 4, (1, 2, 3), set(), "cut"), + ("v1.2.3", 4, (1, 2, 2), {(1, 2, 4)}, "cut"), + ("v1.2.3", 4, (1, 3, 0), {(1, 2, 4), (1, 3, 0)}, "finished"), + ("v0.9.2", 4, (1, 0, 0), {(0, 9, 3)}, "finished"), + ("v1.2.3", 4, (1, 4, 0), {(1, 2, 2), (1, 3, 0)}, "finished"), + ("v1.2.3", 4, None, {(1, 3, 0)}, "finished"), + ("v1.2.3", 4, None, set(), "finished"), + ("v1.2.3", 0, (1, 3, 0), {(1, 2, 4)}, "unplanned"), + ("v1.2.3", 0, None, set(), "unplanned"), + ("v1.2.3", Failure("count unreadable"), None, set(), "unknown"), ) - for tag, commits, earliest, stands in cases: - with self.subTest(tag=tag, commits=commits, earliest=earliest): - self.assertEqual(todo_table.standing(tag, commits, earliest), stands) + for tag, landed, earliest, named, stands in cases: + with self.subTest(tag=tag, landed=landed, earliest=earliest, named=named): + self.assertEqual(todo_table.standing(tag, landed, earliest, named), stands) + + def test_counts_work_landed_since_the_last_cut_by_unreleased_entries_and_else_by_commits(self): + changelog = "# Changelog\n\n## Unreleased\n\n- One.\n - A nested line.\n- Two.\n\n## 0.1.0\n\n- Old.\n" + self.assertEqual(todo_table.landed(todo_table.LastCut("v0.1.0", changelog, 5, [])), 2) + self.assertEqual(todo_table.landed(todo_table.LastCut("v0.1.0", "# Changelog\n\n## Unreleased\n\n## 0.1.0\n", 5, [])), 0) + self.assertEqual(todo_table.landed(todo_table.LastCut("v0.1.0", "# Changelog\n\n## 0.1.0\n", 5, [])), 5) + self.assertEqual(todo_table.landed(todo_table.LastCut("v0.1.0", Failure("unreadable"), 5, [])), 5) + + def test_names_each_release_a_todo_md_since_the_last_cut_filed_items_under(self): + row = "| {id} | {release} | | | **Do {id}.** | 1 | 1 | 1 | 1 | 1 | 1 by 1 | 10.0 |\n" + header = "## Items\n\n| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |\n|---|---|---|---|---|---|---|---|---|---|---|---|\n" + texts = [header + row.format(id=1, release="0.2.0"), "", "not a table | x |", header + row.format(id=2, release="0.3.0")] + self.assertEqual(todo_table.named_releases(texts), {(0, 2, 0), (0, 3, 0)}) + self.assertEqual(todo_table.named_releases(Failure("log unreadable")), set()) class Main(unittest.TestCase): diff --git a/bin/todo_table.py b/bin/todo_table.py index c41376cf..bb3ea8c2 100644 --- a/bin/todo_table.py +++ b/bin/todo_table.py @@ -3,7 +3,7 @@ import re import typing from failure import Failure -from markdown_text import FENCE +from markdown_text import FENCE, sections # Each score a Shape names, and each goal's move, runs from 1 to TOP_SCORE, but for the levels L, E and I, which run from 1 to their LEVELS: ~/.claude/rules/todo-items.md defines each level. TOP_SCORE = 10 @@ -17,8 +17,8 @@ BLOCKED_BY = "Blocked by" MOVES = "Moves" # How the items table's header opens, which tells it from any other table in todo.md. HEADER_START = "| ID | Release |" -# How the plan's earliest release stands to the version x.y.z the newest tag names. "next": it is x.y.z+1, x.y+1.0 or x+1.0.0, or no tag names a version. "cut": it is x.y.z or earlier. -# Else the release after the tag holds no item: "finished" where commits followed the tag, "unplanned" where none did, and "unknown" where they cannot be counted. +# How the plan's earliest release stands to the version x.y.z the newest tag names, the last cut. "next": it is the earliest release after x.y.z that todo.md has named since the cut, or no tag names a version. "cut": it is x.y.z or earlier. +# Else the next release, the earliest named since the cut, holds no item: "finished" where work landed since the cut, "unplanned" where none did, and "unknown" where that cannot be read. Standing = typing.Literal["next", "cut", "finished", "unplanned", "unknown"] # todo.md's ## Details section, its body the first group. DETAILS = re.compile(r"^## Details\n(.*?)(?=^## |\Z)", re.M | re.S) @@ -176,24 +176,55 @@ def next_item(found: list[Item]) -> Item | None: return next((item for item in found if item.release == release and item.id not in waits), None) -def standing(tag: str | None | Failure, commits: int | Failure, earliest: tuple[int, int, int] | None) -> Standing: - """How the plan's earliest release, None where the plan holds no item, stands to the newest v* tag, as Standing says; commits counts those after the tag.""" +@dataclasses.dataclass(frozen=True) +class LastCut: + """What the default branch holds about its last release, which chunk_item weighs the plan against.""" + # The newest v* tag, None where the branch has none. + tag: str | None | Failure + # CHANGELOG.md's text, empty where the branch holds none. + changelog: str | Failure + # How many commits follow the tag, or make up the branch where it has none. + commits: int | Failure + # todo.md's text at the tag and at each later commit that changed it; empty without a tag. + todos_since: list[str] | Failure + + +def unreleased_entries(changelog: str) -> int | None: + """How many top-level `- ` entries CHANGELOG.md holds under ## Unreleased; None without that section.""" + found = sections(changelog).get("Unreleased") + return None if found is None else sum(line.startswith("- ") for line in found[0].splitlines()) + + +def landed(cut: LastCut) -> int | Failure: + """How much work has landed since the last cut: the entries under ## Unreleased, or the commits since the tag where CHANGELOG.md has no such section, as `~/.claude/CLAUDE.md` → "Working loop" counts unreleased changes.""" + entries = unreleased_entries(cut.changelog) if isinstance(cut.changelog, str) else None + return cut.commits if entries is None else entries + + +def named_releases(todos: list[str] | Failure) -> set[tuple[int, int, int]]: + """Each release the todo.md texts file items under. A text that does not parse names none, and so does a history that cannot be read, which leaves the plan's earliest release as the next.""" + found = [items(todo) for todo in todos] if isinstance(todos, list) else [] + return {item.release for parsed in found if isinstance(parsed, list) for item in parsed} + + +def standing(tag: str | None | Failure, landed: int | Failure, earliest: tuple[int, int, int] | None, named: set[tuple[int, int, int]]) -> Standing: + """How the plan's earliest release, None where the plan holds no item, stands to the newest v* tag, as Standing says. named holds each release todo.md named since that tag, and landed the work landed since it.""" cut = re.fullmatch(r"v([0-9]+)\.([0-9]+)\.([0-9]+)", tag) if isinstance(tag, str) else None if cut is None: return "next" - major, minor, patch = (int(part) for part in cut.groups()) - if earliest in ((major, minor, patch + 1), (major, minor + 1, 0), (major + 1, 0, 0)): - return "next" - if earliest is not None and earliest <= (major, minor, patch): + version = tuple(int(part) for part in cut.groups()) + if earliest is not None and earliest <= version: return "cut" - if isinstance(commits, Failure): + if earliest is not None and earliest == min(release for release in named | {earliest} if release > version): + return "next" + if isinstance(landed, Failure): return "unknown" - return "finished" if commits else "unplanned" + return "finished" if landed else "unplanned" -def chunk_item(found: list[Item], tag: str | None | Failure, commits: int | Failure) -> tuple[Standing, Item | None]: +def chunk_item(found: list[Item], cut: LastCut) -> tuple[Standing, Item | None]: """The item the next chunk takes first, next_item's pick, where standing finds the plan's earliest release the next; else None. Routing and chunk-preflight both pick with it, so they name one item; standing comes with it, so a caller can say why there is none.""" - stands = standing(tag, commits, min((item.release for item in found), default=None)) + stands = standing(cut.tag, landed(cut), min((item.release for item in found), default=None), named_releases(cut.todos_since)) return stands, next_item(found) if stands == "next" else None diff --git a/todo.md b/todo.md index 2d7cb57e..5719c9c6 100644 --- a/todo.md +++ b/todo.md @@ -38,7 +38,7 @@ | 82 | 0.3.0 | | principle | **Sort `AGENTS.md`'s decision titles and `docs/decisions.md`'s entries by title.** | 2 | 2 | 1 | 3 | 4 | 1.1 by 4, 1.4 by 4 | 5.5 | | 173 | 0.3.0 | | | **Have rule-hook's `todo-rank-check` run a worktree's own `bin/rank_todo.py` when the worktree is of this repo, so a branch that changes `todo.md`'s shape commits without an override.** | 2 | 1 | 3 | 4 | 2 | 1.1 by 2, 1.4 by 2 | 5.5 | | 162 | 0.3.0 | | owner | **Script each step that 0.2.0's chunks repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4, 1.5 by 4 | 4.9 | -| 175 | 0.3.0 | | | **Compare the first five chunks loop-claude starts with `chunk-preflight` against the five before them, by time and fresh tokens before the first edit and by review rounds and unfinished verdicts, and file an item where the preflight did not pay.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 4.9 | +| 175 | 0.3.0 | | | **Compare the first five chunks loop-claude starts with `chunk-preflight` against the five before them, by time and fresh tokens before the first edit and by review rounds, unfinished verdicts and 🔴 findings, and file an item where the preflight did not pay.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 4.9 | | 171 | 0.3.0 | | decision | **Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.** | 3 | 2 | 2 | 5 | 4 | 1.2 by 3, 1.4 by 3 | 3.2 | | 165 | 0.3.0 | | | **Make this repo's tests assert the facts a prompt or help text carries in place of its sentences, and drop the tests that scan source or assert a constant.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 4, 1.4 by 3 | 3.0 | | 169 | 0.3.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 2.7 | @@ -205,9 +205,9 @@ lilleman asked, on 2026-10-16, for a standing audit each release, so the loop ke The chunk that ships this item files a copy of it in the release after the one it audits, rewording "0.2.0" to the release that copy audits, and marks the copy `owner`, so the audit recurs each release until lilleman drops it. -### 175. Compare the first five chunks loop-claude starts with `chunk-preflight` against the five before them, by time and fresh tokens before the first edit and by review rounds and unfinished verdicts, and file an item where the preflight did not pay. +### 175. Compare the first five chunks loop-claude starts with `chunk-preflight` against the five before them, by time and fresh tokens before the first edit and by review rounds, unfinished verdicts and 🔴 findings, and file an item where the preflight did not pay. -Item 161 put `chunk-preflight`'s facts into a fresh worker's prompt, so the worker no longer finds them itself. In item 140's chunk, before it, the worker spent 5 min 46 s of 30 min, 16 of its 68 messages and 226k of its 491k fresh tokens before its first edit, through 12 Bash and 5 Read calls. Measure those figures from loop-claude's archive, as medians over the first five chunks that started with the preflight and the five before them: one chunk is too noisy a baseline, as `docs/decisions.md` → `reading cost: a rise is …` records. Measure goal 1.4's counter-signal beside them, review rounds and unfinished verdicts per chunk, since a worker that reads less may start sooner and need more rounds. Where time or tokens did not fall, or rounds or unfinished verdicts rose, file an item naming the facts the workers still found by hand, or what the preflight got wrong. +Item 161 put `chunk-preflight`'s facts into a fresh worker's prompt, so the worker no longer finds them itself. In item 140's chunk, before it, the worker spent 5 min 46 s of 30 min, 16 of its 68 messages and 226k of its 491k fresh tokens before its first edit, through 12 Bash and 5 Read calls. Measure those figures from loop-claude's archive, as medians over the first five chunks that started with the preflight and the five before them: one chunk is too noisy a baseline, as `docs/decisions.md` → `reading cost: a rise is …` records. Measure the counter-signals beside them: goal 1.4's review rounds and unfinished verdicts, and goal 1.5's 🔴 findings, per chunk, since a worker that reads less may start sooner and need more rounds or let more defects through. Where time or tokens did not fall, or a counter-signal rose, file an item naming the facts the workers still found by hand, or what the preflight got wrong. ### 171. Group the routing figures' review rounds by the reviewers' rung as well as the worker's, so a call blames a rung only for rounds its own reviews raised.