Answer stability round 1: 1 🔴, 6 🟡; keep the marker in model_routing so routing_figures imports nothing of loop_claude, total escalations across every chunk, fold CLAUDE.md's subagent rung rules into one ordered rule

This commit is contained in:
2026-10-15 16:28:11 +02:00
parent c0be1fdffc
commit d7193f65da
9 changed files with 44 additions and 24 deletions
+8 -8
View File
@@ -1,8 +1,8 @@
from loop_claude.routing import ESCALATION_MARKER, escalation_rungs
from model_routing.ladder import highest, LADDER, Rung
from model_routing.ladder import climbed, highest, LADDER, Rung
from model_routing.route import ESCALATION_MARKER, Route
from loop_claude.routing import escalation_rungs
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from markdown_text import quoted
from model_routing.route import Route
def either(names: tuple[str, ...]) -> str:
"""The names as `a, b or c`."""
@@ -17,8 +17,8 @@ ANSWERS_RECORDED = f"every answer the human typed in it that a later chunk could
def fresh(task: str, premises: str, route: Route, anchor: Rung | None) -> str:
# A chunk no item routed gets no route paragraph, but may still escalate.
routed = f"{routed_by(route, anchor)}\n\n" if route.item else "".join(f"{text.lstrip()}\n\n" for text in [escalation(route, anchor)] if text)
escalated = escalation(route, anchor).lstrip()
routed = f"{routed_by(route, anchor)}\n\n" if route.item else (f"{escalated}\n\n" if escalated else "")
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.\n\n{routed}The chunk's todo.md items, or else the task above, set its scope. The goals below choose between ways to deliver that scope, and never widen it.\n\nFrom README.md:\n{premises}"
@@ -27,7 +27,7 @@ def routed_by(route: Route, anchor: Rung | None) -> str:
def off_the_projects_rung(route: Route, anchor: Rung | None) -> str:
"""Which subagents to launch on the project's rung, anchor, and below it which on the --plan rung; empty while the worker runs on anchor, as every chunk no item routed starts (routing.first_route)."""
"""Which subagents to launch on the project's rung, anchor, and below it which on the --plan rung; empty while the worker runs on anchor, as every chunk no item routed does until it steps up."""
if anchor is None or route.rung == anchor:
return ""
# Below the project's rung, the reviewers stay on it to hold quality; above it, the seats score every chunk on one rung, and the security pass spends no more than the project chose.
@@ -38,13 +38,13 @@ def off_the_projects_rung(route: Route, anchor: Rung | None) -> str:
def escalation(route: Route, anchor: Rung | None) -> str:
"""The rungs routing.escalation_rungs opens to the worker, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung."""
"""The rungs an escalation trigger opens to the worker, from one above its own up to two above the rung its chunk started on, and how to mark an escalated subagent's prompt; empty off the ladder or on its top rung."""
if anchor is None or route.rung not in LADDER[:-1]:
return ""
marked = f" Open the subagent's prompt with `{ESCALATION_MARKER} <n>:`, n the trigger's number."
rungs = [f"`{rung.agent_args()}`" for rung in escalation_rungs(anchor, route)]
if not rungs:
return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees.{marked}"
return f" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent with the Agent tool set to `{climbed(route.rung, 1).agent_args()}`, one rung above yours, only once the human agrees.{marked}"
further = f", and on each further trigger one rung higher, up to {rungs[-1]}" if len(rungs) > 1 else ""
return f" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to {rungs[0]}, one rung above yours{further}; above that, ask the human first.{marked}"
+1 -2
View File
@@ -7,9 +7,8 @@ from todo_table import Item, items
from model_routing.route import Route
UNFINISHED_PER_STEP = 2
# How many rungs above item_rung the worker may escalate a task without the human's yes, and how it opens an escalated subagent's prompt: docs/decisions.md → `routing: a worker hands a task one rung up`.
# How many rungs above item_rung the worker may escalate a task without the human's yes: docs/decisions.md → `routing: a worker hands a task one rung up`.
ESCALATION_CAP = 2
ESCALATION_MARKER = "Escalation trigger"
# The models `judge-replay` found returning, on their cheapest rung, every verdict the reference judge reproduced: docs/decisions.md → `routing: on a model judge-replay covered`.
JUDGE_REPLAYED = ("claude-opus-5-5",)
+2 -1
View File
@@ -662,8 +662,9 @@ class WorkerArgs(unittest.TestCase):
fresh = prompts.fresh("Do it.", "## Goals", Route(opus, 3, 9), opus)
self.assertIn("whether or not it is item 3. When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number.\n\n", fresh)
self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "high"), 3, 9), opus).endswith(" When an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort xhigh`, one rung above yours; above that, ask the human first. Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number."))
self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent above your rung only once the human agrees. Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number."))
self.assertTrue(prompts.resumed("", Route(Rung("claude-opus-5-5", "xhigh"), 3, 9), opus).endswith(" An escalation trigger in `~/.claude/CLAUDE.md` lets you hand a task to a subagent with the Agent tool set to `model opus, effort max`, one rung above yours, only once the human agrees. Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number."))
self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-fable-5-1", "max"), 3, 20), opus))
self.assertIn("hand the task to a subagent with the Agent tool set to `model fable, effort max`, one rung above yours;", prompts.resumed("", Route(Rung("claude-opus-5-5", "max"), 3, 13), opus))
self.assertNotIn("escalation", prompts.resumed("", Route(Rung("m")), None))
self.assertNotIn("escalation", prompts.resumed("", Route(Rung("claude-opus-5-5", "low"), 3, 9), opus))
self.assertIn("before creating a new one.\n\nWhen an escalation trigger in `~/.claude/CLAUDE.md` fires, hand the task to a subagent with the Agent tool set to `model opus, effort high`, one rung above yours, and on each further trigger one rung higher, up to `model opus, effort xhigh`; above that, ask the human first. Open the subagent's prompt with `Escalation trigger <n>:`, n the trigger's number.\n\nThe chunk's", prompts.fresh("Do it.", "## Goals", Route(opus), opus))