@@ -78,3 +78,45 @@ def test_replaced_result_cannot_become_a_successful_terminal_receipt(tmp_path):
7878 assert (output .path / "result.json" ).read_text () == "foreign"
7979 finally :
8080 output .close ()
81+
82+
83+ def test_oversized_report_retains_bounded_nonpass_and_exact_cleanup_ids (tmp_path ):
84+ output = files .Output (tmp_path / "result" )
85+ cleanup = {"a" * 64 : {"absent" : True , "oom_killed" : False }, "remaining-owned-labels" : {"absent" : True }}
86+ report = {"complete" : True , "scenario" : "pagination" , "runtime_id" : "a" * 64 ,
87+ "consumer_id" : "b" * 64 , "network_id" : "c" * 64 , "cleanup" : cleanup ,
88+ "large_inventory" : "x" * (files .RESULT_LIMIT + 1 )}
89+ try :
90+ output .finish (report )
91+ data = (output .path / "result.json" ).read_bytes ()
92+ receipt = json .loads (data )
93+ assert len (data ) <= files .RESULT_LIMIT
94+ assert receipt ["complete" ] is report ["complete" ] is False
95+ assert receipt ["output_failure" ] == "terminal_result_exceeded_bound"
96+ assert receipt ["runtime_id" ] == "a" * 64
97+ assert receipt ["consumer_id" ] == "b" * 64
98+ assert receipt ["network_id" ] == "c" * 64
99+ assert receipt ["cleanup" ] == cleanup
100+ assert receipt ["oversized_report_bytes" ] > files .RESULT_LIMIT
101+ finally :
102+ output .close ()
103+
104+
105+ def test_oversized_unbounded_cleanup_is_explicitly_unqualified_and_cannot_overwrite_foreign_path (tmp_path ):
106+ output = files .Output (tmp_path / "result" )
107+ original = tmp_path / "retained"
108+ output .path .rename (original )
109+ output .path .mkdir ()
110+ (output .path / "result.json" ).write_text ("foreign" )
111+ report = {"complete" : True , "cleanup" : {"untrusted" : "x" * (files .RESULT_LIMIT * 2 )}}
112+ try :
113+ output .finish (report )
114+ data = (original / "result.json" ).read_bytes ()
115+ receipt = json .loads (data )
116+ assert len (data ) <= files .RESULT_LIMIT
117+ assert receipt ["complete" ] is False
118+ assert receipt ["output_boundary_failure" ] == "identity_changed"
119+ assert receipt ["cleanup" ]["retained" ] is False
120+ assert (output .path / "result.json" ).read_text () == "foreign"
121+ finally :
122+ output .close ()
0 commit comments