Answer principles round 1: 0 🔴, 2 🟡; rename landed to committed, drop the back-pointer, hold the whole condition in work_landed

This commit is contained in:
2026-10-22 00:46:54 +02:00
parent d459c2315b
commit 703a58279a
+10 -10
View File
@@ -6,8 +6,8 @@ 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], landed: 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 it ships, landed whether the default branch holds a commit after its newest release tag, and renamed the releases the chunk's plan marks renamed.
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 it ships, committed whether `committed_since_release` 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, short of one renamed as below. A release the chunk's plan marks renamed is due none.
"""
@@ -18,15 +18,15 @@ def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], lan
reasons = [f"ships item {item.id}, which names the comprehension floor" for item in shipped if "comprehension floor" in item.tagline.lower()]
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, landed):
if work_landed(release, shipped, next_release, committed):
# SKILL.md → "Second run" keys on this wording.
reasons.append(f"leaves release {version(release)} with no plan item")
return reasons
def work_landed(release: tuple[int, int, int], shipped: list[Item], next_release: tuple[int, int, int] | None, landed: bool) -> bool:
"""Whether work has landed towards release. It has when the chunk ships one of the release's items, or when the release is next_release, the earliest the default branch's plan names, and landed holds. larv-review's help points here."""
return any(item.release == release for item in shipped) or (release == next_release and landed)
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, or 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 emptied(before: list[Item], after: list[Item], shipped: list[Item], renamed: set[tuple[int, int, int]]) -> list[tuple[int, int, int]]:
@@ -62,7 +62,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}")
landed = committed_since_release(default)
if isinstance(landed, Failure):
return landed
return scoring_run_due(planned, chunk, ids, landed, renamed)
committed = committed_since_release(default)
if isinstance(committed, Failure):
return committed
return scoring_run_due(planned, chunk, ids, committed, renamed)