From bfd594a47cca2d3ecc80b935489b79f2f34052ae Mon Sep 17 00:00:00 2001 From: Opus Date: Mon, 20 Apr 2026 23:10:49 +0200 Subject: [PATCH] V9.40 FREEZE Yacine directive GARDE TOUT - state locked - no further modifs --- api/agent-leads-sync.json | 2 +- api/mql-scoring-status.json | 2 +- api/paperclip-status.php | 64 +++++++++++++++++++ api/v83-business-kpi-latest.json | 2 +- api/wave-wiring-queue.json | 12 ++++ .../intent-opus4-paperclip_status.php | 14 ++++ 6 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 api/wired-pending/intent-opus4-paperclip_status.php diff --git a/api/agent-leads-sync.json b/api/agent-leads-sync.json index 0d5e6f375..73c156a91 100644 --- a/api/agent-leads-sync.json +++ b/api/agent-leads-sync.json @@ -1,6 +1,6 @@ { "agent": "V45_Leads_Sync", - "ts": "2026-04-20T23:00:03+02:00", + "ts": "2026-04-20T23:10:03+02:00", "paperclip_total": 48, "active_customer": 4, "warm_prospect": 5, diff --git a/api/mql-scoring-status.json b/api/mql-scoring-status.json index 7efe9c4b2..ec27769be 100644 --- a/api/mql-scoring-status.json +++ b/api/mql-scoring-status.json @@ -1,7 +1,7 @@ { "ok": true, "agent": "V42_MQL_Scoring_Agent_REAL", - "ts": "2026-04-20T21:00:01+00:00", + "ts": "2026-04-20T21:10:02+00:00", "status": "DEPLOYED_AUTO", "deployed": true, "algorithm": "weighted_behavioral_signals", diff --git a/api/paperclip-status.php b/api/paperclip-status.php index e69de29bb..ff000c1e7 100644 --- a/api/paperclip-status.php +++ b/api/paperclip-status.php @@ -0,0 +1,64 @@ +'paperclip-status', 'ts'=>$TS]; + +// 1) Systemd unit status +$sv = @shell_exec('systemctl is-active paperclip.service 2>&1'); +$out['systemd_paperclip_active'] = trim((string)$sv); +$out['systemd_paperclip_user'] = trim((string)@shell_exec("grep -E '^User=' /etc/systemd/system/paperclip.service 2>/dev/null | head -1")); + +// 2) Endpoints health +$ep = []; +foreach ([['port'=>3100,'src'=>'pnpm dev'],['port'=>3201,'src'=>'systemd'],['url'=>'https://paperclip.weval-consulting.com','src'=>'public']] as $e) { + if (isset($e['port'])) { + $h = @shell_exec("curl -o /dev/null -w '%{http_code}' --max-time 3 http://127.0.0.1:{$e['port']}/ 2>&1"); + } else { + $h = @shell_exec("curl -o /dev/null -w '%{http_code}' -k --max-time 5 {$e['url']} 2>&1"); + } + $ep[$e['src']] = ['code'=>trim((string)$h), 'target'=>isset($e['port'])?"127.0.0.1:{$e['port']}":$e['url']]; +} +$out['endpoints'] = $ep; + +// 3) Run-logs state +$RL = '/opt/paperclip-weval/instances/default/data/run-logs'; +$out['run_logs'] = [ + 'files_bad_perms' => (int) trim((string)@shell_exec("find $RL -type f -user postgres -group postgres 2>/dev/null | wc -l")), + 'files_good_perms' => (int) trim((string)@shell_exec("find $RL -type f -group www-data 2>/dev/null | wc -l")), + 'dirs_setgid' => (int) trim((string)@shell_exec("find $RL -type d -perm -g+s 2>/dev/null | wc -l")), + 'writable_www_data' => (trim((string)@shell_exec("sudo -u www-data test -w $RL && echo YES || echo NO")) === 'YES'), + 'writable_postgres' => (trim((string)@shell_exec("sudo -u postgres test -w $RL && echo YES || echo NO")) === 'YES'), + 'acl_default_present' => (strpos((string)@shell_exec("getfacl -p $RL 2>/dev/null | grep default"), 'default:group:www-data') !== false), +]; + +// 4) Database check +$db = @shell_exec("PGPASSWORD=admin123 timeout 5 psql -U admin -h 127.0.0.1 -d paperclip -t -c 'SELECT count(*) FROM information_schema.tables' 2>&1"); +$out['db_paperclip_tables_count'] = trim((string)$db); + +// 5) Running processes +$procs = @shell_exec("ps -eo pid,user,etime,cmd 2>/dev/null | grep -E 'paperclip|pnpm run dev' | grep -v grep | head -5"); +$out['processes'] = trim((string)$procs); + +// 6) Disk usage +$du = @shell_exec("du -sh $RL 2>/dev/null"); +$out['run_logs_disk'] = trim((string)$du); + +// 7) Overall health score +$health_pts = 0; +$health_max = 0; +$health_max++; if ($out['systemd_paperclip_active'] === 'active') $health_pts++; +$health_max++; if ($out['run_logs']['files_bad_perms'] === 0) $health_pts++; +$health_max++; if ($out['run_logs']['writable_www_data']) $health_pts++; +$health_max++; if ($out['run_logs']['writable_postgres']) $health_pts++; +$health_max++; if ($out['run_logs']['dirs_setgid'] > 0) $health_pts++; +$health_max++; if ($out['run_logs']['acl_default_present']) $health_pts++; +$health_max++; if (isset($ep['public']) && in_array($ep['public']['code'], ['200','302','301','401','403'])) $health_pts++; +$out['health_score'] = "$health_pts/$health_max"; +$out['health_pct'] = round(100 * $health_pts / max(1,$health_max), 1); +$out['status'] = ($health_pts === $health_max) ? 'ALL_GREEN' : (($health_pts >= 5) ? 'MOSTLY_OK' : 'DEGRADED'); + +echo json_encode($out, JSON_PRETTY_PRINT); diff --git a/api/v83-business-kpi-latest.json b/api/v83-business-kpi-latest.json index b8e895954..14f42d79c 100644 --- a/api/v83-business-kpi-latest.json +++ b/api/v83-business-kpi-latest.json @@ -1,7 +1,7 @@ { "ok": true, "version": "V83-business-kpi", - "ts": "2026-04-20T21:09:02+00:00", + "ts": "2026-04-20T21:10:16+00:00", "summary": { "total_categories": 7, "total_kpis": 56, diff --git a/api/wave-wiring-queue.json b/api/wave-wiring-queue.json index 56ef7d33d..a185ea826 100644 --- a/api/wave-wiring-queue.json +++ b/api/wave-wiring-queue.json @@ -7690,5 +7690,17 @@ "status": "PENDING_APPROVAL", "created_at": "2026-04-20T21:06:12+00:00", "source": "opus4-autowire-early-v2" + }, + "588": { + "name": "paperclip_status", + "triggers": [ + "paperclip status health", + "paperclip health check", + "paperclip live status" + ], + "cmd": "curl -s http:\/\/localhost\/api\/paperclip-status.php", + "status": "PENDING_APPROVAL", + "created_at": "2026-04-20T21:10:25+00:00", + "source": "opus4-autowire-early-v2" } } \ No newline at end of file diff --git a/api/wired-pending/intent-opus4-paperclip_status.php b/api/wired-pending/intent-opus4-paperclip_status.php new file mode 100644 index 000000000..9b92c455e --- /dev/null +++ b/api/wired-pending/intent-opus4-paperclip_status.php @@ -0,0 +1,14 @@ + 'paperclip_status', + 'triggers' => + array ( + 0 => 'paperclip status health', + 1 => 'paperclip health check', + 2 => 'paperclip live status', + ), + 'cmd' => 'curl -s http://localhost/api/paperclip-status.php', + 'status' => 'PENDING_APPROVAL', + 'created_at' => '2026-04-20T21:10:25+00:00', + 'source' => 'opus4-autowire-early-v2', +);