Skip to content

Report run mode and systemd lingering in the service health check - #86

Merged
JOsacky merged 1 commit into
mainfrom
mi/health-run-mode-linger
Nov 12, 2026
Merged

JOsacky merged 1 commit into
mainfrom
mi/health-run-mode-linger

Conversation

@JOsacky

@JOsacky JOsacky commented Nov 12, 2026

Copy link
Copy Markdown
Member

Why

Skillhook Cloud cannot tell why a first-value machine went offline. A closed terminal (foreground `skillhook serve`), a Linux logout with lingering off, and a deliberate stop all show up as the same `link.stopped`. This blocks attribution for two cases: the only external Linux machine (2c2b1258, stopped with SIGTERM twice even though the unit has `Restart=always`) and org aee7a873's macOS machine, which stopped 6 minutes after its first useful job. Ops backlog items: MI-020, MI-029 and PC-010.

What

  • `service.ts`: pure `parseLinger` and `runModeOf`, plus `lingerStatus()`, which runs `loginctl show-user --property=Linger --value`. The call is read-only and never uses sudo; any failure gives `unknown`.
  • `health.ts` service check: the details now carry `run_mode` (`service` when the answering server's pid is the launchd/systemd service pid, `foreground` otherwise, `unknown` with no server) and, for an installed systemd unit, `linger`.
    • A running systemd service with `linger: no` is now a `warn`, with the hint `loginctl enable-linger $USER`.
    • Under `serve`, the server's own pid is used, so the cloud health report carries these fields. No cloud or protocol change is needed: check details are loose records.
  • `service install` on Linux warns when lingering is off and skips the tip when it is on.
  • Docs row in `docs/operations.md` and a CHANGELOG entry.

Privacy

  • Only enum values are sent: no username, no paths.

Tests

  • New unit tests for `parseLinger` and `runModeOf`.
  • `tsc` is clean. `service.test.ts` and `health.test.ts` pass locally (20 of 20).
  • The first local health-test run timed out under a load average of about 465–700 on the operator Mac. The rerun passed, and CI runs the full suite.

Validation after release

  • On the operator Mac, the health tab shows `run_mode: service`.
  • A `skillhook serve` started in a terminal shows `foreground`.
  • The first Linux report shows `linger`.

🤖 Generated with Claude Code

The cloud could not tell why a machine went offline: a terminal that was
closed, a Linux logout with lingering off, or a deliberate stop all show
up as the same link.stopped. The service check's details now carry
run_mode (service | foreground | unknown) and, on systemd, linger
(yes | no | unknown, read-only via loginctl). Linger=no warns with the
enable-linger fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JOsacky
JOsacky merged commit b014676 into main Nov 12, 2026
6 checks passed
@JOsacky
JOsacky deleted the mi/health-run-mode-linger branch November 12, 2026 11:23
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