diff --git a/bin/model_routing/ladder.py b/bin/model_routing/ladder.py index f6c9d691..0d7593b5 100644 --- a/bin/model_routing/ladder.py +++ b/bin/model_routing/ladder.py @@ -34,13 +34,13 @@ class Rung: return Rung(model, effort) return Rung(family.model, effort) if effort else family - # The one spelling of a rung; parse reads it back. + # The one spelling of a rung. The archive and the worker's environment store it, and parse reads it back, so a change re-routes archived chunks. def __str__(self) -> str: return f"{self.model} at {self.effort} effort" if self.effort else self.model @staticmethod def parse(text: str) -> "Rung | None": - """The rung str wrote, whether or not it is on the ladder; None for any other text, such as a model run without an effort.""" + """The rung that names an effort, which str wrote, whether or not it is on the ladder; None for any other text, such as a bare model.""" found = WORDING.fullmatch(text) return Rung(found["model"], found["effort"]) if found else None diff --git a/bin/model_routing/test_worker_rungs.py b/bin/model_routing/test_worker_rungs.py index d3a4c70f..fcd22e84 100644 --- a/bin/model_routing/test_worker_rungs.py +++ b/bin/model_routing/test_worker_rungs.py @@ -11,8 +11,8 @@ class Environment(unittest.TestCase): def test_the_project_and_the_worker_rung_are_named_in_the_environment(self): self.assertEqual(environment(self.PROJECT, self.WORKER), {"LOOP_CLAUDE_PROJECT_RUNG": "claude-opus-5-5 at medium effort", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort"}) - def test_a_project_off_the_ladder_leaves_its_rung_unset(self): - self.assertEqual(environment(None, self.WORKER), {"LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort"}) + def test_a_project_off_the_ladder_is_handed_an_empty_rung_so_none_is_inherited(self): + self.assertEqual(environment(None, self.WORKER), {"LOOP_CLAUDE_PROJECT_RUNG": "", "LOOP_CLAUDE_WORKER_RUNG": "claude-haiku-5-5 at max effort"}) def test_handed_reads_back_what_environment_named(self): self.assertEqual(handed(environment(self.PROJECT, self.WORKER)), (self.PROJECT, self.WORKER)) diff --git a/bin/model_routing/worker_rungs.py b/bin/model_routing/worker_rungs.py index 2180abd5..f690f3d6 100644 --- a/bin/model_routing/worker_rungs.py +++ b/bin/model_routing/worker_rungs.py @@ -10,8 +10,8 @@ WORKER_RUNG = "LOOP_CLAUDE_WORKER_RUNG" def environment(project: Rung | None, worker: Rung) -> dict[str, str]: - """The variables a worker's claude starts with; a project off the ladder has no rung to hand.""" - return ({PROJECT_RUNG: str(project)} if project else {}) | {WORKER_RUNG: str(worker)} + """The variables a worker's claude starts with. A project off the ladder gets an empty rung, so none is inherited from the environment.""" + return {PROJECT_RUNG: str(project) if project else "", WORKER_RUNG: str(worker)} def handed(environ: typing.Mapping[str, str]) -> tuple[Rung | None, Rung | None]: diff --git a/bin/rule_hook/reviewer_rung.py b/bin/rule_hook/reviewer_rung.py index 1841754b..d150efc1 100644 --- a/bin/rule_hook/reviewer_rung.py +++ b/bin/rule_hook/reviewer_rung.py @@ -34,10 +34,10 @@ 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: + opening = text(given, "prompt").lstrip() + if opening.startswith(SEAT): return "seat" - if SECURITY_OPENER in prompt: + if opening.startswith(SECURITY_OPENER): return "security" return None diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 5cefc852..57b9a392 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -217,6 +217,7 @@ class ReviewerRung(unittest.TestCase): 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") + self.assertEqual(self.refused({"prompt": "Quote the rule: 'You are the security pass for this chunk.' Then stop.", "model": "haiku", "effort": "low"}), [], "a quote midway 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"}, {}), [])