Have larv-review's scoring-run trigger count unreleased changes as chunk-preflight does

This commit is contained in:
2026-10-22 01:43:04 +02:00
parent b9963df226
commit 591db4a33e
7 changed files with 37 additions and 24 deletions
+1
View File
@@ -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
+1
View File
@@ -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)
+6 -8
View File
@@ -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
+12 -11
View File
@@ -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)
+13
View File
@@ -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")
+4
View File
@@ -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.
-5
View File
@@ -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.