<?php
declare(strict_types=1);$_SERVER['HTTP_HOST']='customer-fast5.invalid';require __DIR__.'/app.php';require __DIR__.'/data.php';require __DIR__.'/scope.php';require __DIR__.'/fast-scope.php';$app=coreApp('PREFLIGHT_RESUME');ck(file_exists($runtime.'/metadata-tables.json')&&!file_exists($runtime.'/preflight-state.json')&&!file_exists($runtime.'/owned-actor.json'),'Only original six-read scope resume, no metadata replay');saveOnce('initial-scope-error.json',['error'=>'Tool unnecessarily required primary AIStaff; original sports readers do not require it and Rank secondary Staff LEFTJOIN permitsNULL','SQL_already_executed'=>count(file($runtime.'/sql-budget.jsonl')),'HTTP'=>0,'Auth'=>0,'DMLDDL'=>0,'original_source_and_native_preserved'=>true]);CoreGate::$metadataMap=json_decode(file_get_contents($runtime.'/metadata-tables.json'),true);$uid=$lane==='B'?44676:1836;$u=readNative('AI','SELECT * FROM yoshop_user WHERE user_id=? AND store_id=?',[$uid,10001]);$proof=json_decode(file_get_contents($runtime.'/old-marked-user.json'),true);ck($u===$proof['user_fullrows']&&count($u)===1&&$u[0]['is_delete']===0,'Real original sealed marked User/tenant, no invented nonemptyStaff requirement');$staff=[];$fallback=false;saveOnce('owned-actor.json',['user_id'=>$uid,'staff_id'=>null,'store_id'=>10001,'marker'=>$u[0]['nick_name'],'preferred_exact_sealed_actor'=>true,'AIStaff_not_required_by_source'=>true]);
$z=readNative('ZHCT','SELECT * FROM ydy_user WHERE ai_user_id=? AND is_delete=0',[$uid],true);ck(count($z)<=1,'Exact source linked StoreUser cardinality');saveOnce('auth-version.json',['password_version'=>(int)($z[0]['password_version']??0),'linked_StoreUserID'=>$z[0]['id']??null,'no_credentials_saved'=>true]);$sessions=readNative('ZHCT','SELECT * FROM ydy_measurement_session WHERE ai_user_id=? AND vendor=? AND is_valid=1 ORDER BY start_time DESC',[$uid,'yingjiduo']);$type=1;foreach([1,2,3] as $t){$have=array_values(array_filter($sessions,static function($s)use($t){return in_array($s['device_type'],typeDevices($t),true);}));if($have){$type=$t;break;}}$devices=typeDevices($type);$owned=array_values(array_filter($sessions,static function($s)use($devices){return in_array($s['device_type'],$devices,true);}));$day=$owned?substr($owned[0]['start_time'],0,10):'2026-10-11';ck(preg_match('/^\d{4}-\d\d-\d\d$/D',$day)&&strtotime($day)!==false,'Actual original selected day');$action=readNative('AI','SELECT * FROM yoshop_sign_action WHERE store_id=? AND is_delete=0 AND status=1 ORDER BY id'.($dm?' FETCH FIRST 1 ROWS ONLY':' LIMIT 1'),[10001]);$signId=$action[0]['id']??0;$scope=['type'=>$type,'devices'=>$devices,'day'=>$day,'own_session_ids'=>array_column($owned,'session_id'),'sign_id'=>$signId,'own_sports_empty_only'=>$owned===[],'no_fixture'=>true];saveOnce('fast-scope.json',$scope);$schema=[];foreach(['sign_action','sign_address'] as $t){$arg=$dm?strtoupper('yoshop_'.$t):'yoshop_'.$t;$schema[$t]=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,COLUMN_TYPE,IS_NULLABLE,COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=? ORDER BY ORDINAL_POSITION',[$arg]);ck(count($schema[$t])>0,'Original source field columns');}saveOnce('sign-schema.json',$schema);$snap=fastSnapshot();saveOnce('source-snapshot.json',$snap);saveOnce('preflight-state.json',['actor'=>$u,'actor_staff'=>$staff,'preferred_exact_sealed_actor'=>!$fallback,'source'=>sourceProof(),'protection'=>fastProtection(),'snapshot_sha256'=>hash('sha256',json_encode($snap,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_PRESERVE_ZERO_FRACTION)),'HTTP'=>0,'DMLDDL'=>0]);echo json_encode(['lane'=>$lane,'actor'=>$uid,'type'=>$type,'day'=>$day,'own_sports_sessions'=>count($owned),'rank_global_sessions'=>count($snap['global_sessions']),'published_sign_id'=>$signId,'SQL'=>count(file($runtime.'/sql-budget.jsonl')),'HTTP'=>0,'DMLDDL'=>0]),"\n";
