Answer principles round 1: 0 🔴, 6 🟡; derive the reviewers from agents/, open the security pass's prompt with a sentence, and type the review kinds

This commit is contained in:
2026-10-16 06:53:03 +02:00
parent e07c20bd60
commit 56b5924902
5 changed files with 34 additions and 33 deletions
+8 -8
View File
@@ -1,18 +1,18 @@
"""Hold each Agent call that launches a review to the rung loop-claude hands its worker: docs/decisions.md → `routing:`."""
import re
import pathlib
import typing
from rule_hook.rules import Breach
from rule_hook.call import Call, text
from model_routing.worker_rungs import handed
from model_routing.ladder import position, review_rung, Rung
from model_routing.ladder import position, review_rung, ReviewKind, Rung
# larv-review §3's reviewers, by the subagent type its passes launch.
REVIEWERS = frozenset(("override-reviewer", "principles-auditor", "product-owner-reviewer", "prose-reviewer", "stability-reviewer", "systems-architect"))
# A reviewer is an agent under agents/, as CLAUDE.md → "Vocabulary" defines it.
REVIEWERS = frozenset(path.stem for path in (pathlib.Path(__file__).resolve().parents[2] / "agents").glob("*.md"))
# The opening of every comprehension seat's prompt: skills/comprehension-panel/seat-prompts.md → "Opening".
SEAT = "You are one seat of a comprehension panel."
# The security pass's subagent invokes one of these skills.
SECURITY = re.compile(r"/security-review\b|/claude-security\b")
# The opening of the security pass's prompt: skills/larv-review/SKILL.md → "Security".
SECURITY_OPENER = "You are the security pass for this chunk."
SUBJECTS = {"seat": "a comprehension seat", "security": "the security pass's subagent"}
@@ -30,14 +30,14 @@ def reviewer_breaches(call: Call, environ: typing.Mapping[str, str]) -> list[Bre
return [Breach("reviewer-rung", f"{subject} would run on {named}, below {required}: launch it with {required.agent_args()}", call.cwd)]
def review_kind(given: dict[str, typing.Any]) -> str | None:
def review_kind(given: dict[str, typing.Any]) -> ReviewKind | None:
"""What a launch reviews, a reviewer, a comprehension seat or the security pass; None for any other subagent."""
if text(given, "subagent_type") in REVIEWERS:
return "reviewer"
prompt = text(given, "prompt")
if SEAT in prompt:
return "seat"
if SECURITY.search(prompt):
if SECURITY_OPENER in prompt:
return "security"
return None
+10 -4
View File
@@ -177,7 +177,9 @@ class ReviewerRung(unittest.TestCase):
def test_a_reviewer_below_the_project_rung_is_refused_naming_the_arguments_to_pass(self):
breaches = reviewer_breaches(Call("Agent", {"subagent_type": "stability-reviewer", "model": "sonnet", "effort": "high", "prompt": "Review."}, "/r"), self.ENVIRON)
self.assertEqual(rules(breaches), ["reviewer-rung"])
self.assertEqual(breaches[0].detail, "stability-reviewer would run on claude-sonnet-5-5 at high effort, below claude-opus-5-5 at medium effort: launch it with model opus, effort medium")
self.assertIn("stability-reviewer", breaches[0].detail)
self.assertIn("claude-sonnet-5-5 at high effort", breaches[0].detail)
self.assertIn("model opus, effort medium", breaches[0].detail)
def test_a_reviewer_on_the_project_rung_or_a_rerun_above_it_passes(self):
self.assertEqual(self.refused({"subagent_type": "prose-reviewer", "model": "opus", "effort": "medium"}), [])
@@ -205,8 +207,8 @@ class ReviewerRung(unittest.TestCase):
def test_a_seat_or_a_security_launch_is_held_to_the_project_rung_alone(self):
seat = {"prompt": "You are one seat of a comprehension panel. Tools: Read, Grep, Glob.", "model": "opus", "effort": "medium"}
self.assertEqual(self.refused(seat, self.ABOVE), [])
self.assertEqual(self.refused({"prompt": "Invoke /security-review over the branch diff.", "model": "sonnet", "effort": "high"}), ["reviewer-rung"])
self.assertEqual(self.refused({"prompt": "Run /claude-security scan this branch's changes at high.", "model": "opus", "effort": "medium"}), [])
self.assertEqual(self.refused({"prompt": "You are the security pass for this chunk. Invoke /security-review over the branch diff.", "model": "sonnet", "effort": "high"}), ["reviewer-rung"])
self.assertEqual(self.refused({"prompt": "You are the security pass for this chunk. Run /claude-security scan this branch's changes at high.", "model": "opus", "effort": "medium"}), [])
def test_a_seat_named_below_the_project_rung_is_refused(self):
self.assertEqual(self.refused({"prompt": "You are one seat of a comprehension panel.", "model": "sonnet", "effort": "high"}), ["reviewer-rung"])
@@ -214,6 +216,7 @@ class ReviewerRung(unittest.TestCase):
def test_any_other_subagent_keeps_its_own_routing(self):
self.assertEqual(self.refused({"subagent_type": "Explore", "model": "haiku", "effort": "low", "prompt": "Find the callers of run_worker."}), [])
self.assertEqual(self.refused({"prompt": "Note that security-review runs in CI.", "model": "haiku", "effort": "low"}), [])
self.assertEqual(self.refused({"prompt": "Find where /security-review is named.", "model": "haiku", "effort": "low"}), [], "a mention without the opening sentence is no launch")
def test_a_claude_loop_claude_did_not_start_is_not_checked(self):
self.assertEqual(self.refused({"subagent_type": "stability-reviewer", "model": "haiku", "effort": "low"}, {}), [])
@@ -283,7 +286,10 @@ class Hook(unittest.TestCase):
call = {"cwd": self.repo, "tool_input": {"subagent_type": "stability-reviewer", "model": "sonnet", "effort": "high", "prompt": "Review. # rule-override reviewer-rung: trust me"}, "tool_name": "Agent"}
ran = hook(call, self.repo, ReviewerRung.ENVIRON)
self.assertEqual(ran.returncode, 2)
self.assertIn("Blocked by rule reviewer-rung: stability-reviewer would run on claude-sonnet-5-5 at high effort", ran.stderr)
self.assertIn("Blocked by rule reviewer-rung", ran.stderr)
self.assertIn("stability-reviewer", ran.stderr)
self.assertIn("claude-sonnet-5-5 at high effort", ran.stderr)
self.assertIn("model opus, effort medium", ran.stderr)
self.assertNotIn("rule-override", ran.stderr)
def test_an_agent_call_at_its_rung_passes(self):