4242 normalize_physics_backend ,
4343 normalize_render_backend ,
4444)
45- from benchmark_result_adapter import ( # noqa: E402
46- benchmark_info as bundle_benchmark_info ,
47- is_runtime_bundle ,
48- load_info ,
49- to_gate_fields ,
50- )
45+ from benchmark_result_adapter import load_info , project_runtime # noqa: E402
46+ from contracts import BenchResult # noqa: E402
5147from gate_config import load_gate_config # noqa: E402
5248from gate_types import FailurePhase # noqa: E402
5349from gpu_identity import normalize_gpu_fields # noqa: E402
@@ -223,8 +219,8 @@ def main() -> int:
223219 timeout_s = args .timeout_s ,
224220 )
225221
226- # Read the runtime bundle (schema v1) and project it into gate fields .
227- info_provenance : dict = {}
222+ # Read the runtime bundle (schema v1) and project it into a typed RuntimeSample .
223+ sample = None
228224 benchmark_info : dict = {}
229225 config_mismatch : str | None = None
230226 observed_backend = None
@@ -234,19 +230,19 @@ def main() -> int:
234230 if perf_smoke_test_info_present :
235231 info_path = artifact_dir / "perf_smoke_test_info.json"
236232 bundle = load_info (info_path )
237- if bundle is not None and is_runtime_bundle ( bundle ):
238- info_provenance = to_gate_fields ( bundle )
239- benchmark_info = bundle_benchmark_info ( bundle )
233+ sample = project_runtime ( bundle ) if bundle is not None else None
234+ if sample is not None :
235+ benchmark_info = sample . benchmark_info ( )
240236 observed_backend = backend_identity_from_benchmark_info (benchmark_info )
241237 runtime_contract , runtime_contract_hash = build_runtime_contract (
242- provenance = info_provenance . get ( " provenance" ) ,
243- gpu_diag = info_provenance . get ( " gpu_diag" ) ,
238+ provenance = sample . provenance ,
239+ gpu_diag = sample . gpu_diag ,
244240 backend = expected_backend ,
245241 policy = runtime_policy ,
246242 )
247243 runtime_info = build_runtime_publish_info (
248- provenance = info_provenance . get ( " provenance" ) ,
249- gpu_diag = info_provenance . get ( " gpu_diag" ) ,
244+ provenance = sample . provenance ,
245+ gpu_diag = sample . gpu_diag ,
250246 policy = runtime_policy ,
251247 )
252248 config_mismatch = _config_drift (benchmark_info , launch_config )
@@ -257,38 +253,38 @@ def main() -> int:
257253 if config_mismatch and failure_phase is None :
258254 failure_phase = FailurePhase .CONFIG_MISMATCH .value
259255
260- bench_result = {
261- " task_id" : task_id ,
262- " backend" : backend_key ,
263- " physics_backend" : physics_backend ,
264- " render_backend" : render_backend ,
265- " backend_key" : backend_key ,
266- " preset" : preset ,
267- " attempt" : args .attempt ,
268- " was_retried" : args .was_retried ,
269- " exit_code" : args .exit_code ,
270- " failure_phase" : failure_phase ,
271- " stdout_tail" : log_text [- 2000 :] if len (log_text ) > 2000 else log_text ,
272- " wall_time_s" : args .wall_time_s ,
273- " startup_time_s" : info_provenance . get ( " startup_time_s" ) ,
274- " perf_smoke_test_info_present" : perf_smoke_test_info_present ,
275- " raw_fps_mean" : info_provenance . get ( "raw_fps_mean" ) ,
276- " raw_fps_std" : info_provenance . get ( "raw_fps_std" ) ,
277- " raw_fps_min" : info_provenance . get ( "raw_fps_min" ) ,
278- " raw_fps_max" : info_provenance . get ( "raw_fps_max" ) ,
279- " benchmark_info" : benchmark_info ,
280- " observed_backend" : observed_backend .to_dict () if observed_backend else None ,
281- " config_mismatch" : config_mismatch ,
282- " runtime_contract" : runtime_contract ,
283- " runtime_contract_hash" : runtime_contract_hash ,
284- " runtime_info" : runtime_info ,
285- " gpu_diag" : info_provenance . get ( " gpu_diag" ) ,
286- " provenance" : info_provenance . get ( " provenance" ) ,
287- " launch_config" : launch_config ,
288- " launch_config_hash" : launch_config .get ("launch_config_hash" ),
289- " benchmark_contract_hash" : launch_config .get ("benchmark_contract_hash" ),
290- " baseline_epoch" : launch_config .get ("baseline_epoch" , 1 ),
291- " task_config_snapshot" : {
256+ bench_result = BenchResult (
257+ task_id = task_id ,
258+ backend = backend_key ,
259+ physics_backend = physics_backend ,
260+ render_backend = render_backend ,
261+ backend_key = backend_key ,
262+ preset = preset ,
263+ attempt = args .attempt ,
264+ was_retried = args .was_retried ,
265+ exit_code = args .exit_code ,
266+ failure_phase = failure_phase ,
267+ stdout_tail = log_text [- 2000 :] if len (log_text ) > 2000 else log_text ,
268+ wall_time_s = args .wall_time_s ,
269+ startup_time_s = sample . startup_time_s if sample else None ,
270+ perf_smoke_test_info_present = perf_smoke_test_info_present ,
271+ raw_fps_mean = sample . fps_mean if sample else None ,
272+ raw_fps_std = sample . fps_std if sample else None ,
273+ raw_fps_min = sample . fps_min if sample else None ,
274+ raw_fps_max = sample . fps_max if sample else None ,
275+ benchmark_info = benchmark_info ,
276+ observed_backend = observed_backend .to_dict () if observed_backend else None ,
277+ config_mismatch = config_mismatch ,
278+ runtime_contract = runtime_contract ,
279+ runtime_contract_hash = runtime_contract_hash ,
280+ runtime_info = runtime_info ,
281+ gpu_diag = ( sample . gpu_diag or None ) if sample else None ,
282+ provenance = sample . provenance if sample else None ,
283+ launch_config = launch_config ,
284+ launch_config_hash = launch_config .get ("launch_config_hash" ),
285+ benchmark_contract_hash = launch_config .get ("benchmark_contract_hash" ),
286+ baseline_epoch = launch_config .get ("baseline_epoch" , 1 ),
287+ task_config_snapshot = {
292288 "task_id" : task_id ,
293289 "backend" : backend_key ,
294290 "physics_backend" : physics_backend ,
@@ -306,10 +302,10 @@ def main() -> int:
306302 "runtime_contract_hash" : runtime_contract_hash ,
307303 "baseline_epoch" : launch_config .get ("baseline_epoch" , 1 ),
308304 },
309- }
305+ )
310306
311307 out = artifact_dir / "perf_smoke_test_result.json"
312- out .write_text (json .dumps (bench_result , indent = 2 ))
308+ out .write_text (json .dumps (bench_result . to_dict () , indent = 2 ))
313309
314310 status = (
315311 f"failure_phase={ failure_phase !r} , perf_smoke_test_info_present={ perf_smoke_test_info_present } , "
0 commit comments