Answer architecture round 1: 1 🔴, 2 🟡; share one rung search between both replays, searching down from the project's rung, name the sixth git runner in item 114, decline recording the reviewed commit

This commit is contained in:
2026-10-15 20:52:50 +02:00
parent ae7161d2f4
commit 4f722d94f4
21 changed files with 398 additions and 321 deletions
+8 -45
View File
@@ -1,4 +1,4 @@
"""Which archived stability rounds to replay, the lowest rung that finds their findings, and the report: docs/decisions.md → `routing: the stability reviewer stays on the project's rung`."""
"""Which archived stability rounds to replay, the code each reviewed, and the report: docs/decisions.md → `routing: the stability reviewer stays on the project's rung`."""
import dataclasses
import datetime
import pathlib
@@ -6,7 +6,7 @@ import re
import typing
from claude_code.entries import assistant_parts, content, part_text, parts
from loop_claude.cycle.retry import Limited
from rung_replay.search import Replay
from model_routing.ladder import Rung
# A line that opens with a 🔴 or 🟡 mark, after any list, table, heading or bold markup, as review-findings.md has reviewers report them.
@@ -28,21 +28,6 @@ class Round:
findings: tuple[str, ...]
@dataclasses.dataclass(frozen=True)
class Tried:
"""A rung, and each finding it missed that the reference reviewer found, with its round."""
rung: Rung
missed: list[tuple[Round, str]]
@dataclasses.dataclass(frozen=True)
class Replay:
"""unfound counts the findings on record the reference reviewer did not find; tried holds each rung tried, highest first; lowest, the lowest rung that missed none of the rest, or None."""
unfound: int
tried: list[Tried]
lowest: Rung | None
def round_from(root: str, began: float, entries: list[dict]) -> Round | None:
"""The round a stability reviewer's transcript holds: its first entry's prompt, and its last text. None without a 🔴 or 🟡 finding to hold a rung to."""
reports = [text for found in entries for part in assistant_parts(found) if (text := part_text(part))]
@@ -79,7 +64,9 @@ def reviewed_path(prompt: str, root: str, exists: typing.Callable[[str], bool])
named = [LINE_OR_STOP.sub("", path) for path in PATH.findall(prompt)]
gone = set()
for path in map(pathlib.PurePath, named):
first_gone = next((prefix for prefix in [*reversed(path.parents), path][1:] if not exists(str(prefix))), None)
# The path's directories from the top down, without the filesystem root; the first one gone is what a removed worktree took with it.
down_the_path = [*reversed(path.parents), path][1:]
first_gone = next((prefix for prefix in down_the_path if not exists(str(prefix))), None)
if first_gone and (first_gone.parent == checkout.parent or checkout in first_gone.parents):
gone.add(str(first_gone))
if len(gone) == 1:
@@ -97,38 +84,14 @@ def sample(rounds: list[Round], latest: int) -> list[Round]:
return sorted(rounds, key=lambda found: (found.seconds, found.root))[-latest:]
def replayed(rounds: list[Round], reference: Rung, candidates: list[Rung], review_all: typing.Callable[[list[Round], Rung], list[set[int]] | Limited]) -> Replay | Limited:
"""Replays the rounds on the reference rung, then each candidate, highest first, on the rounds where the reference found a finding, until one misses a finding it found.
Going down, every rung at or above the lowest that missed none was tried.
"""
found = review_all(rounds, reference)
if isinstance(found, Limited):
return found
held = [(found_round, kept) for found_round, kept in zip(rounds, found) if kept]
unfound = sum(len(found_round.findings) for found_round in rounds) - sum(len(kept) for _, kept in held)
tried: list[Tried] = []
lowest = None
# With no finding to hold a rung to, every rung would miss none.
for rung in candidates if held else []:
found = review_all([found_round for found_round, _ in held], rung)
if isinstance(found, Limited):
return found
tried.append(Tried(rung, [(found_round, found_round.findings[n]) for (found_round, kept), on_rung in zip(held, found) for n in sorted(kept - on_rung)]))
if tried[-1].missed:
break
lowest = rung
return Replay(unfound, tried, lowest)
def report(model: str, reference: Rung, rounds: list[Round], replay: Replay) -> str:
def report(model: str, reference: Rung, rounds: list[Round], replay: Replay[Round, int, set[int]]) -> str:
total = sum(len(found_round.findings) for found_round in rounds)
lines = [
f"Replayed {len(rounds)} stability rounds of {model} projects, holding {total} 🔴 and 🟡 findings.",
f"The reference reviewer, {reference}, found {total - replay.unfound} of them.",
f"The reference reviewer, {reference}, found {sum(len(found) for found in replay.on_reference)} of them.",
]
for tried in replay.tried:
lines += [f"{tried.rung} missed {len(tried.missed)}{':' if tried.missed else '.'}", *(f" {found_round.root} {found_round.at}: {finding.splitlines()[0]}" for found_round, finding in tried.missed)]
lines += [f"{tried.rung} missed {len(tried.missed)}{':' if tried.missed else '.'}", *(f" {miss.case.root} {miss.case.at}: {miss.case.findings[miss.item].splitlines()[0]}" for miss in tried.missed)]
if not replay.tried:
lines.append("No rung tried: the reference reviewer found no finding to hold one to.")
else: