From a81f878f926cdd12217124c58d8eedfffc466717 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 23 Oct 2026 03:10:31 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20principles=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=205=20=F0=9F=9F=A1;=20make=20the=20routing.py=20a?= =?UTF-8?q?nd=20prompts.py=20module=20docstrings=20true=20and=20short,=20d?= =?UTF-8?q?rop=20the=20routing=5Fcheck=20copy=20of=20the=20figures,=20rena?= =?UTF-8?q?me=20judge=5Frung's=20local,=20and=20keep=20the=20help's=2020?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/cycle/prompts.py | 5 +---- bin/loop_claude/loop/main.py | 10 +++++----- bin/loop_claude/loop/routing_check.py | 4 +--- bin/loop_claude/routing.py | 18 ++++++++---------- bin/loop_claude/test_loop_claude.py | 3 ++- bin/routing_figures/measure.py | 2 +- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 93c9e12c..09fe4669 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,7 +1,4 @@ -"""What loop-claude says to the worker each cycle: the task, the premises and the preflight's facts in a fresh chunk's first prompt, and the rungs routing picked in every prompt. - -The first prompt names the worker's rung and the routing item (routed_by), has the worker name each item the chunk takes and count the item's size again once it has read the code (recount), and names the rung of each review that runs on a rung other than the worker's (review_launches), with the reviewers' rung each higher E + I picks (taken_in_launches). It adds, where the worker runs below the project's rung, where to launch a subagent that files or scores todo.md items, the rungs an escalation hands a task (escalation) and the rung a rerun one rung up takes (reruns). The prompt after an unfinished verdict, a quoted answer or a typed one says them again (rungs_held), since a step-up may have moved the worker. All of it is left out where the project's model is off the ladder. -""" +"""What loop-claude says to the worker each cycle. The rung sentences are routed_by's, review_launches', escalation's and reruns'; a prompt after a step-up or an unfinished verdict says them again (rungs_held).""" from model_routing.ladder import climbed, LADDER, position, review_rungs, reviewers_rung, ReviewKind, Rung from model_routing.route import ESCALATION_MARKER, HIGHEST_ESCAPE_AND_IMPACT, Route from loop_claude.routing import escalation_rungs diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index faf05235..390c1dd5 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -61,11 +61,11 @@ without it. Each verdict, interrupt, quoted answer, stop and step-up in the arch Worker: line, the route's JSON record (Route.record in bin/model_routing/route.py); a rerun resumes an open chunk on the latest route named there. -Every CYCLES_PER_CHECK cycles across all projects in the archive, the first loop to close one -measures every finished chunk there, with no model run, and writes routing-figures.md at the -archive's root (bin/routing_figures/measure.py). Each call the figures make for a routing change -that was not raised before is an interrupt: claude, on the project's model, on the terminal in -~/.claude, asked to put the calls to the human. Once that claude ends, the calls are listed in +Every 20 cycles across all projects in the archive, the first loop to close one measures every +finished chunk there, with no model run, and writes routing-figures.md at the archive's root +(bin/routing_figures/measure.py). Each call the figures make for a routing change that was not +raised before is an interrupt: claude, on the project's model, on the terminal in ~/.claude, asked +to put the calls to the human. Once that claude ends, the calls are listed in routing-calls-raised.md beside the figures, and not raised again. Off a terminal, the calls are said on stderr, the loop goes on, and they are raised again at the next measurement. diff --git a/bin/loop_claude/loop/routing_check.py b/bin/loop_claude/loop/routing_check.py index 373c78d9..3b6344b5 100644 --- a/bin/loop_claude/loop/routing_check.py +++ b/bin/loop_claude/loop/routing_check.py @@ -1,6 +1,4 @@ -"""Every CYCLES_PER_CHECK cycles across all projects, measure the archive's routing figures, keep them at its root, and interrupt the human with each call for a routing change not raised before: docs/decisions.md → `routing:`. - -The figures are routing_figures/measure.py's: tokens by project, subagent type, rung and the tool whose results they took in, and for each chunk a todo.md item routed, its review rounds past each pass's first, its unfinished verdicts and its subagents' rungs. A chunk that cannot be read is skipped and named in the figures. A figure that cannot be measured or written is said on stderr and the loop goes on.""" +"""Every CYCLES_PER_CHECK cycles across all projects, measure the archive's routing figures, keep them at its root, and interrupt the human with each call for a routing change not raised before: docs/decisions.md → `routing:`.""" import pathlib import sys diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index bd6cef0d..adf058ac 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -1,13 +1,11 @@ """Which ladder rung a chunk's worker and judge run on: docs/decisions.md → `routing:`. -The worker, and the session /talk opens, run on a Route (model_routing/route.py) that a model on the ladder gets as follows. A model off the ladder has no route to step: its worker runs on it. +The worker, and the session /talk opens, run on a Route (model_routing/route.py); a model off the ladder has no route to step, and its worker runs on it. -- Start. routed_item is the plan item chunk_pick.chunk_item picks from todo.md on the default branch, as the preflight just fetched it; it is none when the next release is not the earliest, or the item lacks L, E or I. first_route picks the worker's rung from its L, ladder.worker_rung; without an item, the chunk runs on the project's rung. -- Rerun. A rerun resumes an open chunk on the route its archive last names, counting its unfinished verdicts afresh. kept drops a route whose rung is off the ladder or below the one its item's L picks, and the chunk starts afresh. -- Step-up. after_unfinished and after_ruling raise the route after a verdict: by the highest L and E + I the worker took in, by every second unfinished verdict (UNFINISHED_PER_STEP), and by an escalation, up to escalation_cap. -- Judge. judge_rung runs the judge of a JUDGE_REPLAYED model on the rung the route's reviewed_on E + I picks, whatever rung the worker stepped to. - -ladder.review_rungs picks the reviewers' rungs; cycle/prompts.py tells the worker which. +- Start. routed_item is the plan item that routes a fresh chunk, none without one; first_route picks the worker's rung from its L, and the project's rung stands where there is no item. +- Rerun. kept decides whether a rerun resumes the route its archive last names. +- Step-up. after_unfinished raises the route after an unfinished verdict, after_ruling after an interrupt or a quoted answer that carries an escalation; escalation_cap bounds an escalation. +- Judge. judge_rung picks the rung of the judge of a JUDGE_REPLAYED model. """ import dataclasses @@ -117,7 +115,7 @@ def judge_rung(judge_model: str, route: Route) -> Rung: A model off the ladder, or not in JUDGE_REPLAYED, gets no effort flag, so claude runs it at the effort its settings give. """ - project = project_rung(judge_model) - if project is None or judge_model not in JUDGE_REPLAYED: + cheapest = project_rung(judge_model) + if cheapest is None or judge_model not in JUDGE_REPLAYED: return Rung(judge_model) - return review_floor(project, route.reviewed_on()) + return review_floor(cheapest, route.reviewed_on()) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 8643d3a0..ff41e9eb 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -17,7 +17,7 @@ import uuid sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from routing_figures import archive +from routing_figures import archive, measure from loop_claude.project import checkout, model_choice, records from chunk_pick import DefaultPlan, LastCut from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python @@ -1482,6 +1482,7 @@ class HelpLimits(unittest.TestCase): self.assertIn("fails three times running, retried a minute apart", said) self.assertIn(f"retried {retry.PAST_RESET // 60} minutes after the limit resets, or every {retry.UNKNOWN_RESET_POLL // 60} minutes", said) self.assertIn(f"still running after {PYTHON_TIMEOUT} s", said) + self.assertIn(f"Every {measure.CYCLES_PER_CHECK} cycles across all projects", said) class ExitContract(unittest.TestCase): diff --git a/bin/routing_figures/measure.py b/bin/routing_figures/measure.py index ab728351..8ad1e507 100644 --- a/bin/routing_figures/measure.py +++ b/bin/routing_figures/measure.py @@ -1,4 +1,4 @@ -"""Token spend and routing outcomes of the chunks loop-claude finished, and the routing changes they call for: docs/decisions.md → `routing:`.""" +"""Token spend and routing outcomes of the chunks loop-claude finished, and the routing changes they call for: docs/decisions.md → `routing:`. A chunk that cannot be read is skipped and named in the figures.""" import collections import dataclasses import re