Skip to content

health alert: say when the host slept, not the poller failed (#90 item 9) - #94

Merged
ThinkOffApp merged 2 commits into
mainfrom
fix/alert-host-slept
Sep 2, 2026
Merged

health alert: say when the host slept, not the poller failed (#90 item 9)#94
ThinkOffApp merged 2 commits into
mainfrom
fix/alert-host-slept

Conversation

@ThinkOffApp

Copy link
Copy Markdown
Owner

#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 last pmset -g log sleep/wake line on macOS; a growing err log still quotes the last error. The script gained a main guard (import.meta.url check) 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

…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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T02:40:37.183943Z 1aca838 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread scripts/poller-health-alert.mjs Outdated
Comment on lines +101 to +104
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})` : ''}.`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 ThinkOffApp left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@ThinkOffApp

Copy link
Copy Markdown
Owner Author

P2 addressed in 9d0f533: the sleep claim now requires independent OS evidence — a pmset -g log sleep/wake event timestamped inside the stale window (macOS); without it the alert says the process exited silently, was killed, or the host was suspended, with no sleep evidence found. Tests: window check (inside counts, older does not) and the neutral wording path.

@ThinkOffApp

Copy link
Copy Markdown
Owner Author

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.

@ThinkOffApp
ThinkOffApp merged commit 532b946 into main Sep 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant