From 015e39ae97ca3d5d4cd7689180bce0167198b738 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 15 Oct 2026 09:16:11 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1;=20name=20no=20rung=20without?= =?UTF-8?q?=20evidence,=20test=20the=20prompt's=20task,=20premises=20and?= =?UTF-8?q?=20records=20and=20the=20replay's=20edges,=20and=20name=20a=20c?= =?UTF-8?q?opy=20and=20its=20outcomes=20file=20in=20one=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/judge_replay/main.py | 14 +++++--- bin/judge_replay/replay.py | 15 +++++--- bin/judge_replay/test_judge_replay.py | 50 ++++++++++++++++++++++----- bin/loop_claude/loop/main.py | 7 ++-- bin/loop_claude/routing.py | 6 ++-- bin/loop_claude/test_loop_claude.py | 2 ++ bin/transcript_archive/location.py | 13 +++++++ bin/transcript_archive/outcomes.py | 2 -- bin/transcript_archive/read.py | 9 ++--- bin/transcript_archive/write.py | 6 ++-- docs/decisions.md | 2 +- todo.md | 2 ++ 13 files changed, 94 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c88b05a..56ef20a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` runs the judge of an Opus 5.5 project on the rung the chunk's `todo.md` item picks, never below Opus 5.5 at medium effort, the project's rung. Before, the judge ran at the effort `settings.json` sets, xhigh. A replay of 39 archived verdicts found every cheaper rung missing verdicts. The judge keeps its rung when the worker steps up, and runs on the project's rung when no item routed the chunk. A project on another model keeps its judge at its settings' effort. Each verdict in the archive now names the judge's rung on a `Judge:` line. The new `bin/judge-replay ` replays the judge on archived verdicts and prints the cheapest rung that returns them. Expect the judge to cost less on items of R + C 12 or less, and more on items of R + C 15 or more. +- `loop-claude` runs the judge of an Opus 5.5 project on the rung the chunk's `todo.md` item picks, never below Opus 5.5 at medium effort, the project's rung. Before, the judge ran at the effort `settings.json` sets, xhigh. A replay of 39 archived verdicts found every cheaper rung missing verdicts. The judge keeps its rung when the worker steps up or takes in another item, and runs on the project's rung when no item routed the chunk. A project on another model keeps its judge at its settings' effort. Each verdict in the archive now names the judge's rung on a `Judge:` line. The new `bin/judge-replay ` replays the judge on archived verdicts and prints the cheapest rung that returns them. Expect the judge to cost less on items of R + C 12 or less, and more on items of R + C 15 or more. - Every 20 cycles across all projects, `loop-claude` measures every finished chunk in its archive, with no model run, and writes the figures to `routing-figures.md` at the archive's root: tokens by project, subagent type, rung and tool, and, for each chunk a `todo.md` item routed, grouped by the rung it started on: its review rounds past each pass's first, its unfinished verdicts and its subagents' rungs. It interrupts you, with `claude` on the project's model on the terminal in `~/.claude`, when chunks routed onto a rung took more review rounds or unfinished verdicts than chunks routed onto the next rung up, each rung with 5 chunks or more, or when 5 or more subagents of one type wrote reports longer than the tool results they read. Each call is raised once, then listed in `routing-calls-raised.md` beside the figures; the next chunk of this repo files a `todo.md` item for it. Off a terminal, the calls are said on stderr and the loop goes on. They are raised at the next measurement on a terminal. After a routing change, a `- Reset` line in that file makes the figures count only chunks finished after it, and lets its calls be raised again. Expect a pause of about ten seconds at each measurement. - A session delegates a task to a subagent only when it needs just the task's conclusion, such as a search across many files, and keeps edits in its own thread. It scores the task's R and C as for a `todo.md` item, and launches the subagent on the model and effort that the new `bin/subagent-rung ` picks from the project's model, such as `model sonnet, effort high`. `CLAUDE.md` states the rule. Expect searches to run on cheaper models, and less of each session's context to fill with search output. - `loop-claude` routes each chunk's worker on a ladder of model and effort rungs, from Haiku 5.5 at low effort to Fable 5.1 at max, when the project's model is on it. As a chunk starts, the R + C of `todo.md`'s top item in the next release picks the rung: 11–12 picks one rung above the project's rung, so Opus 5.5 at high for an Opus 5.5 project, and so on up to four rungs. An item of R + C 10 or less runs the worker at or below the project's model's cheapest rung, which for Opus 5.5 is medium effort, below the xhigh `settings.json` sets. While the worker runs below the project's model's cheapest rung, it launches every reviewer, comprehension seat and security pass, the full scan included, in a subagent on that rung. While it runs above that rung, it launches each comprehension seat and the security pass on that rung. It steps up one rung after every second unfinished verdict on a chunk, and to a higher rung when it takes in an item of higher R + C. Each cycle's header, and each finished or unfinished verdict, stop and step-up in the archive, name the worker's rung; a rerun resumes an open chunk on the latest rung archived for it. `docs/decisions.md` → `routing:` gives the ladder, its source and the bands. Expect a chunk on an easy item to cost much less than under xhigh, and perhaps to take more review rounds, and one on an item of R + C 15 or more to cost more. diff --git a/bin/judge_replay/main.py b/bin/judge_replay/main.py index d49ec3e7..fde032a0 100644 --- a/bin/judge_replay/main.py +++ b/bin/judge_replay/main.py @@ -13,19 +13,22 @@ ran before it was routed. A verdict the reference judge returns another kind on records and judge rules of its day, so no rung is held to it. It then replays the rest on each rung from the one the lowest R + C picks up to the model's cheapest rung, cheapest first, and stops at the first rung that returns all of them. It prints each verdict a rung missed, and the cheapest -rung that missed none. +rung that missed none. A rung it names is the evidence to add the model to JUDGE_REPLAYED in +bin/loop_claude/routing.py, which routes that model's judge, and to record the run in +docs/decisions.md → `routing:`. Like the loop, it tries a judge three times running before it counts the reply as failed. A verdict whose project or transcript cannot be read replays as failed too. Exit 1, saying why, on -bad arguments, an unreadable archive or models file, or a usage limit. +bad arguments, an unreadable archive or models file, no archived verdict of the model's projects, +or a usage limit. """ import concurrent.futures import pathlib import sys import typing -from transcript_archive.location import archive_root -from transcript_archive.read import archived_outcomes, transcript_of +from transcript_archive.location import archive_root, transcript_of +from transcript_archive.read import archived_outcomes from judge_replay.replay import Case, case_from, Kind, replayed, report, sample, verdict_kind from project_key import checkout_of from loop_claude.effects import Effects @@ -60,6 +63,9 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff if isinstance(cases, Failure): print(f"judge-replay: {cases.reason}", file=sys.stderr) return 1 + if not cases: + print(f"judge-replay: no archived verdicts of projects on {argv[0]} in {archive_root(home, env)}; run loop-claude on one first", file=sys.stderr) + return 1 cases = sample(cases, PER_KIND) reference = Rung(argv[0], REFERENCE_EFFORT) candidates = list(LADDER[position(picked(anchor, LOWEST_R_PLUS_C)):position(anchor) + 1]) diff --git a/bin/judge_replay/replay.py b/bin/judge_replay/replay.py index ed4c792d..e01c8337 100644 --- a/bin/judge_replay/replay.py +++ b/bin/judge_replay/replay.py @@ -40,7 +40,10 @@ class Replay: def case_from(root: str, outcomes: str, transcript: pathlib.Path) -> Case | None: - """The first verdict an outcomes file holds: the judge ruled on the transcript copy beside it as the copy stands. None when it holds none.""" + """The first verdict an outcomes file holds: the judge ruled on the transcript copy beside it as the copy stands. None when it holds none. + + A quoted answer past the cycle's cap is archived as the interrupt it became, so the reference judge's quoted answer sets it aside, holding no rung to it. + """ task, verdict = task_of(outcomes), first_verdict(outcomes) if task is None or verdict is None: return None @@ -84,8 +87,9 @@ def replayed(cases: list[Case], reference: Rung, candidates: list[Rung], rule_al return ruled reproduced = [found for found, kind in zip(cases, ruled) if kind == found.on_record] unreproduced = [(found, kind) for found, kind in zip(cases, ruled) if kind != found.on_record] - tried = [] - for rung in candidates: + tried: list[Tried] = [] + # With no verdict to hold a rung to, every rung would miss none. + for rung in candidates if reproduced else []: ruled = rule_all(reproduced, rung) if isinstance(ruled, Limited): return ruled @@ -104,7 +108,10 @@ def report(model: str, reference: Rung, cases: list[Case], replay: Replay) -> st ] for tried in replay.tried: lines += [f"{tried.rung} missed {len(tried.missed)}{':' if tried.missed else '.'}", *missed_lines(tried.missed)] - lines.append(f"Cheapest rung that returns every verdict the reference judge reproduces: {replay.cheapest or 'none up to the project rung'}") + if not replay.tried: + lines.append("No rung tried: the reference judge reproduced no verdict to hold one to.") + else: + lines.append(f"Cheapest rung that returns every verdict the reference judge reproduces: {replay.cheapest or 'none up to the project rung'}") return "\n".join(lines) diff --git a/bin/judge_replay/test_judge_replay.py b/bin/judge_replay/test_judge_replay.py index e52ecefc..c348e089 100644 --- a/bin/judge_replay/test_judge_replay.py +++ b/bin/judge_replay/test_judge_replay.py @@ -74,8 +74,13 @@ class Replayed(unittest.TestCase): self.assertEqual(asked, [(3, REFERENCE), (2, CHEAP), (2, MIDDLE)]) def test_names_no_rung_when_every_candidate_misses_a_verdict(self): - replay = replayed([case("2026-10-14T10:00:00Z", FINISHED)], REFERENCE, [CHEAP], lambda on, rung: [FINISHED] if rung == REFERENCE else [INTERRUPTED]) - self.assertIsNone(replay.cheapest) + cases = [case("2026-10-14T10:00:00Z", FINISHED)] + replay = replayed(cases, REFERENCE, [CHEAP], lambda on, rung: [FINISHED] if rung == REFERENCE else [INTERRUPTED]) + self.assertEqual(replay, Replay([], [Tried(CHEAP, [(cases[0], INTERRUPTED)])], None)) + + def test_tries_no_rung_when_the_reference_reproduces_no_verdict(self): + cases = [case("2026-10-14T10:00:00Z", FINISHED)] + self.assertEqual(replayed(cases, REFERENCE, [CHEAP], lambda on, rung: [INTERRUPTED] * len(on)), Replay([(cases[0], INTERRUPTED)], [], None)) def test_stops_at_a_usage_limit(self): limit = Limited(None, "limit") @@ -96,7 +101,10 @@ class Report(unittest.TestCase): "claude-sonnet-5-5 at high effort missed 0.", "Cheapest rung that returns every verdict the reference judge reproduces: claude-sonnet-5-5 at high effort", ]) - self.assertTrue(report("claude-opus-5-5", REFERENCE, cases, Replay([], [Tried(CHEAP, [(cases[1], FINISHED)])], None)).endswith(": none up to the project rung")) + missed_all = report("claude-opus-5-5", REFERENCE, cases, Replay([], [Tried(CHEAP, [(cases[1], FINISHED)])], None)).splitlines() + self.assertEqual(missed_all[1], "The reference judge, claude-opus-5-5 at xhigh effort, reproduced 2.") + self.assertEqual(missed_all[-1], "Cheapest rung that returns every verdict the reference judge reproduces: none up to the project rung") + self.assertEqual(report("claude-opus-5-5", REFERENCE, cases, Replay([(cases[0], UNFINISHED), (cases[1], FINISHED)], [], None)).splitlines()[-1], "No rung tried: the reference judge reproduced no verdict to hold one to.") def unused(*_): @@ -110,6 +118,7 @@ class Main(unittest.TestCase): self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) (self.home / ".claude").mkdir() (self.home / ".claude" / "loop-claude-models.json").write_text(json.dumps({"proj": "claude-opus-5-5", "other": "claude-sonnet-5-5"})) + (self.home / ".claude" / "CLAUDE.md").write_text("Be kind.\n") for key, verdicts in (("proj", (FINISHED, INTERRUPTED)), ("other", (FINISHED,))): (self.home / "code" / key).mkdir(parents=True) (self.home / "code" / key / "README.md").write_text("# p\n\n## Goals\n\n1. Ship.\n\n## Audience\n\nMe.\n") @@ -119,11 +128,13 @@ class Main(unittest.TestCase): (chunk / f"t{n}.jsonl").write_text(json.dumps({"type": "assistant", "message": {"content": [{"type": "text", "text": f"said {verdict}"}]}}) + "\n") (chunk / f"t{n}.outcomes.md").write_text(f"Task: Do it.\n\n2026-10-14T10:00:0{n}Z {verdict}\n\nEvidence:\n> e\n") self.calls = [] + self.prompts = [] def run_main(self, argv, reply): def claude(args, cwd, prompt): self.calls.append((args[args.index("--model") + 1], args[args.index("--effort") + 1], cwd)) - result = reply(args[args.index("--model") + 1], "said Verdict: interrupt" in prompt.rsplit("latest last:", 1)[-1]) + self.prompts.append(prompt) + result = reply(Rung(args[args.index("--model") + 1], args[args.index("--effort") + 1]), "said Verdict: interrupt" in prompt.rsplit("latest last:", 1)[-1]) return subprocess.CompletedProcess(args, 0, json.dumps(result), "") effects = Effects(claude=claude, claude_on_terminal=unused, execv=unused, git=unused, input=unused, local_time=unused, now=unused, on_terminal=unused, python=unused, sleep=unused, stream_claude=unused) @@ -139,8 +150,8 @@ class Main(unittest.TestCase): def test_replays_the_models_projects_on_the_reference_then_cheapest_first_and_prints_the_rung_that_returns_all(self): # Haiku misses the interrupt; Sonnet returns both. - def reply(model, interrupted): - return self.verdict(interrupted and model != "claude-haiku-5-5", f"said {INTERRUPTED if interrupted else FINISHED}") + def reply(rung, interrupted): + return self.verdict(interrupted and rung.model != "claude-haiku-5-5", f"said {INTERRUPTED if interrupted else FINISHED}") code, out, err = self.run_main(["claude-opus-5-5"], reply) self.assertEqual(code, 0, err) @@ -148,10 +159,24 @@ class Main(unittest.TestCase): self.assertEqual([(model, effort) for model, effort, _ in self.calls[::2]], [("claude-opus-5-5", "xhigh"), ("claude-haiku-5-5", "xhigh"), ("claude-haiku-5-5", "max"), ("claude-sonnet-5-5", "high")]) self.assertIn("The reference judge, claude-opus-5-5 at xhigh effort, reproduced 2.", out) self.assertTrue(out.endswith("returns every verdict the reference judge reproduces: claude-sonnet-5-5 at high effort\n")) + for said in ("The task an agent was given:\nDo it.", "1. Ship.", "From ~/.claude/CLAUDE.md:\nBe kind."): + self.assertIn(said, self.prompts[0]) + + def test_tries_rungs_up_to_the_models_cheapest_and_names_none_when_all_miss(self): + code, out, _ = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted and rung == REFERENCE, f"said {INTERRUPTED if interrupted else FINISHED}")) + self.assertEqual(code, 0) + self.assertEqual(self.calls[-1][:2], ("claude-opus-5-5", "medium")) + self.assertTrue(out.endswith(": none up to the project rung\n")) + + def test_replays_a_verdict_whose_transcript_is_gone_as_failed(self): + (self.home / ".claude" / "loop-claude-transcripts" / "proj" / "c1" / "t0.jsonl").unlink() + code, out, _ = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED}")) + self.assertEqual(code, 0) + self.assertIn("replayed failed: could not read the transcript", out) def test_tries_up_to_the_models_cheapest_rung_and_retries_a_failed_reply_as_the_loop_does(self): - def reply(model, interrupted): - return self.verdict(interrupted, "not in the transcript" if model != "claude-opus-5-5" else f"said {INTERRUPTED if interrupted else FINISHED}") + def reply(rung, interrupted): + return self.verdict(interrupted, "not in the transcript" if rung.model != "claude-opus-5-5" else f"said {INTERRUPTED if interrupted else FINISHED}") code, out, _ = self.run_main(["claude-opus-5-5"], reply) self.assertEqual(code, 0) @@ -159,14 +184,21 @@ class Main(unittest.TestCase): self.assertIn("claude-opus-5-5 at medium effort missed 0.", out) def test_exits_1_on_a_usage_limit_bad_arguments_or_an_unreadable_models_file(self): - code, _, err = self.run_main(["claude-opus-5-5"], lambda model, interrupted: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) + code, _, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) self.assertEqual(code, 1) self.assertIn("usage limit: You've hit your limit", err) for argv in ([], ["off-ladder"], ["claude-opus-5-5", "x"]): self.assertEqual(self.run_main(argv, unused)[0], 1) + code, _, err = self.run_main(["claude-haiku-5-5"], unused) + self.assertEqual(code, 1) + self.assertIn("no archived verdicts of projects on claude-haiku-5-5", err) (self.home / ".claude" / "loop-claude-models.json").write_text("[") self.assertEqual(self.run_main(["claude-opus-5-5"], unused)[0], 1) + def test_prints_the_help(self): + code, out, _ = self.run_main(["-h"], unused) + self.assertEqual((code, out.splitlines()[2]), (0, "usage: judge-replay ")) + def test_the_launcher_prints_the_help(self): ran = subprocess.run([sys.executable, str(TOOL), "--help"], capture_output=True, text=True) self.assertEqual(ran.returncode, 0) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 43c63226..e6a1cd5f 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -47,9 +47,10 @@ todo.md's top item in the next release, skipping an item marked question, picks counts from the model's cheapest rung, and an R + C of 8 or less picks a rung below it; without such an item, or with a C missing, the chunk runs on the model's cheapest rung. The worker's first prompt names the rung and the item, and asks the worker to name each item the chunk takes, with its -R + C. On a model judge-replay has replayed, the judge runs on the rung that item's R + C picks from -the judge's model, never below that model's cheapest rung, whatever rung the worker steps to; -without such an item, on the cheapest rung. When the worker's rung is below the model's cheapest, the prompt also has the worker launch each +R + C. On a model listed in JUDGE_REPLAYED in bin/loop_claude/routing.py, which judge-replay found +returning every verdict on its cheapest rung, the judge runs on the rung that item's R + C picks from +the judge's model. It never runs below that model's cheapest rung, and keeps its rung when the +worker steps up or takes in another item; without such an item, it runs on the cheapest rung. When the worker's rung is below the model's cheapest, the prompt also has the worker launch each reviewer, each comprehension seat and the security pass in subagents on the cheapest rung. When it is above, the prompt has the worker launch only each comprehension seat and the security pass on the cheapest rung. The prompt after each unfinished verdict diff --git a/bin/loop_claude/routing.py b/bin/loop_claude/routing.py index c861ee02..75797421 100644 --- a/bin/loop_claude/routing.py +++ b/bin/loop_claude/routing.py @@ -29,12 +29,12 @@ def first_route(anchor: Rung, item: Item | None) -> Route: def kept(route: Route, anchor: Rung) -> bool: - """Whether a chunk keeps route: its rung is on the ladder at or above the rung its item's R + C picks from anchor, the project's rung, or anchor itself when no item routed it.""" + """Whether a chunk keeps route: its rung is on the ladder at or above item_rung.""" return highest(route.rung, item_rung(anchor, route)) == route.rung def item_rung(anchor: Rung, route: Route) -> Rung: - """The rung the route's item's R + C picks from anchor, the project's rung, or anchor itself when no item routed it.""" + """The rung the route's item's R + C picks from anchor, the project's rung, or anchor itself when no item routed it. The worker may run below anchor; judge_rung lifts it to anchor.""" return picked(anchor, route.risk_and_complexity) if route.item else anchor @@ -51,6 +51,8 @@ def stepped(anchor: Rung, route: Route, bundled: int) -> Route: def judge_rung(judge_model: str, route: Route) -> Rung: """The rung the route's item picks from the judge model's cheapest rung, never below that rung, whatever rung the worker stepped to. + An item the worker takes in moves the worker's rung but not the judge's, until todo.md item 136 routes the chunk on the item the worker takes. + A model judge-replay has not replayed runs alone, at its settings' effort, as does one off the ladder. """ anchor = project_rung(judge_model) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 440f0722..187ce021 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -254,6 +254,8 @@ class Cycles(unittest.TestCase): self.assertEqual(len(judge_prompts), 2) self.assertNotIn("the second", judge_prompts[0]) self.assertIn("[human] the second", judge_prompts[1]) + self.assertIn("From README.md:\n## Goals", judge_prompts[0]) + self.assertIn("The task an agent was given:\nDo it.", judge_prompts[0]) def test_a_question_the_records_answer_resumes_the_worker_with_the_answer_three_times_a_cycle(self): answered = judged("quoted", answer="Use *A*.") diff --git a/bin/transcript_archive/location.py b/bin/transcript_archive/location.py index 6c4d4e13..170fcceb 100644 --- a/bin/transcript_archive/location.py +++ b/bin/transcript_archive/location.py @@ -5,6 +5,9 @@ import typing from claude_code.transcript import first_timestamped_line from project_key import project_key +# What an outcomes file's name ends with, in place of its transcript copy's .jsonl. +FILE_SUFFIX = ".outcomes.md" + def archive_root(home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path: """Where loop-claude archives every project's chunks.""" @@ -18,3 +21,13 @@ def project_archive(checkout_root: str, home: pathlib.Path, env: typing.Mapping[ def chunk_folder(project_archive: pathlib.Path, transcript: bytes) -> pathlib.Path: # Each chunk's first timestamped line is its own: a finished chunk's session is deleted, so the next chunk's transcript starts afresh. return project_archive / hashlib.sha256(first_timestamped_line(transcript)).hexdigest() + + +def outcomes_of(copy: pathlib.Path) -> pathlib.Path: + """The outcomes file beside a transcript copy; transcript_of is its inverse.""" + return copy.with_suffix(FILE_SUFFIX) + + +def transcript_of(outcomes: pathlib.Path) -> pathlib.Path: + """The transcript copy an outcomes file sits beside; outcomes_of is its inverse.""" + return outcomes.with_name(outcomes.name.removesuffix(FILE_SUFFIX) + ".jsonl") diff --git a/bin/transcript_archive/outcomes.py b/bin/transcript_archive/outcomes.py index f66209bf..191e8285 100644 --- a/bin/transcript_archive/outcomes.py +++ b/bin/transcript_archive/outcomes.py @@ -3,8 +3,6 @@ import re from markdown_text import quoted from utc_stamp import STAMPED -# What an outcomes file's name ends with, in place of its transcript copy's .jsonl. -FILE_SUFFIX = ".outcomes.md" TASK = "Task: " FINISHED = "Verdict: finished" UNFINISHED = "Verdict: unfinished" diff --git a/bin/transcript_archive/read.py b/bin/transcript_archive/read.py index 744357f7..18240ab9 100644 --- a/bin/transcript_archive/read.py +++ b/bin/transcript_archive/read.py @@ -1,9 +1,9 @@ import dataclasses import pathlib -from transcript_archive.location import chunk_folder +from transcript_archive.location import chunk_folder, FILE_SUFFIX, transcript_of from failure import Failure -from transcript_archive.outcomes import FILE_SUFFIX, FINISHED_AT, workers +from transcript_archive.outcomes import FINISHED_AT, workers @dataclasses.dataclass(frozen=True) @@ -41,11 +41,6 @@ def chunk_outcomes(folder: pathlib.Path) -> list[pathlib.Path]: return sorted(folder.glob(f"*{FILE_SUFFIX}")) -def transcript_of(outcomes: pathlib.Path) -> pathlib.Path: - """The transcript copy an outcomes file sits beside.""" - return outcomes.with_name(outcomes.name.removesuffix(FILE_SUFFIX) + ".jsonl") - - def read_threads(chunk: FinishedChunk) -> list[bytes] | Failure: """The worker's transcript, then each subagent's.""" try: diff --git a/bin/transcript_archive/write.py b/bin/transcript_archive/write.py index a34a7e78..cf8e49b2 100644 --- a/bin/transcript_archive/write.py +++ b/bin/transcript_archive/write.py @@ -3,11 +3,11 @@ import os import pathlib import sys -from transcript_archive.location import chunk_folder +from transcript_archive.location import chunk_folder, outcomes_of from failure import Failure -from transcript_archive.outcomes import FILE_SUFFIX, TASK from file_writes import make_private, replace_file from claude_code.session import session_files +from transcript_archive.outcomes import TASK from utc_stamp import utc @@ -23,7 +23,7 @@ def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, a if sibling != path and (unkept := mirror(pathlib.Path(sibling), folder / "session" / os.path.basename(sibling))): return unkept copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl" - outcomes = copy.with_suffix(FILE_SUFFIX) + outcomes = outcomes_of(copy) stamped = f"{utc(at)} {outcome}" if copy.exists() and outcomes.exists(): return add_outcome(outcomes, stamped) diff --git a/docs/decisions.md b/docs/decisions.md index 2b142089..74a131e2 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -182,7 +182,7 @@ The cost of a cheaper worker shows as extra review rounds and unfinished verdict A model off the ladder routes nothing: claude runs it at the effort its settings give. R + C steps a task from the project's rung: 2–4 three rungs down, 5–6 two down, 7–8 one down, 9–10 none, 11–12 one up, 13–14 two up, 15–16 three up, 17 and above four up. A step past either end stops there. The bands spread the R + C that `todo.md`'s items held on 2026-10-14, 2 to 12, across the rungs, so most tasks step down. S never moves a rung, so a huge task with low R and C runs cheap. While the worker runs above the project's rung, loop-claude's prompt has it launch the comprehension seats and the security pass's subagent on the project's rung too. So the seats score every chunk on one rung, and the security pass spends no more than the project chose. The prompt after each unfinished verdict repeats this, since a step-up may have taken the worker above the project's rung. The other reviewers inherit the worker's higher rung until item 90 routes them. `score-outcomes` had too few finished chunks to ground the bands, and a change to the ladder or the bands is lilleman's. -The judge runs on the rung its chunk's item picks, never below the project's rung, and keeps that rung when the worker steps up. Without an item, it runs on the project's rung. On 2026-10-15, `bin/judge-replay claude-opus-5-5` replayed the latest 15 archived verdicts of each kind from the Opus 5.5 projects, 39 in all. The reference judge, Opus 5.5 at the xhigh effort `settings.json` gave every judge before, reproduced 31 of them. The other 8 rest on records and judge rules that have since changed, so no rung is held to them. On the 31, Haiku 5.5 missed 7 at xhigh and 8 at max. Even without the 4 replies that misquoted the transcript, which the loop would have retried, it missed 6 and 5. Sonnet 5.5 at high returned another kind on 3 interrupts, and Opus 5.5 at medium missed none. A missed interrupt lets the worker settle a decision that is lilleman's (goal 1.2), so the judge never runs below the project's rung. Only Opus 5.5 was replayed, so the judge of a project on another model keeps the effort its settings give until `judge-replay` covers that model (goal 1.1); `JUDGE_REPLAYED` in `bin/loop_claude/routing.py` lists the covered models. Above the project's rung, the judge climbs with the item as the worker does. Every routed chunk on record had an item of R + C 9, so the replay could not show that the project's rung suffices for harder items. For R + C 11 to 14 the judge still runs at or below xhigh (goal 1.4), and from 15 lilleman wants the highest quality at any price. Replay again when a new model joins the ladder. +The judge runs on the rung its chunk's item picks, never below the project's rung, and keeps that rung when the worker steps up. Without an item, it runs on the project's rung. On 2026-10-15, `bin/judge-replay claude-opus-5-5` replayed the latest 15 archived verdicts of each kind from the Opus 5.5 projects, 39 in all. The reference judge, Opus 5.5 at the xhigh effort `settings.json` gave every judge before, reproduced 31 of them. The other 8 rest on records and judge rules that have since changed, so no rung is held to them. On the 31, Haiku 5.5 missed 7 at xhigh and 8 at max. Even without the 4 replies that misquoted the transcript, which the loop would have retried, it missed 6 and 5. Sonnet 5.5 at high returned another kind on 3 interrupts, and Opus 5.5 at medium missed none. A missed interrupt lets the worker settle a decision that is lilleman's (goal 1.2), so the judge never runs below the project's rung. Only Opus 5.5 was replayed, so the judge of a project on another model keeps the effort its settings give until `judge-replay` covers that model (goal 1.1); `JUDGE_REPLAYED` in `bin/loop_claude/routing.py` lists the covered models. Above the project's rung, the judge climbs with the routed item as the worker does. An item the worker takes in later lifts the worker, not the judge, until `todo.md` item 136 routes a chunk on the item its worker takes. Every routed chunk on record had an item of R + C 9, so the replay could not show that the project's rung suffices for harder items. For R + C 11 to 14 the judge still runs at or below xhigh (goal 1.4), and from 15 lilleman wants the highest quality at any price. Replay again when a new model joins the ladder. The worker delegates a task only when it needs just the task's conclusion: a search or read across many files, or work independent enough to run in parallel. Edits, and whatever it must check line by line, stay in its own thread, since it would read a delegated diff again to check it. Measured over archived worker transcripts, subagent reports cost a median 8% of the worker's peak context, and `sed -n` and `grep` output made up 41% of its Bash results, so delegated searches save the most context. It scores each delegated task's R and C as for an item, and `bin/subagent-rung` turns them into the Agent tool's model and effort, counted from the project's rung. The rule names both, because the Agent tool sets a subagent's effort only when instructions ask. `CLAUDE.md` states the rule, since it holds in every session. diff --git a/todo.md b/todo.md index d50504f9..258f4c76 100644 --- a/todo.md +++ b/todo.md @@ -94,6 +94,8 @@ Question: drop this item, or say what it should route? Under `docs/decisions.md` loop-claude routes on the first row of the next release, while the worker takes the item the plan's prose orders first, or a prerequisite, as the chunk that shipped item 88, a prerequisite, took item 88 in place of the first row. A first row of higher R + C pays for a dearer rung all chunk; one of lower R + C holds until the judge reports the item taken in. The judge reports the item the worker takes only after the first cycle, so routing the first cycle right needs the item before the worker starts. +The judge routes on the same item, so it then follows the item the worker takes too. + ### 105. Compare review rounds per pass and reading cost for the five chunks before and after the `worker:` decision moved the principles out of the worker's context, and file an item if either rose. The `worker:` decision is valid while review rounds per pass do not rise. Count the rounds from each PR's `Answer round :` commits, and take reading cost from `docs/reading-cost.md`. Run it once five chunks have merged after the one that recorded the decision.