From 72d04227f9f8a46116d0b5a632491d2b6d5f70fb Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 16:27:55 +0200 Subject: [PATCH] Pin that a non-UTF-8 byte in the worker's stream is skipped --- bin/test_loop_claude_black_box.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/test_loop_claude_black_box.py b/bin/test_loop_claude_black_box.py index 66410f87..56a5ccf8 100644 --- a/bin/test_loop_claude_black_box.py +++ b/bin/test_loop_claude_black_box.py @@ -67,6 +67,8 @@ if role == "worker": if "replace" in step: script = pathlib.Path(os.environ["FAKE_CLAUDE_EDIT"]) script.write_text(script.read_text().replace(*step["replace"])) + sys.stdout.flush() + sys.stdout.buffer.write(step.get("stream", "").encode("latin-1")) print(json.dumps(said)) if step.get("result", True): print(json.dumps({{"type": "result"}})) @@ -319,11 +321,12 @@ class Cycles(unittest.TestCase): self.assertEqual(run.roles(), ["worker", "judge", "judge", "worker"]) self.assertIn("the judge quoted 'never said', nothing in the transcript, for the question: A or B?", run.stderr) - def test_skips_a_malformed_transcript_line(self): + def test_skips_a_malformed_transcript_or_stream_line(self): checkout = Checkout(self) raw = "\xff not UTF-8\nnot JSON\n[1]\n" + json.dumps({"type": "assistant", "message": "not an object"}) + "\n" + json.dumps({"type": "user", "message": None}) + "\n" - run = checkout.run([worker(raw=raw, say="past the noise"), judge()]) + run = checkout.run([worker(raw=raw, say="past the noise", stream="\xff not UTF-8\n"), judge()]) self.assertEqual((run.code, run.roles()), (130, ["worker", "judge", "worker"])) + self.assertIn("past the noise", run.stdout) self.assertIn("past the noise", run.calls[1]["stdin"]) @unittest.skipIf(os.geteuid() == 0, "root reads an unreadable file")