feat(health): 24 h load history and a saturated state #74

Merged
maximus merged 4 commits from issue-73-load-history into main 2026-11-05 02:05:46 +00:00

4 commits

Author SHA1 Message Date
le king fu
6c29526ec0 test(health): pin the socket teardown, the unref and the tick guard
All checks were successful
CI / verification (pull_request) Successful in 59s
CI / verification (push) Successful in 1m2s
The review of #74 left three mutations green: socket.destroy() dropped
from probeTls(), timer.unref() dropped, and the in-flight guard removed.
Each now turns at least one case red: the stub socket must be destroyed
after a handshake, an error and a timeout; the sampler timer must not hold
a ref; two intervals over a slow tick give one probe round, not two.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:57:02 -05:00
le king fu
758b62ec47 test(health): pin that the TLS probes never run at request time
All checks were successful
CI / verification (pull_request) Successful in 1m0s
The review of #74 moved the probes into getHealth() and the suite stayed
green: every case ran with TLS_PROBE_HOSTS empty. This case sets two hosts,
stubs tls.connect (no network either way), and requires that GET /health
and GET /health/history open no TLS connection while a tick probes both.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:52:45 -05:00
le king fu
b740f221af feat(health): 24 h load history and a "saturated" state
All checks were successful
CI / verification (pull_request) Successful in 59s
GET /health only gave a snapshot, so the monitoring missed the 2026-11-03
saturation and the nights before it. A one-minute tick, armed in the
require.main block, now records host load, CPU by /proc/stat difference
and, when TLS_PROBE_HOSTS is set, the TLS handshake time of each listed
host into an in-memory buffer of 1440 samples (load-history.js, pure).

- /health gains `saturation` ({state: ok|saturated|unknown, since,
  coverageMinutes, load1, cores}) and `tls`, appended after the existing
  keys. Saturated = the last five samples of an unbroken series all have
  load1 > cores; unknown under five samples, after a gap over 3 minutes,
  or when the last sample is over 3 minutes old. No sample at start-up,
  so the state stays unknown for the first five minutes after a deploy.
- GET /health/history (read token) serves {since, coverageMinutes, cores,
  samples}. The buffer restarts from zero at every deploy.
- probeTls() verifies the certificate, times out after 3 s and reports an
  error code only. TLS_PROBE_HOSTS is empty by default: no network call in
  the tests, the CI or boot-from-copy.sh.
- Dockerfile COPY, REVIEW.md Haut table (and review-levels.py), CLAUDE.md,
  docs and .env.example updated.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:26:05 -05:00
le king fu
8c1b26d2c8 fix(ingest): announce Connection: close on a 413 before the socket is cut
readBody() writes the 413 and then destroys the request socket, without
telling the client. undici's keep-alive pool could send the next request
on that dying socket and get a transport error: writes.test.js failed this
way about one run in six once #73 added load to the suite. The header makes
the client drop the socket instead.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:25:54 -05:00