Answer stability round 1: 0 🔴, 4 🟡 (0 misread); test main's continuing past a failed run, name the denied commits in decided's tests, check the replay puts premises before records
This commit is contained in:
@@ -138,6 +138,8 @@ class Main(unittest.TestCase):
|
||||
self.assertTrue(out.endswith("returns every verdict the reference judge reproduces: claude-opus-5-5 at medium effort\n"))
|
||||
for said in ("The task the worker was given:\nDo it.", "1. Ship.", "From ~/.claude/CLAUDE.md:\nBe kind."):
|
||||
self.assertIn(said, self.prompts[0])
|
||||
# The premises head the prompt and the records follow them.
|
||||
self.assertRegex(self.prompts[0], r"(?s)From README\.md:.*1\. Ship\..*The records:.*Be kind\.")
|
||||
# The replay shows the judge the whole transcript, with no step-up marked in it.
|
||||
self.assertNotIn("[step]", self.prompts[0])
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ def scored_seats(given: SeatsFile) -> ScoringRun | Failure:
|
||||
|
||||
|
||||
def read_seats(path: pathlib.Path, paired: bool) -> tuple[Heading, SeatsFile] | Failure:
|
||||
"""The seats file and the heading its entry goes under, as decided says. It runs before anything is printed."""
|
||||
"""The heading the seats file's entry goes under, and the file, as decided says. Its callers run it first, so a file it refuses fails before anything is printed."""
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
@@ -98,7 +98,7 @@ def read_seats(path: pathlib.Path, paired: bool) -> tuple[Heading, SeatsFile] |
|
||||
|
||||
|
||||
def decided(text: str, now: float, paired: bool, commit_known: typing.Callable[[str], bool], history: tuple[pathlib.Path, str]) -> tuple[Heading, SeatsFile] | Failure:
|
||||
"""The seats file's text and the heading its entry goes under, stamped with now. Fails when the text names a commit commit_known denies, or when the history, as history_file returns it, already holds an entry on what the text reads."""
|
||||
"""The heading the seats file's entry goes under, stamped with now, and the file parsed from text. Fails when text names a commit that commit_known denies, or when the history already holds an entry on what the seats read."""
|
||||
given = seats_file(text)
|
||||
if isinstance(given, Failure):
|
||||
return given
|
||||
|
||||
@@ -321,22 +321,20 @@ class Decided(unittest.TestCase):
|
||||
decided_on = decided("PR #2 at abcdef1\n", self.AT, False, lambda commit: True, self.HISTORY)
|
||||
self.assertEqual(decided_on, (comprehension_history.Heading("2023-11-14T22:13:20Z, PR #2 at abcdef1", "PR #2", "abcdef1", None), SeatsFile("PR #2 at abcdef1", [])))
|
||||
|
||||
def test_fails_on_a_commit_the_check_denies_and_names_only_the_denied(self):
|
||||
asked = []
|
||||
def known(commit):
|
||||
asked.append(commit)
|
||||
return commit == "abcdef1"
|
||||
failed = decided("PR #2 at abcdef1, against 1234567\n", self.AT, True, known, self.HISTORY)
|
||||
self.assertEqual(failed, Failure("the seats file names 1234567, which is no commit in this checkout"))
|
||||
self.assertEqual(asked, ["abcdef1", "1234567"])
|
||||
def test_fails_on_a_commit_the_check_denies_and_names_only_that_commit(self):
|
||||
named = "PR #2 at abcdef1, against 1234567\n"
|
||||
self.assertEqual(decided(named, self.AT, True, lambda commit: commit == "abcdef1", self.HISTORY), Failure("the seats file names 1234567, which is no commit in this checkout"))
|
||||
self.assertEqual(decided(named, self.AT, True, lambda commit: commit == "1234567", self.HISTORY), Failure("the seats file names abcdef1, which is no commit in this checkout"))
|
||||
self.assertEqual(decided(named, self.AT, True, lambda commit: False, self.HISTORY), Failure("the seats file names abcdef1, 1234567, which is no commit in this checkout"))
|
||||
|
||||
def test_fails_on_a_file_the_history_already_holds_an_entry_on(self):
|
||||
def test_fails_where_the_history_already_holds_an_entry_on_the_file(self):
|
||||
held = scored("2023-11-14T22:13:20Z", "PR #2", "abcdef1", "7", "7")
|
||||
failed = decided("PR #2 at abcdef1\n", self.AT, False, lambda commit: True, (pathlib.Path("history.md"), appended("", held)))
|
||||
self.assertEqual(failed, Failure("history.md already holds an entry on PR #2 at abcdef1; record each ruling or run once"))
|
||||
|
||||
def test_fails_on_a_seats_file_that_does_not_parse_before_asking_for_a_commit(self):
|
||||
self.assertEqual(decided("", self.AT, False, lambda commit: self.fail("asked"), self.HISTORY), seats_file(""))
|
||||
def test_fails_on_a_seats_file_that_does_not_parse_without_asking_about_a_commit(self):
|
||||
failed = decided("", self.AT, False, lambda commit: self.fail("asked"), self.HISTORY)
|
||||
self.assertEqual(failed, Failure("the seats file is empty; its first line names what the seats read: <PR or branch> at <commit>"))
|
||||
|
||||
|
||||
class Base(unittest.TestCase):
|
||||
|
||||
@@ -109,7 +109,7 @@ class Grounds(typing.NamedTuple):
|
||||
|
||||
|
||||
class Brief(typing.NamedTuple):
|
||||
"""What the judge reads: the worker's task, the premises and records it is judged by, and the transcript's entries with the route's escalation mark, as loop_claude/escalation_mark.py says."""
|
||||
"""What the judge reads: the worker's task, the premises and records the worker is judged by, the transcript's entries, and escalated_at, how many of those entries the session held when an escalation last stepped the worker up a rung, 0 before any."""
|
||||
task: str
|
||||
premises: str
|
||||
records: str
|
||||
|
||||
@@ -114,7 +114,7 @@ def run(name):
|
||||
|
||||
|
||||
def attempted(name):
|
||||
"""run's result line, or a line naming the failure, so one failed run leaves the others' results to print."""
|
||||
"""run's result line, or a line naming the failure, so one failed run doesn't stop the other runs' results printing."""
|
||||
try:
|
||||
return run(name)
|
||||
except (KeyError, ValueError, subprocess.CalledProcessError, OSError) as failure:
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
import unittest.mock
|
||||
|
||||
@@ -7,12 +10,24 @@ with unittest.mock.patch.dict(os.environ, {"BENCH_SOURCES": "/nonexistent"}):
|
||||
import bench
|
||||
|
||||
|
||||
class Main(unittest.TestCase):
|
||||
def test_prints_every_runs_line_though_an_earlier_run_failed(self):
|
||||
def run(name):
|
||||
if name == "a-v-1":
|
||||
raise KeyError("a")
|
||||
return f"{name}: done"
|
||||
out = io.StringIO()
|
||||
with unittest.mock.patch.object(bench, "run", side_effect=run), unittest.mock.patch.object(sys, "argv", ["bench.py", "a-v-1", "b-v-1"]), contextlib.redirect_stdout(out):
|
||||
bench.main()
|
||||
self.assertEqual(out.getvalue().splitlines(), ["a-v-1: FAILED: KeyError: 'a'", "b-v-1: done"])
|
||||
|
||||
|
||||
class Attempted(unittest.TestCase):
|
||||
def test_returns_the_run_result_of_a_run_that_finished(self):
|
||||
with unittest.mock.patch.object(bench, "run", return_value="a-v-1: done"):
|
||||
self.assertEqual(bench.attempted("a-v-1"), "a-v-1: done")
|
||||
|
||||
def test_returns_a_failed_run_as_a_line_naming_it_so_the_later_runs_still_report(self):
|
||||
def test_returns_a_failed_run_as_a_line_naming_the_run_and_its_error_so_later_runs_still_report(self):
|
||||
failures = [KeyError("nope"), ValueError("not enough values to unpack"), subprocess.CalledProcessError(128, ["git", "clone"]), FileNotFoundError("claude")]
|
||||
for failure in failures:
|
||||
with self.subTest(failure=type(failure).__name__), unittest.mock.patch.object(bench, "run", side_effect=[failure, "b-v-1: done"]):
|
||||
|
||||
Reference in New Issue
Block a user