Have larv-review round-title print a round commit's counts from its report, and rule-hook refuse a title that differs

This commit is contained in:
2026-11-17 07:47:45 +01:00
parent 3543d9e964
commit 934a398be0
17 changed files with 234 additions and 16 deletions
+17
View File
@@ -1055,6 +1055,23 @@ class Hook(unittest.TestCase):
def round_commit(self, title: str, given: str = "") -> subprocess.CompletedProcess:
return hook({"cwd": self.repo, "tool_input": {"command": f"git commit {given}-m '{title}'"}, "tool_name": "Bash"}, self.repo)
def test_a_round_commit_whose_counts_differ_from_its_report_is_refused(self):
home = tempfile.mkdtemp()
self.addCleanup(subprocess.run, ["rm", "-rf", home])
folder = pathlib.Path(home, ".local", "state", "larv-review", self.repo.lstrip("/"))
folder.mkdir(parents=True)
(folder / "stability-round-1.md").write_text("BLOCK\n\n### 🔴 [misread] `a.py:1`: wrong\n\n### 🟡 `b.py:2`: worse\n")
def commit(title: str) -> subprocess.CompletedProcess:
return hook({"cwd": self.repo, "tool_input": {"command": f"git commit -m '{title}'"}, "tool_name": "Bash"}, self.repo, {"HOME": home})
wrong = commit("Answer stability round 1: 1 🔴, 2 🟡 (0 misread); fix")
self.assertEqual(wrong.returncode, 2)
self.assertIn(f"Blocked by rule round-title-counts: {folder}/stability-round-1.md reports `Answer stability round 1: 1 🔴, 1 🟡 (1 misread);`", wrong.stderr)
self.assertEqual(commit("Answer stability round 1: 1 🔴, 1 🟡 (1 misread); fix").returncode, 0)
self.assertEqual(commit("Answer prose round 1: 0 🔴, 3 🟡 (0 misread); fix").returncode, 0, "a round whose report is missing goes through")
self.assertEqual(commit("Answer stability round 1: 1 🔴, 2 🟡 (0 misread); fix # rule-override round-title-counts: the reviewer wrote its findings as a list").returncode, 0)
def test_a_round_commit_past_round_2_is_refused_and_offers_no_override(self):
ran = self.round_commit("Answer stability round 3: 0 🔴, 1 🟡 (0 misread); fix # rule-override round-cap: the human said yes")
self.assertEqual(ran.returncode, 2)