Answer architecture round 1: 0 🔴, 7 🟡; move the reports to a durable review folder under ~/.local/state, carry the yardstick, the named reviewer and the test status in each reply line, read an entry by Grep, name the folder once, print which rules take no override, and file items 185 and 186

This commit is contained in:
2026-10-18 00:20:13 +02:00
parent 9207566328
commit 8df46e3a85
11 changed files with 42 additions and 28 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ subagent. The rules:
{rules}
A file a Bash command writes, such as through `cat > Dockerfile`, is not checked. The reviewer-rung rule takes no override.
A file a Bash command writes, such as through `cat > Dockerfile`, is not checked.
A call overrides a rule with `# rule-override <rule>: <reason>`:
@@ -82,7 +82,7 @@ def breaches_of(call: Call, home: str, environ: typing.Mapping[str, str]) -> tup
return None
before = read(path)
added, after = applied(call, before)
return added, path, report_breaches(call, path) + file_breaches(path, before, added, after)
return added, path, report_breaches(call, path, home) + file_breaches(path, before, added, after)
def answer(judged: Outcome, what: str, now: float) -> int:
+6 -8
View File
@@ -3,17 +3,15 @@ import os
from rule_hook.call import Call
from rule_hook.reviewer_rung import REVIEWERS
from rule_hook.rules import Breach
# Outside every checkout, so no project sees a report. A fixed path, since a headless session has no scratchpad.
REPORTS = "/tmp/larv-review"
from rule_hook.rules import Breach, REPORTS
def report_breaches(call: Call, path: str) -> list[Breach]:
"""The breach of a file call from a reviewer that is not a Write under REPORTS; none from any other agent."""
def report_breaches(call: Call, path: str, home: str) -> list[Breach]:
"""The breach of a file call from a reviewer that is not a Write under REPORTS in home; none from any other agent."""
if call.agent not in REVIEWERS:
return []
written = os.path.realpath(os.path.join(call.cwd, path))
if call.tool == "Write" and written.startswith(os.path.realpath(REPORTS) + "/"):
reports = os.path.realpath(os.path.join(home, REPORTS))
if call.tool == "Write" and written.startswith(reports + "/"):
return []
return [Breach("reviewer-report", f"{call.agent} would {call.tool.lower()} {written}; write your report with Write to the path your prompt names, under {REPORTS}/", call.cwd)]
return [Breach("reviewer-report", f"{call.agent} would {call.tool.lower()} {written}; write your report with Write to the path your prompt names, under {reports}/", call.cwd)]
+4 -2
View File
@@ -18,6 +18,8 @@ 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",
@@ -41,7 +43,7 @@ RULES: dict[RuleName, Rule] = {
),
# A reviewer only reports, so no marker waives it.
"reviewer-report": Rule(
"a reviewer writes nothing but its report, with Write, into a file under /tmp/larv-review/, outside every checkout",
f"a reviewer writes nothing but its report, with Write, into a file under ~/{REPORTS}/",
"a Write, Edit or MultiEdit call from inside an agent under agents/",
overridable=False,
),
@@ -186,4 +188,4 @@ def blocks(written: str) -> list[list[str]]:
def rules_help() -> str:
return "\n".join(f" {name}\n The rule: {rule.holds}.\n Checked in: {rule.checked}." for name, rule in RULES.items())
return "\n".join(f" {name}\n The rule: {rule.holds}.\n Checked in: {rule.checked}." + ("" if rule.overridable else "\n Takes no override.") for name, rule in RULES.items())
+8 -5
View File
@@ -240,16 +240,16 @@ class ReviewerReport(unittest.TestCase):
return rules(found[2]) if found else []
def test_a_reviewer_writes_its_report_into_the_reports_folder(self):
self.assertEqual(self.breached("Write", "/tmp/larv-review/.claude-item-73/prose-round-1.md"), [])
self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/tmp/larv-review/x"), [], "a relative path resolves against the call's cwd")
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_reviewer_writing_anywhere_else_is_refused(self):
for path in ["/r/README.md", "/tmp/larv-review", "/tmp/larv-review-x/a.md", "/tmp/larv-review/../etc/a.md", "/tmp/a.md"]:
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"]:
with self.subTest(path):
self.assertEqual(self.breached("Write", path), ["reviewer-report"])
def test_a_reviewer_edits_no_file_even_in_the_reports_folder(self):
self.assertEqual(self.breached("Edit", "/tmp/larv-review/x/prose-round-1.md"), ["reviewer-report"])
self.assertEqual(self.breached("Edit", "/h/.local/state/larv-review/x/prose-round-1.md"), ["reviewer-report"])
self.assertEqual(self.breached("MultiEdit", "/r/a.py", "stability-reviewer"), ["reviewer-report"])
def test_the_worker_and_other_subagents_write_anywhere(self):
@@ -336,7 +336,7 @@ class Hook(unittest.TestCase):
ran = hook(call, self.repo)
self.assertEqual(ran.returncode, 2)
self.assertIn("Blocked by rule reviewer-report: prose-reviewer would write ", ran.stderr)
self.assertIn("/tmp/larv-review/", ran.stderr)
self.assertIn("/.local/state/larv-review/", ran.stderr)
self.assertNotIn("rule-override", ran.stderr)
def test_a_commit_override_is_logged_in_the_commit_s_checkout(self):
@@ -404,3 +404,6 @@ class Hook(unittest.TestCase):
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"]:
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")
self.assertRegex(helped, r" image-pin\n( .*\n){2} ", "a rule a marker waives says nothing of overrides")