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:
@@ -182,7 +182,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
|
||||
- `compress-archives` gzips each transcript in loop-claude's archive and each file in the review folders 30 days after it last changed, keeping all of them; Install's crontab line runs it daily.
|
||||
- `deploy-release [--cut] [<checkout>]` moves `~/.claude`, or the checkout named, to the newest release, as Update says; with `--cut`, run in the development clone, it first cuts the next release, as Release says.
|
||||
- `judge-replay <model>` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints what each rung a review climbs to misses, and the lowest rung below them that, like each candidate above it, returns them; `judge-replay --help` states the replay.
|
||||
- `larv-review <command>` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger and setup; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts. A reviewer under `agents/` whose frontmatter has `omitClaudeMd: true` starts without `CLAUDE.md`, and the command hands it that file's "Shared goal", "Prose" and "Vocabulary" sections.
|
||||
- `larv-review <command>` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count and the opening of its round commit's title, counted from the round's report, the scoring run's trigger and setup; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts. A reviewer under `agents/` whose frontmatter has `omitClaudeMd: true` starts without `CLAUDE.md`, and the command hands it that file's "Shared goal", "Prose" and "Vocabulary" sections.
|
||||
- `loop-claude <task>` runs a project's next chunks, each in its own tmux window, cycle after cycle; `loop-claude --help` states its contract.
|
||||
- `metric-bench [history]` benches cheap static metrics of a project's Python against the places its comprehension history names as hardest; `metric-bench --help` states the metrics and the scores.
|
||||
- `mutate-changes [--base <ref>] [--prefix <shell text>] [--jobs <n>]` mutation-tests the lines a branch changes and prints each mutant its tests don't kill; `mutate-changes --help` says which tool it runs for each language.
|
||||
|
||||
@@ -12,4 +12,4 @@ Verdict, severities and rounds: ~/.claude/skills/larv-review/review-findings.md.
|
||||
- Per principle or goal: every place the project departs from it, with file:line, the defect in one sentence and its concrete consequence. Then one line: followed, mostly, not followed, or does not apply and why.
|
||||
- A departure a plan item plans away is named with that item, not raised.
|
||||
- A decision in `docs/decisions.md` working against a goal or a technical principle is a 🔴 on the decision, unless it names the plan item that ends it. Weigh it hard: that it was decided is no reason.
|
||||
- Report under one heading per yardstick.
|
||||
- Report under one `##` heading per yardstick.
|
||||
|
||||
+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")
|
||||
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
from review_rules.round_titles import Findings, reported
|
||||
|
||||
# Why here: docs/decisions.md → `review: each reviewer under agents/ writes its full report into the chunk's review folder`.
|
||||
REPORTS = ".local/state/larv-review"
|
||||
@@ -24,3 +25,29 @@ def made_review_folder(worktree: str, home: pathlib.Path) -> pathlib.Path | Fail
|
||||
except OSError as failure:
|
||||
return Failure(f"could not make the review folder {folder}: {failure}")
|
||||
return folder
|
||||
|
||||
|
||||
def round_report(folder: pathlib.Path, pass_: str, round_: int) -> pathlib.Path:
|
||||
"""The report of pass_'s round round_ in the review folder, which asks for the rerun one rung up where there is one."""
|
||||
return folder / f"{pass_}-round-{round_}.md"
|
||||
|
||||
|
||||
def rerun_report(asked: pathlib.Path) -> pathlib.Path:
|
||||
"""The report of the rerun one rung up that the report asked asks for, which stands in its place."""
|
||||
return asked.with_name(asked.stem + "-rerun.md")
|
||||
|
||||
|
||||
def standing_report(folder: pathlib.Path, pass_: str, round_: int) -> pathlib.Path:
|
||||
"""The report that stands for pass_'s round round_ in the review folder: the rerun's where there is one, else the round's."""
|
||||
asked = round_report(folder, pass_, round_)
|
||||
return rerun_report(asked) if rerun_report(asked).exists() else asked
|
||||
|
||||
|
||||
def findings_in(report: pathlib.Path) -> Findings | Failure:
|
||||
"""The findings a round's report gives, as round_titles.reported counts them."""
|
||||
try:
|
||||
return reported(report.read_text(encoding="utf-8"))
|
||||
except FileNotFoundError:
|
||||
return Failure(f"no report at {report}")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {report}: {failure}")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count against its cap, and the findings the rounds reported. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`."""
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count against its cap, and the findings the rounds reported, as titled and as the round's report gives them. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`."""
|
||||
import dataclasses
|
||||
import re
|
||||
|
||||
@@ -16,6 +16,8 @@ EXAMPLE = "Answer stability round 1: 1 🔴, 2 🟡 (1 misread); flag a deleted
|
||||
ROUND = re.compile(r"^Answer (.+?) round ([0-9]+):", re.IGNORECASE)
|
||||
# What follows a round title's colon: the round's 🔴 and 🟡 counts, then how many of them a reviewer marked `[misread]`, a count that titles from before it lack, then `;` and its summary, if any.
|
||||
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)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -93,3 +95,14 @@ def round_findings(titles: list[str]) -> Findings | None:
|
||||
return None
|
||||
misreads = [found.misread for found in counts if found.misread is not 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]`."""
|
||||
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))
|
||||
|
||||
|
||||
def round_prefix(pass_: str, round_: int, findings: Findings) -> str:
|
||||
"""The opening of the round's commit title, up to and including the `;` before its summary."""
|
||||
return f"Answer {pass_} round {round_}: {findings.red} 🔴, {findings.yellow} 🟡 ({findings.misread} misread);"
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import pathlib
|
||||
import tempfile
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from review_rules.review_folder import review_folder
|
||||
from failure import Failure
|
||||
from review_rules.review_folder import findings_in, review_folder, standing_report
|
||||
from review_rules.round_titles import Findings
|
||||
|
||||
|
||||
class ReviewFolder(unittest.TestCase):
|
||||
@@ -14,3 +17,19 @@ class ReviewFolder(unittest.TestCase):
|
||||
def test_keys_a_worktree_outside_home_by_its_path_relative_to_the_root(self):
|
||||
self.assertEqual(review_folder("/h", "/srv/proj-item-3"), "/h/.local/state/larv-review/srv/proj-item-3")
|
||||
self.assertEqual(review_folder("/h", "/hx/proj"), "/h/.local/state/larv-review/hx/proj", "a sibling of home that shares its prefix is outside it")
|
||||
|
||||
|
||||
class RoundReport(unittest.TestCase):
|
||||
def test_counts_the_rounds_report_or_its_rerun_one_rung_up_where_there_is_one(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
folder = pathlib.Path(temp)
|
||||
(folder / "prose-round-1.md").write_text("BLOCK\n\n### 🟡 a\n")
|
||||
self.assertEqual(findings_in(standing_report(folder, "prose", 1)), Findings(0, 1, 0))
|
||||
(folder / "prose-round-1-rerun.md").write_text("BLOCK\n\n### 🔴 [misread] a\n")
|
||||
self.assertEqual(findings_in(standing_report(folder, "prose", 1)), Findings(1, 0, 1))
|
||||
|
||||
def test_names_a_missing_report(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
missing = findings_in(standing_report(pathlib.Path(temp), "prose", 2))
|
||||
self.assertIsInstance(missing, Failure)
|
||||
self.assertEqual(missing.reason, f"no report at {temp}/prose-round-2.md")
|
||||
|
||||
@@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from review_rules.round_titles import Findings, lacks_counts, past_cap, round_counts, round_findings, rounds_past_first
|
||||
from review_rules.round_titles import Findings, lacks_counts, past_cap, reported, round_counts, round_findings, round_prefix, rounds_past_first, title_counts
|
||||
|
||||
|
||||
class Rounds(unittest.TestCase):
|
||||
@@ -81,3 +81,17 @@ class RoundFindings(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class Reported(unittest.TestCase):
|
||||
REPORT = "BLOCK\n\n### 🔴 [misread] `a.py:1` `f`: wrong\n\n### 🟡 `b.py:2`: worse\n\n### 🟡 [misread] `c.py:3`: worse\n\n### 🟢 `d.py:4`: nit\n\n### ❓ `e.py:5`: why\n\n- 🔴 `a.py:1` `f`: wrong, as the reply lists it\n#### 🟡 a sub-heading\nText naming 🔴 and [misread].\n"
|
||||
|
||||
def test_counts_the_findings_whose_heading_opens_with_their_mark(self):
|
||||
self.assertEqual(reported(self.REPORT), Findings(1, 2, 2))
|
||||
|
||||
def test_counts_none_in_a_report_without_findings(self):
|
||||
self.assertEqual(reported("APPROVE\n\nNothing found.\n"), Findings(0, 0, 0))
|
||||
|
||||
def test_spells_the_title_prefix_a_round_commit_opens_with(self):
|
||||
self.assertEqual(round_prefix("prose", 2, Findings(1, 2, 0)), "Answer prose round 2: 1 🔴, 2 🟡 (0 misread);")
|
||||
self.assertEqual(title_counts(round_prefix("prose", 2, Findings(1, 2, 1))), Findings(1, 2, 1), "the prefix parses as the counts it spells")
|
||||
|
||||
@@ -57,6 +57,7 @@ from rule_hook.repeat_read import read_breaches
|
||||
from rule_hook.reviewer_report import report_breaches
|
||||
from rule_hook.reviewer_rung import reviewer_breaches, skill_breaches
|
||||
from rule_hook.round_cap import round_cap_breaches
|
||||
from rule_hook.round_report import round_report_breaches
|
||||
from command_lines.shell_command import simple_commands
|
||||
from project_config import templates
|
||||
from rule_hook.todo_check import todo_breaches
|
||||
@@ -142,7 +143,7 @@ def commit_breaches(commit: CommitCall, home: pathlib.Path) -> list[Breach]:
|
||||
titles = config.titles if isinstance(config, ProjectConfig) else templates.BARE
|
||||
# A checkout no config names has no branch template, so no title of its must fit one.
|
||||
branch = checkout_branch(commit.directory) if isinstance(config, ProjectConfig) else None
|
||||
return unread + title_breaches(commit, titles, config.branch if isinstance(config, ProjectConfig) else templates.BRANCH, branch) + round_cap_breaches(commit, titles) + todo_breaches(commit.directory, home)
|
||||
return unread + title_breaches(commit, titles, config.branch if isinstance(config, ProjectConfig) else templates.BRANCH, branch) + round_cap_breaches(commit, titles) + round_report_breaches(commit, titles, home) + todo_breaches(commit.directory, home)
|
||||
|
||||
|
||||
def checkout_branch(directory: str) -> str | None:
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
"""rule-hook's check of a round commit's counts against the round's report in the chunk's review folder."""
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
from git_cli.git_command import CommitCall
|
||||
from git_cli.git_repo import git
|
||||
from project_config.templates import Titles
|
||||
from review_rules.review_folder import findings_in, review_folder, standing_report
|
||||
from review_rules.round_titles import ROUND, round_prefix, title_counts
|
||||
from rule_hook.rules import Breach
|
||||
|
||||
|
||||
def round_report_breaches(commit: CommitCall, titles: Titles, home: pathlib.Path) -> list[Breach]:
|
||||
"""A breach for each round title, read as its summary in titles, whose counts differ from those its round's report gives. A title without all three counts is title_breaches' to refuse. A round whose report is missing goes through, as does every round where git cannot name the commit's checkout within 5 seconds."""
|
||||
summaries = [titles.summary(message.strip()) for message in commit.messages]
|
||||
rounds = [(named, counts) for summary in summaries if (named := ROUND.match(summary)) and (counts := title_counts(summary)) and counts.misread is not None]
|
||||
if not rounds:
|
||||
return []
|
||||
worktree = git("rev-parse", "--show-toplevel", cwd=commit.directory, timeout=5, guarded=True)
|
||||
if isinstance(worktree, Failure):
|
||||
return []
|
||||
folder = pathlib.Path(review_folder(str(home), worktree.strip()))
|
||||
breaches = []
|
||||
for named, counts in rounds:
|
||||
pass_, round_ = named.group(1).lower(), int(named.group(2))
|
||||
report = standing_report(folder, pass_, round_)
|
||||
found = findings_in(report)
|
||||
if not isinstance(found, Failure) and found != counts:
|
||||
breaches.append(Breach("round-title-counts", f"{report} reports `{round_prefix(pass_, round_, found)}`; open the title so, as `larv-review round-title {pass_}` prints it before the round's commit", commit.directory))
|
||||
return breaches
|
||||
@@ -84,7 +84,7 @@ RULES: dict[RuleName, Rule] = {
|
||||
),
|
||||
"round-title-counts": Rule(
|
||||
f"a larv-review round's commit title gives the counts of 🔴 and 🟡 findings the round reported, and how many of them a reviewer marked `[misread]`, at most the two together, such as `{EXAMPLE}`, since score-outcomes counts them",
|
||||
f"a git commit whose message opens `{OPENING}`",
|
||||
f"a git commit whose message opens `{OPENING}`; its counts are checked against the round's report in the chunk's review folder, where that report exists",
|
||||
),
|
||||
"run-heavy": Rule(
|
||||
"a heavy command, which loads the machine for minutes, runs under ~/.claude/bin/run-heavy, so sessions running at once cannot starve the machine",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2447,3 +2447,47 @@ Read most (opens and searches):
|
||||
- `bin/touch_predictions/main.py` 1
|
||||
- `reviewer-merge-trials/README.md` 1
|
||||
- `rules/todo-items.md` 1
|
||||
|
||||
## Reading cost, chunk 637d840c5031, finished 2026-11-17T05:58:12Z
|
||||
|
||||
97466 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `bin/plan_store/test_jira_epic.py` 11
|
||||
- `bin/plan_store/jira_epic.py` 10
|
||||
- `docs/decisions.md` 6
|
||||
- `README.md` 4
|
||||
- `bin/todo_item/main.py` 4
|
||||
- `bin/plan_store/contract.py` 3
|
||||
- `bin/atlassian/client.py` 1
|
||||
- `bin/plan/todo_table.py` 1
|
||||
- `bin/plan_store/plans.py` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
|
||||
## Reading cost, chunk 4b65f63af158, finished 2026-11-17T06:15:54Z
|
||||
|
||||
112933 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `docs/decisions.md` 7
|
||||
- `bin/plan_store/jira_epic.py` 5
|
||||
- `bin/plan_store/test_jira_epic.py` 5
|
||||
- `bin/record_store/test_confluence_page.py` 4
|
||||
- `todo.md` 3
|
||||
- `bin/adf_codec/convert.py` 2
|
||||
- `bin/adf_codec/test_adf_codec.py` 2
|
||||
- `bin/record_store/confluence_page.py` 2
|
||||
- `README.md` 1
|
||||
- `bin/adf_codec/node_shim/shim.mjs` 1
|
||||
|
||||
## Reading cost, chunk 5e92988cd08e, finished 2026-11-17T06:39:56Z
|
||||
|
||||
134048 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `bin/larv_review/main.py` 1
|
||||
- `skills/comprehension-panel/SKILL.md` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
|
||||
@@ -83,7 +83,7 @@ Give a reviewer without Bash `git ls-files`'s output in its prompt, since some h
|
||||
|
||||
- **Round.** A round is one review by a pass's reviewer: the first and each re-entry. The rerun after the architect returns Stage 0 questions ("Architecture" below) and a relaunch one rung up ("Rung up" below) stay in their round.
|
||||
- **Auto-reviewer.** The external auto-reviewer (§4) is a pass of its own, each review it posts, up to the cap, a round. Its count is the number of its reviews on the PR, less its reviews of a `Record the comprehension check:` commit, and `round-count` doesn't list it. A commit that answers one of its rounds takes an ordinary title, not an `Answer <pass> round` one, and a round that didn't change anything gets no commit.
|
||||
- **Count.** Close each round of a pass other than the auto-reviewer with one commit that holds the round's fixes. Title it `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); …`: `<pass>` is the pass's name in lower case, such as `full scan`, `<k>` and `<m>` are the 🔴 and 🟡 findings all the round's reviewers reported, and `<j>` is how many of those they marked `[misread]` (review-findings.md → "Misread"); a reviewer that marks none, such as `/security-review`, adds 0. Example: `Answer stability round 1: 1 🔴, 2 🟡 (1 misread); flag a deleted test`. A round that didn't change anything gets an empty commit (`git commit --allow-empty`). Push the commits when §4 runs next, where there is a remote. `~/.claude/bin/larv-review round-count` prints each pass's count and marks a pass at the cap.
|
||||
- **Count.** Close each round of a pass other than the auto-reviewer with one commit that holds the round's fixes. Title it `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); …`: `<pass>` is the pass's name in lower case, such as `full scan`, `<k>` and `<m>` are the 🔴 and 🟡 findings all the round's reviewers reported, and `<j>` is how many of those they marked `[misread]` (review-findings.md → "Misread"); a reviewer that marks none, such as `/security-review`, adds 0. Example: `Answer stability round 1: 1 🔴, 2 🟡 (1 misread); flag a deleted test`. For a pass an agent under `~/.claude/agents/` reviews, `~/.claude/bin/larv-review round-title <pass>` prints the title up to and including its `;`, counted from the round's report, and rule-hook's `round-title-counts` refuses a title whose counts differ from it; write only the summary after it. A round that didn't change anything gets an empty commit (`git commit --allow-empty`). Push the commits when §4 runs next, where there is a remote. `~/.claude/bin/larv-review round-count` prints each pass's count and marks a pass at the cap.
|
||||
- **Done.** A pass is done when its latest round leaves no 🔴 or 🟡 standing: none was reported, or each was shown factually wrong, declined, filed, or named under the bar per "Findings", or settled in the PR summary per "Comprehension check" → "Places", or, for the prose pass and a pass at its cap, fixed. A stability pass whose round's fixes skip the next round per "Re-entry" → "Mechanical answers" is done once that rule's run is clean. Resolve that round's 🟢s and ❓s per "Findings" too.
|
||||
- **Cap.** A pass takes at most two rounds per chunk, and the release review's architecture and principles passes five; don't ask the user for more. Answer its last round's findings per "Findings": those fixes merge once the gate passes, unreviewed by that pass. rule-hook's `round-cap` refuses a round commit that would take a pass past its cap, and no override waives it. A review the auto-reviewer posts after its second isn't a round: fix none of it and rerun no pass for it, but file a security finding it raises per `~/.claude/CLAUDE.md` → "Working loop", and any other 🔴 in `todo.md`.
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ Where your report holds a finding against `quality.md`, or you are systems-archi
|
||||
|
||||
## Report
|
||||
|
||||
Write your full report with the Write tool to the file your prompt names. The file is the worker's input, which it searches for each finding's entry, so write it even where your harness says to return findings directly. It holds the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only:
|
||||
Write your full report with the Write tool to the file your prompt names. The file is the worker's input, which it searches for each finding's entry, so write it even where your harness says to return findings directly. It holds the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Open each finding with a `###` heading: its severity mark, `[misread]` where you marked it so, then its place, as in ``### 🔴 [misread] `bin/example.py:42` `parse`: an empty line raises IndexError``. `larv-review round-title` counts the round's 🔴 and 🟡 findings by these headings, so no other line of the report may open with `### 🔴` or `### 🟡`. Then return only:
|
||||
|
||||
- the verdict line
|
||||
- one line per finding, in this order: its severity mark, `[misread]` where you marked the finding so, its place, and what is wrong, in one sentence. Where the finding breaks the review standards' `quality.md` or a file in the config's principles folder, end the line with that file's name. For a 🔀, end it with the reviewer it names. Example: ``🟡 `bin/example.py:42` `parse`: an empty line raises IndexError (technical-principles.md)``
|
||||
|
||||
Reference in New Issue
Block a user