Answer architecture round 5: return the heading as a dataclass, read the Mean line as its own field, mark an entry paired explicitly, move metric-bench's path resolution back to metric_bench, and split the scoring trigger into named steps

This commit is contained in:
2026-10-09 01:44:53 +02:00
parent efed78bf5e
commit c1133edf39
9 changed files with 143 additions and 92 deletions
+21 -16
View File
@@ -41,9 +41,9 @@ def ruling(counted: list[str]) -> str | None:
return "same"
def means(scores: dict[str, list[str]]) -> list[decimal.Decimal]:
"""The seats' mean of each score, in the order each seat's scores are, rounded half up to two decimals."""
return [mean([decimal.Decimal(score) for score in column]) for column in zip(*scores.values())]
def means(lines: list[list[str]]) -> list[decimal.Decimal]:
"""The mean of each score across the lines, in DIMENSIONS' order, rounded half up to two decimals."""
return [mean([decimal.Decimal(score) for score in column]) for column in zip(*lines)]
def mean(values: list[decimal.Decimal]) -> decimal.Decimal:
@@ -68,23 +68,23 @@ def measured_commit(changes: list[HistoryChange]) -> str | None:
for change in changes:
held = {entry.heading for entry in entries(change.before)}
added = [entry for entry in entries(change.after) if entry.heading not in held]
rulings = sorted((entry for entry in added if entry.against), key=lambda entry: entry.time)
if any(entry.against is None for entry in added) or rulings and rulings[-1].ruling == "better":
rulings = sorted((entry for entry in added if entry.paired), key=lambda entry: entry.time)
if any(not entry.paired for entry in added) or rulings and rulings[-1].ruling == "better":
return change.commit
return None
def first_ruling(history: str) -> Entry | None:
rulings = sorted((entry for entry in entries(history) if entry.against), key=lambda entry: entry.time)
rulings = sorted((entry for entry in entries(history) if entry.paired), key=lambda entry: entry.time)
return rulings[0] if rulings else None
def base(changes: list[HistoryChange], history: str, default: str) -> tuple[str, str] | None:
"""The commit a paired ruling reads against, and how it was found: the last measured commit, else the base the history's first paired ruling names; None when neither exists, so the base is the merge base of HEAD and the default branch. history is the default branch's."""
def base(changes: list[HistoryChange], history: str) -> tuple[str, str] | None:
"""The commit a paired ruling reads against, and which fallback found it; None leaves the merge base of HEAD and the default branch. history is the default branch's."""
if found := measured_commit(changes):
return found, f"The newest merged change on {default} that adds a scoring run to the history, or whose last added paired ruling is better."
return found, "the last measured commit"
if (first := first_ruling(history)) and first.against:
return first.against, f"No merged change on {default} adds a scoring run or a better ruling; the base its first paired ruling names."
return first.against, "the base the history's first paired ruling names"
return None
@@ -103,16 +103,21 @@ def plan_items(todo: str) -> list[Item] | Failure:
def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], landed: bool) -> list[str] | Failure:
"""Why the chunk takes a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs it ships, and landed whether the default branch holds a commit after the newest release tag. A release has work landed towards it when the chunk ships one of its items, or when it is the earliest release in before and landed holds."""
"""Why the chunk takes a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs it ships, and landed whether the default branch holds a commit after its newest release tag. Work has landed towards an emptied release when the chunk ships one of its items, or when it is the next release, the earliest before names, and landed holds."""
plan = {item.id: item for item in before + after}
if unknown := sorted(set(ships) - set(plan)):
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()]
left = {item.release for item in after if item.id not in ships}
named = {item.release for item in before} | {item.release for item in shipped}
earliest = min((item.release for item in before), default=None)
for release in sorted(named - left):
if any(item.release == release for item in shipped) or release == earliest and landed:
next_release = min((item.release for item in before), default=None)
for release in emptied(before, after, shipped):
if any(item.release == release for item in shipped) or (release == next_release and landed):
reasons.append(f"leaves release {'.'.join(map(str, release))} with no plan item")
return reasons
def emptied(before: list[Item], after: list[Item], shipped: list[Item]) -> list[tuple[int, int, int]]:
"""Each release the default branch's plan or a shipped item names that the chunk's plan, less the shipped items, names no longer."""
named = {item.release for item in before + shipped}
left = {item.release for item in after if item.id not in {ship.id for ship in shipped}}
return sorted(named - left)