From 083070786bf62a527af26968cde626edecfa7241 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 13 Oct 2026 12:36:46 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20architecture=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20date=20the=20legacy=20case?= =?UTF-8?q?=20by=20PR=20#255,=20count=20the=20newest=20scoring=20entry's?= =?UTF-8?q?=20own=20worse=20places,=20and=20read=20a=20seat's=20vote=20fro?= =?UTF-8?q?m=20the=20votes=20table=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/comprehension_history.py | 19 +++++++++++-------- bin/larv_review/main.py | 8 ++++---- bin/larv_review/record.py | 2 +- bin/larv_review/test_larv_review.py | 4 +++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/bin/comprehension_history.py b/bin/comprehension_history.py index 0b29a8d7..e9f3f5c6 100644 --- a/bin/comprehension_history.py +++ b/bin/comprehension_history.py @@ -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]: diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index db1b8308..b4d85c5a 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -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 diff --git a/bin/larv_review/record.py b/bin/larv_review/record.py index 147ce3fd..138c61e5 100644 --- a/bin/larv_review/record.py +++ b/bin/larv_review/record.py @@ -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 diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index f6ee6e02..26102888 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -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)