From 591db4a33e7747bbeae5e3494d77c42c5ec3fb60 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:43:04 +0200 Subject: [PATCH 01/10] Have larv-review's scoring-run trigger count unreleased changes as chunk-preflight does --- CHANGELOG.md | 1 + bin/chunk_pick.py | 1 + bin/larv_review/git.py | 14 ++++++-------- bin/larv_review/plan.py | 23 ++++++++++++----------- bin/larv_review/test_larv_review.py | 13 +++++++++++++ docs/reading-cost.md | 4 ++++ todo.md | 5 ----- 7 files changed, 37 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33db6f7c..b762d527 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `larv-review needs-scoring-run` now counts the default branch's unreleased changes as `chunk-preflight` does: the entries under `CHANGELOG.md` → `## Unreleased`, or the commits since the newest `v*` tag where there is no such section. Before, it counted commits alone, so a chunk that moved the next release's last items to a later release without shipping them called a scoring run where `chunk-preflight` called the release unplanned. - README → Install now says that every machine taking this checkout must be a sandbox with no direct access to a production environment, since `settings.json` runs Claude Code in auto mode with the dangerous-mode prompt skipped. Before, it asked for a sandbox only for `loop-claude`. ## 0.3.0 diff --git a/bin/chunk_pick.py b/bin/chunk_pick.py index 96dc50e3..024b3a93 100644 --- a/bin/chunk_pick.py +++ b/bin/chunk_pick.py @@ -110,6 +110,7 @@ def standing(tag: str | None | Failure, changes: int | Failure, earliest: tuple[ first_named = min((release for release in named if release > cut_version), default=None) if earliest is not None and (first_named is None or earliest <= first_named): return Next(earliest, first) + # The plan's earliest release is past the next release, or the plan holds none: the next release holds no item. if isinstance(changes, Failure): return Unknown() return Finished(first_named) if changes else Unplanned(first_named) diff --git a/bin/larv_review/git.py b/bin/larv_review/git.py index b9d598d8..64e58d07 100644 --- a/bin/larv_review/git.py +++ b/bin/larv_review/git.py @@ -1,5 +1,6 @@ -from git_repo import commits_since, file_at, full_history, git, newest_release_tag +from chunk_pick import default_plan, unreleased_changes from failure import Failure +from git_repo import file_at, full_history, git from comprehension_history import HISTORY, HistoryChange @@ -22,10 +23,7 @@ def history_changes(default: str) -> list[HistoryChange] | Failure: return changes -def committed_since_release(default: str) -> bool | Failure: - """Whether the default branch holds a commit after its newest `v*` tag, or any commit when it has none.""" - newest = newest_release_tag(default) - if isinstance(newest, Failure): - return newest - count = commits_since(newest, default) - return count if isinstance(count, Failure) else count > 0 +def changes_unreleased(root: str, default: str) -> bool | Failure: + """Whether the default branch holds a change after its last release, counted as chunk-preflight counts it: `chunk_pick.unreleased_changes`. root is the checkout the git commands run in.""" + changes = unreleased_changes(default_plan(root, default).cut) + return changes if isinstance(changes, Failure) else changes > 0 diff --git a/bin/larv_review/plan.py b/bin/larv_review/plan.py index e5a485d2..b784906a 100644 --- a/bin/larv_review/plan.py +++ b/bin/larv_review/plan.py @@ -1,13 +1,13 @@ import pathlib -from larv_review.git import committed_since_release +from larv_review.git import changes_unreleased from failure import Failure from git_repo import file_at, top from todo_table import Item, items, NoItemsTable, renames, version -def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], committed: bool, renamed: set[tuple[int, int, int]]) -> list[str] | Failure: - """Why the plan calls a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs of the items the chunk ships, committed whether `committed_since_release` holds for the default branch, and renamed the releases the chunk's plan marks renamed. +def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], unreleased: bool, renamed: set[tuple[int, int, int]]) -> list[str] | Failure: + """Why the plan calls a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs of the items the chunk ships, unreleased whether `changes_unreleased` holds for the default branch, and renamed the releases the chunk's plan marks renamed. A chunk that ships an item naming the floor is due one, so it can prove the floor met. So is a chunk that empties a release after work has landed towards it, so no release ends unmeasured. A release the chunk's plan marks renamed is due none. """ @@ -16,18 +16,19 @@ def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], com return Failure(f"neither plan holds item {', '.join(map(str, unknown))}") shipped = [plan[id_] for id_ in ships] reasons = [f"ships item {item.id}, which names the comprehension floor" for item in shipped if "comprehension floor" in item.tagline.lower()] + # The earliest release the default branch's plan names. chunk_pick.standing reads "next release" from the last cut and the renames since, which the chunk's own plan marks here through renamed. next_release = min((item.release for item in before), default=None) for release in emptied(before, after, shipped, renamed): - if work_landed(release, shipped, next_release, committed): + if work_landed(release, shipped, next_release, unreleased): # SKILL.md → "Second run" keys on this wording. reasons.append(f"leaves release {version(release)} with no plan item") return reasons # larv-review --help points here rather than restating the rule, so the rule is written once. -def work_landed(release: tuple[int, int, int], shipped: list[Item], next_release: tuple[int, int, int] | None, committed: bool) -> bool: - """Whether work has landed towards release, for the scoring-run trigger. It has when the chunk ships one of the release's items. It has too when the release is next_release, the earliest the default branch's plan names, and committed holds: the default branch has a commit after its newest v* tag, or any commit when it has no v* tag.""" - return any(item.release == release for item in shipped) or (release == next_release and committed) +def work_landed(release: tuple[int, int, int], shipped: list[Item], next_release: tuple[int, int, int] | None, unreleased: bool) -> bool: + """Whether work has landed towards release, for the scoring-run trigger. It has when the chunk ships one of the release's items. It has too when the release is next_release, the earliest the default branch's plan names, and unreleased holds: the default branch has an unreleased change, which `chunk_pick.unreleased_changes` counts for chunk-preflight too.""" + return any(item.release == release for item in shipped) or (release == next_release and unreleased) def emptied(before: list[Item], after: list[Item], shipped: list[Item], renamed: set[tuple[int, int, int]]) -> list[tuple[int, int, int]]: @@ -63,7 +64,7 @@ def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure: renamed = renames(after) if isinstance(renamed, Failure): return Failure(f"the checkout's todo.md: {renamed.reason}") - committed = committed_since_release(default) - if isinstance(committed, Failure): - return committed - return scoring_run_due(planned, chunk, ids, committed, renamed) + unreleased = changes_unreleased(checkout, default) + if isinstance(unreleased, Failure): + return unreleased + return scoring_run_due(planned, chunk, ids, unreleased, renamed) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index a0ff2aa3..85c51385 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -380,6 +380,19 @@ class LarvReviewTool(unittest.TestCase): self.commit("Mark 0.1.0 renamed", {"todo.md": todo(*rows) + "\n## Renamed\n\n- 0.1.0 renamed to 0.2.0\n"}) self.assertEqual(self.run_tool("needs-scoring-run").stdout, "No scoring run due.\n") + def test_counts_work_landed_towards_the_next_release_as_the_changelog_does_where_it_has_an_unreleased_section(self): + self.git("tag", "v0.0.1") + self.commit("Commit after the tag", {"CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n## 0.0.1\n"}) + self.git("push", "-q", "origin", "HEAD:main") + rows = ("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |", "| 2 | 0.2.0 | | **Then this.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |", "| 3 | 0.2.0 | | **And this.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + self.commit("Move 0.1.0's item to 0.2.0", {"todo.md": todo(*rows)}) + self.assertEqual(self.run_tool("needs-scoring-run").stdout, "No scoring run due.\n") + self.git("reset", "-q", "--hard", "HEAD~1") + self.commit("Log a change", {"CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n- Did a thing.\n\n## 0.0.1\n"}) + self.git("push", "-q", "origin", "HEAD:main") + self.commit("Move 0.1.0's item to 0.2.0", {"todo.md": todo(*rows)}) + self.assertEqual(self.run_tool("needs-scoring-run").stdout, "Scoring run due: the chunk leaves release 0.1.0 with no plan item.\n") + def test_refuses_a_checkout_plan_whose_renamed_section_does_not_parse(self): self.commit("Break the mark", {"todo.md": todo("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + "\n## Renamed\n\nsoon\n"}) broken = self.run_tool("needs-scoring-run") diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 45870866..0b0e2b2a 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -754,3 +754,7 @@ Read most (opens and searches): Read most (opens and searches): - `rules/decisions.md` 1 + +## Reading cost, chunk d69472f986e3, finished 2026-10-21T23:32:33Z + +73910 new input tokens before the first commit. diff --git a/todo.md b/todo.md index 9a3d8fc7..c60c8c15 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 207 | 0.4.0 | | | **Have `chunk-preflight` and larv-review's scoring-run trigger decide "work has landed towards the next release" in one place.** | 2 | 2 | 3 | 5 | 3 | code health by 5 | 22.5 | | 130 | 0.4.0 | | | **Move the vote counting out of `bin/larv_review/ruling.py`'s `votes`, so reading a votes file decides nothing.** | 2 | 1 | 2 | 3 | 3 | code health by 4, 1.4 by 4 | 21.9 | | 170 | 0.4.0 | | decision | **Re-tune `WORKER_STEPS` and `REVIEW_STEPS` once 10 chunks have shipped under them, from how well L, E and I order their review rounds and 🔴 findings.** | 2 | 2 | 3 | 5 | 2 | 1.1 by 3, 1.4 by 5 | 10.9 | | 154 | 0.4.0 | | defect | **Have `bin/shell_command.py`'s `segments` keep a command's words together across a redirect, so `git > out commit` reads as one git commit.** | 1 | 1 | 3 | 3 | 2 | 1.1 by 6 | 8.4 | @@ -79,10 +78,6 @@ ## Details -### 207. Have `chunk-preflight` and larv-review's scoring-run trigger decide "work has landed towards the next release" in one place. - -`bin/chunk_pick.py:97` `standing` and `bin/larv_review/plan.py`'s `work_landed`, with `committed_since_release` in `bin/larv_review/git.py`, both decide whether work has landed towards the next release, and can disagree. `standing` takes its count from `unreleased_changes`, which counts the entries under `CHANGELOG.md` → `## Unreleased` first and falls back to the commits since the tag. `work_landed` counts only the commits since the newest `v*` tag. Take a project whose `## Unreleased` is empty but which has commits since the tag. If a chunk moves the next release's last items to a later release without shipping them, the scoring-run trigger calls a run, while chunk-preflight calls the release unplanned. Principles reviews of PR #343 (item 126) raised it. So did seats of PR #324's scoring run, who named both `standing` and `scoring_run_due` as hard places: "next release" is computed two ways. Make `standing` and the trigger share one function for it, or say in a decision why they differ, and make `standing` and `scoring_run_due` easier to read. - ### 130. Move the vote counting out of `bin/larv_review/ruling.py`'s `votes`, so reading a votes file decides nothing. Mid A of PR #257's scoring run named `bin/larv_review/ruling.py:8` `votes`. It calls `counted` while validating, to reject the maintainability senior's and Junior A's lines when Mid A and the inherited architect already agree overall: a ruling hidden in a parser. The counting rule is spread over `seats.py`, `ruling.py`, `comprehension_history.place_dimensions` and the help. Make `votes` easier to read. -- 2.52.0 From 4e5902fcc5edf937986d8a60a91c834ec78d440a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:43:15 +0200 Subject: [PATCH 02/10] Name larv_review's import of chunk_pick in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ee48994..a81999d6 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ pytest_add_cli_args=-k Then, in the copy: `uvx --with pytest 'mutmut>=3,<4' run && uvx --with pytest 'mutmut>=3,<4' results`, and `uvx --with pytest 'mutmut>=3,<4' show ` to see a mutant's change. The config keys are mutmut 3's. -`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. +`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking and `chunk_pick`'s count of unreleased changes, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. ## Tracking a new file -- 2.52.0 From 8e1d16653438ebf75f538b5c512e373cd9e28218 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:54:08 +0200 Subject: [PATCH 03/10] =?UTF-8?q?Answer=20principles=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20take=20the=20next=20release?= =?UTF-8?q?=20from=20chunk=5Fitem's=20pick,=20read=20default=5Fplan=20once?= =?UTF-8?q?,=20and=20test=20the=20changelog,=20the=20next=20release=20and?= =?UTF-8?q?=20the=20unreadable=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- README.md | 2 +- bin/larv_review/git.py | 7 ---- bin/larv_review/plan.py | 43 ++++++++++++------- bin/larv_review/test_larv_review.py | 64 +++++++++++++++++++++-------- 5 files changed, 77 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b762d527..7332dbcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `larv-review needs-scoring-run` now counts the default branch's unreleased changes as `chunk-preflight` does: the entries under `CHANGELOG.md` → `## Unreleased`, or the commits since the newest `v*` tag where there is no such section. Before, it counted commits alone, so a chunk that moved the next release's last items to a later release without shipping them called a scoring run where `chunk-preflight` called the release unplanned. +- `larv-review needs-scoring-run` now decides which release work has landed towards as `chunk-preflight` does: the next release it names, once `CHANGELOG.md` → `## Unreleased` holds an entry, or, where there is no such section, a commit follows the newest `v*` tag. Before, it took the plan's earliest release and counted commits alone, so a chunk that moved the next release's last items to a later release without shipping them called a scoring run where `chunk-preflight` called the release unplanned. - README → Install now says that every machine taking this checkout must be a sandbox with no direct access to a production environment, since `settings.json` runs Claude Code in auto mode with the dangerous-mode prompt skipped. Before, it asked for a sandbox only for `loop-claude`. ## 0.3.0 diff --git a/README.md b/README.md index a81999d6..2c57e7a5 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ pytest_add_cli_args=-k Then, in the copy: `uvx --with pytest 'mutmut>=3,<4' run && uvx --with pytest 'mutmut>=3,<4' results`, and `uvx --with pytest 'mutmut>=3,<4' show ` to see a mutant's change. The config keys are mutmut 3's. -`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking and `chunk_pick`'s count of unreleased changes, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. +`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking and `chunk_pick`'s next release and count of unreleased changes, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. ## Tracking a new file diff --git a/bin/larv_review/git.py b/bin/larv_review/git.py index 64e58d07..627ba32c 100644 --- a/bin/larv_review/git.py +++ b/bin/larv_review/git.py @@ -1,4 +1,3 @@ -from chunk_pick import default_plan, unreleased_changes from failure import Failure from git_repo import file_at, full_history, git from comprehension_history import HISTORY, HistoryChange @@ -21,9 +20,3 @@ def history_changes(default: str) -> list[HistoryChange] | Failure: return after changes.append(HistoryChange(commit, before, after)) return changes - - -def changes_unreleased(root: str, default: str) -> bool | Failure: - """Whether the default branch holds a change after its last release, counted as chunk-preflight counts it: `chunk_pick.unreleased_changes`. root is the checkout the git commands run in.""" - changes = unreleased_changes(default_plan(root, default).cut) - return changes if isinstance(changes, Failure) else changes > 0 diff --git a/bin/larv_review/plan.py b/bin/larv_review/plan.py index b784906a..9cacc4ed 100644 --- a/bin/larv_review/plan.py +++ b/bin/larv_review/plan.py @@ -1,13 +1,13 @@ import pathlib -from larv_review.git import changes_unreleased +from chunk_pick import chunk_item, default_plan, LastCut, Next, Unknown, unreleased_changes from failure import Failure -from git_repo import file_at, top from todo_table import Item, items, NoItemsTable, renames, version +from git_repo import top -def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], unreleased: bool, renamed: set[tuple[int, int, int]]) -> list[str] | Failure: - """Why the plan calls a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs of the items the chunk ships, unreleased whether `changes_unreleased` holds for the default branch, and renamed the releases the chunk's plan marks renamed. +def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], landed: tuple[int, int, int] | None, renamed: set[tuple[int, int, int]]) -> list[str] | Failure: + """Why the plan calls a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs of the items the chunk ships, landed the release unreleased changes have landed towards (`landed_towards`), and renamed the releases the chunk's plan marks renamed. A chunk that ships an item naming the floor is due one, so it can prove the floor met. So is a chunk that empties a release after work has landed towards it, so no release ends unmeasured. A release the chunk's plan marks renamed is due none. """ @@ -16,19 +16,31 @@ def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], unr return Failure(f"neither plan holds item {', '.join(map(str, unknown))}") shipped = [plan[id_] for id_ in ships] reasons = [f"ships item {item.id}, which names the comprehension floor" for item in shipped if "comprehension floor" in item.tagline.lower()] - # The earliest release the default branch's plan names. chunk_pick.standing reads "next release" from the last cut and the renames since, which the chunk's own plan marks here through renamed. - next_release = min((item.release for item in before), default=None) for release in emptied(before, after, shipped, renamed): - if work_landed(release, shipped, next_release, unreleased): + if work_landed(release, shipped, landed): # SKILL.md → "Second run" keys on this wording. reasons.append(f"leaves release {version(release)} with no plan item") return reasons # larv-review --help points here rather than restating the rule, so the rule is written once. -def work_landed(release: tuple[int, int, int], shipped: list[Item], next_release: tuple[int, int, int] | None, unreleased: bool) -> bool: - """Whether work has landed towards release, for the scoring-run trigger. It has when the chunk ships one of the release's items. It has too when the release is next_release, the earliest the default branch's plan names, and unreleased holds: the default branch has an unreleased change, which `chunk_pick.unreleased_changes` counts for chunk-preflight too.""" - return any(item.release == release for item in shipped) or (release == next_release and unreleased) +def work_landed(release: tuple[int, int, int], shipped: list[Item], landed: tuple[int, int, int] | None) -> bool: + """Whether work has landed towards release, for the scoring-run trigger. It has when the chunk ships one of the release's items. It has too when release is landed, the release that unreleased changes on the default branch landed towards.""" + return any(item.release == release for item in shipped) or release == landed + + +def landed_towards(found: list[Item], cut: LastCut) -> tuple[int, int, int] | None | Failure: + """The release unreleased changes on the default branch have landed towards: the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), where `chunk_pick.unreleased_changes` counts one or more. None where there is no such release or no such change; a Failure where either cannot be read. found is the default branch's plan.""" + pick = chunk_item(found, cut) + if isinstance(pick, Unknown): + return Failure("could not tell the next release from the default branch's tags and todo.md history") + # Next is the one pick with a release that holds items; Cut, Finished and Unplanned have none to empty. + if not isinstance(pick, Next): + return None + changes = unreleased_changes(cut) + if isinstance(changes, Failure): + return changes + return pick.release if changes else None def emptied(before: list[Item], after: list[Item], shipped: list[Item], renamed: set[tuple[int, int, int]]) -> list[tuple[int, int, int]]: @@ -43,7 +55,8 @@ def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure: checkout = top() if isinstance(checkout, Failure): return checkout - before = file_at(default, "todo.md") + held = default_plan(checkout, default) + before = held.todo if isinstance(before, Failure): return before try: @@ -64,7 +77,7 @@ def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure: renamed = renames(after) if isinstance(renamed, Failure): return Failure(f"the checkout's todo.md: {renamed.reason}") - unreleased = changes_unreleased(checkout, default) - if isinstance(unreleased, Failure): - return unreleased - return scoring_run_due(planned, chunk, ids, unreleased, renamed) + landed = landed_towards(planned, held.cut) + if isinstance(landed, Failure): + return landed + return scoring_run_due(planned, chunk, ids, landed, renamed) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 85c51385..57e89c79 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -1,5 +1,6 @@ import decimal import itertools +from unittest import mock import os import pathlib import subprocess @@ -14,13 +15,14 @@ from larv_review.agreement import agreement_report, ruling_agreement, run_agreem from comprehension_history import appended, entries, HistoryChange, latest_places, Place, recorded, ruling_entry, scoring_entry, ScoringRun, Seat import comprehension_history from larv_review.ruling import counted, ruling, split, votes +from chunk_pick import DefaultPlan, LastCut from failure import Failure from test_env import isolated_env from todo_table import Item, items, NoItemsTable +from larv_review.plan import landed_towards, plan_reasons, scoring_run_due 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 -from larv_review.plan import scoring_run_due TOOL = pathlib.Path(__file__).resolve().parents[1] / "larv-review" SCORING = "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |\n" @@ -266,45 +268,66 @@ class ScoringRunDue(unittest.TestCase): def test_is_due_for_an_item_naming_the_floor(self): plan = [item(1, (0, 1, 0), "**Lift the project to the Comprehension floor.**"), item(2, (0, 1, 0))] - self.assertEqual(scoring_run_due(plan, plan, [1], True, set()), ["ships item 1, which names the comprehension floor"]) - self.assertIsInstance(scoring_run_due(plan, plan, [9], True, set()), Failure) + self.assertEqual(scoring_run_due(plan, plan, [1], (0, 1, 0), set()), ["ships item 1, which names the comprehension floor"]) + self.assertIsInstance(scoring_run_due(plan, plan, [9], (0, 1, 0), set()), Failure) def test_is_due_when_the_chunk_ships_a_releases_last_item(self): plan = [item(1, (0, 1, 0)), item(2, (0, 2, 0))] - self.assertEqual(scoring_run_due(plan, plan, [1], False, set()), ["leaves release 0.1.0 with no plan item"]) - self.assertEqual(scoring_run_due(plan, plan + [item(3, (0, 1, 0))], [1], True, set()), []) + self.assertEqual(scoring_run_due(plan, plan, [1], None, set()), ["leaves release 0.1.0 with no plan item"]) + self.assertEqual(scoring_run_due(plan, plan + [item(3, (0, 1, 0))], [1], (0, 1, 0), set()), []) def test_is_due_when_the_chunk_removes_the_next_releases_last_item_after_work_landed(self): before = [item(1, (0, 1, 0)), item(2, (0, 1, 0)), item(3, (0, 2, 0))] after = [item(2, (0, 1, 0)), item(3, (0, 2, 0))] - self.assertEqual(scoring_run_due(before, after, [2], True, set()), ["leaves release 0.1.0 with no plan item"]) - self.assertEqual(scoring_run_due(before, after, [], True, set()), []) + self.assertEqual(scoring_run_due(before, after, [2], (0, 1, 0), set()), ["leaves release 0.1.0 with no plan item"]) + self.assertEqual(scoring_run_due(before, after, [], (0, 1, 0), set()), []) emptied = [item(3, (0, 2, 0))] - self.assertEqual(scoring_run_due(before, emptied, [2], False, set()), ["leaves release 0.1.0 with no plan item"]) - self.assertEqual(scoring_run_due(before, emptied, [], True, set()), ["leaves release 0.1.0 with no plan item"]) - self.assertEqual(scoring_run_due(before, emptied, [], False, set()), []) + self.assertEqual(scoring_run_due(before, emptied, [2], None, set()), ["leaves release 0.1.0 with no plan item"]) + self.assertEqual(scoring_run_due(before, emptied, [], (0, 1, 0), set()), ["leaves release 0.1.0 with no plan item"]) + self.assertEqual(scoring_run_due(before, emptied, [], None, set()), []) def test_is_not_due_when_the_chunk_marks_the_next_release_renamed(self): before = [item(1, (0, 2, 1)), item(2, (0, 3, 0))] renamed = {(0, 2, 1)} - self.assertEqual(scoring_run_due(before, [item(1, (0, 3, 0)), item(2, (0, 4, 0))], [], True, renamed), []) - self.assertEqual(scoring_run_due(before, [item(1, (0, 3, 0)), item(2, (0, 3, 0))], [], True, renamed), []) + self.assertEqual(scoring_run_due(before, [item(1, (0, 3, 0)), item(2, (0, 4, 0))], [], (0, 2, 1), renamed), []) + self.assertEqual(scoring_run_due(before, [item(1, (0, 3, 0)), item(2, (0, 3, 0))], [], (0, 2, 1), renamed), []) dropped = [item(1, (0, 2, 1)), item(3, (0, 2, 1)), item(2, (0, 3, 0))] - self.assertEqual(scoring_run_due(dropped, [item(1, (0, 3, 0)), item(2, (0, 3, 0))], [], True, renamed), []) + self.assertEqual(scoring_run_due(dropped, [item(1, (0, 3, 0)), item(2, (0, 3, 0))], [], (0, 2, 1), renamed), []) def test_is_due_when_the_chunk_defers_the_next_releases_last_items_unmarked(self): before = [item(1, (0, 2, 1)), item(2, (0, 3, 0))] - self.assertEqual(scoring_run_due(before, [item(1, (0, 3, 0)), item(2, (0, 3, 0))], [], True, set()), ["leaves release 0.2.1 with no plan item"]) + self.assertEqual(scoring_run_due(before, [item(1, (0, 3, 0)), item(2, (0, 3, 0))], [], (0, 2, 1), set()), ["leaves release 0.2.1 with no plan item"]) def test_words_the_emptied_release_reason_as_skill_md_s_second_run_quotes_it(self): skill = (pathlib.Path(__file__).resolve().parents[2] / "skills" / "larv-review" / "SKILL.md").read_text() self.assertIn("`leaves release … with no plan item`", skill) - reasons = scoring_run_due([item(1, (0, 1, 0))], [], [], True, set()) + reasons = scoring_run_due([item(1, (0, 1, 0))], [], [], (0, 1, 0), set()) self.assertRegex(reasons[0], r"^leaves release [0-9.]+ with no plan item$") def test_is_not_due_when_a_later_release_loses_its_last_item_unshipped(self): before = [item(1, (0, 1, 0)), item(3, (0, 2, 0))] - self.assertEqual(scoring_run_due(before, before[:1], [], True, set()), []) + self.assertEqual(scoring_run_due(before, before[:1], [], (0, 1, 0), set()), []) + + + +class LandedTowards(unittest.TestCase): + def test_names_the_next_release_only_where_a_change_is_unreleased(self): + plan = [item(1, (0, 2, 0))] + changelog = "# Changelog\n\n## Unreleased\n\n- Did a thing.\n" + self.assertEqual(landed_towards(plan, LastCut("v0.1.0", changelog, 0, [])), (0, 2, 0)) + self.assertEqual(landed_towards(plan, LastCut("v0.1.0", "# Changelog\n\n## Unreleased\n", 3, [])), None) + self.assertEqual(landed_towards(plan, LastCut("v0.1.0", "", 3, [])), (0, 2, 0)) + self.assertEqual(landed_towards(plan, LastCut(None, "", 0, [])), None) + + def test_names_no_release_where_chunk_preflight_names_none_that_holds_items(self): + changelog = "# Changelog\n\n## Unreleased\n\n- Did a thing.\n" + self.assertIsNone(landed_towards([item(1, (0, 1, 0))], LastCut("v0.1.0", changelog, 0, []))) + self.assertIsNone(landed_towards([], LastCut("v0.1.0", changelog, 0, [""]))) + + def test_fails_where_the_changes_or_the_next_release_cannot_be_read(self): + plan = [item(1, (0, 2, 0))] + self.assertIsInstance(landed_towards(plan, LastCut("v0.1.0", Failure("unreadable"), Failure("count unreadable"), [])), Failure) + self.assertIsInstance(landed_towards([], LastCut("v0.1.0", "", 3, Failure("log unreadable"))), Failure) class LarvReviewTool(unittest.TestCase): @@ -385,7 +408,7 @@ class LarvReviewTool(unittest.TestCase): self.commit("Commit after the tag", {"CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n## 0.0.1\n"}) self.git("push", "-q", "origin", "HEAD:main") rows = ("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |", "| 2 | 0.2.0 | | **Then this.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |", "| 3 | 0.2.0 | | **And this.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") - self.commit("Move 0.1.0's item to 0.2.0", {"todo.md": todo(*rows)}) + self.commit("Move 0.1.0's item to 0.2.0 and log a change", {"todo.md": todo(*rows), "CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n- The chunk's own change.\n\n## 0.0.1\n"}) self.assertEqual(self.run_tool("needs-scoring-run").stdout, "No scoring run due.\n") self.git("reset", "-q", "--hard", "HEAD~1") self.commit("Log a change", {"CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n- Did a thing.\n\n## 0.0.1\n"}) @@ -393,6 +416,13 @@ class LarvReviewTool(unittest.TestCase): self.commit("Move 0.1.0's item to 0.2.0", {"todo.md": todo(*rows)}) self.assertEqual(self.run_tool("needs-scoring-run").stdout, "Scoring run due: the chunk leaves release 0.1.0 with no plan item.\n") + def test_refuses_where_the_default_branchs_unreleased_changes_cannot_be_read(self): + unreadable = DefaultPlan((self.checkout / "todo.md").read_text(), LastCut("v0.0.1", Failure("changelog unreadable"), Failure("count unreadable"), [])) + self.addCleanup(os.chdir, os.getcwd()) + os.chdir(self.checkout) + with mock.patch("larv_review.plan.default_plan", return_value=unreadable): + self.assertEqual(plan_reasons("main", []), Failure("count unreadable")) + def test_refuses_a_checkout_plan_whose_renamed_section_does_not_parse(self): self.commit("Break the mark", {"todo.md": todo("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + "\n## Renamed\n\nsoon\n"}) broken = self.run_tool("needs-scoring-run") -- 2.52.0 From c554746f8e84f8b4f191f7fbf75cd825f1676019 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:54:08 +0200 Subject: [PATCH 04/10] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20answered=20in=20the=20princ?= =?UTF-8?q?iples=20round's=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From f6f2ec86b1eaf671792a735a01c1c7c43cb15c7c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:54:08 +0200 Subject: [PATCH 05/10] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 10abbaff9fdca341798bd461c4999a451ed171a9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:59:19 +0200 Subject: [PATCH 06/10] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20test=20the=20refusal=20on?= =?UTF-8?q?=20a=20ref=20that=20doesn't=20exist=20instead=20of=20a=20mock,?= =?UTF-8?q?=20and=20say=20why=20only=20Next=20names=20a=20release=20to=20e?= =?UTF-8?q?mpty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/larv_review/plan.py | 4 ++-- bin/larv_review/test_larv_review.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/bin/larv_review/plan.py b/bin/larv_review/plan.py index 9cacc4ed..261483cb 100644 --- a/bin/larv_review/plan.py +++ b/bin/larv_review/plan.py @@ -30,11 +30,11 @@ def work_landed(release: tuple[int, int, int], shipped: list[Item], landed: tupl def landed_towards(found: list[Item], cut: LastCut) -> tuple[int, int, int] | None | Failure: - """The release unreleased changes on the default branch have landed towards: the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), where `chunk_pick.unreleased_changes` counts one or more. None where there is no such release or no such change; a Failure where either cannot be read. found is the default branch's plan.""" + """The release unreleased changes on the default branch have landed towards: the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), where it holds items and `chunk_pick.unreleased_changes` counts one or more. None otherwise; a Failure where either cannot be read. found is the default branch's plan.""" pick = chunk_item(found, cut) if isinstance(pick, Unknown): return Failure("could not tell the next release from the default branch's tags and todo.md history") - # Next is the one pick with a release that holds items; Cut, Finished and Unplanned have none to empty. + # Only Next names a release a chunk can empty after work landed: Cut's is already cut, and Finished's and Unplanned's hold no item. if not isinstance(pick, Next): return None changes = unreleased_changes(cut) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 57e89c79..5517d1db 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -1,6 +1,5 @@ import decimal import itertools -from unittest import mock import os import pathlib import subprocess @@ -15,11 +14,11 @@ from larv_review.agreement import agreement_report, ruling_agreement, run_agreem from comprehension_history import appended, entries, HistoryChange, latest_places, Place, recorded, ruling_entry, scoring_entry, ScoringRun, Seat import comprehension_history from larv_review.ruling import counted, ruling, split, votes -from chunk_pick import DefaultPlan, LastCut from failure import Failure from test_env import isolated_env from todo_table import Item, items, NoItemsTable from larv_review.plan import landed_towards, plan_reasons, scoring_run_due +from chunk_pick import LastCut 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 @@ -319,7 +318,7 @@ class LandedTowards(unittest.TestCase): self.assertEqual(landed_towards(plan, LastCut("v0.1.0", "", 3, [])), (0, 2, 0)) self.assertEqual(landed_towards(plan, LastCut(None, "", 0, [])), None) - def test_names_no_release_where_chunk_preflight_names_none_that_holds_items(self): + def test_names_no_release_where_chunk_preflight_names_none_a_chunk_can_empty(self): changelog = "# Changelog\n\n## Unreleased\n\n- Did a thing.\n" self.assertIsNone(landed_towards([item(1, (0, 1, 0))], LastCut("v0.1.0", changelog, 0, []))) self.assertIsNone(landed_towards([], LastCut("v0.1.0", changelog, 0, [""]))) @@ -417,11 +416,9 @@ class LarvReviewTool(unittest.TestCase): self.assertEqual(self.run_tool("needs-scoring-run").stdout, "Scoring run due: the chunk leaves release 0.1.0 with no plan item.\n") def test_refuses_where_the_default_branchs_unreleased_changes_cannot_be_read(self): - unreadable = DefaultPlan((self.checkout / "todo.md").read_text(), LastCut("v0.0.1", Failure("changelog unreadable"), Failure("count unreadable"), [])) self.addCleanup(os.chdir, os.getcwd()) os.chdir(self.checkout) - with mock.patch("larv_review.plan.default_plan", return_value=unreadable): - self.assertEqual(plan_reasons("main", []), Failure("count unreadable")) + self.assertIsInstance(plan_reasons("no-such-ref", []), Failure) def test_refuses_a_checkout_plan_whose_renamed_section_does_not_parse(self): self.commit("Break the mark", {"todo.md": todo("| 1 | 0.2.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |") + "\n## Renamed\n\nsoon\n"}) -- 2.52.0 From 8974031c2d538a73bd212bb76e15a442a7526724 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 01:59:19 +0200 Subject: [PATCH 07/10] =?UTF-8?q?Answer=20principles=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20the=20=F0=9F=9F=A2=20commen?= =?UTF-8?q?t=20fix=20is=20in=20the=20stability=20round's=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 0f60cac9ba291618fb12bc985f64c01f1e0d4fdd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 02:00:34 +0200 Subject: [PATCH 08/10] =?UTF-8?q?Answer=20stability=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 68c44f312834e390e99e51ad4cb3de1c06c7624b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 02:00:34 +0200 Subject: [PATCH 09/10] =?UTF-8?q?Answer=20principles=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 31fb1a0093dd1d2bc4265bfa7173767341f95646 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 22 Oct 2026 02:07:24 +0200 Subject: [PATCH 10/10] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=205=20=F0=9F=9F=A1;=20say=20what=20landed=5Ftowar?= =?UTF-8?q?ds=20returns=20and=20fails=20on,=20point=20--help=20at=20it,=20?= =?UTF-8?q?reword=20the=20changelog=20entry=20and=20two=20test=20names,=20?= =?UTF-8?q?and=20leave=20the=20README=20as=20it=20was?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- README.md | 2 +- bin/larv_review/main.py | 2 +- bin/larv_review/plan.py | 10 +++++----- bin/larv_review/test_larv_review.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7332dbcd..fb6bc587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `larv-review needs-scoring-run` now decides which release work has landed towards as `chunk-preflight` does: the next release it names, once `CHANGELOG.md` → `## Unreleased` holds an entry, or, where there is no such section, a commit follows the newest `v*` tag. Before, it took the plan's earliest release and counted commits alone, so a chunk that moved the next release's last items to a later release without shipping them called a scoring run where `chunk-preflight` called the release unplanned. +- `larv-review needs-scoring-run` now calls a scoring run for the release `chunk-preflight` names as next, not for the earliest release in the plan. It also counts a change as unreleased the way `chunk-preflight` does: an entry under `CHANGELOG.md` → `## Unreleased`, or, where there is no such section, a commit after the newest `v*` tag (any commit when there is none). Before, a chunk that moved the next release's last items to a later release without shipping them called a scoring run, while `chunk-preflight` called that release unplanned. - README → Install now says that every machine taking this checkout must be a sandbox with no direct access to a production environment, since `settings.json` runs Claude Code in auto mode with the dangerous-mode prompt skipped. Before, it asked for a sandbox only for `loop-claude`. ## 0.3.0 diff --git a/README.md b/README.md index 2c57e7a5..7ee48994 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ pytest_add_cli_args=-k Then, in the copy: `uvx --with pytest 'mutmut>=3,<4' run && uvx --with pytest 'mutmut>=3,<4' results`, and `uvx --with pytest 'mutmut>=3,<4' show ` to see a mutant's change. The config keys are mutmut 3's. -`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking and `chunk_pick`'s next release and count of unreleased changes, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. +`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. ## Tracking a new file diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index f9758723..bb7c017e 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -31,7 +31,7 @@ needs-scoring-run takes the IDs of the todo.md items the chunk ships, none when prints why the chunk is due a scoring run, or `No scoring run due.` It is due when the chunk ships an item whose tagline names the comprehension floor. It is also due when the chunk leaves a release with no item in the checkout's todo.md, once the shipped items are set aside, and work has landed -towards that release; bin/larv_review/plan.py's `work_landed` says when. A release the checkout's +towards that release; bin/larv_review/plan.py's `work_landed` and `landed_towards` say when. A release the checkout's todo.md marks renamed in its ## Renamed section, as `- 0.2.1 renamed to 0.3.0`, is due none. A second scoring run of one head names itself ` rerun at `, so record-scoring diff --git a/bin/larv_review/plan.py b/bin/larv_review/plan.py index 261483cb..798bc8d4 100644 --- a/bin/larv_review/plan.py +++ b/bin/larv_review/plan.py @@ -7,7 +7,7 @@ from git_repo import top def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], landed: tuple[int, int, int] | None, renamed: set[tuple[int, int, int]]) -> list[str] | Failure: - """Why the plan calls a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs of the items the chunk ships, landed the release unreleased changes have landed towards (`landed_towards`), and renamed the releases the chunk's plan marks renamed. + """Why the plan calls a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs of the items the chunk ships, landed the release that unreleased changes landed towards (`landed_towards`), and renamed the releases the chunk's plan marks renamed. A chunk that ships an item naming the floor is due one, so it can prove the floor met. So is a chunk that empties a release after work has landed towards it, so no release ends unmeasured. A release the chunk's plan marks renamed is due none. """ @@ -25,16 +25,16 @@ def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], lan # larv-review --help points here rather than restating the rule, so the rule is written once. def work_landed(release: tuple[int, int, int], shipped: list[Item], landed: tuple[int, int, int] | None) -> bool: - """Whether work has landed towards release, for the scoring-run trigger. It has when the chunk ships one of the release's items. It has too when release is landed, the release that unreleased changes on the default branch landed towards.""" + """Whether work has landed towards release, for the scoring-run trigger. It has when the chunk ships one of the release's items. It has too when release is the one `landed_towards` names.""" return any(item.release == release for item in shipped) or release == landed def landed_towards(found: list[Item], cut: LastCut) -> tuple[int, int, int] | None | Failure: - """The release unreleased changes on the default branch have landed towards: the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), where it holds items and `chunk_pick.unreleased_changes` counts one or more. None otherwise; a Failure where either cannot be read. found is the default branch's plan.""" + """The release that unreleased changes on the default branch have landed towards, None where there is none. It is the next release, as chunk-preflight names it (`chunk_pick.chunk_item`), once `chunk_pick.unreleased_changes` counts one or more changes. A Failure where chunk_item's pick is Unknown, or is Next and the count cannot be read. found is the default branch's plan.""" pick = chunk_item(found, cut) if isinstance(pick, Unknown): - return Failure("could not tell the next release from the default branch's tags and todo.md history") - # Only Next names a release a chunk can empty after work landed: Cut's is already cut, and Finished's and Unplanned's hold no item. + return Failure("could not tell the next release: the default branch's todo.md history or its unreleased changes cannot be read") + # Only Next names a release a chunk can empty after work landed: Cut's is the last cut's version or earlier, and Finished's and Unplanned's hold no item. if not isinstance(pick, Next): return None changes = unreleased_changes(cut) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 5517d1db..a9706d7e 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -318,7 +318,7 @@ class LandedTowards(unittest.TestCase): self.assertEqual(landed_towards(plan, LastCut("v0.1.0", "", 3, [])), (0, 2, 0)) self.assertEqual(landed_towards(plan, LastCut(None, "", 0, [])), None) - def test_names_no_release_where_chunk_preflight_names_none_a_chunk_can_empty(self): + def test_names_no_release_unless_chunk_preflight_names_a_next_release_with_items(self): changelog = "# Changelog\n\n## Unreleased\n\n- Did a thing.\n" self.assertIsNone(landed_towards([item(1, (0, 1, 0))], LastCut("v0.1.0", changelog, 0, []))) self.assertIsNone(landed_towards([], LastCut("v0.1.0", changelog, 0, [""]))) @@ -402,7 +402,7 @@ class LarvReviewTool(unittest.TestCase): self.commit("Mark 0.1.0 renamed", {"todo.md": todo(*rows) + "\n## Renamed\n\n- 0.1.0 renamed to 0.2.0\n"}) self.assertEqual(self.run_tool("needs-scoring-run").stdout, "No scoring run due.\n") - def test_counts_work_landed_towards_the_next_release_as_the_changelog_does_where_it_has_an_unreleased_section(self): + def test_counts_work_landed_from_the_changelogs_unreleased_entries_where_it_has_that_section(self): self.git("tag", "v0.0.1") self.commit("Commit after the tag", {"CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n## 0.0.1\n"}) self.git("push", "-q", "origin", "HEAD:main") -- 2.52.0