<?php
declare(strict_types=1);$natural=static function()use($read,$check){$out=[];$n=(int)$read('SELECT COUNT(*) n FROM yoshop_dishes_cate')[0]['n'];$check($n>0&&$n<=128,'Bounded public category dictionary');$out['categories']=$read('SELECT id,name,pid FROM yoshop_dishes_cate ORDER BY id');$out['category_source_order']=$read('SELECT id,name FROM yoshop_dishes_cate WHERE pid=0');$check(count($out['categories'])===$n,'Category concurrent count stable');$n=(int)$read('SELECT COUNT(*) n FROM yoshop_store WHERE is_delete=0')[0]['n'];$check($n>0&&$n<=128,'Bounded only Store id/name projection');$out['store_source_order']=$read('SELECT store_id,store_name FROM yoshop_store WHERE is_delete=0');$check(count($out['store_source_order'])===$n,'Store projection concurrent count stable');$n=(int)$read('SELECT COUNT(*) n FROM yoshop_equipment WHERE store_id NOT IN (2147001111,2147001112,2147001113)')[0]['n'];$check($n<=512,'Bounded natural equipment identity digest');$out['equipment_identity_digests']=$read("SELECT id,type,mate_flag,mate_time,status,store_id,is_delete,create_time,update_time,MD5(CONCAT('V:',code)) code_digest,MD5(CONCAT('V:',name)) name_digest,MD5(CONCAT('V:',matecode)) matecode_digest,MD5(CONCAT('V:',create_by)) creator_digest FROM yoshop_equipment WHERE store_id NOT IN (2147001111,2147001112,2147001113) ORDER BY id");$check(count($out['equipment_identity_digests'])===$n,'Natural equipment digest count stable');foreach(['store','store_user','staff','staff_face'] as $t)$check((int)$read('SELECT COUNT(*) n FROM yoshop_'.$t.' WHERE store_id=2147001113')[0]['n']===0,'No identity/Store/Staff/Face equipment-only tenant '.$t);return $out;};
function naturalDigest(array $value):array{$out=[];foreach($value as $t=>$rows)$out[$t]=['rows'=>count($rows),'sha256'=>hash('sha256',json_encode($rows,JSON_PRESERVE_ZERO_FRACTION))];return $out;}
