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 isolada obrigatória.');} $db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY'); try{ $record=App\Models\Opportunity::findOrFail(32);$context=$record->workflow_context??[]; $review=$context['reviews']['land_legal_review']??[]; $conditions=[]; foreach($context['conditions']??[]as$condition){ $resolution=$condition['resolution']??[];$matches=true; foreach($resolution['document_hashes']??[]as$id=>$sha){$matches=$matches&&($context['submission']['resources']['documents'][$id]['sha256']??null)===$sha;} $conditions[]=['id'=>$condition['id'],'gate'=>$condition['gate'],'status'=>$condition['status'], 'blocking_action'=>$condition['blocking_action'],'resolution_actor'=>$resolution['actor_id']??null, 'resolution_at'=>$resolution['at']??null,'scope'=>$resolution['scope']??null, 'resolution_evidence_count'=>count($resolution['document_hashes']??[]),'evidence_hashes_match_submission'=>$matches]; } $audits=$db->select("SELECT id,created_at,actor_user_id,action,after_data->'after'->>'status' AS state_after, after_data->'after'->>'version' AS version_after FROM audit_events WHERE source_system='portal-profiles-v1' AND after_data->>'record_id'='32' AND created_at >= '2026-10-14T09:11:59+00:00'::timestamptz AND action IN ('workflow_review_gate','workflow_approve','workflow_publish') ORDER BY created_at"); $proof=['at'=>gmdate('c'),'base_review'=>'396c691930bc','target'=>$target,'SQL_read_only'=>true,'case'=>32, 'working_state'=>app(App\Services\PortalProfileAccess::class)->state($record),'version'=>(int)$record->management_version, 'review_cycle'=>$context['review_cycle'],'content_revision'=>$context['content_revision'], 'legal_review'=>array_intersect_key($review,array_flip(['actor_id','decision','at','content_revision','review_cycle'])), 'legal_review_scope_matches'=>app(App\Services\OpportunityReviewMateriality::class)->matches($context['submission'],'land_legal_review',$review), 'conditions'=>$conditions,'audits'=>$audits,'active_changes'=>0,'QA_database_changes'=>0, 'authentication_and_field_values_not_exported'=>true]; file_put_contents($proofPath,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL); echo json_encode($proof,JSON_THROW_ON_ERROR).PHP_EOL; }finally{$db->rollBack();}