From c424fa66aee700c4c1a73fba41f5a184c5fd81f1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 19:03:59 +0100 Subject: [PATCH 1/5] Drop LEGACY_WORKER so route_from reads only JSON worker lines --- bin/loop_claude/test_loop_claude.py | 13 ++----------- bin/model_routing/ladder.py | 2 +- bin/model_routing/route.py | 15 ++------------- bin/routing_figures/test_routing_figures.py | 7 ------- docs/reading-cost.md | 17 +++++++++++++++++ todo.md | 7 +------ 6 files changed, 23 insertions(+), 38 deletions(-) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 75c2485c..99f32f72 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1156,17 +1156,8 @@ class Routing(unittest.TestCase): def test_leaves_the_count_of_unfinished_verdicts_out_of_the_worker_line_so_a_rerun_restarts_it(self): self.assertEqual(route_from(Route(self.HIGH, 3, 4, 5, unfinished=1).worker_line()), Route(self.HIGH, 3, 4, 5)) - def test_reads_no_route_from_a_worker_line_of_unknown_or_mistyped_fields_or_levels_off_their_scales(self): - for line in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": '): - with self.subTest(line=line): - self.assertIsNone(route_from(line)) - - def test_reads_the_route_from_a_line_loop_claude_wrote_before_it_archived_json(self): - self.assertEqual(route_from("claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5"), Route(self.HIGH, 3, 4, 5)) - self.assertEqual(route_from("claude-opus-5-5 at high effort"), Route(self.HIGH)) - self.assertEqual(route_from("claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5, taking in an E + I of 7, escalated at transcript entry 12"), Route(self.HIGH, 3, 4, 5, escape_and_impact_taken_in=7, escalated_at=12)) - self.assertEqual(route_from("claude-opus-5-5 at high effort, taking in an E + I of 6"), Route(self.HIGH, escape_and_impact_taken_in=6)) - for line in ("worker-model", "claude-opus-5-5 at high effort, routed by item 3's L of 5 and E + I of 5", "claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5, taking in an E + I of 5", "claude-opus-5-5 at high effort, routed by item 3's R + C of 11"): + def test_reads_no_route_from_a_worker_line_that_is_no_json_or_has_unknown_or_mistyped_fields_or_levels_off_their_scales(self): + for line in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": ', "worker-model", "claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5"): with self.subTest(line=line): self.assertIsNone(route_from(line)) diff --git a/bin/model_routing/ladder.py b/bin/model_routing/ladder.py index 3cd8b875..12a7e55d 100644 --- a/bin/model_routing/ladder.py +++ b/bin/model_routing/ladder.py @@ -36,7 +36,7 @@ class Rung: return Rung(model, effort) return Rung(family.model, effort) if effort else family - # The one spelling of a rung. loop-claude hands it to rule-hook in environment variables, and archive lines written before route.Route.worker_line hold it, so parse must keep reading it. + # The one spelling of a rung. loop-claude hands it to rule-hook in environment variables, so parse must keep reading it. def __str__(self) -> str: return f"{self.model} at {self.effort} effort" if self.effort else self.model diff --git a/bin/model_routing/route.py b/bin/model_routing/route.py index 8a34e67a..b04e53e9 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -1,7 +1,6 @@ """A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as JSON on the Worker: line that ends each outcome.""" import dataclasses import json -import re import typing from todo_table import LEVELS @@ -11,8 +10,6 @@ from model_routing.ladder import REVIEW_STEPS, Rung ESCALATION_MARKER = "Escalation trigger" # What Route.worker_line writes. The outcome writers take only this as the worker, so mypy refuses a str(route) there. WorkerLine = typing.NewType("WorkerLine", str) -# A worker line loop-claude wrote before it archived the route as JSON. Nothing writes this format any more, so its wording never changes. route_from reads it for the chunks the routing figures still count, and for a chunk a rerun resumes across the change. -LEGACY_WORKER = re.compile(r"(?P.+?)(?:, routed by item (?P[0-9]+)'s L of (?P[0-9]+) and E \+ I of (?P[0-9]+))?(?:, taking in an E \+ I of (?P[0-9]+))?(?:, escalated at transcript entry (?P[0-9]+))?") HIGHEST_ESCAPE_AND_IMPACT = LEVELS["E"] + LEVELS["I"] @@ -82,8 +79,8 @@ WORKER_LINE_FIELDS = tuple(field.name for field in dataclasses.fields(Route) if def route_from(worker: str) -> Route | None: - """The route an archived worker line names, whether JSON or a line written before JSON. None where it names no model, holds fields Route.worker_line never writes, or holds levels off their scales; and for an older line, where it names a model without an effort.""" - fields = json_fields(worker) if worker.startswith("{") else legacy_fields(worker) + """The route an archived worker line names. None where the line isn't JSON, names no model, holds fields Route.worker_line never writes, or holds levels off their scales.""" + fields = json_fields(worker) if fields is None or not Route.fits(fields): return None return Route(Rung(fields["model"], fields.get("effort", "")), **{name: fields.get(name, 0) for name in WORKER_LINE_FIELDS}) @@ -100,11 +97,3 @@ def json_fields(line: str) -> dict[str, typing.Any] | None: # type(), not isinstance(): JSON true is no integer. return fields if all(type(fields.get(name, 0)) is int and fields.get(name, 0) >= 0 for name in WORKER_LINE_FIELDS) else None - -def legacy_fields(line: str) -> dict[str, typing.Any] | None: - """The fields of a LEGACY_WORKER line, as json_fields gives them; None for any other text.""" - found = LEGACY_WORKER.fullmatch(line) - rung = Rung.parse(found["rung"]) if found else None - if not (found and rung): - return None - return {"model": rung.model, "effort": rung.effort, **{name: int(value or 0) for name, value in found.groupdict().items() if name != "rung"}} diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 7ecb1c1d..23614f74 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -139,13 +139,6 @@ class Measured(unittest.TestCase): def test_leaves_the_later_fixes_unknown_where_the_route_names_no_item(self): self.assertIsNone(self.fixed_later([shipping(7, fixed_by=("c",))], Route(LOW).worker_line())) - def test_reads_the_route_of_a_line_loop_claude_wrote_before_it_archived_json(self): - older = f"{LOW}, routed by item 7's L of 3 and E + I of 4" - kept = stamped("2026-10-14T10:00:00Z", outcomes.finished(older, "m", "j")) - found = measured(Chunk("log", [kept], [message("m1", "2026-10-14T09:00:00Z")], []), "/h") - self.assertEqual(found.start, LOW) - self.assertEqual(found.dollars["rung"], {str(LOW): 2.0}) - def test_starts_no_route_for_a_chunk_no_item_routed(self): kept = stamped("2026-10-14T10:00:00Z", outcomes.finished(Route(LOW).worker_line(), "m", "j")) found = measured(Chunk("log", [kept], [message("m1", "2026-10-14T09:00:00Z")], []), "/h") diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 93eaee7e..ebd5c168 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -1008,3 +1008,20 @@ Read most (opens and searches): - `AGENTS.md` 1 - `bin/rule_hook/test_rule_hook.py` 1 - `bin/run_heavy/capped_docker.py` 1 + +## Reading cost, chunk 84fca41a7ef4, finished 2026-11-08T18:02:06Z + +139686 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 4 +- `bin/score_outcomes/main.py` 3 +- `bin/score_outcomes/results.py` 3 +- `bin/branch_chunks/cut.py` 2 +- `bin/todo_table.py` 2 +- `AGENTS.md` 1 +- `bin/branch_chunks/read.py` 1 +- `bin/loop_claude/loop/main.py` 1 +- `bin/routing_figures/archive.py` 1 +- `bin/score-outcomes` 1 diff --git a/todo.md b/todo.md index 666d47ca..c710244f 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 1 | 0.7.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | -| 218 | 0.7.0 | | | **Drop `LEGACY_WORKER` from `bin/model_routing/route.py`, so `route_from` reads only JSON worker lines.** | 1 | 2 | 1 | 2 | 1 | code health by 2 | 14.4 | | 219 | 0.7.0 | | | **Name the project's rung `project` in `bin/judge_replay/main.py`, `bin/subagent_rung/main.py` and `bin/review_replay/main.py`, in place of `anchor`, as `bin/model_routing/ladder.py` and `bin/loop_claude` name it.** | 1 | 1 | 3 | 3 | 2 | code health by 2 | 12.0 | | 224 | 0.7.0 | | | **Split `docs/decisions.md` → `todo.md: one table of items, …`'s 420-word scoring paragraph into one paragraph per choice, and drop the sentences that tell how the goal weights changed.** | 1 | 1 | 1 | 1 | 2 | code health by 2 | 12.0 | | 123 | 0.7.0 | | | **Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.** | 2 | 1 | 2 | 3 | 5 | code health by 5, 1.4 by 5 | 11.0 | @@ -86,10 +85,6 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3). -### 218. Drop `LEGACY_WORKER` from `bin/model_routing/route.py`, so `route_from` reads only JSON worker lines. - -PR #357 archived the route as JSON on each `Worker:` line, and kept `LEGACY_WORKER` to read the lines an older loop-claude wrote as sentences. The routing figures count only chunks finished after the `Reset` of 2026-10-29T19:49:09Z in `routing-calls-raised.md`, which follows PR #357's merge, so every chunk they count has JSON worker lines. Delete `LEGACY_WORKER`, `legacy_fields`, the tests that read sentences (in `bin/loop_claude/test_loop_claude.py` and `bin/routing_figures/test_routing_figures.py`), and the sentence on them in "loop-claude --help". Reword `route_from`'s docstring, and the comment at `Rung.__str__` in `bin/model_routing/ladder.py`, which gives the old lines as a reason `parse` must keep reading that spelling. - ### 219. Name the project's rung `project` in `bin/judge_replay/main.py`, `bin/subagent_rung/main.py` and `bin/review_replay/main.py`, in place of `anchor`, as `bin/model_routing/ladder.py` and `bin/loop_claude` name it. Item 172 renamed `anchor` to `project` across `bin/loop_claude`, after release 0.3.0's inherited architect named `bin/loop_claude/cycle/judge.py:68` `Reply.bundled`: "the project's rung is also called anchor". Three tools outside it still call the same rung `anchor`: `bin/judge_replay/main.py:54` (`anchor = arguments_or_exit(...)`, a `Rung` parsed from the model argument), `bin/subagent_rung/main.py:26` (`anchor = project_rung(model)`), and `bin/review_replay/main.py:74`, `:100` and `:180`, with `findings_found`'s docstring. While the name differs between tools, a reader works out each time that the two are one rung. The rename keeps behaviour. `bin/score_outcomes/anchors.py` uses `anchor` for score anchors, a different thing, and keeps the name. @@ -112,7 +107,7 @@ F is 8 until then, about one S 3 change, lilleman's call in PR #283. A chunk cos ### 155. Lower the reading cost of the files a chunk reads most before its first commit. -`bin/reading-cost` on 2026-11-08, after item 170's chunk: the median of the last 5 chunks is 144,200 new input tokens before their first commit, up from 105,744 for the 5 before them. The files read most over the last 5, counting opens and searches, were `todo.md` 17 times, `README.md` 14, `docs/decisions.md` 14, `AGENTS.md` 9, `CHANGELOG.md` 7, `bin/loop_claude/test_black_box.py` 7, `bin/chunk_preflight/test_chunk_preflight.py` 6, `bin/loop_claude/loop/main.py` 5, `bin/rule_hook/test_rule_hook.py` 4 and `bin/run_heavy/test_run_heavy.py` 4. The chunk that ships this item runs `bin/reading-cost --reset`. +`bin/reading-cost` on 2026-11-08, before item 218's chunk: the median of the last 5 chunks is 139,686 new input tokens before their first commit, up from 105,744 for the 5 before them. The files read most over the last 5, counting opens and searches, were `todo.md` 15 times, `README.md` 11, `docs/decisions.md` 8, `CHANGELOG.md` 7, `AGENTS.md` 6, `bin/chunk_preflight/test_chunk_preflight.py` 6, `bin/loop_claude/loop/main.py` 6, `bin/loop_claude/test_black_box.py` 5, `bin/rule_hook/test_rule_hook.py` 4 and `bin/run_heavy/test_run_heavy.py` 4. The chunk that ships this item runs `bin/reading-cost --reset`. ### 215. Decode a reload's handed JSON with a decoder for `LoopRun` and its `Route`, in place of `decoded_as`'s generic one with its two sentinels and `Route.fits` hook. -- 2.52.0 From 7823c4374cc87516fb1c2b0972027588a176e2ac Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 19:04:41 +0100 Subject: [PATCH 2/5] Drop the blank line at the end of route.py --- bin/model_routing/route.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/model_routing/route.py b/bin/model_routing/route.py index b04e53e9..d9abda54 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -96,4 +96,3 @@ def json_fields(line: str) -> dict[str, typing.Any] | None: return None # type(), not isinstance(): JSON true is no integer. return fields if all(type(fields.get(name, 0)) is int and fields.get(name, 0) >= 0 for name in WORKER_LINE_FIELDS) else None - -- 2.52.0 From ff354a90a8c56cd6c83e423b3202fbded4798937 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 19:08:44 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20note=20in?= =?UTF-8?q?=20the=20changelog=20that=20sentence-form=20Worker:=20lines=20a?= =?UTF-8?q?re=20no=20longer=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 937abdae..c6eeb67c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- `loop-claude` and the routing figures no longer read a `Worker:` line written as a sentence, as versions before 0.4.0 archived. A rerun routes a chunk whose archive still ends in one afresh. + ## 0.6.0 - `deploy-release --cut`, run in `~/code/claude-config`, now cuts a release. Once the next release holds no item in `todo.md` and its release review has landed, it renames `## Unreleased` in `CHANGELOG.md` to the version and merges that through a pull request: it opens the pull request, waits for its checks and merges it fast-forward only. Then it tags the merged commit, pushes the tag and moves `~/.claude` to it. Where a step fails it stops with git's or the forge's reason, and a rerun continues. Nobody can push to `main` on the remote any more, so the old manual steps under README → Release no longer work. Cut 0.6.0 itself from the clone, `~/code/claude-config/bin/deploy-release --cut`, since `~/.claude` still holds 0.5.0. -- 2.52.0 From 1a5cf15a6089258699f65a45606a5805352cda04 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 19:08:44 +0100 Subject: [PATCH 4/5] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20complete=20?= =?UTF-8?q?route=5Ffrom's=20docstring,=20trim=20the=20rung=20comment=20and?= =?UTF-8?q?=20the=20test=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/test_loop_claude.py | 2 +- bin/model_routing/ladder.py | 2 +- bin/model_routing/route.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 99f32f72..492cdb25 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1156,7 +1156,7 @@ class Routing(unittest.TestCase): def test_leaves_the_count_of_unfinished_verdicts_out_of_the_worker_line_so_a_rerun_restarts_it(self): self.assertEqual(route_from(Route(self.HIGH, 3, 4, 5, unfinished=1).worker_line()), Route(self.HIGH, 3, 4, 5)) - def test_reads_no_route_from_a_worker_line_that_is_no_json_or_has_unknown_or_mistyped_fields_or_levels_off_their_scales(self): + def test_reads_no_route_from_a_worker_line_that_route_worker_line_could_not_have_written(self): for line in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": ', "worker-model", "claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5"): with self.subTest(line=line): self.assertIsNone(route_from(line)) diff --git a/bin/model_routing/ladder.py b/bin/model_routing/ladder.py index 12a7e55d..b0cd1b77 100644 --- a/bin/model_routing/ladder.py +++ b/bin/model_routing/ladder.py @@ -36,7 +36,7 @@ class Rung: return Rung(model, effort) return Rung(family.model, effort) if effort else family - # The one spelling of a rung. loop-claude hands it to rule-hook in environment variables, so parse must keep reading it. + # loop-claude hands a rung to rule-hook in environment variables in this spelling, so parse must keep reading it. def __str__(self) -> str: return f"{self.model} at {self.effort} effort" if self.effort else self.model diff --git a/bin/model_routing/route.py b/bin/model_routing/route.py index d9abda54..a435db6b 100644 --- a/bin/model_routing/route.py +++ b/bin/model_routing/route.py @@ -1,4 +1,4 @@ -"""A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as JSON on the Worker: line that ends each outcome.""" +"""A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as JSON on the Worker: line that ends each verdict, interrupt, quoted answer, stop and step-up.""" import dataclasses import json import typing @@ -79,7 +79,7 @@ WORKER_LINE_FIELDS = tuple(field.name for field in dataclasses.fields(Route) if def route_from(worker: str) -> Route | None: - """The route an archived worker line names. None where the line isn't JSON, names no model, holds fields Route.worker_line never writes, or holds levels off their scales.""" + """The route an archived worker line names; None for a line Route.worker_line could not have written, such as text that isn't JSON.""" fields = json_fields(worker) if fields is None or not Route.fits(fields): return None -- 2.52.0 From d18ceec249cb48ac2212ad08901f69aaff61ba16 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 19:10:55 +0100 Subject: [PATCH 5/5] =?UTF-8?q?Answer=20product-owner=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20say=20in=20?= =?UTF-8?q?the=20changelog=20what=20the=20figures=20do=20with=20a=20senten?= =?UTF-8?q?ce-form=20chunk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6eeb67c..d97ed0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` and the routing figures no longer read a `Worker:` line written as a sentence, as versions before 0.4.0 archived. A rerun routes a chunk whose archive still ends in one afresh. +- `loop-claude` and the routing figures no longer read a `Worker:` line written as a sentence, as versions before 0.4.0 archived. A rerun routes a chunk whose archive still ends in one afresh, and the figures leave it out of the routed chunks and charge its dollars to a row named by the sentence. ## 0.6.0 -- 2.52.0