Count, per finished chunk, the findings that arose from misreading code that had already shipped
This commit is contained in:
+17
-5
@@ -1,4 +1,4 @@
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡; <summary>`: each pass's round count, and the findings the rounds reported."""
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count, and the findings the rounds reported. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`, because the implementer misread code that had already shipped."""
|
||||
import re
|
||||
|
||||
from review_passes import PASSES
|
||||
@@ -6,8 +6,8 @@ from review_passes import PASSES
|
||||
# The most rounds a pass takes before the run asks the human, per `docs/decisions.md` → `review: a pass gets at most three rounds per chunk; …`. rule-hook's `round-cap` refuses a round title past it, and `larv-review round-count` marks a pass at or past it.
|
||||
CAP = 3
|
||||
ROUND = re.compile(r"^Answer (.+?) round ([0-9]+):", re.IGNORECASE)
|
||||
# What follows a round title's colon: the round's 🔴 and 🟡 counts, then `;` and its summary, if any.
|
||||
FINDINGS = re.compile(r" ([0-9]+) 🔴, ([0-9]+) 🟡(?:;|$)")
|
||||
# What follows a round title's colon: the round's 🔴 and 🟡 counts, then how many of them were misread, which titles from before the count lack, then `;` and its summary, if any.
|
||||
FINDINGS = re.compile(r" ([0-9]+) 🔴, ([0-9]+) 🟡(?: \(([0-9]+) misread\))?(?:;|$)")
|
||||
|
||||
|
||||
def round_counts(titles: list[str]) -> dict[str, int]:
|
||||
@@ -23,9 +23,9 @@ def round_counts(titles: list[str]) -> dict[str, int]:
|
||||
|
||||
|
||||
def lacks_counts(title: str) -> bool:
|
||||
"""Whether title is a round title without the counts after its colon."""
|
||||
"""Whether title is a round title without all three counts after its colon."""
|
||||
named = ROUND.match(title)
|
||||
return named is not None and not FINDINGS.match(title, named.end())
|
||||
return named is not None and ((found := FINDINGS.match(title, named.end())) is None or found.group(3) is None)
|
||||
|
||||
|
||||
def past_cap(title: str) -> bool:
|
||||
@@ -44,3 +44,15 @@ def round_findings(titles: list[str]) -> tuple[int, int] | None:
|
||||
return None
|
||||
counts.append((int(found.group(1)), int(found.group(2))))
|
||||
return (sum(red for red, _ in counts), sum(yellow for _, yellow in counts)) if counts else None
|
||||
|
||||
|
||||
def round_misreads(titles: list[str]) -> int | None:
|
||||
"""The misread counts summed over the round titles among titles; None where a round title lacks one, or no title is a round."""
|
||||
counts = []
|
||||
for title in titles:
|
||||
if named := ROUND.match(title):
|
||||
found = FINDINGS.match(title, named.end())
|
||||
if not found or found.group(3) is None:
|
||||
return None
|
||||
counts.append(int(found.group(3)))
|
||||
return sum(counts) if counts else None
|
||||
|
||||
Reference in New Issue
Block a user