Answer architecture round 1: 1 🔴, 12 🟡 (0 misread); route every verdict through next_route with one step-up writer, give a release one home in release.py and rename chunk_pick to release_standing, split loop/main.py, delete the unreachable lowered-pass code, render agent-followed Markdown from one list, refuse a round title naming no pass, and rename the clashing names

This commit is contained in:
2026-11-04 22:57:30 +01:00
parent 97b35f9def
commit 452a0c4271
56 changed files with 689 additions and 694 deletions
+5 -5
View File
@@ -6,8 +6,8 @@ import typing
from failure import Failure
from model_routing.ladder import LADDER, position, Rung
from claude_code.reply import Limited
from loop_claude.paths import paths_from
from loop_claude.project.model_choice import read_models_file
from loop_claude.stop import Stop
# What a tool reads from its arguments, such as the project's rung of the model they name.
Parsed = typing.TypeVar("Parsed")
@@ -25,10 +25,10 @@ def arguments_or_exit(tool: str, argv: list[str], help_text: str, usage: str, re
def projects_on(model: str, home: pathlib.Path) -> list[str] | Failure:
"""The keys of the projects ~/.claude/loop-claude-models.json runs on model, sorted."""
models = read_models_file(home / ".claude" / "loop-claude-models.json")
if isinstance(models, Stop):
return Failure(models.reason)
"""The keys of the projects loop-claude's models file, under home, runs on model, sorted."""
models = read_models_file(paths_from(home).models_file)
if isinstance(models, Failure):
return models
return sorted(key for key, on in models.items() if on == model)
+17 -17
View File
@@ -14,30 +14,30 @@ AT_ONCE = 4
Case = typing.TypeVar("Case")
# What of an archived case a reply reproduces, such as a verdict's kind or a finding's index.
Item = typing.TypeVar("Item")
Reply = typing.TypeVar("Reply")
Aim = typing.TypeVar("Aim")
Answer = typing.TypeVar("Answer")
T = typing.TypeVar("T")
@dataclasses.dataclass(frozen=True)
class Miss(typing.Generic[Case, Item, Reply]):
class Miss(typing.Generic[Case, Aim, Answer]):
"""An item of case that the reference reproduced and a rung's reply missed."""
case: Case
item: Item
reply: Reply
item: Aim
reply: Answer
@dataclasses.dataclass(frozen=True)
class Tried(typing.Generic[Case, Item, Reply]):
class Tried(typing.Generic[Case, Aim, Answer]):
rung: Rung
missed: list[Miss[Case, Item, Reply]]
missed: list[Miss[Case, Aim, Answer]]
@dataclasses.dataclass(frozen=True)
class Replay(typing.Generic[Case, Item, Reply]):
class Replay(typing.Generic[Case, Aim, Answer]):
"""on_reference holds the reference's reply on each case; tried, each candidate tried, highest first; lowest, the lowest rung that, like each candidate above it, missed nothing, or None."""
on_reference: list[Reply]
tried: list[Tried[Case, Item, Reply]]
on_reference: list[Answer]
tried: list[Tried[Case, Aim, Answer]]
lowest: Rung | None
@@ -45,10 +45,10 @@ def replayed(
cases: list[Case],
reference: Rung,
candidates: list[Rung],
replay_one: typing.Callable[[Case, Rung], Reply | Limited],
reproduced: typing.Callable[[Case, Reply], list[Item]],
replay_one: typing.Callable[[Case, Rung], Answer | Limited],
reproduced: typing.Callable[[Case, Answer], list[Aim]],
what: str,
) -> Replay[Case, Item, Reply] | Limited:
) -> Replay[Case, Aim, Answer] | Limited:
"""Replays the cases on the reference rung, then each candidate, highest first, on the cases where the reference reproduced anything, until one misses an item it reproduced.
Going down, every rung at or above the one named was tried and missed nothing, so the result needs no assumption that a higher rung does at least as well; and a miss high up spares the cheaper rungs their replays.
@@ -57,14 +57,14 @@ def replayed(
if isinstance(on_reference, Limited):
return on_reference
held = [(case, aim) for case, reply in zip(cases, on_reference) if (aim := reproduced(case, reply))]
tried: list[Tried[Case, Item, Reply]] = []
tried: list[Tried[Case, Aim, Answer]] = []
lowest = None
# With nothing to hold a rung to, every rung would miss nothing.
for rung in candidates if held else []:
replies = replayed_on([case for case, _ in held], rung, replay_one, what)
if isinstance(replies, Limited):
return replies
misses: list[Miss[Case, Item, Reply]] = []
misses: list[Miss[Case, Aim, Answer]] = []
for (case, aim), reply in zip(held, replies):
got = reproduced(case, reply)
misses += [Miss(case, item, reply) for item in aim if item not in got]
@@ -75,12 +75,12 @@ def replayed(
return Replay(on_reference, tried, lowest)
def replayed_on(cases: list[Case], rung: Rung, replay_one: typing.Callable[[Case, Rung], Reply | Limited], what: str) -> list[Reply] | Limited:
def replayed_on(cases: list[Case], rung: Rung, replay_one: typing.Callable[[Case, Rung], Answer | Limited], what: str) -> list[Answer] | Limited:
"""Each case's reply on rung, AT_ONCE at a time; a usage limit cancels the rest."""
print(f"replaying {len(cases)} {what} on {rung}", file=sys.stderr, flush=True)
with concurrent.futures.ThreadPoolExecutor(AT_ONCE) as pool:
running = [pool.submit(replay_one, case, rung) for case in cases]
replies: list[Reply] = []
replies: list[Answer] = []
for future in running:
reply = future.result()
if isinstance(reply, Limited):