<?php
declare(strict_types=1);require __DIR__.'/native.php';require __DIR__.'/cases.php';$label='R1_DISEASE_INFO';ck(file_exists($runtime.'/oracle-v2-W1_DISEASE_EDIT.json')&&file_exists($runtime.'/run-stopped.json')&&!file_exists($runtime.'/client-attempt-'.$label.'.json')&&!file_exists($runtime.'/run-remaining-attempt.json'),'Only original unissued R1 after tool-only source oracle repair');saveOnce('run-remaining-attempt.json',['HTTP_cap'=>1,'never_replay_W1'=>true,'at'=>date('c')]);[$method,$path,$body]=cases()[$label];$token=json_decode(file_get_contents($runtime.'/tokens.json'),true)['U1'];$url='http://127.0.0.1:'.($lane==='B'?19011:19012).$path;$headers="Host: owned-disease.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',['method'=>$method,'url'=>$url,'body_raw'=>$body,'at'=>microtime(true),'token_sha256'=>hash('sha256',$token)]);$start=microtime(true);$raw=file_get_contents($url,false,stream_context_create(['http'=>['method'=>$method,'header'=>$headers,'content'=>$body,'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(200000);$ok=$status===200&&file_exists($runtime.'/oracle-'.$label.'.json')&&!file_exists($runtime.'/observer-error-'.$label.'.json');saveOnce('run-final.json',['actual_total_HTTP'=>2,'R1_pass'=>$ok,'W1_original_saved_wire_source_corrected_oracle'=>true,'W1_not_replayed'=>true]);echo json_encode(['lane'=>$lane,'actual_total_HTTP'=>2,'R1_pass'=>$ok,'W1_not_replayed'=>true]),"\n";exit($ok?0:2);
