from pathlib import Path import json R=Path(__file__).resolve().parent.parent;P=R/'storage/app/private/investmoz-v2/portal-audit' plan=json.loads((P/'service-followup-latest.json').read_text());S=Path(plan['source']) assert S.name.startswith('workflow-service-followup-source-') and plan['target']['port']==55441 p=S/'app/Services/PortalProfileInstallation.php';t=p.read_text(encoding='utf-8') needle=" $plan = ['target' => $identity" insert=""" $pending = $installed && ! $pair ? DB::table('portal_security_approvals')->where('kind', 'bootstrap')->whereNull('consumed_at')->where('expires_at', '>', now()) ->where(fn ($q) => $q->where('requested_by', $actor->id)->orWhere('subject_user_id', $actor->id))->first() : null; $bootstrap['pending'] = $pending ? ['approval_id' => $pending->id, 'confirmation_url' => '/management/profile-install/bootstrap/'.$pending->id, 'expires_at' => $pending->expires_at] : null; """ assert needle in t;t=t.replace(needle,insert+needle) t=t.replace("$p['installed'] && $p['consistent'] && ! $p['bootstrap']['initialized']","$p['installed'] && $p['consistent'] && ! in_array(false, $p['dependencies'], true) && ! $p['bootstrap']['initialized']") p.write_text(t,encoding='utf-8') p=S/'resources/js/pages/profiles/installation.tsx';t=p.read_text(encoding='utf-8') t=t.replace(" rule: string;"," rule: string;\n pending: {approval_id:string;confirmation_url:string;expires_at:string} | null;") t=t.replace(" !plan.installed ||"," !plan.installed ||\n !!plan.bootstrap.pending ||") t=t.replace("

{plan.bootstrap.rule}

","

{plan.bootstrap.rule}

\n {plan.bootstrap.pending &&

Pedido pendente até {plan.bootstrap.pending.expires_at}. Recuperar pedido de confirmação. Nenhum privilégio foi atribuído pelo pedido.

}") p.write_text(t,encoding='utf-8') print(json.dumps({'result':'pending_request_recovery_added_QA_only','active_writes':0}))