<?php
declare(strict_types=1);require __DIR__.'/connect.php';$check=static function($ok,$why){if(!$ok)throw new RuntimeException($why);};$m=json_decode(file_get_contents(__DIR__.'/structure-'.$lane.'.json'),true)['tables'];
$eqAllowed=['id','code','name','type','matecode','mate_flag','mate_time','status','store_id','is_delete','create_by','create_time','update_time'];$eqCols=array_column($m['equipment']['columns'],'column_name');$check(array_diff($eqCols,$eqAllowed)===[],'Equipment full schema secrets/unknown columns gate');$check($m['equipment']['rows']<=512,'Equipment small table count bound');$groups=$q('SELECT type,is_delete,COUNT(*) n FROM yoshop_equipment GROUP BY type,is_delete ORDER BY type,is_delete');
$cateCols=array_column($m['dishes_cate']['columns'],'column_name');sort($cateCols);$check($cateCols===['id','name','pid']&&$m['dishes_cate']['rows']>0&&$m['dishes_cate']['rows']<=128,'Only public bounded category columns');$categories=$q('SELECT id,name,pid FROM yoshop_dishes_cate ORDER BY id');$check(count($categories)===$m['dishes_cate']['rows'],'Category count stable');$storeCount=(int)$q('SELECT COUNT(*) n FROM yoshop_store WHERE is_delete=0')[0]['n'];$check($storeCount>0&&$storeCount<=128,'Only bounded store id/name projection');$stores=$q('SELECT store_id,store_name FROM yoshop_store WHERE is_delete=0 ORDER BY store_id');$check(count($stores)===$storeCount,'Store projection count stable');
$file=$q('SELECT * FROM yoshop_upload_file WHERE file_id=? AND store_id=2147001112',[$lane==='B'?24452:9715]);$check(count($file)===1&&$file[0]['file_name']==='CDXCM11F782_terminal','Prior own file exact marker');$check($file[0]['storage']==='local'&&(int)$file[0]['file_type']===10,'Only own local file URL metadata');$old=json_decode(file_get_contents('/tmp/cdx-ai-operator-dictionary-read9-20261011/private/evidence/final-original.json'),true);$expected=array_values(array_filter($old['original']['upload_file'],static function($r){return (int)$r['store_id']===2147001112;}));foreach($file as &$r)ksort($r);unset($r);$check($file===$expected,'Frozen prior own file all-column exact');
$check((int)$q('SELECT COUNT(*) n FROM yoshop_equipment WHERE code=? OR name=?',['CDXAD11E70B','CDXAD11E70B_SYNTHETIC'])[0]['n']===0,'New equipment marker unused');$check((int)$q('SELECT COUNT(*) n FROM yoshop_dishes WHERE name=?',['CDXAD11E70B_SYNTHETIC'])[0]['n']===0,'New dish marker unused');$persist('inspect-original.json',['equipment_type_counts'=>$groups,'categories'=>$categories,'stores_id_name'=>$stores,'existing_own_file'=>$file]);$out=['lane'=>$lane,'identity_verified'=>true,'HTTP'=>0,'business_dml'=>0,'equipment_full_schema_whitelisted'=>true,'equipment_status_missing'=>!in_array('status',$eqCols,true),'equipment_type_counts'=>$groups,'natural_categories'=>['rows'=>count($categories),'sha256'=>hash('sha256',json_encode($categories))],'natural_active_store_id_name'=>['rows'=>count($stores),'sha256'=>hash('sha256',json_encode($stores))],'existing_own_file'=>['file_id'=>(int)$file[0]['file_id'],'all_columns_old_evidence_exact'=>true,'sha256'=>hash('sha256',json_encode($file))],'own_equipment_dishes_img_rows'=>[$m['equipment']['own_rows'],$m['dishes']['own_rows'],$m['dishes_img']['own_rows']],'new_markers_unused'=>true];file_put_contents(__DIR__.'/inspect-'.$lane.'.json',json_encode($out,JSON_PRETTY_PRINT));echo json_encode($out),"\n";
