Answer stability round 1: 1 🔴, 5 🟡 (0 misread); imports sorted, the replay cuts the task and the rules from its grounds and fails on a missing heading, outcome parameters keyword-only, the mtime order dropped

This commit is contained in:
2026-11-17 01:13:39 +01:00
parent b5afb4c36a
commit 2600fbb254
11 changed files with 93 additions and 39 deletions
+4 -1
View File
@@ -27,6 +27,9 @@ class JudgeRun:
def read(path: pathlib.Path) -> "JudgeRun | Failure":
try:
kept = json.loads(path.read_text(encoding="utf-8"))
return JudgeRun(kept["prompt"], kept["reply"])
prompt, reply = kept["prompt"], kept["reply"]
except (OSError, ValueError, KeyError, TypeError) as failure:
return Failure(f"could not read the archived judge run {path}: {failure}")
if not (isinstance(prompt, str) and isinstance(reply, dict)):
return Failure(f"could not read the archived judge run {path}: its prompt is no string or its reply no object")
return JudgeRun(prompt, reply)
+6 -6
View File
@@ -1,11 +1,11 @@
import re
import typing
from transcript_archive.judge_run import FOLDER, JudgeRun
from model_routing.prices import PRICES
from text_files.markdown_text import quoted
from text_files.utc_stamp import STAMPED
from claude_code.tokens import Tokens
from transcript_archive.judge_run import JudgeRun
from model_routing.route import WorkerLine
TASK = "Task: "
@@ -32,7 +32,7 @@ JUDGE_COST = "Judge cost: "
JUDGE_COST_AT = re.compile(rf"^{re.escape(JUDGE)}(.+)\n{re.escape(JUDGE_COST)}([0-9.]+)$", re.MULTILINE)
# The judge run the verdict came from, as a path in the chunk's folder (judge_run.JudgeRun.file), on the line after the judge's rung and cost; absent where the archive kept none.
JUDGE_RUN = "Judge run: "
JUDGE_RUN_AT = re.compile(rf"^{re.escape(JUDGE_RUN)}(.+)$", re.MULTILINE)
JUDGE_RUN_AT = re.compile(rf"^{re.escape(JUDGE_RUN)}({FOLDER}/[0-9a-f]{{64}}\.json)$", re.MULTILINE)
# The claude-config release and commit that ran the cycle, on the line before JUDGE, such as `Config: v0.8.0 (<sha>)`.
@@ -111,17 +111,17 @@ def escalation_block(escalation: str) -> str:
return f"Escalation:\n{quoted(escalation)}\n\n" if escalation else ""
def finished(worker: WorkerLine, evidence: str, judge: str, judge_cost: float = 0.0, annotation: Annotation = Annotation(), judge_run: JudgeRun | None = None) -> str:
def finished(worker: WorkerLine, evidence: str, judge: str, *, judge_cost: float = 0.0, annotation: Annotation = Annotation(), judge_run: JudgeRun | None = None) -> str:
return f"{FINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{annotation_lines(annotation)}{judge_lines(judge, judge_cost, judge_run)}\n{WORKER}{worker}"
def unfinished(worker: WorkerLine, evidence: str, judge: str, escalation: str, judge_cost: float = 0.0, annotation: Annotation = Annotation(), judge_run: JudgeRun | None = None) -> str:
def unfinished(worker: WorkerLine, evidence: str, judge: str, escalation: str, *, judge_cost: float = 0.0, annotation: Annotation = Annotation(), judge_run: JudgeRun | None = None) -> str:
"""escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none."""
escalated = escalation_block(escalation)
return f"{UNFINISHED}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{annotation_lines(annotation)}{judge_lines(judge, judge_cost, judge_run)}\n{WORKER}{worker}"
def interrupted(question: str, evidence: str, judge: str, escalation: str, worker: WorkerLine, judge_cost: float = 0.0, annotation: Annotation = Annotation(), judge_run: JudgeRun | None = None) -> str:
def interrupted(question: str, evidence: str, judge: str, escalation: str, worker: WorkerLine, *, judge_cost: float = 0.0, annotation: Annotation = Annotation(), judge_run: JudgeRun | None = None) -> str:
"""escalation is the judge's quote showing that the worker's cited escalation trigger fired; empty for none. worker is the line naming the route the worker ran on until the interrupt."""
escalated = escalation_block(escalation)
return f"{INTERRUPTED}\n\n{question}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{annotation_lines(annotation)}{judge_lines(judge, judge_cost, judge_run)}\n{WORKER}{worker}"
@@ -133,7 +133,7 @@ def answered(*, question: str, sources: str, answer: str, evidence: str, escalat
return f"{ANSWERED}\n\n{question}\n\n{sources} says:\n{quoted(answer)}\n\nEvidence:\n{quoted(evidence)}\n\n{escalated}{annotation_lines(annotation)}{judge_lines(judge, judge_cost, judge_run)}\n{WORKER}{worker}"
def rejected(why: str, reply: str, judge: str, judge_cost: float = 0.0, judge_run: JudgeRun | None = None) -> str:
def rejected(why: str, reply: str, judge: str, *, judge_cost: float = 0.0, judge_run: JudgeRun | None = None) -> str:
"""A judge reply loop-claude rejected, with the reason and the reply as json."""
return f"{REJECTED}: {why}\n\nReply:\n{quoted(reply)}\n\n{judge_lines(judge, judge_cost, judge_run)}"
@@ -11,8 +11,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from transcript_archive.project_key import checkout_of, project_key
from failure import Failure
from transcript_archive import outcomes, read, write
from transcript_archive.judge_run import JudgeRun
from transcript_archive import outcomes, read, write
from transcript_archive.location import project_archive
from text_files.utc_stamp import utc
@@ -66,6 +66,18 @@ class JudgeRuns(unittest.TestCase):
run = JudgeRun("Prompt é.", {"a": 1})
self.assertEqual(run.content(), b'{\n "prompt": "Prompt \xc3\xa9.",\n "reply": {\n "a": 1\n }\n}')
def test_reads_a_file_that_is_no_run_as_a_failure(self):
with tempfile.TemporaryDirectory() as root:
for text in ("not json", '{"prompt": "P"}', '{"prompt": 1, "reply": {}}', '{"prompt": "P", "reply": []}'):
with self.subTest(text=text):
path = pathlib.Path(root, "run.json")
path.write_text(text)
self.assertRegex(JudgeRun.read(path).reason, f"^could not read the archived judge run {path}: ")
def test_reads_no_path_that_leaves_the_judge_folder_from_an_outcome(self):
outcome = f"{utc(NOW)} Verdict: finished\n\nJudge run: judge/../../secret.json\n"
self.assertIsNone(outcomes.judge_run_at(outcome, utc(NOW)))
def test_names_the_run_on_each_kind_of_outcome_that_has_a_judge(self):
named = f"Judge: j\nJudge run: {self.judged.file}\n"
kept = [
+1 -1
View File
@@ -4,8 +4,8 @@ import pathlib
import typing
from transcript_archive.location import chunk_folder, outcomes_of
from transcript_archive.judge_run import JudgeRun
from failure import Failure
from transcript_archive.judge_run import JudgeRun
from text_files.file_writes import make_private, replace_file
from claude_code.session import session_files
from transcript_archive.outcomes import TASK