Skip to content

Official Codebase of 3DCodeVerse

Python

ab_plan: one non-UTF-8 byte from a worker killed the whole A/B driver

gaoypeng7933b624bbb8
diff --git a/harness/bench/ab_plan.py b/harness/bench/ab_plan.py
index 08563085..613c8687 100644
--- a/harness/bench/ab_plan.py
+++ b/harness/bench/ab_plan.py
@@ -187,7 +187,10 @@ def spawn_cell(battery_path: Path, out: Path, item: BenchPrompt, arm: str, opts:
stdout=fh, stderr=subprocess.STDOUT, check=False).returncode
if marker.is_file():
return CellResult.model_validate_json(marker.read_text())
- tail = log.read_text()[-1500:] if log.is_file() else ""
+ # errors="replace": the child's raw stdout lands in this log, and one non-UTF-8 byte
+ # from an agent CLI used to raise UnicodeDecodeError *here* — on the very path whose
+ # job is to classify an outage — killing the whole driver through fut.result().
+ tail = log.read_text(errors="replace")[-1500:] if log.is_file() else ""
return CellResult(prompt_id=item.id, tier=item.tier, arm=arm, kind="harness", target=opts.generator,
judge=opts.judge, workspace=str(cell), wall_s=round(time.time() - t0, 1),
status="infra_failed" if is_infra_failure(tail) else "error",
diff --git a/harness/runtime_js/node_modules b/harness/runtime_js/node_modules
new file mode 120000
index 00000000..19e73641
--- /dev/null
+++ b/harness/runtime_js/node_modules
@@ -0,0 +1 @@
+/home/yipeng/3dcodeverse/harness/runtime_js/node_modules
\ No newline at end of file
diff --git a/harness/tests/compare_bench/test_ab_plan.py b/harness/tests/compare_bench/test_ab_plan.py
index 6c6673e1..d995027e 100644
--- a/harness/tests/compare_bench/test_ab_plan.py
+++ b/harness/tests/compare_bench/test_ab_plan.py
@@ -231,6 +231,22 @@ def test_a_child_that_dies_without_a_cell_is_an_error_not_a_score(tmp_path: Path
assert (Path(res.workspace) / "worker.log").is_file()
+def test_a_non_utf8_byte_in_the_worker_log_does_not_kill_the_driver(tmp_path: Path, monkeypatch):
+ """CP-1: on the no-cell.json path the log tail is the only evidence there is, and an
+ agent CLI is free to print any byte. One 0xff used to raise UnicodeDecodeError out of
+ spawn_cell — which run_ab re-raises through fut.result(), ending the whole A/B without
+ a summary — for a log that says '503 UNAVAILABLE' and classifies perfectly well."""
+ import bench.ab_plan as ab
+ from bench.run_bench import BenchPrompt
+
+ monkeypatch.setattr(ab, "worker_argv",
+ lambda *a, **k: ["bash", "-c", r"printf 'starting cell\n503 Service Unavailable \xff\xfe\n'; exit 1"])
+ item = BenchPrompt(id="p_bad_bytes", prompt="x", tier="easy")
+ res = ab.spawn_cell(BATTERY, tmp_path, item, CONTROL, AbOptions(variant_env={"K": "v"}))
+ assert res.status == "infra_failed" and res.score is None
+ assert "503 Service Unavailable" in res.error
+
+
# ----------------------------------------------------------------------------- the driver, with a fake cell runner
class FakeCells:
"""Records (prompt, arm, env-at-call) and answers from a script; the pair order is observable."""