From 45007d54f2d047acc15e08aa215906f72ae0ad20 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 4 Nov 2026 21:14:51 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20product-owner=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20count=20an?= =?UTF-8?q?=20untagged=20branch's=20unreleased=20commits=20from=20the=20co?= =?UTF-8?q?mmit=20that=20dated=20its=20heading,=20and=20drop=20the=20chang?= =?UTF-8?q?elog's=20advice=20to=20restart=20loops?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++-- bin/chunk_pick.py | 11 +++++++++-- bin/chunk_preflight/facts.py | 5 +++-- bin/chunk_preflight/main.py | 7 ++++--- bin/chunk_preflight/test_chunk_preflight.py | 1 + bin/test_chunk_pick.py | 4 ++++ 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4338636..423fe7f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,9 @@ ## Unreleased - The routing figures now count what `loop-claude`'s judge costs. `loop-claude` archives each judge run's cost, from claude's reply, in a `Judge cost:` line beside the verdict or rejection, and `routing-figures.md` adds it to its dollars by project, rung and tool, and under the subagent type `judge`. Before, the judge's cost was left out. Chunks archived before this change, and a judge run that failed, add none. -- In a repo with no tag, `chunk-preflight` now counts the newest version under a dated `CHANGELOG.md` heading, such as `## 0.0.1 - 2026-10-03`, as the last cut. A later release in `todo.md` reads as next, and a `Release review of` commit counts only for a release after it. A heading without a date doesn't count, and a tag always wins. Before, such a repo was sent to review a release it had already cut. +- In a repo with no tag, `chunk-preflight` now counts the newest version under a dated `CHANGELOG.md` heading, such as `## 0.0.1 - 2026-10-03`, as the last cut. A later release in `todo.md` reads as next, the unreleased commits are those after the commit that added that heading, and a `Release review of` commit counts only for a release after it. A heading without a date doesn't count, and a tag always wins. Before, such a repo was sent to review a release it had already cut. - `rule-hook` no longer hangs, or reads without end, on an Edit, MultiEdit or Write whose `file_path` is a FIFO or a device: it reads only a regular file. -- A `loop-inbox` ask file now stores when the loop asked as an ISO UTC datetime, such as `2026-11-04T09:30:00Z`, in place of seconds since the epoch. Restart any `loop-claude` running when you deploy this release: until then, `loop-inbox` doesn't list its questions. +- A `loop-inbox` ask file now stores when the loop asked as an ISO UTC datetime, such as `2026-11-04T09:30:00Z`, in place of seconds since the epoch. A `loop-claude` running when you deploy reloads itself at its next cycle; `loop-inbox` doesn't list a question it asks before then, so answer that one on the loop's terminal. - Each chunk's first worker prompt now holds a reading rule: never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context. Once 20 chunks have run under it, a plan item measures them against the 20 before and drops the rule where any figure rose. ## 0.5.0 diff --git a/bin/chunk_pick.py b/bin/chunk_pick.py index 93eb4db8..b50712a2 100644 --- a/bin/chunk_pick.py +++ b/bin/chunk_pick.py @@ -18,7 +18,7 @@ class LastCut: 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. + # How many commits follow the tag; on a branch with no tag, those after the commit that added the newest dated CHANGELOG.md heading, or all of them where it has none. commits: int | Failure # todo.md's text at the tag and at each later commit that changed it, oldest first, as named_releases reads them; where the branch has no tag, at each commit that changed it. Empty where the tags cannot be read. todos_since: list[str] | Failure @@ -93,13 +93,20 @@ class DefaultPlan: 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) - commits = tag if isinstance(tag, Failure) else commits_since(tag, ref, root) changelog = file_at(ref, "CHANGELOG.md", root) after = max(dated_headings(changelog), default=None) if tag is None else None + since = tag if after is None else heading_commit(after, ref, root) + commits = since if isinstance(since, Failure) else commits_since(since, ref, root) reviewed = tag if isinstance(tag, Failure) else release_reviewed(tag, ref, root, after) return DefaultPlan(file_at(ref, "todo.md", root), LastCut(tag, changelog, commits, todos_since(tag, ref, root), reviewed)) +def heading_commit(release: tuple[int, int, int], ref: str, cwd: str) -> str | None | Failure: + """The oldest commit on ref that added release's dated heading to CHANGELOG.md, which a branch with no tag counts the unreleased commits from; None where git finds none.""" + added = git("log", "--reverse", "--format=%H", "-S", f"## {version(release)} - ", ref, "--", "CHANGELOG.md", cwd=cwd) + return added if isinstance(added, Failure) else next(iter(added.split()), None) + + def release_reviewed(tag: str | None, ref: str, cwd: str, after: tuple[int, int, int] | None = None) -> bool | Failure: """Whether ref holds, after tag or in all where tag is None, a commit titled as a release review opens: `Release review of `. Where after is given, the version a branch with no tag counts as cut, a title counts only where its release is later.""" titles = git("log", "--format=%s", f"{tag}..{ref}" if tag else ref, cwd=cwd) diff --git a/bin/chunk_preflight/facts.py b/bin/chunk_preflight/facts.py index 95a8d79b..bfddd55c 100644 --- a/bin/chunk_preflight/facts.py +++ b/bin/chunk_preflight/facts.py @@ -1,6 +1,6 @@ """The lines the preflight prints, stated from what it gathered.""" from todo_table import bundle_candidates, BUNDLE_MAX_R, Item, ships_alone, version -from chunk_pick import cut_name, LastCut, unreleased_entries +from chunk_pick import cut_name, dated_headings, LastCut, unreleased_entries from failure import Failure from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran from chunk_preflight.choices import PULLS_LIST @@ -24,7 +24,8 @@ def last_release(default: str, release: LastCut) -> str: entries = unreleased_entries(release.changelog) if isinstance(release.changelog, str) else None if entries is not None: return f"{cut} Unreleased: {counted(entries, 'entry', 'entries')} under CHANGELOG.md → ## Unreleased." - since = f"since {release.tag}" if release.tag else f"on {default}" + headed = max(dated_headings(release.changelog), default=None) if release.tag is None else None + since = f"since {release.tag}" if release.tag else f"since CHANGELOG.md dated {version(headed)}" if headed else f"on {default}" commits = f"the commits {since} cannot be counted: {release.commits.reason}" if isinstance(release.commits, Failure) else f"{counted(release.commits, 'commit', 'commits')} {since}" changelog = f"CHANGELOG.md cannot be read: {release.changelog.reason}" if isinstance(release.changelog, Failure) else "no ## Unreleased in CHANGELOG.md" return f"{cut} Unreleased: {commits}; {changelog}." diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index 313b4399..ca6c87ec 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -10,9 +10,10 @@ and quotes what it prints in the worker's prompt. It leaves the checkout as it i todo.md as the default branch holds it, the plan loop-claude routes on. It prints: - the last version cut, and how many entries the default branch's CHANGELOG.md holds under - ## Unreleased, or else how many commits followed the tag. The last cut is the newest v* tag on + ## Unreleased, or else how many commits followed the cut. The last cut is the newest v* tag on the default branch. On a branch with no tag, it is the newest version CHANGELOG.md heads - `## X.Y.Z - YYYY-MM-DD`; an undated heading doesn't count; + `## X.Y.Z - YYYY-MM-DD`, and the commits counted follow the commit that added that heading; an + undated heading doesn't count; - the next release and its first item that does not wait, the item loop-claude routes on, with its L and E + I. An item waits while it is marked question, or while an item still in todo.md blocks it. Where the last cut is a version x.y.z, the next release is the earliest after x.y.z @@ -21,7 +22,7 @@ todo.md as the default branch holds it, the plan loop-claude routes on. It print renamed, so a release whose items are all done still reads as next. Where the next release holds no item, it says so, naming it where todo.md named it since the cut: its release review due where changes are unreleased (the ## Unreleased entries, or else the - commits since the tag) and no commit titled `Release review of ` followed the tag, + commits since the cut) and no commit titled `Release review of ` followed the tag, finished and ready to cut once one did, and else to be planned first. On a branch with no tag, such a commit counts only where its is after the version under the dated heading. Where todo.md's earliest release is x.y.z or earlier, it says todo.md files items under a release diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index d1e4c634..346c0502 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -369,6 +369,7 @@ class Render(unittest.TestCase): self.assertIn("1 commit on origin/main", untagged) headed = rendered(NoItem("x."), LastCut(None, "## 0.0.1 - 2026-10-03\n", 1, [])) self.assertIn("cut: 0.0.1, under CHANGELOG.md's dated heading, with no tag.", headed) + self.assertIn("1 commit since CHANGELOG.md dated 0.0.1", headed) def test_states_why_the_changelog_and_the_commits_since_the_last_cut_cannot_be_read(self): said = rendered(NoItem("x."), LastCut("v0.1.0", Failure("changelog unreadable"), Failure("count unreadable"), [])) diff --git a/bin/test_chunk_pick.py b/bin/test_chunk_pick.py index c3169fdd..2a66446f 100644 --- a/bin/test_chunk_pick.py +++ b/bin/test_chunk_pick.py @@ -167,6 +167,10 @@ class ChunkItem(unittest.TestCase): run("add", "CHANGELOG.md") run("commit", "-q", "-m", "Cut 0.0.1") self.assertIs(chunk_pick.default_plan(repo, "main").cut.reviewed, False, "that review reviewed 0.0.1, which is cut") + self.assertEqual(chunk_pick.default_plan(repo, "main").cut.commits, 0, "no commit follows the one that cut 0.0.1") + self.assertEqual(chunk_pick.chunk_item([], chunk_pick.default_plan(repo, "main").cut), chunk_pick.Unplanned(None)) + run("commit", "-q", "--allow-empty", "-m", "Ship item 2") + self.assertEqual(chunk_pick.default_plan(repo, "main").cut.commits, 1) run("commit", "-q", "--allow-empty", "-m", "Release review of 0.1.0") self.assertIs(chunk_pick.default_plan(repo, "main").cut.reviewed, True)