<?php
declare(strict_types=1);date_default_timezone_set('Asia/Shanghai');require __DIR__.'/oracle.php';$db=smPdo();$sha=catSha();$runtime=getenv('SM7_RUNTIME');$spec=json_decode(file_get_contents($runtime.'/dining-spec-private.json'),false,512,JSON_THROW_ON_ERROR);$case=json_decode(json_encode($spec,JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR),true);unset($case['before']);$after=n7Snapshot($db,$case);$raw=file_get_contents($runtime.'/raw-DINING_TODAY-private.json');$body=json_decode($raw,false,512,JSON_THROW_ON_ERROR);$diff=[];catStrict($spec->before->body,$body,'$',$diff);$events=[];$end=null;$dml=0;
foreach(file($runtime.'/queries.jsonl',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)?:[] as $line){$event=json_decode($line,true);if(($event['scenario']??'')!=='PILOT_CAT7_DINING_TODAY'){continue;}$events[]=$event;if($event['kind']==='request_end'){$end=$event;}if($event['kind']==='query_observed'&&in_array($event['operation'],['insert','update','delete','replace','merge'],true)){$dml++;}}
$window=$spec->before->source_digest===$after['source_digest'];$positiveMenus=count($after['source_sets']['actual_today_menus'])>0;$result=['lane'=>getenv('SM7_LANE'),'source_sha256'=>$sha,'cases'=>[['case'=>'DINING_TODAY','method'=>'POST','path'=>$case['path'],'http_status'=>$end['http_status']??0,'fatal'=>$end['fatal']??true,'code'=>$body->code??null,'positive'=>!empty($body->data->department),'actual_dining_nonempty'=>$positiveMenus,'scope'=>$positiveMenus?'real dining counters':'natural leaf departments with zero actual menus; no nonempty meal claim','source_pass'=>($end['http_status']??0)===200&&!($end['fatal']??true)&&$diff===[]&&$window,'source_window_unchanged'=>$window,'differences'=>$diff,'wire_bytes'=>strlen($raw),'wire_sha256'=>hash('sha256',$raw)]],'events'=>$events,'http_dml'=>$dml,'new_fixture_dml'=>0,'ddl'=>0,'actor_unchanged'=>(bool)catActor($db)];smSave('dining-after-private.json',$after);smSave('dining-report-private.json',$result);unset($result['events']);echo json_encode($result),PHP_EOL;
