Answer architecture round 2: 0 🔴, 2 🟡; date the Entry docstring's legacy case, test wrapped and empty places, split places into scoring and worse, and recheck origin before the ruling
This commit is contained in:
@@ -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 holds them where the scoring seats' scores are part of it."""
|
||||
"""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."""
|
||||
heading: str
|
||||
time: str
|
||||
commit: str
|
||||
@@ -106,17 +106,21 @@ 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."""
|
||||
found = sorted(entries(history), key=lambda entry: entry.time)
|
||||
start = max((index for index, entry in enumerate(found) if entry.scored_places), default=0)
|
||||
parts = [entry_places(entry, scored=index == start and bool(entry.scored_places)) for index, entry in enumerate(found) if index >= start]
|
||||
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:])]
|
||||
return "\n".join(part for part in parts if part) or None
|
||||
|
||||
|
||||
def entry_places(entry: Entry, scored: bool) -> str:
|
||||
"""An entry's heading and the places latest_places counts in it, each under its seat's label; empty when none counts."""
|
||||
worse = {} if scored else worse_votes(entry.body)
|
||||
labelled = labelled_bullets(entry.body, SCORED_PLACES if scored else RULED_PLACES)
|
||||
kept = [(label, bullets if scored else [bullet for bullet in bullets if moves_worse(bullet, worse.get(label.split(",")[0], set()))]) for label, bullets in labelled]
|
||||
text = "".join(f"\n{label}\n\n" + "".join(f"{bullet}\n" for bullet in bullets) for label, bullets in kept if bullets)
|
||||
def worse_places(entry: Entry) -> list[tuple[str, list[str]]]:
|
||||
"""Under each of a ruling's seat labels, the bullets that open with a dimension that seat's vote counted as worse; Overall counts as one."""
|
||||
worse = worse_votes(entry.body)
|
||||
return [(label, [bullet for bullet in bullets if worse.get(label.split(",")[0], set()) & set(place_dimensions(bullet.removeprefix("- ")))]) for label, bullets in labelled_bullets(entry.body, RULED_PLACES)]
|
||||
|
||||
|
||||
def placed(entry: Entry, labelled: list[tuple[str, list[str]]]) -> str:
|
||||
"""The entry's heading, then each label with bullets and its bullets; empty when no label has any."""
|
||||
text = "".join(f"\n{label}\n\n" + "".join(f"{bullet}\n" for bullet in bullets) for label, bullets in labelled if bullets)
|
||||
return f"## {entry.heading}\n{text}" if text else ""
|
||||
|
||||
|
||||
@@ -126,11 +130,6 @@ def worse_votes(body: str) -> dict[str, set[str]]:
|
||||
return {name: {dimension for dimension, vote in zip(DIMENSIONS, votes) if vote == "worse"} for name, *votes in rows if len(votes) == len(DIMENSIONS)}
|
||||
|
||||
|
||||
def moves_worse(bullet: str, worse: set[str]) -> bool:
|
||||
"""Whether a ruled place opens with a dimension its seat counted worse; Overall counts as one."""
|
||||
return bool(worse & set(place_dimensions(bullet.removeprefix("- "))))
|
||||
|
||||
|
||||
def place_dimensions(place: str) -> list[str]:
|
||||
"""The dimensions a place opens with, as in `Locality, Shape: `path:line` ...`; empty when any name before the first `: ` is no dimension."""
|
||||
named = place.partition(": ")[0].split(", ")
|
||||
|
||||
@@ -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 a scoring run found hard.").rstrip("\n"))
|
||||
print((latest_places(history[1]) or "The comprehension history names no places seats found hard since its newest scoring run.").rstrip("\n"))
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -144,6 +144,11 @@ class History(unittest.TestCase):
|
||||
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"
|
||||
self.assertEqual(latest_places(appended(appended(appended("", older), ruled), scored)), "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n and wrapped\n\nInherited architect, would restructure first:\n\n- `bin/c.py:1` `k`: tangled\n\n" + hard_since)
|
||||
self.assertEqual(latest_places(appended(appended("", ruled), older)), "## 2026-10-07T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n\n" + hard_since)
|
||||
wrapped = "## 2026-10-09T12:00:00Z, PR #3 at ccccccc\n\nJunior A, hardest first:\n\n an indented line before any bullet\n- `bin/f.py:1` `p`: long,\n like `bin/g.py:2` `q`\n"
|
||||
calm = paired("2026-10-09T13:00:00Z", "same", "ddddddd") + "\n| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |\n|---|---|---|---|---|---|\n| Mid A | same | same | same | same | same |\n\nMid A, decided by:\n\n- Locality: `bin/h.py:1` `r`: as before\n"
|
||||
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)
|
||||
|
||||
|
||||
class Base(unittest.TestCase):
|
||||
@@ -318,8 +323,8 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertIn("Inherited architect, would restructure first:", text)
|
||||
self.assertEqual(entries(text)[0].scored_places, [Place("bin/a.py", "f")] * 4)
|
||||
|
||||
def test_prints_the_places_the_newest_scoring_seats_named(self):
|
||||
self.assertEqual(self.run_tool("places").stdout, "The comprehension history names no places a scoring run found hard.\n")
|
||||
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.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)
|
||||
|
||||
@@ -149,7 +149,7 @@ Launch prose-reviewer with what the diff touched and every section this review c
|
||||
## 5. Goal alignment, then merge
|
||||
|
||||
1. Read the finished PR against the README goals: does anything in it work against one? Misaligned → do not merge; ask the human, stating the conflict.
|
||||
2. Run the comprehension check (§3) where it runs.
|
||||
2. Run the comprehension check (§3) where it runs. When `origin/<default branch>` has moved since §4 step 1, return to §4 first.
|
||||
3. Aligned, every pass done and everything green → **merge**. Follow the repo's merge method (`AGENTS.md`; ff-only where that is the convention). A repo withholds this in its `AGENTS.md` → leave the PR ready and unmerged, and say which line withheld it.
|
||||
4. Merged → remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` → "Working loop".
|
||||
5. Stop. The next chunk gets a fresh session.
|
||||
|
||||
Reference in New Issue
Block a user