<?php
declare(strict_types=1);
require __DIR__.'/contract.php';$runtime=getenv('SM7_RUNTIME');$spec=json_decode(file_get_contents($runtime.'/h7-native-spec-private.json'),false,512,JSON_THROW_ON_ERROR);$reports=[];foreach(['h7-native','h7-native-raw'] as $name){$file=$runtime.'/native-report/'.$name.'.json';$cli=json_decode(file_get_contents($file),true,512,JSON_THROW_ON_ERROR);$stats=$cli['run']['stats'];if($stats['requests']['total']!==3||$stats['assertions']['total']!==6||$stats['assertions']['failed']!==0||count($cli['run']['failures'])!==0){throw new RuntimeException('Native CLI gate');}$reports[$name]=['requests'=>3,'assertions'=>6,'failures'=>0,'report_sha256'=>hash_file('sha256',$file)];}
$cases=[];foreach($spec as $case){$file=$runtime.'/raw-'.$case->name.'-private.json';$raw=file_get_contents($file);$actual=json_decode($raw,false,512,JSON_THROW_ON_ERROR);$diff=[];n6Strict($case->expected,$actual,'$',$diff);if($diff){throw new RuntimeException('Native raw response differs from independent source');}$cases[]=['case'=>$case->name,'method'=>'POST','path'=>$case->path,'source_pass'=>true,'wire_sha256'=>hash('sha256',$raw),'wire_bytes'=>strlen($raw),'json_body'=>$actual];}
$before=smLoad('h7-native-before-private.json');$after=smLoad('h7-native-after-private.json');if(empty($after['unchanged'])||$before['consumed_source']!==$after['consumed_source']||$before['source_sha256']!==$after['source_sha256']){throw new RuntimeException('Native source window drift');}
$out=['lane'=>getenv('SM7_LANE'),'status'=>'pass','native_cli_version'=>'2.2.8','reports'=>$reports,'cases'=>$cases,'actual_native_requests'=>6,'unique_scenarios'=>3,'new_http_methods'=>0,'new_fixture_dml'=>0,'ddl'=>0,'owned_consumed_unchanged'=>true,'source_sha256'=>$before['source_sha256'],'raw_capture_original_bytes'=>true,'first_cli_report_had_no_raw'=>true];smSave('h7-native-verification-private.json',$out);echo json_encode(['lane'=>$out['lane'],'native_requests'=>6,'unique_scenarios'=>3,'assertions'=>12,'raw_source_pass'=>3,'database_dml_ddl'=>0]),PHP_EOL;
