diff --git a/src/steerbench/cli.py b/src/steerbench/cli.py index c0f1e29..9e85f3d 100644 --- a/src/steerbench/cli.py +++ b/src/steerbench/cli.py @@ -124,6 +124,11 @@ def main(argv: list[str] | None = None) -> int: if not csv_path.exists(): parser.error(f"{label} CSV not found: {csv_path}") + # An explicitly named side CSV must exist; only an *unspecified* one may + # fall back to the header-only stub. + if args.side_csv is not None and not args.side_csv.exists(): + parser.error(f"side-effects CSV not found: {args.side_csv}") + side_csv = _ensure_side_csv(args.side_csv, args.out) outputs = report.build_report( dose_csv=args.dose_csv, diff --git a/tests/test_cli.py b/tests/test_cli.py index 48de874..87c3f7e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -67,3 +67,25 @@ def test_cli_json_emits_artifact_paths(tmp_path: Path, capsys: pytest.CaptureFix def test_cli_errors_on_missing_csv(tmp_path: Path) -> None: with pytest.raises(SystemExit): cli.main(["--dose-csv", str(tmp_path / "nope.csv"), "--out", str(tmp_path / "o")]) + + +def test_cli_errors_on_missing_named_side_csv( + tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + # An explicitly named --side-csv that doesn't exist must error, not + # silently fall back to the header-only stub (that's for unspecified only). + with pytest.raises(SystemExit) as exc: + cli.main( + [ + "--dose-csv", + str(_DOSE), + "--layer-csv", + str(_LAYER), + "--side-csv", + str(tmp_path / "typo.csv"), + "--out", + str(tmp_path / "o"), + ] + ) + assert exc.value.code != 0 + assert "side-effects CSV not found" in capsys.readouterr().err