Answer architecture round 1: 2 🔴, 13 🟡; test the replay's main and report, share one judge run and the archive format, pin the reference judge, route only replayed models, and say why the judge climbs

This commit is contained in:
2026-10-15 08:39:10 +02:00
parent 069b3814b9
commit 16aba4cd98
18 changed files with 309 additions and 139 deletions
+20 -2
View File
@@ -3,8 +3,14 @@ import re
from markdown_text import quoted
from utc_stamp import STAMPED
TASK = "Task: "
FINISHED = "Verdict: finished"
UNFINISHED = "Verdict: unfinished"
INTERRUPTED = "Verdict: interrupt"
ANSWERED = "Verdict: quoted answer"
# The file opens with the task, then a blank line, then the first stamped outcome.
TASK_AT = re.compile(rf"\A{re.escape(TASK)}(.*?)\n\n{STAMPED} ", re.DOTALL)
ANY_VERDICT_AT = re.compile(rf"^({STAMPED}) ({'|'.join(re.escape(verdict) for verdict in (FINISHED, UNFINISHED, INTERRUPTED, ANSWERED))})$", re.MULTILINE)
FINISHED_AT = re.compile(rf"^({STAMPED}) {re.escape(FINISHED)}$", re.MULTILINE)
UNFINISHED_AT = re.compile(rf"^{STAMPED} {re.escape(UNFINISHED)}$", re.MULTILINE)
# A verdict closes each cycle the judge ruled on; an interrupt or a stop closes none.
@@ -24,11 +30,11 @@ def unfinished(worker: str, evidence: str) -> str:
def interrupted(question: str, evidence: str) -> str:
return f"Verdict: interrupt\n\n{question}\n\nEvidence:\n{quoted(evidence)}"
return f"{INTERRUPTED}\n\n{question}\n\nEvidence:\n{quoted(evidence)}"
def answered(question: str, sources: str, answer: str, evidence: str) -> str:
return f"Verdict: quoted answer\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}"
return f"{ANSWERED}\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}"
def stepped_up(worker: str) -> str:
@@ -50,3 +56,15 @@ def workers(outcomes: str) -> list[tuple[str, str]]:
if outcome.startswith(NAMES_A_WORKER) and last.startswith(WORKER):
found.append((start[1], last.removeprefix(WORKER)))
return found
def task_of(outcomes: str) -> str | None:
"""The task an outcomes file opens with; None when it opens with none."""
found = TASK_AT.match(outcomes)
return found[1] if found else None
def first_verdict(outcomes: str) -> tuple[str, str] | None:
"""The UTC stamp and the verdict, such as FINISHED, of the first verdict in an outcomes file; None when it holds none."""
found = ANY_VERDICT_AT.search(outcomes)
return (found[1], found[2]) if found else None
+14 -1
View File
@@ -22,12 +22,25 @@ def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Fail
copies = sorted((stamps[-1], outcomes) for outcomes in folder.glob("*.outcomes.md") if (stamps := FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))))
if copies:
finished, outcomes = copies[-1]
found.append(FinishedChunk(folder.name, finished, outcomes.with_name(outcomes.name.removesuffix(".outcomes.md") + ".jsonl"), sorted(folder.glob("session/*/subagents/*.jsonl"))))
found.append(FinishedChunk(folder.name, finished, transcript_of(outcomes), sorted(folder.glob("session/*/subagents/*.jsonl"))))
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read the archive {project_archive}: {failure}")
return sorted(found, key=lambda chunk: (chunk.finished, chunk.folder))
def archived_outcomes(root: pathlib.Path) -> list[tuple[str, pathlib.Path]] | Failure:
"""Each outcomes file in the archive at root, with the key of the project it belongs to, sorted."""
try:
return sorted((str(path.parent.parent.relative_to(root)), path) for path in root.rglob("*.outcomes.md"))
except OSError as failure:
return Failure(f"could not read the archive {root}: {failure}")
def transcript_of(outcomes: pathlib.Path) -> pathlib.Path:
"""The transcript copy an outcomes file sits beside."""
return outcomes.with_name(outcomes.name.removesuffix(".outcomes.md") + ".jsonl")
def read_threads(chunk: FinishedChunk) -> list[bytes] | Failure:
"""The worker's transcript, then each subagent's."""
try:
@@ -8,10 +8,10 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from project_key import checkout_of, project_key
from failure import Failure
from transcript_archive import outcomes, read, write
from transcript_archive.location import project_archive
from project_key import project_key
from utc_stamp import utc
NOW = 1790000000
@@ -94,6 +94,12 @@ class Location(unittest.TestCase):
self.assertEqual(project_archive("/h/code/log", home, {}), pathlib.Path("/h/.claude/loop-claude-transcripts/log"))
self.assertEqual(project_archive("/h/code/log", home, {"LOOP_CLAUDE_TRANSCRIPTS": "/a"}), pathlib.Path("/a/log"))
def test_finds_the_checkout_a_key_names_under_code_or_else_under_the_root(self):
with tempfile.TemporaryDirectory() as home:
(pathlib.Path(home) / "code" / "log").mkdir(parents=True)
self.assertEqual(checkout_of("log", pathlib.Path(home)), f"{home}/code/log")
self.assertEqual(checkout_of("home/me/.claude", pathlib.Path(home)), "/home/me/.claude")
if __name__ == "__main__":
unittest.main()
+2 -1
View File
@@ -7,6 +7,7 @@ from transcript_archive.location import chunk_folder
from failure import Failure
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
@@ -27,7 +28,7 @@ def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, a
if copy.exists() and outcomes.exists():
return add_outcome(outcomes, stamped)
# The copy lands last, so a copy on disk always has its outcomes and its session's files beside it.
for dest, data in ((outcomes, f"Task: {task}\n\n{stamped}\n".encode()), (copy, raw)):
for dest, data in ((outcomes, f"{TASK}{task}\n\n{stamped}\n".encode()), (copy, raw)):
if unwritten := replace_file(dest, data):
return unarchived(dest, unwritten.reason)
print(f"transcript: {copy}", file=sys.stderr)