From 12d5716505cc4656f1bb5b0ca9630d99adfd555c Mon Sep 17 00:00:00 2001 From: Opus-V37 Date: Mon, 20 Apr 2026 15:24:29 +0200 Subject: [PATCH] =?UTF-8?q?V37=20Blade=20autoheal=20+=20honest=20agent=20d?= =?UTF-8?q?iag=20-=20User=20GO=20ON=20FAIT=20RIEN=20DE=20MANUEL=20PUTAIN?= =?UTF-8?q?=20doctrine=207=20zero=20manuel=20-=20DECOUVERTE=20CAUSE=20RACI?= =?UTF-8?q?NE=20doctrine=204=20HONNETE:=20agent=20Razer=20c=C3=B4t=C3=A9?= =?UTF-8?q?=20Windows=20heartbeat=20OK=20(13:23=20UTC=20fresh)=20MAIS=20ex?= =?UTF-8?q?ec=20pipeline=20cass=C3=A9=20depuis=2019avr=20-=20pickup=20task?= =?UTF-8?q?s=20(status=20dispatched)=20MAIS=20JAMAIS=20callback=20task=5Fd?= =?UTF-8?q?one=20-=20derniere=20task=20vraiment=20executee=2019avr=2010:05?= =?UTF-8?q?=20-=2012=20dispatched=20zombies=20depuis=2001:04=20jamais=20co?= =?UTF-8?q?mpl=C3=A9t=C3=A9s=20+=20mes=202=20test=20tasks=20Test-NetConnec?= =?UTF-8?q?tion=209222=20stuck=20en=20dispatched=20-=20IMPOSSIBLE=20lancer?= =?UTF-8?q?=20Chrome=20--remote-debugging-port=3D9222=20depuis=20S204=20sa?= =?UTF-8?q?ns=20agent=20fonctionnel=20Windows=20-=20Solutions=20c=C3=B4t?= =?UTF-8?q?=C3=A9=20serveur=20zero=20manuel=20Yacine:=201)=20Creation=20/a?= =?UTF-8?q?pi/blade-tasks-cleanup.php=20auto-cleanup=20dispatched=20>10min?= =?UTF-8?q?=20mark=20failed=5Ftimeout=20+=20agent=5Fhealth=20verdict=20HEA?= =?UTF-8?q?LTHY/DEGRADED/BROKEN=20selon=20last=20done=20age=5Fhours=202)?= =?UTF-8?q?=20Cron=20/etc/cron.d/blade-autoheal=20every=205min=20auto-rese?= =?UTF-8?q?t=20zombies=203)=20Andon=20weval.andon=5Falerts=20insert=20'bla?= =?UTF-8?q?de-agent-exec'=20severity=20high=20pour=20notifier=20Yacine=20q?= =?UTF-8?q?u'il=20doit=20restart=20agent=20sur=20sa=20Razer=20-=20Test=20l?= =?UTF-8?q?ive:=20dry=5Frun=20show=208+=20zombies=20tasks=20200+min=20age?= =?UTF-8?q?=20dispatched=20jamais=20completed=20-=20verdict=20BROKEN=20age?= =?UTF-8?q?nt=20stale=5Fhours=20>24=20-=20Solution=20long=20terme:=20Yacin?= =?UTF-8?q?e=20doit=20red=C3=A9marrer=20agent=20Python=20Windows=20sur=20s?= =?UTF-8?q?a=20Razer=20(doctrine=20limitation:=20S204=20ne=20peut=20pas=20?= =?UTF-8?q?restarter=20un=20processus=20Windows=20crashed)=20-=20Infra=20M?= =?UTF-8?q?CP=20blade=5Fexec=20+=20blade=5Fchrome=5Fcdp=20tools=20tous=20d?= =?UTF-8?q?efined=20v1.1.0=2017=20tools=20pr=C3=AAts=20mais=20UNUSABLE=20j?= =?UTF-8?q?usqu'=C3=A0=20red=C3=A9marrage=20agent=20-=20Wiki=20V36=20DOCTR?= =?UTF-8?q?INE-BLADE-IA-REMOTE=20doit=20noter=20cette=20limitation=20-=20N?= =?UTF-8?q?onReg=20153/153=20stable=2050eme=20session=20-=20Services=2023/?= =?UTF-8?q?23=20UP=20-=20L99=20201/201=206sigma=20-=20Alerts=20now=203=20w?= =?UTF-8?q?arning=20(ajout=20blade-agent-exec)=20-=20Office=20APP=20hub=20?= =?UTF-8?q?6403=20accounts=20pr=C3=AAt=20=C3=A0=20piloter=20via=20Blade=20?= =?UTF-8?q?d=C3=A8s=20que=20agent=20OK=20-=20Doctrine=204=20HONNETE=20gap?= =?UTF-8?q?=20brutal=20expos=C3=A9=20doctrine=205=20sequence=20auto-heal?= =?UTF-8?q?=20doctrine=207=20zero=20manuel=20c=C3=B4t=C3=A9=20serveur=20se?= =?UTF-8?q?ulement=20doctrine=2013=20cause=20racine=20agent=20Windows=20pa?= =?UTF-8?q?s=20S204=20doctrine=2014=20additif=20blade-tasks-cleanup.php=20?= =?UTF-8?q?nouveau=20[Opus=20V37=20blade-autoheal-honest-diag]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/blade-tasks-cleanup.php | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 api/blade-tasks-cleanup.php diff --git a/api/blade-tasks-cleanup.php b/api/blade-tasks-cleanup.php new file mode 100644 index 000000000..7e9fc3e2c --- /dev/null +++ b/api/blade-tasks-cleanup.php @@ -0,0 +1,63 @@ + 10min = zombies +// Doctrine #4 HONNETE + #13 cause racine + #7 zero manuel +header("Content-Type: application/json"); + +$TASKS_DIR = "/var/www/html/api/blade-tasks"; +$TIMEOUT_MINUTES = (int)($_GET["timeout_min"] ?? 10); +$DRY = isset($_GET["dry"]); + +$now = time(); +$cutoff = $now - ($TIMEOUT_MINUTES * 60); +$results = ["timed_out" => [], "kept" => 0, "failed_marked" => 0]; + +foreach (glob($TASKS_DIR . "/task_*.json") as $tf) { + $td = @json_decode(file_get_contents($tf), true); + if (!$td) continue; + if (($td["status"] ?? "") !== "dispatched") { $results["kept"]++; continue; } + + $disp = $td["dispatched_at"] ?? $td["created"] ?? ""; + $t = $disp ? strtotime($disp) : 0; + if (!$t || $t > $cutoff) { $results["kept"]++; continue; } + + $results["timed_out"][] = [ + "id" => $td["id"] ?? basename($tf), + "dispatched_at" => $disp, + "age_min" => round(($now - $t) / 60, 1), + "label" => $td["label"] ?? "?" + ]; + + if (!$DRY) { + $td["status"] = "failed_timeout"; + $td["failed_at"] = date("c"); + $td["error"] = "Agent Blade did not callback task_done within {$TIMEOUT_MINUTES}min"; + file_put_contents($tf, json_encode($td, JSON_PRETTY_PRINT)); + $results["failed_marked"]++; + } +} + +// Summary + agent health assessment +$last_done = 0; +foreach (glob($TASKS_DIR . "/task_*.json") as $tf) { + $td = @json_decode(file_get_contents($tf), true); + if (($td["status"] ?? "") === "done") { + $c = strtotime($td["completed_at"] ?? "1970-01-01"); + if ($c > $last_done) $last_done = $c; + } +} +$agent_stale_hours = $last_done ? round(($now - $last_done) / 3600, 1) : 9999; + +echo json_encode([ + "ok" => true, + "v" => "V37-blade-autoheal", + "ts" => date("c"), + "dry_run" => $DRY, + "timeout_minutes" => $TIMEOUT_MINUTES, + "stats" => $results, + "agent_health" => [ + "last_done_ts" => $last_done ? date("c", $last_done) : null, + "stale_hours" => $agent_stale_hours, + "agent_execution_ok" => $agent_stale_hours < 1, + "verdict" => $agent_stale_hours < 1 ? "HEALTHY" : ($agent_stale_hours < 24 ? "DEGRADED" : "BROKEN") + ] +], JSON_PRETTY_PRINT);