make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$c=config('database.connections.'.config('database.default'));if($c['database']!=='investemoz'||(int)$c['port']!==5432)throw new RuntimeException('Destination guard');use Illuminate\Support\Facades\DB;DB::beginTransaction();DB::statement('SET TRANSACTION READ ONLY');try{$rows=DB::table('documents as d')->join('portal_resources as r','r.document_id','=','d.id')->whereIn('d.external_id',['legacy-tempo-post-171985-20260420','legacy-tempo-agronegocio-image-5e3840705cf98226'])->get(['d.id','d.external_id','d.sha256','d.status','d.storage_key','d.data_classification','d.rights_status','d.malware_scan_status','d.malware_scanned_sha256','r.id as resource_id','r.published','r.metadata_version']);if($rows->count()!==2)throw new RuntimeException('Need exactly two originals');foreach($rows as$x){if($x->malware_scan_status!=='clean'||trim($x->sha256)!==$x->malware_scanned_sha256||!$x->published||$x->data_classification!=='public'||$x->rights_status!=='authorized')throw new RuntimeException('Scan/private state mismatch');}$v=['at'=>gmdate('c'),'target'=>'investemoz:5432','SQL_read_only'=>true,'result'=>'two exact clean originals explicitly published; ready to enable reader','resources'=>$rows];file_put_contents(__DIR__.'/PUBLISHED-BEFORE-ENABLE.json',json_encode($v,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($v);}finally{DB::rollBack();}