Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
fix: accept UTF-8 BOMs in user-supplied file readers (#2155)
vaputac61a43f12d0b
diff --git a/changelog.d/0.76.0/2155.fixed.md b/changelog.d/0.76.0/2155.fixed.mdnew file mode 100644index 00000000..793f4a21--- /dev/null+++ b/changelog.d/0.76.0/2155.fixed.md@@ -0,0 +1,7 @@+- Accept UTF-8 BOMs in user-supplied command inputs (#2136, #2155), preserving the first+ JSONL record and prompt text. Covers agent predictions, tokenizer corpora,+ benchmark prompts, draft inputs, edit and shrink calibration data, diagnose+ evidence, Can attestations, generation context and Autopilot's local model+ config probe. Attestation verification accepts BOM-prefixed statements and+ signature sidecars while retaining canonical signing and trusted-key checks;+ embedded U+FEFF and UTF-8 output encoding are unchanged.diff --git a/docs/adapters-and-governance.md b/docs/adapters-and-governance.mdindex 34de4b43..d154c29b 100644--- a/docs/adapters-and-governance.md+++ b/docs/adapters-and-governance.md@@ -537,6 +537,9 @@ entry can never outlive a discarded local bundle; browser OIDC is explicit opt-iVerification exits 3 on tamper or policy mismatch, and exits 1 when Sigstoreverification itself is unavailable (for example TUF/network failure) so anoperational outage is not reported as tampering. Usage/input errors exit 2.+The statement and signature sidecar accept UTF-8 with or without a leading BOM.+Verification still uses the same canonical JSON and preserves U+FEFF inside+field values; a leading BOM does not bypass tamper or trusted-key checks.An explicit Sigstore signing request fails closed if OIDC/Fulcio/Rekor isunavailable; it is never silently downgraded to unsigned. A valid signature proves the signer*asserted* the statement; it does not re-verify the subject digest against andiff --git a/docs/data.md b/docs/data.mdindex e8f9facf..ba2f08c0 100644--- a/docs/data.md+++ b/docs/data.md@@ -693,6 +693,13 @@ Local JSONL, JSON, CSV and TXT files accept UTF-8 with or without a leading BOM,including Excel's CSV UTF-8 exports. The signature is removed before parsing;U+FEFF characters inside field values or document text are preserved.+The same leading-BOM handling applies to tokenizer corpora, inference benchmark+prompts, Agent Forge predictions, draft JSONL inputs, edit covariance corpora,+shrink calibration prompts, diagnose evidence, Can attestation inputs, synthetic+generation context documents, and Autopilot's local model `config.json` probe.+Only the file's initial UTF-8 signature is consumed; embedded U+FEFF remains+content, and these commands continue writing ordinary UTF-8 without a BOM.+**Auto-detection.** It reads the first 100 rows, not just the first. Each row resolvesto the richest format its keys fit. If every row agrees, that format is used. A filethat mixes `chatml` and `tool-calling` rows loads as `tool-calling` (the plain rowsdiff --git a/src/soup_cli/autopilot/decisions.py b/src/soup_cli/autopilot/decisions.pyindex b2e87c4e..20985932 100644--- a/src/soup_cli/autopilot/decisions.py+++ b/src/soup_cli/autopilot/decisions.py@@ -186,7 +186,7 @@ def detect_prequantized_format_from_path(model_dir: object) -> Optional[str]:if _stat.S_ISLNK(st.st_mode):return Nonetry:- with open(config_path, encoding="utf-8") as fh:+ with open(config_path, encoding="utf-8-sig") as fh:data = json.load(fh)except (OSError, ValueError, UnicodeDecodeError):return Nonediff --git a/src/soup_cli/commands/agent.py b/src/soup_cli/commands/agent.pyindex 03bdc02c..f003f22d 100644--- a/src/soup_cli/commands/agent.py+++ b/src/soup_cli/commands/agent.py@@ -276,7 +276,7 @@ def eval(tool_ok = 0args_ok = 0try:- with open(predictions, "r", encoding="utf-8") as fh:+ with open(predictions, "r", encoding="utf-8-sig") as fh:for line in fh:line = line.strip()if not line:@@ -346,7 +346,7 @@ def _eval_sandbox(predictions: str, tool_to_endpoint: dict, max_pred_lines: int)total = 0counts = {"ok": 0, "tool_error": 0, "timeout": 0, "arg_error": 0}try:- with open(predictions, "r", encoding="utf-8") as fh:+ with open(predictions, "r", encoding="utf-8-sig") as fh:for line in fh:line = line.strip()if not line:diff --git a/src/soup_cli/commands/attest.py b/src/soup_cli/commands/attest.pyindex 72dfb7ce..dda52bce 100644--- a/src/soup_cli/commands/attest.py+++ b/src/soup_cli/commands/attest.py@@ -265,9 +265,9 @@ def verify_cmd(raise typer.Exit(2)try:- with open(statement, encoding="utf-8") as fh:+ with open(statement, encoding="utf-8-sig") as fh:raw_text = fh.read()- with open(signature, encoding="utf-8") as fh:+ with open(signature, encoding="utf-8-sig") as fh:sig_doc = json.load(fh)except (OSError, ValueError) as exc:console.print(f"[red]Could not read inputs: {escape(str(exc))}[/]")diff --git a/src/soup_cli/commands/bench.py b/src/soup_cli/commands/bench.pyindex ee361fee..48768684 100644--- a/src/soup_cli/commands/bench.py+++ b/src/soup_cli/commands/bench.py@@ -186,7 +186,7 @@ def bench(prompts = []try:if p_path.suffix == ".jsonl":- with open(p_path, encoding="utf-8") as fh:+ with open(p_path, encoding="utf-8-sig") as fh:for line in fh:line = line.strip()if line:@@ -194,7 +194,7 @@ def bench(if "prompt" in data:prompts.append(data["prompt"])else:- with open(p_path, encoding="utf-8") as fh:+ with open(p_path, encoding="utf-8-sig") as fh:for line in fh:line = line.strip()if line:diff --git a/src/soup_cli/commands/can.py b/src/soup_cli/commands/can.pyindex 8171bb75..5e5429e1 100644--- a/src/soup_cli/commands/can.py+++ b/src/soup_cli/commands/can.py@@ -43,7 +43,7 @@ def _load_attestation_files(paths: Optional[List[str]]) -> list[dict]:raise ValueError(f"attestation file too large (> {_MAX_ATTESTATION_BYTES} bytes)")- with open(real, encoding="utf-8") as fh:+ with open(real, encoding="utf-8-sig") as fh:stmt = json.load(fh)statements.append(validate_attestation_statement(stmt))except (OSError, ValueError, json.JSONDecodeError) as exc:diff --git a/src/soup_cli/commands/diagnose.py b/src/soup_cli/commands/diagnose.pyindex 839cfe03..286a3e48 100644--- a/src/soup_cli/commands/diagnose.py+++ b/src/soup_cli/commands/diagnose.py@@ -123,7 +123,7 @@ def _load_evidence(path: str) -> dict:fd = os.open(path, flags)except OSError as exc:raise typer.BadParameter(f"evidence path unreadable: {exc}") from exc- with os.fdopen(fd, "r", encoding="utf-8") as handle:+ with os.fdopen(fd, "r", encoding="utf-8-sig") as handle:if os.fstat(handle.fileno()).st_size > _MAX_EVIDENCE_BYTES:raise typer.BadParameter(f"evidence file exceeds {_MAX_EVIDENCE_BYTES} bytes"diff --git a/src/soup_cli/commands/draft.py b/src/soup_cli/commands/draft.pyindex 70fc7cb2..f74f300d 100644--- a/src/soup_cli/commands/draft.py+++ b/src/soup_cli/commands/draft.py@@ -146,7 +146,7 @@ def _read_jsonl(path: str, label: str, max_rows: int) -> list[dict]:except OSError as exc:raise ValueError(f"{label} unreadable: {exc}") from excrows: list[dict] = []- with os.fdopen(fd, "r", encoding="utf-8") as handle:+ with os.fdopen(fd, "r", encoding="utf-8-sig") as handle:if os.fstat(handle.fileno()).st_size > _MAX_INPUT_BYTES:raise ValueError(f"{label} exceeds {_MAX_INPUT_BYTES} bytes")for line in handle:diff --git a/src/soup_cli/commands/edit.py b/src/soup_cli/commands/edit.pyindex c920e73b..f33dfe20 100644--- a/src/soup_cli/commands/edit.py+++ b/src/soup_cli/commands/edit.py@@ -101,7 +101,7 @@ def _load_cov_corpus(path: str) -> list[str]:f"--cov-corpus file too large (> {_MAX_COV_CORPUS_BYTES} bytes)")rows: list[str] = []- with os.fdopen(fd, encoding="utf-8") as fh:+ with os.fdopen(fd, encoding="utf-8-sig") as fh:for i, line in enumerate(fh):if i >= _MAX_COV_CORPUS_LINES:breakdiff --git a/src/soup_cli/commands/generate.py b/src/soup_cli/commands/generate.pyindex 7f6a86f1..03ab2912 100644--- a/src/soup_cli/commands/generate.py+++ b/src/soup_cli/commands/generate.py@@ -247,7 +247,7 @@ def generate(if not ctx_path.exists():console.print(f"[red]Context file not found: {ctx_path}[/]")raise typer.Exit(1)- context_text = ctx_path.read_text(encoding="utf-8")+ context_text = ctx_path.read_text(encoding="utf-8-sig")# Generateconsole.print(f"[dim]Generating {count} examples using {provider}/{model_name}...[/]")diff --git a/src/soup_cli/commands/shrink.py b/src/soup_cli/commands/shrink.pyindex 1ac4dea0..0dc08e66 100644--- a/src/soup_cli/commands/shrink.py+++ b/src/soup_cli/commands/shrink.py@@ -99,7 +99,7 @@ def _load_calib(path: str) -> list[str]:fd = os.open(path, flags)except OSError as exc:raise typer.BadParameter(f"calib path unreadable: {exc}") from exc- with os.fdopen(fd, "r", encoding="utf-8") as handle:+ with os.fdopen(fd, "r", encoding="utf-8-sig") as handle:if os.fstat(handle.fileno()).st_size > _MAX_INPUT_BYTES:raise typer.BadParameter(f"calib file exceeds {_MAX_INPUT_BYTES} bytes"diff --git a/src/soup_cli/commands/tokenizer.py b/src/soup_cli/commands/tokenizer.pyindex 2ff268f2..e31cd3f1 100644--- a/src/soup_cli/commands/tokenizer.py+++ b/src/soup_cli/commands/tokenizer.py@@ -60,7 +60,7 @@ def _extract_texts(input_path: Path) -> list[str]:texts: list[str] = []total_bytes = 0if input_path.suffix.lower() == ".jsonl":- with open(input_path, encoding="utf-8") as fh:+ with open(input_path, encoding="utf-8-sig") as fh:for raw in fh:if len(raw.encode("utf-8", errors="replace")) > _MAX_LINE_BYTES:continue # silently skip oversized line@@ -92,7 +92,7 @@ def _extract_texts(input_path: Path) -> list[str]:elif isinstance(row, str):texts.append(row)else:- with open(input_path, encoding="utf-8") as fh:+ with open(input_path, encoding="utf-8-sig") as fh:for raw in fh:if len(raw.encode("utf-8", errors="replace")) > _MAX_LINE_BYTES:continuediff --git a/tests/test_utf8_bom_readers.py b/tests/test_utf8_bom_readers.pynew file mode 100644index 00000000..ea5f2ec5--- /dev/null+++ b/tests/test_utf8_bom_readers.py@@ -0,0 +1,363 @@+"""User-supplied UTF-8 files accept a leading BOM without losing row content (#2136)."""++from __future__ import annotations++import codecs+import json+from pathlib import Path+from unittest.mock import Mock++import pytest++from tests.cli_runner import CliRunner+from tests.conftest import strip_ansi++_TEXTS = ["first\ufeffvalue", "\ufeffsecond value"]++[email protected](params=[False, True], ids=["utf8", "utf8-bom"])+def bom(request: pytest.FixtureRequest) -> bool:+ return request.param++[email protected](params=["\n", "\r\n"], ids=["lf", "crlf"])+def newline(request: pytest.FixtureRequest) -> str:+ return request.param+++def _write_input(path: Path, text: str, bom: bool, newline: str) -> None:+ payload = text.replace("\n", newline).encode("utf-8")+ path.write_bytes((codecs.BOM_UTF8 if bom else b"") + payload)+++def _text_rows(suffix: str) -> str:+ rows = [json.dumps({"text": text}, ensure_ascii=False) for text in _TEXTS]+ return "\n".join(rows if suffix == ".jsonl" else _TEXTS) + "\n"++[email protected]("suffix", [".jsonl", ".txt"])+def test_tokenizer_keeps_first_record_and_embedded_feff(+ tmp_path: Path, suffix: str, bom: bool, newline: str+) -> None:+ from soup_cli.commands.tokenizer import _extract_texts++ path = tmp_path / ("corpus" + suffix)+ _write_input(path, _text_rows(suffix), bom, newline)+ assert _extract_texts(path) == _TEXTS+++def test_draft_keeps_first_jsonl_record(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, bom: bool, newline: str+) -> None:+ from soup_cli.commands.draft import _read_jsonl++ monkeypatch.chdir(tmp_path)+ path = tmp_path / "prompts.jsonl"+ _write_input(path, _text_rows(".jsonl"), bom, newline)+ assert _read_jsonl(str(path), "--prompts", max_rows=10) == [{"text": text} for text in _TEXTS]++[email protected]("suffix", [".jsonl", ".txt"])+def test_edit_covariance_corpus_extracts_text(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, suffix: str, bom: bool, newline: str+) -> None:+ from soup_cli.commands.edit import _load_cov_corpus++ monkeypatch.chdir(tmp_path)+ path = tmp_path / ("corpus" + suffix)+ _write_input(path, _text_rows(suffix), bom, newline)+ assert _load_cov_corpus(str(path)) == _TEXTS++[email protected]("suffix", [".jsonl", ".txt"])+def test_shrink_calibration_extracts_text(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, suffix: str, bom: bool, newline: str+) -> None:+ from soup_cli.commands.shrink import _load_calib++ monkeypatch.chdir(tmp_path)+ path = tmp_path / ("calib" + suffix)+ _write_input(path, _text_rows(suffix), bom, newline)+ assert _load_calib(str(path)) == _TEXTS+++def test_diagnose_evidence_keeps_document(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, bom: bool, newline: str+) -> None:+ from soup_cli.commands.diagnose import _load_evidence++ monkeypatch.chdir(tmp_path)+ payload = {"scores": {}, "note": _TEXTS[0]}+ path = tmp_path / "evidence.json"+ _write_input(path, json.dumps(payload, ensure_ascii=False, indent=2), bom, newline)+ assert _load_evidence(str(path)) == payload+++def test_can_attestation_keeps_document(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, bom: bool, newline: str+) -> None:+ from soup_cli.commands.can import _load_attestation_files++ monkeypatch.chdir(tmp_path)+ payload = {+ "_type": "https://in-toto.io/Statement/v1",+ "predicateType": "https://slsa.dev/provenance/v1",+ "predicate": {"note": _TEXTS[0]},+ }+ path = tmp_path / "statement.json"+ _write_input(path, json.dumps(payload, ensure_ascii=False, indent=2), bom, newline)+ assert _load_attestation_files([str(path)]) == [payload]++[email protected]("suffix", [".jsonl", ".txt"])+def test_bench_passes_complete_prompts_to_inference(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, suffix: str, bom: bool, newline: str+) -> None:+ import torch++ import soup_cli.commands.infer as infer+ from soup_cli.commands.bench import app++ monkeypatch.chdir(tmp_path)+ (tmp_path / "model").mkdir()+ path = tmp_path / ("prompts" + suffix)+ rows = [json.dumps({"prompt": text}, ensure_ascii=False) for text in _TEXTS]+ content = "\n".join(rows if suffix == ".jsonl" else _TEXTS) + "\n"+ _write_input(path, content, bom, newline)+ monkeypatch.setattr(torch.cuda, "is_available", lambda: False)+ monkeypatch.setattr(infer, "_load_model", Mock(return_value=("model", "tokenizer")))+ generate = Mock(return_value=("answer", 10))+ monkeypatch.setattr(infer, "_generate", generate)++ result = CliRunner().invoke(app, ["infer", "model", "--prompts-file", path.name])+ assert result.exit_code == 0, (result.output, repr(result.exception))+ assert "Running 2 test inferences" in strip_ansi(result.output)+ prompts = [call.args[2][0]["content"] for call in generate.call_args_list]+ assert prompts[-2:] == _TEXTS++[email protected]("sandbox", [False, True], ids=["heuristic", "sandbox"])+def test_agent_scores_every_prediction(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, sandbox: bool, bom: bool, newline: str+) -> None:+ import soup_cli.trainer.rewards as rewards+ import soup_cli.utils.agent_sandbox as agent_sandbox+ from soup_cli.commands.agent import app++ monkeypatch.chdir(tmp_path)+ spec = {+ "openapi": "3.0.0",+ "info": {"title": "Synthetic", "version": "1"},+ "paths": {+ "/ping": {+ "get": {+ "operationId": "ping",+ "parameters": [{"name": "name", "in": "query", "schema": {"type": "string"}}],+ "responses": {"200": {"description": "OK"}},+ }+ },+ },+ }+ (tmp_path / "spec.json").write_text(json.dumps(spec), encoding="utf-8")+ rows = [{"tool": "ping", "arguments": {"name": text}} for text in _TEXTS]+ content = "\n".join(json.dumps(row, ensure_ascii=False) for row in rows) + "\n"+ _write_input(tmp_path / "pred.jsonl", content, bom, newline)+ score = Mock(return_value="ok")+ monkeypatch.setattr(agent_sandbox, "score_sandbox", score)+ monkeypatch.setattr(rewards, "_get_isolation_strategy", lambda: "synthetic")+ args = ["eval", "--spec", "spec.json", "--predictions", "pred.jsonl"]+ result = CliRunner().invoke(app, args + (["--sandbox"] if sandbox else []))+ assert result.exit_code == 0, (result.output, repr(result.exception))+ plain = " ".join(strip_ansi(result.output).split())+ assert "Predictions: 2" in plain+ if sandbox:+ assert [call.kwargs["arguments"]["name"] for call in score.call_args_list] == _TEXTS+ else:+ assert "Tool match: 2 (100.0%)" in plain+ assert "Args valid: 2 (100.0%)" in plain+ score.assert_not_called()+++def test_generate_context_and_output_encoding(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, bom: bool, newline: str+) -> None:+ import soup_cli.commands.generate as generate+ from soup_cli.cli import app++ monkeypatch.chdir(tmp_path)+ context = "\n".join(_TEXTS) + "\n"+ _write_input(tmp_path / "context.txt", context, bom, newline)+ example = {"instruction": _TEXTS[0], "input": "", "output": _TEXTS[1]}+ batch = Mock(return_value=[example])+ monkeypatch.setattr(generate, "_generate_batch", batch)+ result = CliRunner().invoke(+ app,+ [+ "data",+ "generate",+ "--prompt",+ "synthetic",+ "--provider",+ "local",+ "--context",+ "context.txt",+ "--template",+ "qa",+ "--count",+ "1",+ "--output",+ "output.jsonl",+ ],+ )+ assert result.exit_code == 0, (result.output, repr(result.exception))+ assert batch.call_args.kwargs["context_text"] == context+ output = (tmp_path / "output.jsonl").read_bytes()+ assert not output.startswith(codecs.BOM_UTF8)+ assert json.loads(output.decode("utf-8")) == example++[email protected]("quant_method, expected", [("gptq", "gptq"), ("gp\ufefftq", None)])+def test_autopilot_reads_local_quantization_metadata(+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ quant_method: str,+ expected: str | None,+ bom: bool,+ newline: str,+) -> None:+ from soup_cli.autopilot.decisions import detect_prequantized_format_from_path++ monkeypatch.chdir(tmp_path)+ model = tmp_path / "neutral-model"+ model.mkdir()+ config = {"quantization_config": {"quant_method": quant_method}}+ _write_input(+ model / "config.json", json.dumps(config, ensure_ascii=False, indent=2), bom, newline+ )+ assert detect_prequantized_format_from_path(str(model)) == expected+++ "statement_bom, sidecar_bom",+ [(False, False), (True, False), (False, True), (True, True)],+ ids=["plain", "statement-bom", "sidecar-bom", "both-bom"],+)[email protected]("integrity", ["valid", "tampered", "wrong-key"])+def test_attest_bom_preserves_signature_and_trust_checks(+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ statement_bom: bool,+ sidecar_bom: bool,+ integrity: str,+ newline: str,+) -> None:+ from soup_cli.commands.attest import app+ from soup_cli.utils.signing import (+ generate_ed25519_private_pem,+ private_key_from_pem,+ public_key_pem,+ )++ monkeypatch.chdir(tmp_path)+ private_pem = generate_ed25519_private_pem()+ (tmp_path / "signing.pem").write_text(private_pem, encoding="utf-8")+ emitted = CliRunner().invoke(+ app,+ [+ "emit",+ "--stage",+ "train",+ "--subject",+ "synthetic",+ "--sha",+ "a" * 64,+ "--sign",+ "ed25519",+ "--key",+ "signing.pem",+ "--invocation",+ _TEXTS[0],+ "--output",+ "statement.json",+ ],+ )+ assert emitted.exit_code == 0, (emitted.output, repr(emitted.exception))+ statement = tmp_path / "statement.json"+ sidecar = tmp_path / "statement.json.sig"+ assert not statement.read_bytes().startswith(codecs.BOM_UTF8)+ assert not sidecar.read_bytes().startswith(codecs.BOM_UTF8)+ document = json.loads(statement.read_text(encoding="utf-8"))+ signature = json.loads(sidecar.read_text(encoding="utf-8"))+ if integrity == "tampered":+ document["predicate"]["tampered"] = True+ if integrity == "wrong-key":+ private_pem = generate_ed25519_private_pem()+ public_pem = public_key_pem(private_key_from_pem(private_pem))+ (tmp_path / "trusted.pub").write_text(public_pem, encoding="utf-8")+ # Change formatting and line endings as well as the file's BOM. Verification+ # must still use emit's canonical JSON, retaining the embedded U+FEFF.+ _write_input(+ statement, json.dumps(document, ensure_ascii=False, indent=1), statement_bom, newline+ )+ _write_input(sidecar, json.dumps(signature, indent=1), sidecar_bom, newline)++ result = CliRunner().invoke(+ app,+ [+ "verify",+ statement.name,+ "--signature",+ sidecar.name,+ "--public-key",+ "trusted.pub",+ ],+ )+ plain = " ".join(strip_ansi(result.output).split())+ if integrity == "valid":+ assert result.exit_code == 0, (plain, repr(result.exception))+ assert "Attestation signature valid" in plain+ else:+ assert result.exit_code == 3, (plain, repr(result.exception))+ expected = "Attestation signature INVALID" if integrity == "tampered" else "untrusted key"+ assert expected in plain++[email protected]("reader", ["draft", "edit", "shrink", "diagnose", "can"])+def test_bom_readers_still_enforce_raw_file_size(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], reader: str+) -> None:+ import importlib++ import typer++ monkeypatch.chdir(tmp_path)+ module = importlib.import_module(f"soup_cli.commands.{reader}")+ text = '{"_type":"type","predicateType":"predicate","text":"ok","scores":{}}'+ path = tmp_path / "input.jsonl"+ _write_input(path, text, True, "\n")+ limit = len(path.read_bytes()) - 1 # Decoded text fits; raw bytes including the BOM do not.+ caps = {+ "draft": "_MAX_INPUT_BYTES",+ "edit": "_MAX_COV_CORPUS_BYTES",+ "shrink": "_MAX_INPUT_BYTES",+ "diagnose": "_MAX_EVIDENCE_BYTES",+ }+ if reader == "can":+ from soup_cli.cans import schema++ monkeypatch.setattr(schema, "_MAX_ATTESTATION_BYTES", limit)+ else:+ monkeypatch.setattr(module, caps[reader], limit)+ with pytest.raises((ValueError, typer.BadParameter, typer.Exit)) as caught:+ if reader == "draft":+ module._read_jsonl(str(path), "--prompts", max_rows=10)+ elif reader == "edit":+ module._load_cov_corpus(str(path))+ elif reader == "shrink":+ module._load_calib(str(path))+ elif reader == "diagnose":+ module._load_evidence(str(path))+ else:+ module._load_attestation_files([str(path)])+ message = " ".join((str(caught.value) + strip_ansi(capsys.readouterr().out)).split())+ assert "too large" in message or "exceeds" in message