diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 60b0399e..999b11a8 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1537,6 +1537,8 @@ class WorkerArgs(unittest.TestCase): self.assertIn(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand the hard part of a task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours, only once the human agrees; loop-claude will not resume you higher for a trigger either, so ask the human for that yes. Open the subagent's prompt with `Escalation trigger :`, n the trigger's number.", prompts.resumed("", Route(Rung("claude-fable-5-2", "medium"), 3, 3, 4), LADDER, opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-2", "max"), 3, 4, 8), LADDER, opus)) self.assertIn("only once the human agrees", prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 4, 5), LADDER, opus)) + self.assertIn("only once the human agrees", prompts.resumed("", Route(Rung("claude-fable-5-2", "high"), 3, 4, 5), LADDER, opus), "one rung below the top still names the rung above") + self.assertNotIn("rerun", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 3, 4), LADDER, opus), "a worker off the ladder is told no rerun rung") self.assertIn("hand the hard part of the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours;", prompts.resumed("", Route(Rung("claude-fable-5-2", "medium"), 3, 4, 5), LADDER, opus)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), LADDER, None)) self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 3, 4), LADDER, opus)) diff --git a/bin/model_routing/test_ladder.py b/bin/model_routing/test_ladder.py index 6e3adb4f..6b7b8fa1 100644 --- a/bin/model_routing/test_ladder.py +++ b/bin/model_routing/test_ladder.py @@ -91,6 +91,7 @@ class Ladder(unittest.TestCase): with self.subTest(model=model, effort=effort): self.assertNotIn(LADDER.from_agent(model, effort), LADDER.rungs) self.assertEqual(LADDER.from_agent("opus", "low"), Rung("claude-opus-5-5", "low")) + self.assertEqual(LADDER.from_agent("gpt", "high"), Rung("gpt", "high")) def test_puts_reviewers_on_the_highest_of_the_projects_rung_the_workers_and_the_one_e_plus_i_picks(self): sonnet, fable = LADDER.rungs[0], LADDER.rungs[-1] diff --git a/bin/project_config/test_project_config.py b/bin/project_config/test_project_config.py index 57a5cf2d..941ac178 100644 --- a/bin/project_config/test_project_config.py +++ b/bin/project_config/test_project_config.py @@ -122,7 +122,9 @@ class LoadTest(ConfigCase): def test_tells_a_checkout_no_config_names_from_one_whose_config_is_faulty(self) -> None: self.assertIsInstance(load(self.checkout, self.checkout, self.home), Unnamed) - self.assertIsInstance(located(str(self.checkout), self.home), Unnamed, "a folder that is no checkout has no config either") + outside = located(str(self.checkout), self.home) + self.assertIsInstance(outside, Unnamed, "a folder that is no checkout has no config either") + self.assertIn("not a git repository", outside.reason) self.write("acme", CLIENT.replace('plan = "folder:todo.md"\n', "")) self.assertNotIsInstance(load(self.checkout, self.checkout, self.home), Unnamed) self.assertIn("`plan` is missing", self.failure()) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index bcdcf052..b866f17a 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -337,6 +337,17 @@ class ReviewerRung(unittest.TestCase): breaches = reviewer_breaches(Call("Agent", {**reviewer, "effort": "medium"}, checkout), self.ON_TWO_RUNGS, home) self.assertEqual([breach.detail for breach in breaches], ["stability-reviewer would run on claude-fable-5-2 at medium effort, below claude-fable-5-2 at high effort: launch it with model fable, effort high"]) self.assertEqual(rules(reviewer_breaches(Call("Agent", {**reviewer, "effort": "medium"}, "/r"), self.ON_TWO_RUNGS, HOME)), []) + self.assertEqual(rules(breaches_of(Call("Agent", {**reviewer, "effort": "medium"}, checkout), home, self.ON_TWO_RUNGS)[2]), ["reviewer-rung"], "the hook reads the ladder under the home it is given") + + def test_a_rung_loop_claude_handed_that_the_projects_ladder_does_not_hold_is_not_checked(self): + # As when the ladder's file changed after loop-claude started the worker: the next cycle routes on the new ladder. + checkout, home = self.project(self.TWO_RUNGS) + reviewer = Call("Agent", {"subagent_type": "stability-reviewer", "model": "haiku", "effort": "low"}, checkout) + for name in ("LOOP_CLAUDE_PROJECT_RUNG", "LOOP_CLAUDE_WORKER_RUNG"): + with self.subTest(name=name): + environ = self.ON_TWO_RUNGS | {name: "claude-opus-5-5 at medium effort"} + self.assertEqual(reviewer_breaches(reviewer, environ, home), []) + self.assertEqual(skill_breaches(Call("Skill", {"skill": "security-review"}, checkout), environ, home), []) def test_a_security_skill_is_held_to_the_projects_rung_on_the_projects_own_ladder(self): checkout, home = self.project('[{"model": "claude-fable-5-2", "effort": "high"}, {"model": "claude-fable-5-2", "effort": "low"}]') @@ -344,6 +355,10 @@ class ReviewerRung(unittest.TestCase): environ = {"LOOP_CLAUDE_PROJECT_RUNG": "claude-fable-5-2 at high effort", "LOOP_CLAUDE_WORKER_RUNG": "claude-fable-5-2 at low effort"} self.assertEqual(skill_breaches(Call("Skill", {"skill": "security-review"}, checkout), environ, home), []) self.assertEqual(rules(skill_breaches(Call("Skill", {"skill": "security-review"}, "/r"), environ, HOME)), ["reviewer-rung"]) + self.assertEqual(rules(breaches_of(Call("Skill", {"skill": "security-review"}, "/r"), home, environ)[2]), ["reviewer-rung"]) + self.assertEqual(breaches_of(Call("Skill", {"skill": "security-review"}, checkout), home, environ)[2], []) + on_the_projects = environ | {"LOOP_CLAUDE_WORKER_RUNG": "claude-fable-5-2 at high effort"} + self.assertEqual(skill_breaches(Call("Skill", {"skill": "security-review"}, checkout), on_the_projects, home), [], "a worker on the project's rung runs the skill itself") def test_a_review_is_refused_where_the_projects_ladder_cannot_be_read_and_loop_claude_handed_rungs(self): checkout, home = self.project("[]") @@ -352,6 +367,7 @@ class ReviewerRung(unittest.TestCase): for breaches in (reviewer_breaches(reviewer, self.ON_TWO_RUNGS, home), skill_breaches(Call("Skill", {"skill": "security-review"}, checkout), self.ON_TWO_RUNGS, home)): self.assertEqual(rules(breaches), ["reviewer-rung"]) self.assertTrue(breaches[0].detail.startswith(f"the rung this review needs cannot be worked out: {own}: it holds no list of rungs. "), breaches[0].detail) + self.assertEqual(breaches[0].directory, checkout) self.assertEqual(reviewer_breaches(reviewer, {}, home), [], "a claude loop-claude did not start is not checked") self.assertEqual(reviewer_breaches(Call("Agent", {"subagent_type": "Explore"}, checkout), self.ON_TWO_RUNGS, home), [], "nor is a subagent that reviews nothing") self.assertEqual(skill_breaches(Call("Skill", {"skill": "simplify"}, checkout), self.ON_TWO_RUNGS, home), [])