Answer architecture round 1: 0 🔴, 8 🟡; read old routes' rungs, write R in rank_todo, route reviews through review_rungs, file item 168

This commit is contained in:
2026-10-16 12:11:25 +02:00
parent 149108e8d8
commit 12909f233d
20 changed files with 141 additions and 94 deletions
+17 -6
View File
@@ -3,12 +3,13 @@ import dataclasses
import re
from todo_table import LEVELS
from model_routing.ladder import Rung, WORKER_STEPS
from model_routing.ladder import Rung
# How a worker opens the prompt of a subagent it escalates a task to, `Escalation trigger 2: …`: docs/decisions.md → `routing: a worker hands a task one rung up`.
ESCALATION_MARKER = "Escalation trigger"
# A line an older loop-claude wrote, naming an R + C, reads as no route, so its chunk routes afresh.
ROUTED = re.compile(r"(?P<rung>.+?)(?:, routed by item (?P<item>[0-9]+)'s L of (?P<likelihood>[0-9]+) and E \+ I of (?P<escape_and_impact>[0-9]+))?")
# An archived worker line: the rung, then the item and the levels that routed it, if any. resume reads only LEVELS_ROUTED's levels, so a line an older loop-claude wrote, naming an R + C, routes its chunk afresh; the figures still read its rung.
ROUTED = re.compile(r"(?P<rung>.+?)(?:, routed by item (?P<item>[0-9]+)'s (?P<levels>.+))?")
LEVELS_ROUTED = re.compile(r"L of (?P<likelihood>[0-9]+) and E \+ I of (?P<escape_and_impact>[0-9]+)")
@dataclasses.dataclass(frozen=True)
@@ -29,14 +30,24 @@ class Route:
def route_from(worker: str) -> Route | None:
"""The route an archived worker line names; None for a model run off the ladder, or levels off their scales."""
"""The route an archived worker line names; None for a model run off the ladder, or a route by anything but levels on their scales."""
found = ROUTED.fullmatch(worker)
rung = Rung.parse(found["rung"]) if found else None
if not found or not rung:
return None
if not found["item"]:
return Route(rung)
likelihood, escape_and_impact = int(found["likelihood"]), int(found["escape_and_impact"])
if likelihood not in WORKER_STEPS or not 2 <= escape_and_impact <= LEVELS["E"] + LEVELS["I"]:
levels = LEVELS_ROUTED.fullmatch(found["levels"])
if not levels:
return None
likelihood, escape_and_impact = int(levels["likelihood"]), int(levels["escape_and_impact"])
if not 1 <= likelihood <= LEVELS["L"] or not 2 <= escape_and_impact <= LEVELS["E"] + LEVELS["I"]:
return None
return Route(rung, int(found["item"]), likelihood, escape_and_impact)
def archived_rung(worker: str) -> tuple[Rung, bool] | None:
"""The rung an archived worker line names, and whether an item routed it, whatever the route names after the rung; None for a model run off the ladder."""
found = ROUTED.fullmatch(worker)
rung = Rung.parse(found["rung"]) if found else None
return (rung, bool(found["item"])) if found and rung else None