Answer architecture round 1: 0 🔴, 4 🟡 (0 misread); move the shared loop state out of loop_claude, split ranking and routing, give the reviewer rung one rule
CI / tests (pull_request) Successful in 2m14s

This commit is contained in:
2026-11-10 22:03:16 +01:00
parent 8a80d452f2
commit 70a1b95086
70 changed files with 748 additions and 625 deletions
+10 -14
View File
@@ -5,9 +5,8 @@ import pathlib
import sys
import typing
from loop_claude.effects import Effects, say
from model_routing.route import Route
from model_routing.ladder import Rung
from loop_effects.effects import Effects, say
from model_routing.route import Route, route_of
from loop_claude.stop import Stop
RELOAD_FLAG = "--reloaded"
@@ -67,23 +66,20 @@ def decoded_ids(value: object) -> tuple[int, ...]:
return tuple(exactly(int)(each) for each in value)
def decoded_rung(value: object) -> Rung:
return Rung(**decoded_fields(value, {"model": exactly(str), "effort": exactly(str)}, "model"))
def decoded_route(value: object) -> Route | None:
"""The Route the JSON holds; None for null, or for a route holding a key Route.RETIRED names, so the chunk routes afresh."""
if value is None or (isinstance(value, dict) and value.keys() & Route.RETIRED):
"""The Route the JSON holds; None for null. dataclasses.asdict wrote it: a worker line's fields, but with the rung nested and the unfinished count beside them, so route_of decodes it once flattened."""
if value is None:
return None
fields = decoded_fields(value, ROUTE_FIELDS, "rung")
if not Route.fits(fields):
if not isinstance(value, dict) or not isinstance(value.get("rung"), dict) or not value["rung"].keys() <= {"model", "effort"} or value.keys() & {"model", "effort"}:
raise Unreadable
return Route(**fields)
route = route_of({**{name: field for name, field in value.items() if name not in ("rung", "unfinished")}, **value["rung"]})
if route is None:
raise Unreadable
return dataclasses.replace(route, unfinished=exactly(int)(value.get("unfinished", 0)))
# One decoder per field of LoopRun and of Route, which tests hold to those dataclasses' fields: a field missing here stops a loop at the reload after it joined.
# One decoder per field of LoopRun, which a test holds to the dataclass's fields: a field missing here stops a loop at the reload after it joined.
LOOP_RUN_FIELDS = {"cycle_number": exactly(int), "root": exactly(str), "task": exactly(str), "unfinished_evidence": exactly(str), "route": decoded_route, "unfinished_run": exactly(int), "items_taken_in": decoded_ids}
ROUTE_FIELDS = {"rung": decoded_rung, **{name: exactly(int) for name in ("item", "likelihood", "escape_and_impact", "unfinished", "escape_and_impact_taken_in", "escalated_at")}}
def fingerprint(launcher: pathlib.Path) -> str: