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 { $since = $reference['latest_submission_event']['at']; $rows = $db->select("SELECT id, created_at, action, actor_user_id, after_data->>'method' AS method, after_data->>'path' AS path, after_data->>'status' AS http_status, after_data->>'record_id' AS record_id, after_data->'before'->>'status' AS state_before, after_data->'after'->>'status' AS state_after, after_data->'after'->>'version' AS saved_version FROM audit_events WHERE source_system='portal-profiles-v1' AND actor_user_id=24 AND created_at >= ?::timestamptz AND (after_data->>'record_id'='32' OR after_data->>'path' LIKE 'minhas-oportunidades/32/%') ORDER BY created_at DESC LIMIT 40", [$since]); $denials = array_values(array_filter($rows, fn ($row) => $row->action === 'request_denied')); $record = App\Models\Opportunity::findOrFail(32); $receipt = [ 'at'=>gmdate('c'), 'target'=>$target, 'SQL_read_only'=>true, 'user_reported_URL'=>'https://portal-investidor.test:18445/minhas-oportunidades/32/view', 'user_statement'=>($argv[2] ?? '') === 'correction-done' ? 'ja feito' : (str_ends_with($traceName, '20261014.json') ? 'nao acontece nada' : 'os passos solicitados foram executados'), 'message_after_last_click_not_provided'=>true, 'since'=>$since, 'QA_account'=>24, 'opportunity_id'=>32, 'working_state'=>app(App\Services\PortalProfileAccess::class)->state($record), 'matching_audit_events'=>$rows, 'request_denial_count'=>count($denials), 'sensitive_fields_omitted'=>['origin_ip', 'reason', 'cookies', 'request_body', 'MFA', 'sessions'], 'limits'=>['Successful page GET requests are not logged by AuditProfileDecision.', 'The denial audit records HTTP status but not validation errors or the submitted action body.', 'Absence of an audit event does not prove a button was not clicked.'], 'active_changes'=>0, 'QA_database_changes'=>0, ]; file_put_contents($tracePath, json_encode($receipt, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR).PHP_EOL); echo json_encode(['case'=>32, 'state'=>$receipt['working_state'], 'audited_requests'=>$rows, 'denial_count'=>count($denials), 'active_changes'=>0, 'QA_database_changes'=>0], JSON_THROW_ON_ERROR).PHP_EOL; } finally { $db->rollBack(); }