<?php
$file=__DIR__.'/private/readiness.json';if(is_file($file))throw new RuntimeException('Readiness no replay');$r=['started'=>true];file_put_contents($file,json_encode($r));chmod($file,0600);$code=0;
try{require __DIR__.'/common.php';$current=$source();$expected=json_decode(file_get_contents(__DIR__.'/private/baseline-original-'.$lane.'.json'),true)['source'];if($current!==$expected)throw new RuntimeException('Fresh full typed lease');$r['source']=$current;$r['completed']=true;$r['typed_exact_equal']=true;$save('lease-expected-'.$lane.'.json',['source_after'=>$current]);}
catch(Throwable $e){$code=1;$r['error']=['class'=>get_class($e),'message'=>$e->getMessage()];}
$r['oracle']=$GLOBALS['NF_ORACLE']??[];$r['oracle_attempts']=$GLOBALS['NF_ORACLE_ATTEMPTS']??[];$r['HTTP']=0;$r['DML']=0;file_put_contents($file,json_encode($r,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION));chmod($file,0600);echo json_encode(['success'=>$r['completed']??false,'SELECT'=>count($r['oracle']),'HTTP'=>0,'DML'=>0]),PHP_EOL;exit($code);
