Flag hosts whose reported hostname differs from their registered name #13

Merged
patrick merged 2 commits from feat/hostname-mismatch into main 2026-10-30 01:22:28 +00:00
Owner

Summary

Agents already report their own hostname, and the host page shows it, but
nothing compared it with the name the host is registered under. A token copied
to the wrong machine would report happily under the wrong identity with no
visible sign.

When the two differ, the dashboard row and host page now show a note:
"registered as web01 but reports itself as db01.example.internal; token on the
wrong machine?"

  • A note only: it never changes a host's status or the fleet counts.
  • Only the first DNS label is compared, ignoring case. Registered names are
    usually hostname -s (deploy.sh) while the agent reports hostname -f.
  • evaluate() takes an optional host. Alerts and history rows don't pass it,
    so ntfy messages and the history table are unchanged.
  • Reported names are HTML-escaped.

Known limitation

Hosts registered under a custom label via agent/hosts (<ssh target> <name>)
will always show the note. The README says so and suggests registering under
hostname -s.

Testing

make test: 115 tests pass (3 new): note without level change, lenient matching
(FQDN vs short, case, no reported name, no registered name), and rendering on
the dashboard and host page with HTML escaping.

🤖 Generated with Claude Code

## Summary Agents already report their own hostname, and the host page shows it, but nothing compared it with the name the host is registered under. A token copied to the wrong machine would report happily under the wrong identity with no visible sign. When the two differ, the dashboard row and host page now show a note: "registered as web01 but reports itself as db01.example.internal; token on the wrong machine?" - A note only: it never changes a host's status or the fleet counts. - Only the first DNS label is compared, ignoring case. Registered names are usually `hostname -s` (deploy.sh) while the agent reports `hostname -f`. - `evaluate()` takes an optional `host`. Alerts and history rows don't pass it, so ntfy messages and the history table are unchanged. - Reported names are HTML-escaped. ## Known limitation Hosts registered under a custom label via `agent/hosts` (`<ssh target> <name>`) will always show the note. The README says so and suggests registering under `hostname -s`. ## Testing `make test`: 115 tests pass (3 new): note without level change, lenient matching (FQDN vs short, case, no reported name, no registered name), and rendering on the dashboard and host page with HTML escaping. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 2 commits 2026-10-30 01:18:30 +00:00
A note on the dashboard row and host page, not a status change, so a token
copied to the wrong machine is visible. Only the first DNS label is compared,
ignoring case, since registered names are usually hostname -s and the agent
reports hostname -f.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Document hostname check
CI / tests (Python 3.10) (pull_request) Successful in 20s
CI / tests (Python 3.11) (pull_request) Successful in 20s
CI / tests (Python 3.12) (pull_request) Successful in 20s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 2s
201a1c5f4b
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
patrick merged commit 40bfdc3236 into main 2026-10-30 01:22:28 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#13