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:
+13
-3
@@ -1,4 +1,4 @@
|
||||
"""Hold larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's rounds, the scoring run's trigger and setup; the comprehension history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt.
|
||||
"""Hold larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's rounds and its round commit's title, the scoring run's trigger and setup; the comprehension history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt.
|
||||
|
||||
usage: larv-review {commands}
|
||||
|
||||
@@ -10,8 +10,8 @@ to 10. Each seat names the places it found hard.
|
||||
Run it inside a project checkout or one of its worktrees. Each command but review-folder,
|
||||
record-ruling, places and agreement first fetches origin, when the checkout has that remote, and
|
||||
takes origin's default branch, or else the local main or master, as the default branch. When the
|
||||
fetch fails, round-count and reviewer-header read origin as last fetched and say so on stderr; the
|
||||
other four exit 1.
|
||||
fetch fails, round-count, reviewer-header and round-title read origin as last fetched and say so on
|
||||
stderr; the other four exit 1.
|
||||
The history is docs/comprehension-history.md in the checkout.
|
||||
|
||||
review-folder makes the chunk's review folder, where each reviewer writes its report, and prints its
|
||||
@@ -142,6 +142,14 @@ it. It exits 1 when the pass takes no more rounds, when `project-config` fails i
|
||||
the principles or standards folder is not a folder with a file in it, or, with --rerun, when the
|
||||
report that asked is missing.
|
||||
|
||||
round-title takes a pass as reviewer-header does, and prints how the commit that answers the pass's
|
||||
next round opens its title, up to and including the `;` before the summary, such as `Answer prose
|
||||
round 1: 0 🔴, 2 🟡 (0 misread);`. It counts the findings in the round's report in the review
|
||||
folder, or in its rerun's where there is one: each line that opens `### 🔴` or `### 🟡`, and of
|
||||
them each whose mark is followed by ` [misread]`. rule-hook's round-title-counts refuses a round
|
||||
title whose counts differ from it. It exits 1 when the pass takes no more rounds or the report is
|
||||
missing.
|
||||
|
||||
reviewer-context is the SubagentStart hook. It reads the hook's input on stdin. For a reviewer
|
||||
whose definition under ~/.claude/agents/ has `omitClaudeMd: true`, and so starts without CLAUDE.md,
|
||||
it prints the hook reply that hands the agent the Shared goal, Prose and Vocabulary sections of
|
||||
@@ -176,6 +184,7 @@ from larv_review.plan import plan_reasons
|
||||
from larv_review.scoring_setup import prepare_scoring
|
||||
from larv_review.history_commands import read_agreement, read_places, record_ruling, record_scoring
|
||||
from larv_review.reviewer_header import reviewer_header
|
||||
from larv_review.round_title import round_title
|
||||
from project_config.main import title_templates
|
||||
|
||||
|
||||
@@ -231,6 +240,7 @@ COMMANDS = {
|
||||
"places": Command("places", no_arguments, lambda given: printed(read_places(pathlib.Path.home()))),
|
||||
"agreement": Command("agreement", no_arguments, lambda given: printed(read_agreement(pathlib.Path.home()))),
|
||||
"reviewer-header": Command("reviewer-header <pass> [--rerun]", fits_reviewer_header, run_reviewer_header),
|
||||
"round-title": Command("round-title <pass>", lambda given: len(given) == 1 and given[0] in REVIEWERS, lambda given: with_default_branch(lambda default: printed(round_title(default, given[0], pathlib.Path.home())), stale_ok=True)),
|
||||
"reviewer-context": Command("reviewer-context", no_arguments, lambda given: printed(hook_reply(sys.stdin.read(), pathlib.Path.home()))),
|
||||
}
|
||||
SHAPES = " | ".join(command.shape for command in COMMANDS.values())
|
||||
|
||||
@@ -9,7 +9,7 @@ from forge.commands import forge_of, runner
|
||||
from record_store.stores import goals_store, local_file, store
|
||||
from larv_review.history_commands import history_file, places_report
|
||||
from project_config.main import located, title_templates
|
||||
from review_rules.review_folder import made_review_folder
|
||||
from review_rules.review_folder import made_review_folder, rerun_report, round_report
|
||||
from forge.pulls import open_pull
|
||||
from larv_review.plan_listing import plan_listing
|
||||
from plan_store.stores import store as plan_store
|
||||
@@ -47,11 +47,11 @@ class Launch:
|
||||
|
||||
def asked(self) -> pathlib.Path:
|
||||
"""The round's report, which asks for the rerun where there is one."""
|
||||
return self.folder / f"{self.pass_}-round-{self.round_}.md"
|
||||
return round_report(self.folder, self.pass_, self.round_)
|
||||
|
||||
def header(self) -> str:
|
||||
asked = self.asked()
|
||||
report = f"{asked.with_name(asked.stem + '-rerun.md')}, in place of {asked}, which asked for this rerun" if self.rerun else str(asked)
|
||||
report = f"{rerun_report(asked)}, in place of {asked}, which asked for this rerun" if self.rerun else str(asked)
|
||||
return "\n".join([
|
||||
f"Pass: {self.pass_}, round {self.round_}.",
|
||||
f"PR: {self.pull}.",
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
"""round-title: print the opening of a round commit's title, counted from the round's report."""
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import branch_titles, top
|
||||
from larv_review.reviewer_header import unanswered_round
|
||||
from project_config.main import title_templates
|
||||
from review_rules.review_folder import findings_in, review_folder, standing_report
|
||||
from review_rules.round_titles import round_prefix
|
||||
|
||||
|
||||
def round_title(default: str, pass_: str, home: pathlib.Path) -> str | Failure:
|
||||
"""The title prefix of pass_'s unanswered round, counted from that round's report in the chunk's review folder."""
|
||||
titles = branch_titles(default)
|
||||
if isinstance(titles, Failure):
|
||||
return titles
|
||||
templates = title_templates(None, home)
|
||||
if isinstance(templates, Failure):
|
||||
return templates
|
||||
round_ = unanswered_round([templates.summary(title) for title in titles], pass_)
|
||||
if isinstance(round_, Failure):
|
||||
return round_
|
||||
worktree = top()
|
||||
if isinstance(worktree, Failure):
|
||||
return worktree
|
||||
findings = findings_in(standing_report(pathlib.Path(review_folder(str(home), worktree)), pass_, round_))
|
||||
return findings if isinstance(findings, Failure) else round_prefix(pass_, round_, findings)
|
||||
@@ -1093,7 +1093,7 @@ class LarvReviewTool(unittest.TestCase):
|
||||
def test_help_and_the_usage_line_list_the_same_commands(self):
|
||||
usage = next(line for line in self.run_tool("--help").stdout.splitlines() if line.startswith("usage: larv-review "))
|
||||
listed = usage.removeprefix("usage: larv-review ").split(" | ")
|
||||
self.assertEqual([shape.split()[0] for shape in listed], ["review-folder", "ruling-base", "round-count", "needs-scoring-run", "scoring-run-owed", "record-ruling", "prepare-scoring", "record-scoring", "places", "agreement", "reviewer-header", "reviewer-context"])
|
||||
self.assertEqual([shape.split()[0] for shape in listed], ["review-folder", "ruling-base", "round-count", "needs-scoring-run", "scoring-run-owed", "record-ruling", "prepare-scoring", "record-scoring", "places", "agreement", "reviewer-header", "round-title", "reviewer-context"])
|
||||
self.assertIn(f"usage: larv-review {' | '.join(listed)}", self.run_tool().stderr)
|
||||
|
||||
def test_takes_a_local_main_without_origin_and_reads_origin_as_last_fetched_when_the_fetch_fails(self):
|
||||
@@ -1173,6 +1173,22 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertIn(f"Report: write it to {folder}/prose-round-2-rerun.md, in place of {folder}/prose-round-2.md, which asked for this rerun.", lines)
|
||||
self.assertFalse(any(line.startswith("Places:") for line in lines), "only architecture and stability take the places")
|
||||
|
||||
def test_round_title_counts_the_unanswered_rounds_report_and_names_one_that_is_missing(self):
|
||||
folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj"
|
||||
folder.mkdir(parents=True)
|
||||
(folder / "prose-round-1.md").write_text("BLOCK\n\n### 🔴 [misread] `a.md:1`: wrong\n\n### 🟡 `b.md:2`: worse\n\n### 🟢 `c.md:3`: nit\n")
|
||||
ran = self.run_tool("round-title", "prose")
|
||||
self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, "Answer prose round 1: 1 🔴, 1 🟡 (1 misread);\n", ""))
|
||||
self.commit("Answer prose round 1: 1 🔴, 1 🟡 (1 misread); fix")
|
||||
missing = self.run_tool("round-title", "prose")
|
||||
self.assertEqual((missing.returncode, missing.stdout), (1, ""))
|
||||
self.assertIn(f"no report at {folder}/prose-round-2.md", missing.stderr)
|
||||
(folder / "prose-round-2.md").write_text("BLOCK\n\n### 🟡 a\n\nRerun one rung up\n")
|
||||
(folder / "prose-round-2-rerun.md").write_text("APPROVE\n")
|
||||
self.assertEqual(self.run_tool("round-title", "prose").stdout, "Answer prose round 2: 0 🔴, 0 🟡 (0 misread);\n", "the rerun's report stands in place of the one that asked")
|
||||
for given in (["security"], ["Prose"], ["prose", "2"], []):
|
||||
self.assertEqual(self.run_tool("round-title", *given).returncode, 1, given)
|
||||
|
||||
def test_reviewer_header_refuses_a_pass_at_its_cap_and_a_pass_no_agent_reviews(self):
|
||||
self.commit("Answer stability round 1: a")
|
||||
self.commit("Answer stability round 2: b")
|
||||
|
||||
Reference in New Issue
Block a user