From 5632138cc33669d7c25ae992aadc94baa1ce5271 Mon Sep 17 00:00:00 2001 From: openhands Date: Thu, 19 Mar 2026 09:16:56 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20bug:=20supervisor=20never=20delivers=20d?= =?UTF-8?q?isk=20alerts=20=E2=80=94=20crashes=20during=20PR=20scan=20(#252?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Send P0 and P1 alerts to Matrix immediately after detection, before per-project checks run. Also guard check_project calls with || flog so any API timeout or jq parse failure inside the per-project scan cannot kill the script before alert delivery. Co-Authored-By: Claude Sonnet 4.6 --- supervisor/supervisor-poll.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/supervisor/supervisor-poll.sh b/supervisor/supervisor-poll.sh index 5bc94c2..46a8fa2 100755 --- a/supervisor/supervisor-poll.sh +++ b/supervisor/supervisor-poll.sh @@ -141,6 +141,12 @@ if [ "${AVAIL_MB:-9999}" -lt 500 ] || { [ "${SWAP_USED_MB:-0}" -gt 3000 ] && [ " fi fi +# P0 is urgent — send immediately before per-project checks can crash the script +if [ -n "$P0_ALERTS" ]; then + matrix_send "supervisor" "🚨 Supervisor P0 alerts: +$(printf '%b' "$P0_ALERTS")" 2>/dev/null || true +fi + # ============================================================================= # P1: DISK # ============================================================================= @@ -184,6 +190,12 @@ if [ "${DISK_PERCENT:-0}" -gt 80 ]; then fi fi +# P1 is urgent — send immediately before per-project checks can crash the script +if [ -n "$P1_ALERTS" ]; then + matrix_send "supervisor" "⚠️ Supervisor P1 alerts: +$(printf '%b' "$P1_ALERTS")" 2>/dev/null || true +fi + # Emit infra metric _RAM_TOTAL_MB=$(free -m | awk '/Mem:/{print $2}') _RAM_USED_PCT=$(( ${_RAM_TOTAL_MB:-0} > 0 ? (${_RAM_TOTAL_MB:-0} - ${AVAIL_MB:-0}) * 100 / ${_RAM_TOTAL_MB:-1} : 0 )) @@ -963,14 +975,14 @@ if [ -d "$PROJECTS_DIR" ]; then # Load project config (overrides CODEBERG_REPO, PROJECT_REPO_ROOT, etc.) source "${FACTORY_ROOT}/lib/load-project.sh" "$project_toml" - check_project + check_project || flog "check_project failed for ${project_toml} (per-project checks incomplete)" done fi if [ "$PROJECT_COUNT" -eq 0 ]; then # Fallback: no project TOML files, use .env config (backwards compatible) flog "No projects/*.toml found, using .env defaults" - check_project + check_project || flog "check_project failed with .env defaults (per-project checks incomplete)" fi # #############################################################################