<?php
declare(strict_types=1);require __DIR__.'/native.php';$cases=json_decode(file_get_contents($runtime.'/cases.json'),true);$tokens=json_decode(file_get_contents($runtime.'/tokens.json'),true);ck(!file_exists($runtime.'/run-attempt.json')&&file_exists($runtime.'/guard.json'),'Exact batch once');saveOnce('run-attempt.json',['HTTP_cap'=>24,'planned'=>count($cases),'DML'=>0,'at'=>date('c')]);$port=$lane==='B'?18975:18976;$results=[];foreach($cases as $label=>$c){$url='http://127.0.0.1:'.$port.$c['path'].($c['query_raw']===''?'':'?'.$c['query_raw']);$headers='Host: customer.read.invalid'."\r\n".'platform: POC'."\r\n".'Access-Token: '.$tokens['U1']."\r\n".'X-Core-Case: '.$label."\r\n";saveOnce('client-attempt-'.$label.'.json',['method'=>'GET','url'=>$url,'query_raw'=>$c['query_raw'],'at'=>microtime(true),'access_token_sha256'=>hash('sha256',$tokens['U1'])]);$start=microtime(true);$raw=file_get_contents($url,false,stream_context_create(['http'=>['method'=>'GET','header'=>$headers,'ignore_errors'=>true,'timeout'=>30]]));$end=microtime(true);$status=isset($http_response_header[0])&&preg_match('/HTTP\/\S+\s+(\d+)/',$http_response_header[0],$m)?(int)$m[1]:0;$r=['label'=>$label,'http_status'=>$status,'body_raw'=>$raw,'headers_raw'=>$http_response_header,'start'=>$start,'end'=>$end];saveOnce('client-'.$label.'.json',$r);$results[$label]=['http_status'=>$status,'business_status'=>is_string($raw)?(json_decode($raw,true)['status']??null):null];}saveOnce('run-complete.json',['results'=>$results,'actual_HTTP'=>count($results),'DML'=>0,'at'=>date('c')]);echo json_encode(['lane'=>$lane,'actual_HTTP'=>count($results),'results'=>$results]),"\n";
