Pulse/internal
rcourtman dcd5f52684 feat: improve alert system performance, UX, and edge case handling
Implement 5 medium/low priority improvements identified in systematic review:

UX IMPROVEMENTS:
- Notify existing critical alerts when activating from pending_review state
  Previously: critical alerts during observation window would never notify
  Now: users receive notifications for active critical alerts after activation
  Implementation: Added NotifyExistingAlert() method and logic in ActivateAlerts()

PERFORMANCE OPTIMIZATIONS:
- Replace per-alert cleanup goroutines with periodic batch cleanup
  Prevents spawning 1000s of goroutines during alert flapping
  recentlyResolved entries now cleaned up once per minute instead of 1 goroutine per alert
- Simplify GetActiveAlerts() implementation
  Removed intermediate map copy, holds lock slightly longer but operation is fast
  Cleaner code with reduced memory allocation

CONFIGURATION VALIDATION:
- Validate timezone in quiet hours configuration
  Invalid timezones now disable quiet hours with error log instead of silent fallback
  Prevents unexpected behavior when timezone is typo'd or invalid

GRACEFUL SHUTDOWN:
- Add 100ms delay in Stop() for background goroutine cleanup
  Reduces risk of state corruption during shutdown
  Allows escalation checker and periodic save to exit cleanly

Technical details:
- internal/alerts/alerts.go: Added NotifyExistingAlert(), optimized cleanup patterns
- internal/api/alerts.go: Enhanced ActivateAlerts() to notify existing critical alerts
- Removed ~20 lines of goroutine spawning code
- Added periodic cleanup for recentlyResolved map
- All changes preserve backward compatibility

Testing: Verified compilation with 'go build -o /dev/null ./...'
2025-10-21 11:05:45 +00:00
..
adapters feat: add complete Proxmox Mail Gateway (PMG) monitoring support 2025-10-10 14:30:51 +00:00
alerts feat: improve alert system performance, UX, and edge case handling 2025-10-21 11:05:45 +00:00
api feat: improve alert system performance, UX, and edge case handling 2025-10-21 11:05:45 +00:00
auth chore: tidy repo formatting and linting 2025-09-29 20:19:18 +00:00
config feat: improve discovery with progress tracking, validation, and structured errors 2025-10-20 22:29:30 +00:00
crypto fix: prevent catastrophic data loss from encryption key regeneration 2025-10-01 18:52:10 +00:00
discovery feat: improve discovery with progress tracking, validation, and structured errors 2025-10-20 22:29:30 +00:00
dockeragent Docker agent: add arch-aware self-update download 2025-10-16 08:43:59 +00:00
errors chore: tidy repo formatting and linting 2025-09-29 20:19:18 +00:00
interfaces feat: add complete Proxmox Mail Gateway (PMG) monitoring support 2025-10-10 14:30:51 +00:00
logging feat: add professional logging with runtime configuration and performance optimization 2025-10-20 15:13:38 +00:00
mock Adjust backup and snapshot alert handling 2025-10-18 20:11:01 +00:00
models Adjust backup and snapshot alert handling 2025-10-18 20:11:01 +00:00
monitoring feat: enhance runtime configuration and system settings management 2025-10-20 17:41:19 +00:00
notifications security: complete Phase 1 sensor proxy hardening 2025-10-20 15:13:37 +00:00
ssh/knownhosts security: complete Phase 1 sensor proxy hardening 2025-10-20 15:13:37 +00:00
tempproxy security: add resilience and error handling to tempproxy client 2025-10-19 16:37:11 +00:00
types chore: tidy repo formatting and linting 2025-09-29 20:19:18 +00:00
updates fix: skip update check for source builds and show appropriate UI message 2025-10-21 10:08:00 +00:00
utils perf: optimize mock mode state retrieval and JSON encoding 2025-10-01 13:35:49 +00:00
websocket refactor: use strconv.Itoa instead of string(rune()) in test 2025-10-20 15:12:14 +00:00