<?php
declare(strict_types=1);require __DIR__.'/native.php';ck(!file_exists($runtime.'/auth-preflight.json'),'Auth preflight once');$out=[];
foreach(['store','store_setting','user_oauth','upload_file'] as $table){$out['metadata'][$table]=readNative('AI',$dm?'SELECT COLUMN_NAME,DATA_TYPE,NULLABLE,DATA_DEFAULT FROM USER_TAB_COLUMNS WHERE TABLE_NAME=? ORDER BY COLUMN_ID':'SELECT COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=? ORDER BY ORDINAL_POSITION',[$dm?'YOSHOP_'.strtoupper($table):'yoshop_'.$table]);ck(count($out['metadata'][$table])>0,'Auth original table exists '.$table);}
$out['store_status']=readNative('AI','SELECT store_id,is_delete,is_recycle,logo_image_id FROM yoshop_store WHERE store_id=?',[2147001111]);$out['store_effective_count']=count($out['store_status']);$out['store_controller_pass']=count($out['store_status'])===1&&!(bool)$out['store_status'][0]['is_delete']&&!(bool)$out['store_status'][0]['is_recycle'];
$all=readNative('AI','SELECT * FROM yoshop_store WHERE store_id=?',[2147001111],true);$out['full_store_sha256']=hash('sha256',json_encode($all,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_PRESERVE_ZERO_FRACTION));$setting=readNative('AI','SELECT * FROM yoshop_store_setting WHERE store_id IN (?,?) ORDER BY store_id',[0,2147001111],true);$out['setting_count']=count($setting);$out['setting_full_rows_sha256']=hash('sha256',json_encode($setting,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_PRESERVE_ZERO_FRACTION));$out['store_controller_source_rule']='Original API Controller checks detail present and is_recycle/is_delete; no expiry gate in this Controller';$out['setting_original_rule']='Original getListAll reads [0,tenant], merges original defaultData; empty store-specific setting is not itself a denial';saveOnce('auth-preflight.json',$out);echo json_encode(['lane'=>$lane,'store_count'=>$out['store_effective_count'],'store_controller_pass'=>$out['store_controller_pass'],'setting_count'=>$out['setting_count'],'HTTP'=>0,'DML'=>0]),"\n";
