From 78843560cf549e84e4b451887623f1a64d6addf5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:50:54 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20architecture=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20give=20the=20review=20folde?= =?UTF-8?q?r=20one=20owner=20in=20larv-review=20review-folder,=20which=20m?= =?UTF-8?q?akes=20it=20private=20and=20prints=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- bin/larv_review/main.py | 46 +++++++++++++++++------ bin/larv_review/test_larv_review.py | 11 ++++++ bin/repo_checks/test_reviewer_launches.py | 5 +-- skills/larv-review/SKILL.md | 2 +- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bed8b534..7247291a 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `chunk-preflight` finds the mechanical facts a chunk starts from and makes its worktree; `loop-claude` runs it before it routes each chunk, and `chunk-preflight --help` lists the facts. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints the lowest rung that, like each rung above it, returns them; `judge-replay --help` states the replay. -- `larv-review ` holds larv-review's mechanical rules: the paired ruling's base and vote count, each pass's round count, the scoring run's trigger, and the comprehension history's format and latest places, and its count of how often seats agree; `larv-review --help` states them. +- `larv-review ` 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 the comprehension history's format and latest places, and its count of how often seats agree; `larv-review --help` states them. - `loop-claude ` runs a project's next chunk 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. - `rank_todo.py [--check] [todo.md]` scores and ranks a project's `todo.md`; `rank_todo.py --help` states the format. diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index e0300743..f51d87f8 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -1,17 +1,21 @@ -"""Hold larv-review's mechanical rules: the paired ruling's base and vote count, each pass's rounds, the scoring run's trigger, and the comprehension history's format and latest places, and its count of how often seats agree. +"""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 the comprehension history's format and latest places, and its count of how often seats agree. -usage: larv-review ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement +usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement The comprehension check records how hard a project is to read, two ways, and blocks no merge. In a paired ruling, simulated readers, the seats, read the branch's head beside a base and vote better, same or worse, overall and on each dimension. In a scoring run, four seats score the project from 1 to 10. Each seat names the places it found hard. -Run it inside a project checkout or one of its worktrees. Each command but 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 reads origin as -last fetched and says so on stderr; the other three exit 1. The history is -docs/comprehension-history.md in the checkout. +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 reads origin as last fetched and says so on stderr; the other three 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 +path: ~/.local/state/larv-review/ followed by the worktree's path relative to ~, or to / outside it. +It leaves ~/.local/state/larv-review readable by you alone. ruling-base prints the commit a paired ruling reads against, then which of these found it. The last measured commit is the default branch's newest merged change that adds a paired ruling or a scoring @@ -87,7 +91,8 @@ when the history already holds an entry on what that line reads. Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that breaks the shape above, or when git cannot start, finds no checkout or no default branch, cannot -fetch origin for ruling-base, needs-scoring-run or record-scoring, or cannot read or write the history or todo.md. +fetch origin for ruling-base, needs-scoring-run or record-scoring, or cannot read or write the +history, todo.md or the review folder. """ import pathlib import re @@ -95,7 +100,7 @@ import sys import typing from round_titles import CAP, PASSES, round_counts -from git_repo import default_branch, git +from git_repo import default_branch, git, top from failure import Failure from larv_review.scoring import FLOOR from larv_review.git import history_changes @@ -103,8 +108,9 @@ from larv_review.ruling_base import measured_commit from larv_review.agreement import MIN_PAIRS from larv_review.plan import plan_reasons from larv_review.record import record_ruling, record_scoring, show_agreement, show_places +from review_folder import REPORTS, review_folder -USAGE = "usage: larv-review ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement" +USAGE = "usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement" def main(argv: list[str]) -> int: @@ -112,7 +118,9 @@ def main(argv: list[str]) -> int: print(__doc__.strip().format(cap=CAP, floor=FLOOR, pairs=MIN_PAIRS)) return 0 command, *given = argv or [""] - if command == "ruling-base" and not given: + if command == "review-folder" and not given: + done = make_review_folder() + elif command == "ruling-base" and not given: done = with_default_branch(show_ruling_base, stale_ok=False) elif command == "round-count" and not given: done = with_default_branch(round_count, stale_ok=True) @@ -152,6 +160,22 @@ def with_default_branch(command: typing.Callable[[str], Failure | None], stale_o return command(branch) +def make_review_folder() -> Failure | None: + worktree = top() + if isinstance(worktree, Failure): + return worktree + home = pathlib.Path.home() + folder = pathlib.Path(review_folder(str(home), worktree)) + try: + (home / REPORTS).mkdir(parents=True, exist_ok=True) + (home / REPORTS).chmod(0o700) + folder.mkdir(parents=True, exist_ok=True) + except OSError as failure: + return Failure(f"could not make the review folder {folder}: {failure}") + print(folder) + return None + + def show_ruling_base(default: str) -> Failure | None: changes = history_changes(default) if isinstance(changes, Failure): diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index c18b6732..cf9eb45d 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -447,6 +447,17 @@ class LarvReviewTool(unittest.TestCase): self.git("remote", "set-head", "origin", "--delete") self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n") + def test_makes_and_prints_the_worktrees_review_folder_readable_by_the_user_alone(self): + reports = self.checkout.parent / ".local" / "state" / "larv-review" + reports.mkdir(parents=True, mode=0o755) + (self.checkout / "sub").mkdir() + ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout / "sub", env=self.env, text=True) + self.assertEqual((ran.returncode, ran.stdout), (0, f"{reports}/proj\n"), ran.stderr) + self.assertTrue((reports / "proj").is_dir()) + self.assertEqual(reports.stat().st_mode & 0o777, 0o700) + self.assertEqual(self.run_tool("review-folder").stdout, f"{reports}/proj\n") + self.assertIn("unknown arguments", self.run_tool("review-folder", "x").stderr) + def test_takes_a_local_main_without_origin_and_reads_origin_as_last_fetched_when_the_fetch_fails(self): self.commit("Answer prose round 1: a") self.git("remote", "set-url", "origin", str(self.checkout.parent / "gone.git")) diff --git a/bin/repo_checks/test_reviewer_launches.py b/bin/repo_checks/test_reviewer_launches.py index 7658af39..7351e1c9 100644 --- a/bin/repo_checks/test_reviewer_launches.py +++ b/bin/repo_checks/test_reviewer_launches.py @@ -5,7 +5,6 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from review_folder import REPORTS from rule_hook.reviewer_rung import REVIEWERS, SEAT, SECURITY_OPENER from repo_checks.test_python_floor import ROOT @@ -30,5 +29,5 @@ class ReviewerLaunches(unittest.TestCase): security = LARV_REVIEW.split("### Security", 1)[1].split("### Overrides", 1)[0] self.assertIn(SECURITY_OPENER, security) - def test_larv_review_names_the_reports_folder_rule_hook_lets_a_reviewer_write_into(self): - self.assertIn(f"`~/{REPORTS}//`. Make it, and keep `~/.local/state/larv-review` readable by you alone: `mkdir -p && chmod 700 ~/.local/state/larv-review`. Keep it after the merge: `stability-replay` replays a round from the reports its prompt names. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's write anywhere else. +**Reports.** Run `~/.claude/bin/larv-review review-folder` in the chunk's worktree: it makes the chunk's review folder and prints its path. Keep the folder after the merge: `stability-replay` replays a round from the reports its prompt names. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's write anywhere else. `~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger, and the history's format and latest places, and its count of how often seats agree. Run it in the chunk's worktree; `~/.claude/bin/larv-review --help` states each rule. On exit 1, repair what its message names and run it again; when you cannot, ask the user.