feat: proper push monitor lifecycle — PENDING, LATE, DOWN #34

Merged
lerko merged 1 commits from feat/push-monitor-states into main 2026-05-28 00:01:57 +00:00
Owner

Summary

Push monitors no longer lie about status. Previously, newly created push monitors showed UP with 100% uptime before ever receiving a heartbeat.

State Machine (inspired by Healthchecks.io)

PENDING → (first heartbeat) → UP → (overdue) → LATE → (grace expires) → DOWN
                                ↑                                          |
                                +------ (heartbeat arrives) ---------------+

What changed

Engine:

  • PENDING stays until first heartbeat arrives (no auto-promote)
  • New LATE state when overdue but within grace period (amber, no alert)
  • Grace period = interval/2, minimum 60s (scales with check frequency)
  • DOWN only fires after grace expires (alert triggers here)
  • RecordHeartbeat handles PENDING→UP, LATE→UP, DOWN→UP transitions with appropriate logging and state change persistence

TUI:

  • LATE rendered in amber/warning color
  • Status bar: 11/14 UP 1 LATE
  • Tab badge: Sites (1⚠) for late monitors
  • Sort: DOWN > LATE > UP > PENDING > PAUSED
  • Error reason shown for LATE monitors in table + detail

Status page: LATE gets amber CSS (same as PENDING)

Files (5)

  • internal/monitor/monitor.go — checkPush rewrite, RecordHeartbeat enrichment
  • internal/monitor/monitor_test.go — updated + new test for LATE state
  • internal/tui/tab_sites.go — LATE in fmtStatus + inline error
  • internal/tui/tui.go — status bar + tab badge + sort order
  • internal/server/server.go — LATE CSS class
## Summary Push monitors no longer lie about status. Previously, newly created push monitors showed UP with 100% uptime before ever receiving a heartbeat. ### State Machine (inspired by Healthchecks.io) ``` PENDING → (first heartbeat) → UP → (overdue) → LATE → (grace expires) → DOWN ↑ | +------ (heartbeat arrives) ---------------+ ``` ### What changed **Engine:** - PENDING stays until first heartbeat arrives (no auto-promote) - New LATE state when overdue but within grace period (amber, no alert) - Grace period = interval/2, minimum 60s (scales with check frequency) - DOWN only fires after grace expires (alert triggers here) - RecordHeartbeat handles PENDING→UP, LATE→UP, DOWN→UP transitions with appropriate logging and state change persistence **TUI:** - LATE rendered in amber/warning color - Status bar: `11/14 UP 1 LATE` - Tab badge: `Sites (1⚠)` for late monitors - Sort: DOWN > LATE > UP > PENDING > PAUSED - Error reason shown for LATE monitors in table + detail **Status page:** LATE gets amber CSS (same as PENDING) ### Files (5) - `internal/monitor/monitor.go` — checkPush rewrite, RecordHeartbeat enrichment - `internal/monitor/monitor_test.go` — updated + new test for LATE state - `internal/tui/tab_sites.go` — LATE in fmtStatus + inline error - `internal/tui/tui.go` — status bar + tab badge + sort order - `internal/server/server.go` — LATE CSS class
lerko added 1 commit 2026-05-27 23:57:07 +00:00
feat: proper push monitor lifecycle — PENDING, LATE, DOWN states
CI / test (pull_request) Successful in 2m41s
CI / lint (pull_request) Successful in 1m7s
CI / vulncheck (pull_request) Successful in 46s
5dc31108f8
Push monitors no longer lie about status:

- PENDING stays until first heartbeat (no auto-promote to UP)
- LATE state (amber) when overdue but within grace period
- DOWN only after grace period expires
- Grace period = interval/2, minimum 60s

RecordHeartbeat now handles all transitions:
- PENDING → UP (first heartbeat, logged)
- LATE → UP (late arrival, logged)
- DOWN → UP (recovery, alert + state change persisted)

TUI updates:
- LATE rendered in amber/warning color
- Status bar shows LATE count separately
- Tab badge shows ⚠ for late monitors
- Sort order: DOWN > LATE > UP > PENDING > PAUSED
- Detail panel shows error for LATE monitors

Inspired by Healthchecks.io state machine (new/up/grace/down).
lerko merged commit a2b38ddc60 into main 2026-05-28 00:01:57 +00:00
lerko deleted branch feat/push-monitor-states 2026-05-28 00:01:57 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lerkolabs/uptop#34