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))]; } $access=app(App\Services\PortalProfileAccess::class);$proof['operational_records']=[]; foreach([32,34,56]as$id){$o=App\Models\Opportunity::findOrFail($id);$p=app(App\Services\OpportunityManagement::class)->values($o)['canonical']; $proof['operational_records'][]=['id'=>$id,'state'=>$access->state($o),'category'=>$o->opportunity_category,'owner'=>$o->owner_user_id,'organization_id'=>$o->organization_id,'documents'=>$p['documents'],'reviews'=>$o->workflow_context['reviews']??[],'conditions'=>$o->workflow_context['conditions']??[]]; } $proof['represented_synthetic_orgs']=app(App\Services\OrganizationCountry::class)->represented(App\Models\User::findOrFail(21)); $proof['declared_companies']=$db->table('investment_company_declarations')->where('user_id',21)->get(['id','version']); $proof['owned_submissions']=$db->table('investment_submissions')->where('user_id',21)->get(['id','status','version']); $proof['business_role_designations']=[]; foreach(['triagers','reviewers','approvers_l1','approvers_l2','publishers']as$role){ $proof['business_role_designations'][$role]=$db->table('users')->whereIn('email',config('existing-business.'.$role,[]))->get(['id'])->map(fn($u)=>['id'=>(int)$u->id,'can_manage'=>App\Models\User::findOrFail($u->id)->can('manage-portal'),'MFA_configured'=>App\Models\User::findOrFail($u->id)->two_factor_confirmed_at!==null])->all(); } $proof['public_portfolios']=App\Http\Controllers\InvestmentPortfolioController::visible()->limit(2)->get(['id','kind']); $proof['QA_scanner_health']=app(App\Services\Malware\MalwareScanner::class)->health(); $dest=__DIR__.'/option-B6-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(array_diff_key($proof,['protected_tables'=>true,'operational_records'=>true,'represented_synthetic_orgs'=>true,'QA_scanner_health'=>true]),JSON_UNESCAPED_UNICODE).PHP_EOL; }finally{$db->rollBack();}