@@ -840,3 +840,58 @@ def test_report_rejects_semantic_unit_fold_digest_on_non_turn_worker(trial):
840840 with pytest .raises (ValueError , match = "non-turn-resume" ):
841841 export (runs , selection , bad_output , observed_at = "2026-12-01T00:00:00+00:00" )
842842 assert not bad_output .exists ()
843+
844+
845+ @pytest .mark .parametrize (
846+ "runner_value,profile_value" ,
847+ [
848+ (None , "OMIT" ),
849+ ("OMIT" , None ),
850+ (None , None ),
851+ ],
852+ )
853+ def test_report_rejects_explicit_null_semantic_unit_fold_digest_in_export_and_verify (
854+ trial , runner_value , profile_value
855+ ):
856+ runs , selection , output , _ = trial
857+ task = runs / "run" / "case"
858+ for name , role_key in (("runtime-receipt" , "worker" ), ("worker-profile" , "profile" )):
859+ path = task / (name + ".json" )
860+ record = json .loads (path .read_text ())
861+ record [role_key ] = "turn-resume"
862+ record ["validation_argv_sha256" ] = "a" * 64
863+ write (path , record )
864+
865+ # 1. Valid baseline turn-resume export without fold digest succeeds; resealing explicit null fails --verify.
866+ export (runs , selection , output , observed_at = "2026-12-01T00:00:00+00:00" )
867+ assert verify (output )["verified" ] is True
868+ settings_path = output / "settings/run.json"
869+ tampered = json .loads (settings_path .read_text ())
870+ if runner_value != "OMIT" :
871+ tampered ["runner" ]["semantic_unit_fold_sha256" ] = runner_value
872+ if profile_value != "OMIT" :
873+ tampered ["worker_profile" ]["semantic_unit_fold_sha256" ] = profile_value
874+ write (settings_path , tampered )
875+ reseal (output , "settings/run.json" )
876+ with pytest .raises (ValueError , match = "semantic_unit_fold_sha256|Semantic unit fold digest" ):
877+ verify (output )
878+ cli_verify = subprocess .run (
879+ [sys .executable , "-m" , "benchmark.edgebench.export_report" , "--verify" , str (output )],
880+ capture_output = True ,
881+ text = True ,
882+ )
883+ assert cli_verify .returncode != 0
884+ assert "semantic_unit_fold_sha256" in cli_verify .stderr or "Semantic unit fold digest" in cli_verify .stderr
885+
886+ # 2. Exporting turn-resume with explicit null on one or both sides rejects upfront.
887+ for name , val in (("runtime-receipt" , runner_value ), ("worker-profile" , profile_value )):
888+ if val == "OMIT" :
889+ continue
890+ path = task / (name + ".json" )
891+ record = json .loads (path .read_text ())
892+ record ["semantic_unit_fold_sha256" ] = val
893+ write (path , record )
894+ bad_output = output .parent / "out-explicit-null-fold"
895+ with pytest .raises (ValueError , match = "semantic_unit_fold_sha256|Semantic unit fold digest" ):
896+ export (runs , selection , bad_output , observed_at = "2026-12-01T00:00:00+00:00" )
897+ assert not bad_output .exists ()
0 commit comments