where('id',$id)->firstOrFail(); if($d->file_name!=='synthetic-qa-proof.txt'||$d->status!=='active'||$d->malware_scan_status!=='clean'||trim($d->sha256)!==$d->malware_scanned_sha256)throw new RuntimeException('Existing authorized synthetic support required'); $from='C:/Users/macbook/.config/investmoz/referencias-economicas-QA-20261016/source/storage/app/private/'.$d->storage_key; $stored=file_get_contents($from);$bytes=$d->storage_encryption==='laravel'?Crypt::decryptString($stored):$stored; if(hash('sha256',$bytes)!==trim($d->sha256))throw new RuntimeException('Support bytes mismatch'); $to=$source.'/storage/app/private/'.$d->storage_key;if(!is_dir(dirname($to)))mkdir(dirname($to),0700,true);file_put_contents($to,$stored); if(DB::table('investment_zone_attachments')->where('document_id',$id)->exists())throw new RuntimeException('Preserve prior attachment'); $attachment=(string)Illuminate\Support\Str::uuid(); DB::table('investment_zone_attachments')->insert(['id'=>$attachment,'zone_id'=>$zone,'document_id'=>$id,'kind'=>'other','caption'=>'SIMULAÇÃO QA — suporte existente reutilizado','source_reference'=>'Synthetic QA proof; no operational/legal validity','rights_status'=>'pending','personal_data_status'=>'unknown','review_status'=>'pending','uploaded_by'=>2,'version_no'=>1,'created_at'=>now(),'updated_at'=>now()]); file_put_contents(__DIR__.'/SUPORTE-QA.json',json_encode(['document_id'=>$id,'attachment_id'=>$attachment,'sha256'=>trim($d->sha256),'bytes_verified'=>true,'existing_clean_scan_reused'=>true,'publicly_selected'=>false,'fixture_only'=>true,'uploads'=>0],JSON_PRETTY_PRINT));echo 'Existing synthetic support privately linked in clone; no upload/publication';