health alert: say when the host slept, not the poller failed (#90 item 9) - #94
Conversation
…m 9) On 2026-09-02 02:09 the alert fired on codexmb's poller while the MacBook had been in Maintenance Sleep for 921 s (pmset); the process was fine and the all-clear followed 32 s later. The alert now reads the gap shape: a stale heartbeat with an err log that has not grown since the heartbeat stopped means the host was suspended, and on macOS the last pmset sleep/wake line is quoted; a growing err log still quotes the last error. The script gained a main guard so tests can import its helpers without running it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1aca83882d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const slept = errLog && age !== Infinity && errLogQuietSince(errLog, heartbeat); | ||
| const sleepLine = slept ? lastSleepLine() : ''; | ||
| const shape = slept | ||
| ? `\nLooks like the host slept rather than the poller failing: the err log has not grown since the heartbeat stopped${sleepLine ? ` (pmset: ${sleepLine})` : ''}.` |
There was a problem hiding this comment.
Require evidence of sleep before reporting it
When the poller exits silently, is killed with SIGKILL, or hangs after its last heartbeat, the persistent stderr log also remains older than the heartbeat, so this condition reports that the host slept even though the poller actually failed. The independently running health check in scripts/codex-webhook-supervisor.sh passes exactly such a persistent log, and lastSleepLine() is only used to decorate the result rather than confirm a sleep event. Require a matching macOS sleep interval before selecting this message, or describe a quiet log without attributing the outage to sleep.
Useful? React with 👍 / 👎.
ThinkOffApp
left a comment
There was a problem hiding this comment.
Reviewed at 1aca838. No blocking findings. The new main guard keeps imports side-effect free, the host-slept classification is limited to a stale heartbeat with a quiet err log, and the macOS pmset lookup is bounded and non-fatal. The focused poller-health test passes 7/7 after installing dependencies; GitHub CI is green on Node 18, 20, and 22.
…indow (codex review of #94) A quiet err log also follows a silent exit or SIGKILL. The sleep claim now needs a pmset sleep/wake event timestamped after the heartbeat stopped (macOS); otherwise the alert stays neutral: exited silently, killed, or suspended, no OS sleep evidence found. Tests cover the window check and the neutral wording. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
P2 addressed in 9d0f533: the sleep claim now requires independent OS evidence — a |
|
Follow-up reviewed at 9d0f533. The P2 is addressed: the host-slept wording now requires independent pmset sleep/wake evidence in the stale-heartbeat window, and otherwise stays neutral. The isolated full test suite passes 297/297. No blocking findings. |
#90 item 9 (claudeMB's note from the 02:09 alert): the MacBook had been in Maintenance Sleep for 921 s (pmset), the poller was fine, and the alert read as a failure.
Change in
scripts/poller-health-alert.mjs: the down-alert classifies the gap shape — a stale heartbeat while the poller's err log has not grown since the heartbeat stopped means the host was suspended, and the alert says so ("Looks like the host slept rather than the poller failing…"), quoting the lastpmset -g logsleep/wake line on macOS; a growing err log still quotes the last error. The script gained a main guard (import.meta.urlcheck) so tests import its helpers without executing it.Tests: both shapes against a local HTTP stub (host-slept vs last-error), plus the helper unit test. Suite green.
Merge after #91 and #93 per the order in the room; no conflict with either (different file).
🤖 Generated with Claude Code