Repository navigation
Phase 3: hang detection and events - #9
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The hub watches every machine with a KVM every 30 s (helper status, its port, an ICMP ping over Tailscale, three power-light readings) and tells a hung machine from one that's booting, shutting down, installing updates, asleep or missing its helper. Hung needs 3 minutes (2 to 30, owner setting) of silence with a wired light steadily on and nothing to excuse it. - Helpers tell their hubs before sleep, shutdown and restart and after a wake (POST /v2/note): Windows through PowerRegisterSuspendResumeNotification and the service's pre-shutdown notice, Linux when systemd is stopping. - Windows helpers report their sleep facts (S3, Modern Standby, idle timeout on AC); the hub learns what the light does while asleep. - State changes are events: GET /v2/machines/events (SSE with replay and heartbeats), and owner webhooks signed with HMAC-SHA256, with retries. - GET /v2/machines gains hung, reason, since and evidence. - App: a frozen computer says so on its page, with what the hub saw, and the phone notifies about frozen and recovered machines. - docs/protocol.md: Machine states and events. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3 of the recovery layer plan: the hub tells a hung machine apart from one that's booting, asleep, installing updates or just missing its helper, says why, and tells whoever listens.
What changes
Hub watch (every 30 s per machine with a KVM): evidence gathered in parallel, 8 s at most:
tailscale ping --icmp, three power-light readings 0.5 s apart (on / off / blinking / unreadable), Tailscale's online flag (shown only).machines.Track.Step) turns the history intoon,off,hungorunknown+reason. Hung = 3 min (owner setting 2–30) of silence, port not refusing, no ping reply, a wired light steadily on, and no excuse: booting (10 min after a hub action or the light coming on), a shutdown/restart note or countdown (10 min; 90 with Windows updates pending →updating), or possibly asleep. No helper or an untrusted light is never hung.Notes from helpers (
POST /v2/note, peer keys only, machine taken from the caller's address): Windows sendssleep/resumefromPowerRegisterSuspendResumeNotification(a callback Windows waits for) andshutdown/restartfrom the service's pre-shutdown notice; Linux sendsshutdownwhen systemd is stopping. Windows helpers also reportsleepfacts (S3, Modern Standby, idle timeout on AC). After a sleep note the hub learns what the light does asleep.Events:
GET /v2/machines/events: SSE, snapshot orLast-Event-IDreplay (last 500), 25 s heartbeat, a per-write deadline so the server's 150 s write timeout doesn't end it, 16 streams max, filtered likeGET /v2/machines.timestamp.body; retries at 10 s, 1 min, 5 min; no redirects.hung/recoveredalso go to the activity log; the phone now notifies about them.App: the device page says Frozen since … and shows what the hub saw; starting up, installing updates and may-be-asleep show as such.
Docs:
docs/protocol.md"Machine states and events" (with a signature known-answer), plan text brought in line with what was built, CHANGELOG 2.3.0.Tests
hungAfterMinutesvalidation.fleet.Tellreaches every keyed peer and gives up on a slow one in 1.5 s.A real sleep, shutdown and hang on hardware is for the hardware checklist (phase 5).
🤖 Generated with Claude Code