Answer principles round 1: 1 🔴, 7 🟡; sort the new imports, test a symlink in the reports folder, own the folder's path in review_folder.py and check SKILL.md names it, redirect stability-replay's reviewer to a copy of the chunk's folder and keep folders after the merge, keep the folder private, override the harness's no-report-files note, and state what a reviewer may write

This commit is contained in:
2026-10-18 00:37:24 +02:00
parent 3adf58c619
commit 3928d84acb
13 changed files with 83 additions and 21 deletions
@@ -5,6 +5,7 @@ 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
@@ -28,3 +29,6 @@ class ReviewerLaunches(unittest.TestCase):
def test_the_security_opening_is_the_sentence_larv_review_has_the_security_pass_open_with(self):
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}/<the worktree's path", LARV_REVIEW)
+2 -1
View File
@@ -1,9 +1,10 @@
"""Refuse a reviewer's file call other than a Write of its report into the reports folder: skills/larv-review/review-findings.md → "Report"."""
import os
from rule_hook.rules import Breach
from rule_hook.call import Call
from review_folder import REPORTS
from rule_hook.reviewer_rung import REVIEWERS
from rule_hook.rules import Breach, REPORTS
def report_breaches(call: Call, path: str, home: str) -> list[Breach]:
+1 -2
View File
@@ -5,6 +5,7 @@ import typing
from git_command import commits
from round_titles import lacks_counts
from review_folder import REPORTS
from shell_command import Simple
RuleName = typing.Literal["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "reviewer-rung", "round-title-counts", "todo-rank-check"]
@@ -18,8 +19,6 @@ class Rule:
overridable: bool = True
# The reviewers' reports folder, under the home folder: outside every checkout, so no project sees a report, and kept across a reboot, so a resumed chunk still reads its rounds. A fixed path, since a headless session has no scratchpad.
REPORTS = ".local/state/larv-review"
RULES: dict[RuleName, Rule] = {
"action-pin": Rule(
"a GitHub or Gitea Action is pinned to a semver tag, such as @v3 or @v3.1.2, never to a branch, and to a commit SHA only in a pipeline that tests our own specific builds",
+13 -2
View File
@@ -241,7 +241,16 @@ class ReviewerReport(unittest.TestCase):
def test_a_reviewer_writes_its_report_into_the_reports_folder(self):
self.assertEqual(self.breached("Write", "/h/.local/state/larv-review/.claude-item-73/prose-round-1.md"), [])
self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/h/.local/state/larv-review/x"), [], "a relative path resolves against the call's cwd")
def test_a_relative_path_resolves_against_the_calls_cwd(self):
self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/h/.local/state/larv-review/x"), [])
def test_a_symlink_in_the_reports_folder_is_followed_to_where_it_points(self):
home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
(home / ".local" / "state" / "larv-review").mkdir(parents=True)
(home / ".local" / "state" / "larv-review" / "out").symlink_to(home)
found = breaches_of(Call("Write", {"file_path": f"{home}/.local/state/larv-review/out/a.md", "content": "x"}, "/r", "prose-reviewer"), str(home), {})
self.assertEqual(rules(found[2]) if found else [], ["reviewer-report"])
def test_a_reviewer_writing_anywhere_else_is_refused(self):
for path in ["/r/README.md", "/h/.local/state/larv-review", "/h/.local/state/larv-review-x/a.md", "/h/.local/state/larv-review/../a.md", "/tmp/larv-review/a.md"]:
@@ -250,6 +259,8 @@ class ReviewerReport(unittest.TestCase):
def test_a_reviewer_edits_no_file_even_in_the_reports_folder(self):
self.assertEqual(self.breached("Edit", "/h/.local/state/larv-review/x/prose-round-1.md"), ["reviewer-report"])
def test_a_reviewers_multiedit_is_refused(self):
self.assertEqual(self.breached("MultiEdit", "/r/a.py", "stability-reviewer"), ["reviewer-report"])
def test_the_worker_and_other_subagents_write_anywhere(self):
@@ -402,7 +413,7 @@ class Hook(unittest.TestCase):
def test_help_lists_every_rule(self):
helped = subprocess.run([str(HOOK), "--help"], capture_output=True, check=True, env=isolated_env(), text=True).stdout
for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "round-title-counts", "todo-rank-check"]:
for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "reviewer-rung", "round-title-counts", "todo-rank-check"]:
self.assertIn(f" {rule}\n The rule: ", helped)
self.assertIn("reviewer-report\n The rule: a reviewer writes nothing but its report", helped)
self.assertRegex(helped, r" reviewer-report\n( .*\n){2} Takes no override\.\n")
+14 -5
View File
@@ -46,6 +46,7 @@ from failure import Failure
from rung_replay.search import first_reply, replayed
from claude_code.transcript import first_timestamped_line, read_transcript
from claude_code.entries import parse_entry, structured_output
from review_folder import REPORTS, review_folder
from model_routing.ladder import Rung
TOOL = "stability-replay"
@@ -80,7 +81,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
return failed(TOOL, f"no archived stability round of projects on {anchor.model} in {archive_root(home, env)} holds a 🔴 or 🟡 on code it can find")
chosen = sample(list(codes), LATEST)
# The project's rung is the reference, so the candidates start below it.
replay = replayed(chosen, anchor, down_from(anchor)[1:], lambda found, rung: findings_found(found, codes[found], rung, anchor, effects), lambda _, found: sorted(found), "stability rounds")
replay = replayed(chosen, anchor, down_from(anchor)[1:], lambda found, rung: findings_found(found, codes[found], rung, anchor, home, effects), lambda _, found: sorted(found), "stability rounds")
if isinstance(replay, Limited):
return limited_exit(TOOL, replay)
print(report(anchor.model, anchor, chosen, replay))
@@ -147,9 +148,9 @@ def commit_log(listed: str) -> list[tuple[str, float]]:
return [(commit, float(authored)) for commit, authored in (line.split() for line in listed.splitlines())]
def findings_found(found: Round, code: Code, rung: Rung, anchor: Rung, effects: Effects) -> set[int] | Limited:
def findings_found(found: Round, code: Code, rung: Rung, anchor: Rung, home: pathlib.Path, effects: Effects) -> set[int] | Limited:
"""The indexes of the round's findings that its replay on rung reports, as the reviewer on anchor matches them."""
reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, effects))
reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, effects))
if isinstance(reviewed, Limited):
return reviewed
matched: set[int] | Failure | Limited = reviewed if isinstance(reviewed, Failure) else first_reply(lambda: match(found.findings, reviewed, found.root, anchor, effects))
@@ -160,8 +161,15 @@ def findings_found(found: Round, code: Code, rung: Rung, anchor: Rung, effects:
# The shell makes and removes the clone itself, and is tested on a temporary home as judge-replay's is; rounds.py's core takes the filesystem as an argument.
def review(found: Round, code: Code, rung: Rung, effects: Effects) -> str | Failure | Limited:
def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects) -> str | Failure | Limited:
clone = tempfile.mkdtemp(prefix="stability-replay-")
# The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names.
folder = pathlib.Path(review_folder(str(home), code.path))
(home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True)
reports = tempfile.mkdtemp(prefix="stability-replay-", dir=home / REPORTS)
if folder.is_dir():
shutil.copytree(folder, reports, dirs_exist_ok=True)
prompt = found.prompt.replace(str(folder), reports).replace(f"~/{folder.relative_to(home)}", reports).replace(code.path, clone)
try:
for command in (
("clone", "--quiet", "--shared", "--no-checkout", found.root, clone),
@@ -172,12 +180,13 @@ def review(found: Round, code: Code, rung: Rung, effects: Effects) -> str | Fail
if isinstance(ran := git(effects, found.root, *command), Failure):
return ran
args = ["--agent", REVIEWER, *rung.flags()]
reply = claude_reply(effects.claude, args, clone, found.prompt.replace(code.path, clone), "claude")
reply = claude_reply(effects.claude, args, clone, prompt, "claude")
if isinstance(reply, Failure | Limited):
return reply
return reply["result"] if isinstance(reply.get("result"), str) else Failure("the reviewer replied with no report")
finally:
shutil.rmtree(clone, ignore_errors=True)
shutil.rmtree(reports, ignore_errors=True)
def match(findings: tuple[str, ...], replay_report: str, root: str, rung: Rung, effects: Effects) -> set[int] | Failure | Limited:
@@ -232,6 +232,28 @@ class Main(unittest.TestCase):
self.assertIn(f" {self.checkout} 2026-10-14T10:00:00Z: 🟡 slow", out)
self.assertTrue(out.endswith("finds: claude-sonnet-5-5 at high effort\n"))
def test_points_the_prompts_review_folder_at_a_copy_that_it_removes(self):
folder = self.home / ".local" / "state" / "larv-review" / "code" / "proj-x"
folder.mkdir(parents=True)
(folder / "stability-round-1.md").write_text("round 1\n")
self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/larv-review/code/proj-x/stability-round-1.md.")
seen = []
def review(rung):
named = pathlib.Path(re.search(r"report to (\S+)/stability-round-2\.md", self.reviews[-1][4]).group(1))
seen.append((named, (named / "stability-round-1.md").read_text()))
(named / "stability-round-2.md").write_text("replayed\n")
return {"type": "result", "result": f"review on {rung.model} {rung.effort}"}
code, _, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]}, review)
self.assertEqual(code, 0, err)
named, earlier = seen[0]
self.assertEqual(named.parent, folder.parents[1], "the copy sits in the reports folder, where rule-hook lets the reviewer write")
self.assertNotEqual(named, folder)
self.assertEqual(earlier, "round 1\n")
self.assertFalse(named.exists())
self.assertEqual(sorted(path.name for path in folder.iterdir()), ["stability-round-1.md"])
def test_replays_the_rounds_of_every_chunk(self):
self.write_chunk("proj", "c2", "2026-10-14T10:30:00Z")
code, out, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]})
+16
View File
@@ -0,0 +1,16 @@
import pathlib
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from review_folder import review_folder
class ReviewFolder(unittest.TestCase):
def test_keys_a_worktree_under_home_by_its_path_relative_to_home(self):
self.assertEqual(review_folder("/h", "/h/code/proj-item-3"), "/h/.local/state/larv-review/code/proj-item-3")
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")