<?php
declare(strict_types=1);
$natural=static function()use($read,$check){$out=[];foreach(['store_api'=>['api_id',2000],'store_menu'=>['menu_id',512],'store_menu_api'=>['id',4096]] as $t=>$v){$n=(int)$read('SELECT COUNT(*) n FROM yoshop_'.$t)[0]['n'];$check($n>0&&$n<=$v[1],'Bounded public dictionary '.$t);$order=$t==='store_menu_api'?'id':'sort,create_time';$r=$read('SELECT * FROM yoshop_'.$t.' ORDER BY '.$order);$check(count($r)===$n,'Natural dictionary concurrent count stable');$out[$t]=$r;}
$n=(int)$read('SELECT COUNT(*) n FROM yoshop_store_user WHERE store_id NOT IN (2147001111,2147001112)')[0]['n'];$check($n<=512,'Bounded natural operator identity digests');$r=$read("SELECT store_user_id,store_id,is_super,is_delete,sort,user_type,create_time,update_time,MD5(CONCAT('V:',user_name)) username_digest,MD5(CONCAT('V:',password)) credential_digest,MD5(CONCAT('V:',real_name)) realname_digest,MD5(CONCAT('V:',node)) node_digest,MD5(CONCAT('V:',create_by)) creator_digest FROM yoshop_store_user WHERE store_id NOT IN (2147001111,2147001112) ORDER BY store_user_id");$check(count($r)===$n,'Natural operator digest count stable');$out['operator_identity_digests']=$r;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;}
