Answer principles round 2: 0 🔴, 0 🟡; decide ships-alone in one predicate both modules call

This commit is contained in:
2026-10-22 20:56:45 +02:00
parent 6150c5289e
commit fbdb6c9f08
2 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
"""The lines the preflight prints, stated from what it gathered."""
from todo_table import BUNDLE_MAX_R, bundle_candidates, Item, version
from todo_table import BUNDLE_MAX_R, bundle_candidates, Item, ships_alone, version
from failure import Failure
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran
from chunk_pick import LastCut, unreleased_entries
@@ -66,7 +66,7 @@ def open_pulls(stdout: str, forge: Forge, branch: str) -> list[str]:
def bundled(plan: Plan) -> list[str]:
first, candidates = plan.first, bundle_candidates(plan.items, plan.first)
if first.scores.get("R", 0) > BUNDLE_MAX_R:
if ships_alone(first):
return [f"- Item {first.id} has R above {BUNDLE_MAX_R}, so it ships alone."]
if not candidates:
return [f"- No other item of release {version(first.release)} may join item {first.id}'s chunk."]
+8 -3
View File
@@ -202,11 +202,16 @@ def renames(todo: str) -> set[tuple[int, int, int]] | Failure:
return marked
def ships_alone(item: Item) -> bool:
"""An item above BUNDLE_MAX_R joins no chunk, and none joins it."""
return item.scores.get("R", 0) > BUNDLE_MAX_R
def bundle_candidates(found: list[Item], first: Item) -> list[Item]:
"""The items of first's release, in the table's order, that a chunk taking first may take too: those that do not wait once the chunk's own items count as done. An item above BUNDLE_MAX_R ships alone."""
chunk = {item.id for item in found if item.release == first.release and item.scores.get("R", 0) <= BUNDLE_MAX_R}
if first.id not in chunk:
"""The items of first's release, in the table's order, that a chunk taking first may take too: those that do not ship alone, and do not wait once the chunk's own items count as done."""
if ships_alone(first):
return []
chunk = {item.id for item in found if item.release == first.release and not ships_alone(item)}
# Dropping an item that waits may make another wait on it, so drop until none waits.
while waits := waiting(found, chunk) & chunk:
chunk -= waits