<?php
declare(strict_types=1);
require __DIR__.'/bootstrap.php';
$p=json_decode(file_get_contents($runtime.'/private-http-progress.json'),true);$check($lane==='C'&&count($p['cases'])===8&&count($p['errors'])===4,'Actual C initial failed creation evidence');$counts=[];foreach($tables as $t){$counts[$t]=(int)$query('SELECT COUNT(*) n FROM yoshop_'.$t.' WHERE store_id IN (?,?)',array_values($tenants))[0]['n'];$check($counts[$t]===0,'Failed create committed zero');}$before=['h5_setting'=>['natural_rows'=>2,'sha256'=>'3dc861d147b6015052b7f7e86fcacce1e949983bc424f660542c77debb3620b8'],'wxapp_setting'=>['natural_rows'=>7,'sha256'=>'57e34dc770e26ecda3fe395cd4dbed7a8eab39cb8b7e504c0a1d6b0dda9e8043']];$check($snapshot()===$before,'Initial failed creation full natural snapshot');$cases=$p['cases'];foreach($cases as &$c){$body=json_decode($p['responses'][$c['scenario']]['raw'],true);$c['body']=$body;$trace=$body['trace_id']??null;$c['trace_format_valid']=is_string($trace)&&preg_match('/^[0-9a-f]{13}$/D',$trace)===1;if($c['trace_format_valid'])$c['body']['trace_id']='VALID_DYNAMIC_TRACE';if($body['status']===500){$check(strpos($body['message'],'-2007')!==false&&strpos($body['message'],'[values]')!==false,'Actual DM reserved values error');$c['private_unexpected_error_sha256']=hash('sha256',$body['message']);$c['body']['message']='DM_RESERVED_VALUES_-2007_FULL_RAW_PRIVATE';}}unset($c);$events=[];if(is_file($runtime.'/queries.jsonl'))foreach(file($runtime.'/queries.jsonl',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES) as $l)$events[]=json_decode($l,true);$r=['lane'=>$lane,'cases'=>$cases,'errors'=>$p['errors'],'committed_owned_rows'=>$counts,'natural_full_sha_unchanged'=>true,'successful_DML'=>0,'events'=>$events,'loaded_boundary'=>$boundary,'tool_secondary_failure'=>'Missing optional write-audit file after all four real INSERT preparations failed; raw checkpoint retained, no false success'];file_put_contents($runtime.'/red-evidence.json',json_encode($r,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES));echo json_encode(['lane'=>$lane,'failed_actual_HTTP_creates'=>4,'committed_owned_rows'=>$counts,'natural_full_sha_unchanged'=>true]),"\n";
