<?php
declare(strict_types=1);require __DIR__.'/native.php';require __DIR__.'/cases.php';$token=json_decode(file_get_contents($runtime.'/tokens.json'),true)['U1'];ck(file_exists($runtime.'/guard.json')&&!file_exists($runtime.'/run-attempt.json'),'Exact once batch');saveOnce('run-attempt.json',['HTTP_cap'=>5,'at'=>date('c')]);$port=$lane==='B'?19041:19042;$results=[];foreach(cases() as $c){$label=$c['label'];if(count(file($runtime.'/sql-budget.jsonl'))+($lane==='B'?80:140)+60>600){$results[$label]=['skipped'=>'Budget reserve, noHTTP'];continue;}$url='http://127.0.0.1:'.$port.$c['path'].'?'.$c['query'];$headers="Host: customer-fast5.invalid\r\nplatform: POC\r\nAccess-Token: ".$token."\r\nX-Core-Case: ".$label."\r\nContent-Type: application/json\r\n";saveOnce('client-attempt-'.$label.'.json',['case'=>$c,'url'=>$url,'at'=>microtime(true),'token_sha256'=>hash('sha256',$token)]);$start=microtime(true);$raw=file_get_contents($url,false,stream_context_create(['http'=>['method'=>$c['method'],'header'=>$headers,'content'=>$c['body_raw'],'ignore_errors'=>true,'timeout'=>40]]));$end=microtime(true);$status=isset($http_response_header[0])&&preg_match('/HTTP\/\S+\s+(\d+)/',$http_response_header[0],$m)?(int)$m[1]:0;saveOnce('client-'.$label.'.json',['label'=>$label,'http_status'=>$status,'body_raw'=>$raw,'headers_raw'=>$http_response_header,'start'=>$start,'end'=>$end]);usleep(150000);$results[$label]=['http_status'=>$status,'oracle'=>file_exists($runtime.'/oracle-'.$label.'.json'),'observer_error'=>file_exists($runtime.'/observer-error-'.$label.'.json'),'harness_error'=>file_exists($runtime.'/harness-error-'.$label.'.json')];}saveOnce('run-complete.json',['results'=>$results,'actual_HTTP'=>count(glob($runtime.'/client-attempt-*.json')),'no_retry'=>true]);echo json_encode(['lane'=>$lane,'actual_HTTP'=>count(glob($runtime.'/client-attempt-*.json')),'results'=>$results]),"\n";
