Read the routing ladder from routing-ladder.json, which a project replaces with a file of its own in its config's folder
CI / tests (pull_request) Successful in 2m37s

This commit is contained in:
2026-11-15 18:51:59 +01:00
parent 9d0e2ad853
commit 0a20b6d4f6
42 changed files with 848 additions and 453 deletions
+7 -7
View File
@@ -6,11 +6,11 @@ import typing
from routing_figures.calls import Call, Figures, mean, summed
from routing_figures.chunk import ChunkFigures
from routing_figures.dollars import DIMENSIONS
from model_routing.ladder import position
from model_routing.ladder import Ladder
def render(figures: Figures, found: list[Call], at: str, cycle: int, since: str) -> str:
"""The figures as markdown, for the human to read. since is the latest reset's stamp, empty for none."""
def render(ladder: Ladder, figures: Figures, found: list[Call], at: str, cycle: int, since: str) -> str:
"""The figures as markdown, for the human to read. ladder orders the rungs, and since is the latest reset's stamp, empty for none."""
sections = [
"# Routing figures",
f"Measured {at}, at cycle {cycle} across loop-claude's archive, from {figures.chunks} finished chunk{'' if figures.chunks == 1 else 's'}{f' that finished after the reset of {since}' if since else ''}. {basis(figures)}",
@@ -19,7 +19,7 @@ def render(figures: Figures, found: list[Call], at: str, cycle: int, since: str)
*[part for dimension in DIMENSIONS for part in (f"## Dollars by {dimension}", dollars_table(figures, dimension))],
"## Routed chunks by the rung they started on",
fixes_basis(figures),
routed_table(figures),
routed_table(ladder, figures),
"## Escalations by trigger across every chunk, routed or not",
f"{triggers(figures.escalated) or 'None'}.",
"## Subagent reports against the tool results they read, in characters",
@@ -35,8 +35,8 @@ def dollars_table(figures: Figures, dimension: str) -> str:
return table((dimension.capitalize(), "Dollars"), [(label, money(dollars)) for label, dollars in sorted(figures.dollars[dimension].items(), key=lambda spent: -spent[1])])
def routed_table(figures: Figures) -> str:
"""One row per rung the routed chunks started on, from the bottom of the ladder up."""
def routed_table(ladder: Ladder, figures: Figures) -> str:
"""One row per rung the routed chunks started on, from the bottom of the ladder up, after the rungs off it."""
return table(("Rung", "Chunks", "Review rounds past each pass's first, mean", "Unfinished verdicts, mean", "Later fixes, mean", "Subagent rungs", "Escalations by trigger"), [
(
str(rung),
@@ -47,7 +47,7 @@ def routed_table(figures: Figures) -> str:
subagent_rungs(chunks),
triggers(summed(chunks, lambda chunk: chunk.escalated)),
)
for rung, chunks in sorted(figures.routed.items(), key=lambda routed: position(routed[0]))
for rung, chunks in sorted(figures.routed.items(), key=lambda routed: ladder.position(routed[0]))
])