From a4071f59ce9951292833ff5175d43271ae60fd2c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 23 Oct 2026 03:20:54 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=201=20=F0=9F=9F=A1;=20state=20the=20help's=20step-up=20rule=20?= =?UTF-8?q?as=20the=20code=20holds=20it,=20and=20reword=20the=20docstrings?= =?UTF-8?q?=20and=20the=20changelog=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/loop_claude/cycle/prompts.py | 2 +- bin/loop_claude/loop/main.py | 38 +++++++++++++++-------------- bin/loop_claude/routing.py | 8 +++--- bin/loop_claude/test_loop_claude.py | 2 +- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c129982..ef54f3d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude --help` now describes routing in two short paragraphs for the person running the loop, and points to `bin/loop_claude/routing.py`, `bin/loop_claude/cycle/prompts.py` and `bin/routing_figures/measure.py` for the rules. The rules it used to repeat are now stated once, in the docstrings of the code that enforces them. +- `loop-claude --help` now describes routing in two short paragraphs for the person running the loop. The rules it used to repeat are now stated once, in the code that enforces them. - loop-claude now archives the route on each `Worker:` line as a JSON record, such as `{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 4, "escape_and_impact": 5, "escalated_at": 12}`, and reads it back field by field. The line used to be a sentence, such as `claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5`, which loop-claude parsed back word for word: rewording the sentence in the code would have made every archived line unreadable, and a rerun would have routed the open chunk afresh. A rerun and the routing figures still read the sentences archived since loop-claude routed on L. A rerun that finds a `Worker:` line it can't read now says so on stderr. The judge's reply now names the levels the worker took in `highest_likelihood_taken_in` and `highest_escape_and_impact_taken_in`, in place of `bundled` and `bundled_escape_and_impact`. - A chunk now takes every unblocked item of its release that fires the same review passes, whatever its purpose: one PR title no longer has to state what the items achieve together. An item with R above 5 ships alone. `chunk-preflight` says so for such an item, and never lists one as an item that may join another. - A branch whose name is not UTF-8 now shows no branch in the status line, in place of a name with replacement characters. diff --git a/bin/loop_claude/cycle/prompts.py b/bin/loop_claude/cycle/prompts.py index 09fe4669..c16f2a76 100644 --- a/bin/loop_claude/cycle/prompts.py +++ b/bin/loop_claude/cycle/prompts.py @@ -1,4 +1,4 @@ -"""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).""" +"""What loop-claude says to the worker each cycle. routed_by, review_launches, escalation and reruns build the sentences about its rungs; rungs_held says the last three again in a prompt after a step-up or an unfinished verdict.""" 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 390c1dd5..8cef7e70 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -47,27 +47,29 @@ time. The layout, and when a copy is replaced, are in bin/transcript_archive/__i Every claude loop-claude starts runs the project's model, saved per in ~/.claude/loop-claude-models.json and read each cycle, unless routing, below, puts the worker, the session /talk opens and the judge on another rung, a model at an effort. A project without an -entry, as on its first run, is asked for one. LOOP_CLAUDE_JUDGE_MODEL overrides it for the judge, -LOOP_CLAUDE_WORKER_MODEL for the worker and the session /talk opens; with both set, nothing is -asked. +entry, as on its first run, is asked for one. LOOP_CLAUDE_JUDGE_MODEL overrides the model for the +judge, LOOP_CLAUDE_WORKER_MODEL for the worker and the session /talk opens; with both set, nothing +is asked. Where the project's model is on the routing ladder (bin/model_routing/ladder.py), the worker and the session /talk opens run on the rung that the chunk's todo.md item picks, and the judge of some -models on another. The worker's prompts name the rungs it launches its reviews on. The worker's -rung steps up as a chunk stays unfinished or the worker asks for a higher one. The rules are in -bin/loop_claude/routing.py, and the prompts' wording in bin/loop_claude/cycle/prompts.py. A +models on another; a chunk no item routes runs on the project's model. The worker's prompts name the +rungs it launches its reviews on. The worker's rung steps up as a chunk stays unfinished, or when +the judge finds in the transcript an escalation trigger that fired and the worker asked for a higher +rung. The rules are in bin/loop_claude/routing.py and bin/model_routing/ladder.py, and the prompts' +wording in bin/loop_claude/cycle/prompts.py. Each verdict, interrupt, quoted answer, stop and +step-up in the archive ends with a 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. A todo.md or an archive that cannot be read or parsed is said on stderr, and the chunk is routed -without it. Each verdict, interrupt, quoted answer, stop and step-up in the archive ends with a -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. +without it. -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. +Once 20 cycles have closed across all projects in the archive since the last measurement, the next +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, unless 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. A change to bin/loop-claude or any bin/**/*.py takes effect at the next cycle boundary, once loop-claude --help succeeds: the loop reloads into the edited script. @@ -198,7 +200,7 @@ def routed(route: Route | None, project: Rung | None, model: str, archived: typi def after_verdict(loop_run: LoopRun, project: Rung | None, concluded: Concluded) -> LoopRun: - """The loop run the next cycle starts from. A finished chunk drops its route; an unfinished one carries its route on, stepped_route's, and the evidence the judge gave for the verdict.""" + """The loop run the next cycle starts from. A finished chunk drops its route. An unfinished one takes the route stepped_route makes, and the evidence the judge gave for the verdict.""" verdict = concluded.verdict if isinstance(verdict, Finished): return dataclasses.replace(loop_run, route=None, unfinished_evidence="") @@ -206,7 +208,7 @@ def after_verdict(loop_run: LoopRun, project: Rung | None, concluded: Concluded) def stepped_route(project: Rung | None, ended_on: Route, verdict: Unfinished) -> Route: - """The route an unfinished chunk's next cycle starts on: after_unfinished's of the route its cycle ended on, which an interrupt's or a quoted answer's escalation may have raised. Off the ladder there is no rung to step, and it keeps that route.""" + """The route an unfinished chunk's next cycle starts on: the route after_unfinished makes of the route its cycle ended on, which an interrupt's or a quoted answer's escalation may have raised. Off the ladder there is no rung to step, and it keeps that route.""" return after_unfinished(project, ended_on, verdict) if project else ended_on diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index adf058ac..61dde258 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -1,8 +1,8 @@ """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); a model off the ladder has no route to step, and 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 gets a route without an item, and it is never stepped. -- 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. +- Start. routed_item finds the plan item that routes a fresh chunk, if there is one with L, E and I scored; first_route picks the worker's rung from its L, or the project's rung without an 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. @@ -36,7 +36,7 @@ def routed_item(todo: str, cut: LastCut) -> Item | Failure | None: def first_route(project: Rung, item: Item | None) -> Route: - """The route a chunk starts on: the rung its item's L picks from the project's rung.""" + """The route a chunk starts on: the rung its item's L picks from the project's rung, or the project's rung without an item.""" if item is None: return Route(project) return Route(worker_rung(project, item.likelihood), item.id, item.likelihood, item.escape_and_impact) @@ -53,7 +53,7 @@ def kept_rung(project: Rung, route: Route) -> Rung: def item_rung(project: Rung, route: Route) -> Rung: - """The rung the route's item's L picks from the project's rung, or the project's rung itself when no item routed it. The worker may run on a rung below it.""" + """The rung the route's item's L picks from the project's rung, or the project's rung itself when no item routed it. The worker may run on a rung below the project's.""" return worker_rung(project, route.likelihood) if route.item else project diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index c1b770d1..683787a0 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1483,7 +1483,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) + self.assertIn(f"Once {measure.CYCLES_PER_CHECK} cycles have closed across all projects", said) class ExitContract(unittest.TestCase):