selectOne('SELECT current_database() AS database,inet_server_port() AS port'); if($target!==['database'=>'stability_consumers_20261011_084534_test','port'=>55441])throw new RuntimeException('QA isolation required'); $db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY'); try{ if(config('portal.notifications_enabled')||config('suitecrm.enabled')||config('investmoz_ai.enabled'))throw new RuntimeException('External integrations must remain off'); $proof=['at'=>gmdate('c'),'target'=>$target,'SQL_read_only'=>true,'active_writes'=>0,'browser_observed'=>false,'protected_tables'=>[]]; foreach(['opportunities','opportunity_documents','opportunity_images','opportunity_locations','opportunity_location_drafts','tasks','documents','organizations','memberships','portal_role_assignments','portal_superuser_pair','desk_cases','desk_documents','desk_requests','investor_journeys','journey_steps','users','investment_submissions','investment_company_declarations','investment_accounts','jobs','outbox_events']as$t){ $rows=$db->table($t)->get();$bytes=$rows->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($bytes,SORT_STRING); $proof['protected_tables'][$t]=['count'=>$rows->count(),'sha256'=>hash('sha256',implode("\n",$bytes))]; } foreach([32,56]as$id){$o=App\Models\Opportunity::findOrFail($id);$p=app(App\Services\OpportunityManagement::class)->values($o)['canonical']; $proof['records'][]=['id'=>$id,'state'=>app(App\Services\PortalProfileAccess::class)->state($o),'canonical'=>$p,'workflow'=>$o->workflow_context,'resources'=>[]]; foreach(['locations','documents','images']as$kind)$proof['records'][count($proof['records'])-1]['resources'][$kind]=app(App\Services\OpportunityResources::class)->listing($id,$kind); } $proof['scanner']=app(App\Services\Malware\MalwareScanner::class)->health(); $dest=__DIR__.'/option-B8-preflight.json';if(is_file($dest))throw new RuntimeException('Preserve preflight'); file_put_contents($dest,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR)); echo json_encode(['target'=>$target,'scanner'=>$proof['scanner'],'records'=>array_map(fn($r)=>['id'=>$r['id'],'state'=>$r['state'],'land_rights'=>$r['canonical']['land_rights']??null,'franchise_terms'=>$r['canonical']['business_transaction']['franchise_terms']??null,'resources'=>array_map(fn($list)=>array_map(fn($x)=>['id'=>$x->id,'payload'=>$x->payload],$list),$r['resources'])],$proof['records'])],JSON_UNESCAPED_UNICODE).PHP_EOL; }finally{$db->rollBack();}