Files
openclaw/docs/jarvis-smart-alert-2026-02-17.md
Clawd Bot ca9b510922 chore: align with upstream openclaw/openclaw and overlay local additions
- Reset master to upstream/main (16,697 commits)
- Overlay 2,271 local-only files (skills, tools, workspace, configs, apps)
- Restore IDENTITY.md and USER.md templates
- Build verified, gateway running, Discord working

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 07:40:46 +01:00

4.7 KiB

JARVIS Smart Alert System (Anti-Spam)

Date: 2026-02-17 Status: ACTIVE

Problem

Notifications spamming even when issue persists (same error every hour).

Solution

Smart Alert with Deduplication:

  • Track alert timestamps per issue type
  • Only alert if >1 hour since last alert
  • Defer duplicates to daily summary (prevent spam)

Logic Flow

Problem detected
    ↓
Auto-fix attempt
    ↓
Fixed?
├─ YES → Log to silent-fixes.log ✅ (no alert)
└─ NO  → Check last alert time
          ├─ Never alerted OR >1h ago → Alert now ❌
          └─ <1h ago → Defer to pending.log ⏰

Implementation

1. Smart Alert System (jarvis-smart-alert.sh)

  • Tracks alert timestamps in .jarvis-state/
  • Functions:
    • should_alert(issue_key) → true if >1h since last
    • alert_critical(issue_key, msg) → alert or defer
    • defer_to_tomorrow(msg) → batch for summary

2. Updated Health Check

  • Uses smart alert functions
  • Auto-fixes silently when possible
  • Smart alerts only when cannot fix

3. Daily Summary (20:00)

  • Shows critical issues (alerted today)
  • Shows deferred issues (spam prevented)
  • Clears pending log for next day
  • Auto-cleans old state (>7 days)

Examples

Example 1: Transient Issue (Auto-Fixed)

10:00 Gateway crash → restart ✅ (silent)
10:30 Gateway crash → restart ✅ (silent)
11:00 Gateway crash → restart ✅ (silent)

User notification: NONE
Logs: 3 entries in silent-fixes.log

Example 2: Persistent Issue (Cannot Fix)

14:00 Gateway crash → cannot fix → ALERT ❌
14:30 Still down → cannot fix → defer ⏰ (spam prevented)
15:00 Still down → cannot fix → defer ⏰
15:30 Still down → cannot fix → defer ⏰
15:45 Manual fix applied → back online

User notifications:
- 14:00: "Gateway CANNOT be auto-fixed" (immediate)
- 20:00: Daily summary shows 1 alert + 3 deferred

Prevented spam: 3 duplicate notifications

Example 3: External Service Down

12:00 MariaDB unreachable → ALERT ❌ (cannot restart external)
12:30 Still unreachable → defer ⏰
13:00 Still unreachable → defer ⏰
13:30 Still unreachable → defer ⏰
14:00 Still unreachable → defer ⏰
14:05 Back online (Synology rebooted) → silence

Immediate alerts: 1 (at 12:00)
Deferred: 4 (prevented spam)
Daily summary (20:00): Shows all 5 occurrences for visibility

State Files

# Alert state directory
/home/alex/clawd/.jarvis-state/

# Files (one per issue type)
gateway_down.last-alert          # timestamp of last gateway alert
kanban_down.last-alert           # timestamp of last kanban alert
mariadb_synology_down.last-alert # timestamp of last DB alert

# Auto-cleaned after 7 days

Logs

File Purpose When Written
jarvis-silent-fixes.log Auto-fixed issues Every successful fix
jarvis-critical.log Immediate alerts First occurrence or >1h
jarvis-pending-tomorrow.log Deferred alerts Duplicates <1h

Benefits

Before After
Same error every hour → spam Same error every hour → 1 alert + deferred
No visibility on spam prevention Daily summary shows what was deferred
Persistent issues = notification hell Persistent issues = 1 alert + batch summary

Verification

# Simulate persistent issue (run twice)
source /home/alex/clawd/tools/jarvis-smart-alert.sh
alert_critical "test_issue" "Test error"  # Should alert
sleep 2
alert_critical "test_issue" "Test error"  # Should defer

# Check results
tail -1 /home/alex/clawd/logs/jarvis-critical.log   # Shows first alert
tail -1 /home/alex/clawd/logs/jarvis-pending-tomorrow.log  # Shows deferred

Cron Integration

# Health check (every hour, silent, smart alerts)
0 * * * * jarvis-health-check.sh >/dev/null 2>&1

# Daily summary (20:00, includes deferred)
0 20 * * * jarvis-daily-summary.sh

Spam Prevention Statistics

Example Day:

  • Gateway crashes: 8 times
  • Kanban hangs: 3 times
  • MariaDB unreachable: 5 times

Without Smart Alerts:

  • 16 notifications total

With Smart Alerts:

  • 3 immediate notifications (first occurrence each)
  • 13 deferred to summary
  • 81% spam reduction

What User Sees

Normal Day:

  • Nothing (all auto-fixed)

Day with Persistent Issue:

  • 1 immediate alert (first occurrence)
  • Daily summary at 20:00 showing all occurrences + deferred count

No More Spam! 🎉