Answer architecture round 4: 0 🔴, 1 🟡; pin the vote-row length check, and skip non-table lines plainly

This commit is contained in:
2026-10-13 16:41:40 +02:00
parent 7b30085b8d
commit a12b6859cd
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -104,7 +104,7 @@ def entries(history: str) -> list[Entry]:
def latest_places(history: str) -> str | None:
"""The places seats found hard from the newest entry, by time, that is a scoring run or 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 places count. None when no place counts."""
"""The places seats found hard from the newest entry, by time, that is a scoring run or 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, it starts at the oldest entry. None when no place counts."""
found = sorted(entries(history), key=lambda entry: entry.time)
newest = max((index for index, entry in enumerate(found) if not entry.paired or entry.scored_places), default=0)
parts = [placed(entry, worse_places(entry) + labelled_bullets(entry.body, SCORED_PLACES)) for entry in found[newest:]]
@@ -127,7 +127,9 @@ 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. 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 not line.startswith("| "):
continue
name, *votes = [cell.strip() for cell in line.strip("|").split("|")]
if len(votes) == len(DIMENSIONS):
found.setdefault(name, {dimension for dimension, vote in zip(DIMENSIONS, votes) if vote == "worse"})
return found
+1 -1
View File
@@ -141,7 +141,7 @@ class History(unittest.TestCase):
older = paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |\n|---|---|---|---|---|---|\n| Mid A | same | worse | same | same | worse |\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n"
self.assertIsNone(latest_places(""))
self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "same"))))
self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Vote |\n|---|---|\n| Mid A | worse |\n\n- Locality: `bin/k.py:1` `t`: before any label\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n")))
self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Vote | Locality |\n|---|---|---|\n| Mid A | same | worse |\n\n- Locality: `bin/k.py:1` `t`: before any label\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n")))
unscored = "## 2026-10-11T12:00:00Z, PR #4 at eeeeeee\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |\n"
self.assertIsNone(latest_places(appended(appended("", scored), unscored)))
hard_since = "## 2026-10-10T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nMid A, decided by:\n\n- Locality, Shape: `bin/a.py:3` `f`: held at once\n"