Answer stability round 1: 1 🔴, 1 🟡 (0 misread); refuse to count a report whose headings hold a mark in another form, and test the hook's report lookup
CI / tests (pull_request) Successful in 3m12s

This commit is contained in:
2026-11-17 08:30:22 +01:00
parent b43f2242c5
commit cb6dd6d3a7
5 changed files with 41 additions and 8 deletions
+8 -2
View File
@@ -2,6 +2,7 @@
import dataclasses
import re
from failure import Failure
from review_rules.review_passes import PASSES
# The most rounds a pass takes per chunk, per `docs/decisions.md` → `review: a pass gets at most two rounds per chunk, …`. rule-hook's `round-cap` refuses a round commit that `past_cap` finds takes its pass past it, and `larv-review round-count` marks a pass that reached it.
@@ -18,6 +19,7 @@ ROUND = re.compile(r"^Answer (.+?) round ([0-9]+):", re.IGNORECASE)
FINDINGS = re.compile(r" ([0-9]+) 🔴, ([0-9]+) 🟡(?: \(([0-9]+) misread\))?(?:;|$)")
# A 🔴 or 🟡 finding's heading in a round's report, as skills/larv-review/review-findings.md → "Report" pins it: `### `, the severity mark, then ` [misread]` where the reviewer marked it so.
FINDING = re.compile(r"^### (🔴|🟡)( \[misread\])?", re.MULTILINE)
HEADING = re.compile(r"^#{1,6} .*$", re.MULTILINE)
@dataclasses.dataclass(frozen=True)
@@ -97,8 +99,12 @@ def round_findings(titles: list[str]) -> Findings | None:
return Findings(sum(found.red for found in counts), sum(found.yellow for found in counts), sum(misreads) if len(misreads) == len(counts) else None)
def reported(report: str) -> Findings:
"""The 🔴 and 🟡 findings a round's report gives in FINDING headings, and how many of them the reviewer marked `[misread]`."""
def reported(report: str) -> Findings | Failure:
"""The 🔴 and 🟡 findings a round's report gives in FINDING headings, and how many of them the reviewer marked `[misread]`; a Failure naming a heading that holds a 🔴 or 🟡 in another form, which a count would miss."""
for heading in HEADING.findall(report):
pinned = FINDING.match(heading)
if ("🔴" in heading or "🟡" in heading) and (not pinned or "[misread]" in heading and not pinned.group(2)):
return Failure(f"its heading `{heading}` holds a 🔴 or 🟡 but doesn't open `### 🔴` or `### 🟡`, followed by ` [misread]` where marked so")
marks = FINDING.findall(report)
return Findings(sum(mark == "🔴" for mark, _ in marks), sum(mark == "🟡" for mark, _ in marks), sum(bool(misread) for _, misread in marks))