Answer stability round 1: 0 🔴, 2 🟡 (0 misread); test the failed removal, run the new tests under the guard, and reword the prose round's finding
This commit is contained in:
@@ -172,7 +172,7 @@ Worker: {OFF_LADDER}
|
||||
self.assertEqual(workers[1][workers[1].index("-p") + 1], "Resumed: working")
|
||||
self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n\nConfig: {CONFIG}\nJudge: judge-model\nWorker: {OFF_LADDER}\n"] * 2)
|
||||
|
||||
def test_a_session_whose_transcript_is_empty_starts_fresh_with_its_session_id_where_claude_cannot_resume_it(self):
|
||||
def test_a_session_whose_transcript_is_empty_starts_fresh_with_its_session_id(self):
|
||||
path = self.paths.claude_code_transcripts / "-fake" / f"{self.session.id}.jsonl"
|
||||
path.parent.mkdir(parents=True)
|
||||
path.touch()
|
||||
@@ -196,6 +196,19 @@ Worker: {OFF_LADDER}
|
||||
self.assertIn("retrying the worker in a minute", said.getvalue())
|
||||
self.assertEqual(["--session-id" in worker and "--resume" not in worker for worker in fake.made("stream_claude")], [True, True])
|
||||
|
||||
def test_a_worker_stops_where_it_cannot_remove_the_empty_transcript_of_its_session(self):
|
||||
assert_not_root(self)
|
||||
path = self.paths.claude_code_transcripts / "-fake" / f"{self.session.id}.jsonl"
|
||||
path.parent.mkdir(parents=True)
|
||||
path.touch()
|
||||
path.parent.chmod(0o500)
|
||||
self.addCleanup(path.parent.chmod, 0o700)
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)])
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
stop = run.run_cycle(self.cycle(fake))
|
||||
self.assertEqual(stop, Stop(1, f"the worker failed three times running: could not remove the empty transcript {path}: Permission denied; claude refuses to start the session while that file stands"))
|
||||
self.assertEqual(fake.made("stream_claude"), [])
|
||||
|
||||
def test_a_cycle_stopped_by_a_failure_or_ctrl_c_archives_what_its_session_holds(self):
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[ran(code=1)] * 3)
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).code, 1)
|
||||
|
||||
@@ -34,14 +34,14 @@ def session_open(session: Session) -> bool:
|
||||
|
||||
|
||||
def discard_empty_transcript(session: Session) -> Failure | None:
|
||||
"""Removes a 0-byte transcript, which a run that died early leaves: claude refuses `--session-id` for an id whose file exists, and cannot `--resume` it."""
|
||||
"""Removes the 0-byte transcript a failed run can leave: claude refuses `--session-id` for an id whose file stands, and cannot `--resume` it."""
|
||||
path = transcript_file(session)
|
||||
if path is None or os.path.getsize(path) > 0:
|
||||
return None
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not remove the empty transcript {path}: {failure.strerror or failure}; remove it, then run it again")
|
||||
return Failure(f"could not remove the empty transcript {path}: {failure.strerror or failure}; claude refuses to start the session while that file stands")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -226,10 +226,6 @@ class ClaudeReply(unittest.TestCase):
|
||||
self.assertEqual(reply.claude_reply(self.claude(FileNotFoundError(2, "No such file or directory")), [], "/r", "p", "claude"), Failure("could not start claude: No such file or directory"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class EmptyTranscript(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
@@ -253,11 +249,15 @@ class EmptyTranscript(unittest.TestCase):
|
||||
self.assertIsNone(session.discard_empty_transcript(self.session))
|
||||
self.assertEqual(self.path.read_text(), "{")
|
||||
|
||||
def test_discarding_says_where_it_could_not_remove_the_file(self):
|
||||
def test_discarding_fails_naming_the_file_it_could_not_remove(self):
|
||||
assert_not_root(self)
|
||||
self.path.touch()
|
||||
self.path.parent.chmod(0o500)
|
||||
self.addCleanup(self.path.parent.chmod, 0o700)
|
||||
failure = session.discard_empty_transcript(self.session)
|
||||
self.assertIsInstance(failure, Failure)
|
||||
self.assertEqual(failure.reason, f"could not remove the empty transcript {self.path}: Permission denied; remove it, then run it again")
|
||||
self.assertEqual(failure.reason, f"could not remove the empty transcript {self.path}: Permission denied; claude refuses to start the session while that file stands")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user