Answer architecture round 3: 0 🔴, 3 🟡; date the legacy case by PR #255, count the newest scoring entry's own worse places, and read a seat's vote from the votes table only

This commit is contained in:
2026-10-13 12:36:46 +02:00
parent ddfc0b4583
commit 083070786b
4 changed files with 19 additions and 14 deletions
+11 -8
View File
@@ -40,7 +40,7 @@ class Place:
@dataclasses.dataclass(frozen=True)
class Entry:
"""One paired ruling, which names the commit it was against and its ruling, or one scoring run, which names neither. The places under a scoring seat's label are scored_places; a ruling recorded before 2026-10-13 holds them too where a fallen dimension called the scoring seats."""
"""One paired ruling, which names the commit it was against and its ruling, or one scoring run, which names neither. The places under a scoring seat's label are scored_places; a ruling recorded before PR #255 holds them too where a fallen dimension called the scoring seats."""
heading: str
time: str
commit: str
@@ -104,11 +104,10 @@ def entries(history: str) -> list[Entry]:
def latest_places(history: str) -> str | None:
"""The places seats found hard since the newest entry, by time, that holds scoring seats' places: all of that entry's scoring places, then, in each later paired ruling, each place opening with a dimension its seat's vote counted as worse. Each entry's places come under its heading, oldest first; with no such entry, every ruling's count. None when no place counts."""
"""The places seats found hard from the newest entry, by time, that holds scoring seats' places: in it and each later entry, each ruled place opening with a dimension its seat's vote counted as worse, and every scoring seat's place. Each entry's places come under its heading, oldest first; with no such entry, every ruling's count. None when no place counts."""
found = sorted(entries(history), key=lambda entry: entry.time)
newest = max((index for index, entry in enumerate(found) if entry.scored_places), default=None)
first = [placed(found[newest], labelled_bullets(found[newest].body, SCORED_PLACES))] if newest is not None else []
parts = first + [placed(entry, worse_places(entry)) for entry in (found if newest is None else found[newest + 1:])]
newest = max((index for index, entry in enumerate(found) if entry.scored_places), default=0)
parts = [placed(entry, worse_places(entry) + labelled_bullets(entry.body, SCORED_PLACES)) for entry in found[newest:]]
return "\n".join(part for part in parts if part) or None
@@ -125,9 +124,13 @@ def placed(entry: Entry, labelled: list[tuple[str, list[str]]]) -> str:
def worse_votes(body: str) -> dict[str, set[str]]:
"""Each seat's dimensions, Overall included, whose vote in the ruling's table counted as worse; `same (voted worse, …)` counted as same."""
rows = [[cell.strip() for cell in line.strip("|").split("|")] for line in body.splitlines() if line.startswith("| ")]
return {name: {dimension for dimension, vote in zip(DIMENSIONS, votes) if vote == "worse"} for name, *votes in rows if len(votes) == len(DIMENSIONS)}
"""Each seat's dimensions, Overall included, whose vote in the ruling's table counted as worse; `same (voted worse, …)` counted as same. The votes table comes first, so a seat's row in a later scores table is not its vote."""
found: dict[str, set[str]] = {}
for line in body.splitlines():
name, *votes = [cell.strip() for cell in line.strip("|").split("|")] if line.startswith("| ") else [""]
if len(votes) == len(DIMENSIONS):
found.setdefault(name, {dimension for dimension, vote in zip(DIMENSIONS, votes) if vote == "worse"})
return found
def place_dimensions(place: str) -> list[str]:
+4 -4
View File
@@ -67,10 +67,10 @@ paired ruling's base. It appends the seats' scores and their means, rounded half
decimals, prints the means and, when a mean is under the floor of {floor}, a line opening `Floor:`
naming each one.
places prints the places seats found hard since the history's newest entry, by time, that holds
scoring seats' places: all of that entry's, then, from each later paired ruling, each place that
opens with a dimension, or Overall, its seat's vote counted as worse. Each entry's places come under
its heading, oldest first. With no such entry, it reads every ruling.
places prints the places seats found hard from the history's newest entry, by time, that holds
scoring seats' places: in it and each later entry, every scoring seat's place, and each ruled place
that opens with a dimension, or Overall, its seat's vote counted as worse. Each entry's places come
under its heading, oldest first. With no such entry, it reads every ruling.
Each record is appended to the history, created when missing, under a heading of the current UTC
time and the seats file's first line. Each commit that line names must be in the checkout. It exits 1
+1 -1
View File
@@ -81,7 +81,7 @@ def show_places() -> Failure | None:
history = history_file()
if isinstance(history, Failure):
return history
print((latest_places(history[1]) or "The comprehension history names no places seats found hard since its newest scoring run.").rstrip("\n"))
print((latest_places(history[1]) or "The comprehension history names no places seats found hard since its newest scoring run, or ever when it holds none.").rstrip("\n"))
return None
+3 -1
View File
@@ -149,6 +149,8 @@ class History(unittest.TestCase):
history = appended(appended(appended("", wrapped), calm), ruled)
self.assertEqual(entries(history)[0].scored_places, [Place("bin/f.py", "p")])
self.assertEqual(latest_places(history), "## 2026-10-09T12:00:00Z, PR #3 at ccccccc\n\nJunior A, hardest first:\n\n- `bin/f.py:1` `p`: long,\n like `bin/g.py:2` `q`\n\n" + hard_since)
fell = ruled.replace("2026-10-10T12:00:00Z", "2026-10-09T12:00:00Z") + "\n| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |\n|---|---|---|---|---|---|\n| Mid A | 7 | 6 | 7 | 7 | 7 |\n| Mean | 7 | 6 | 7 | 7 | 7 |\n\nJunior A, hardest first:\n\n- `bin/j.py:5` `s`: wide\n"
self.assertEqual(latest_places(appended(appended("", scored), fell)), hard_since.replace("2026-10-10T12:00:00Z", "2026-10-09T12:00:00Z") + "\nJunior A, hardest first:\n\n- `bin/j.py:5` `s`: wide\n")
class Base(unittest.TestCase):
@@ -324,7 +326,7 @@ class LarvReviewTool(unittest.TestCase):
self.assertEqual(entries(text)[0].scored_places, [Place("bin/a.py", "f")] * 4)
def test_prints_the_places_seats_found_hard_since_the_newest_scoring_run(self):
self.assertEqual(self.run_tool("places").stdout, "The comprehension history names no places seats found hard since its newest scoring run.\n")
self.assertEqual(self.run_tool("places").stdout, "The comprehension history names no places seats found hard since its newest scoring run, or ever when it holds none.\n")
self.commit("Record a scoring run", {"docs/comprehension-history.md": appended("", SCORING + "\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n")})
ran = self.run_tool("places")
self.assertEqual((ran.returncode, ran.stdout), (0, "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n"), ran.stderr)