Review fixes: demo fans, record averages and restarts, combined alerts, quiet sensors

- demo.py: FakeBoard grows rpms(). The top fans' stall check (b2da221) called
  it, so under --demo every poll raised AttributeError and the case fans sat
  in CONTROL ERROR at 100%.
- control.py: TopFanCurve.update hands the headers back to the BIOS on any
  failure, a bug included, instead of letting it escape into the case fans'
  loop (unexpected errors are logged with a traceback once). The worker's
  catch-all now fails the top fans safe as well as the case fans, as the
  device-error path already did. The snapshot gives None for a channel whose
  tach has never turned, and the UI says "no tach reading" (and "Channel",
  not "Port") rather than showing SYS_FAN1's unwired tach as a dead fan.
- record.py: an hour's average is over the samples that carried the metric,
  not all of them: a GPU that dropped out for half an hour no longer halves
  its recorded power. Lines carry the count as a fourth number; the reader
  weights by it, and treats three-number lines as before.
- record.py: the hour in progress is checkpointed to records-current.json
  every minute and on close and resumed at start, so a hard stop (schtasks
  /End, the documented restart) loses at most a minute instead of the hour;
  a checkpoint from an earlier hour is written out at start. A failing write
  no longer stops recording for the run: it is logged at most once an hour
  and finished hours wait in memory (up to 48) until the disk works.
- app.py: alerts that start together share one balloon (Windows shows one at
  a time, so each notify() replaced the last), shortened to fit 255
  characters; a problem that clears and comes back balloons again only after
  10 minutes.
- telemetry/service.py: health also counts a source that returns no
  temperature three reads running. GpuSensors and CpuSensors don't raise
  when their device is lost, so a lost GPU driver used to show as healthy.
- hid.py: buffers of IRPs the driver never finished cancelling are kept for
  the life of the process; freeing them with their channel could still let a
  late completion write into reused memory.
- Tests: 13 new (160 pass). README updated to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
paulandClaude Opus 5.5 committed 2026-12-05 18:31:11 +13:00
1 parent 8cc1e9223f
commit b983528183
12 files changed
+394 -73

No files matched your search

+9 -5
View File
@@ -54,10 +54,12 @@ Open it from the tray icon (left-click, or **Open The Kurgan** in its menu) or b
<http://127.0.0.1:8080/>. It only listens on 127.0.0.1. The page refreshes once a second while it
is visible. Every chart has a **Table** button that shows the same numbers as a table. The tray
icon also pops a balloon tip when something starts to go wrong — a fan group entering failsafe,
an AI server reporting an error, or a sensor source starting to fail. What is already wrong when
The Kurgan starts is not ballooned; it sits in the tray menu and the UI.
an AI server reporting an error, or a sensor source starting to fail. Problems that start together
share one balloon (Windows shows one at a time), and a problem that clears and comes back
balloons again only after 10 minutes. What is already wrong when The Kurgan starts is not
ballooned; it sits in the tray menu and the UI.
- **System**: CPU and GPU temperature, load, clock and power; GPU memory; the LCD's state. Charts show whole-PC power (stacked: other, CPU, GPU) and temperatures over the last 10 minutes. A range selector above the charts switches them to hourly averages for 24 hours, 7 days, 30 days or a year. Those long-term rollups live in `%LOCALAPPDATA%\Kurgan\records-YYYY-MM.jsonl` — one JSON line per hour, about 400 days kept, written best effort (a failing disk stops recording and nothing else notices; `--demo` never records). When a sensor source's last read failed — a disconnected Commander PRO, a busy NVML — a pill in the header names it and hover shows the error.
- **System**: CPU and GPU temperature, load, clock and power; GPU memory; the LCD's state. Charts show whole-PC power (stacked: other, CPU, GPU) and temperatures over the last 10 minutes. A range selector above the charts switches them to hourly averages for 24 hours, 7 days, 30 days or a year. Those long-term rollups live in `%LOCALAPPDATA%\Kurgan\records-YYYY-MM.jsonl` — one JSON line per hour with min, average and max per metric (the average only over the samples that had the metric), about 400 days kept. The hour in progress is checkpointed to `records-current.json` every minute and on exit and resumed at the next start, so a restart — even `schtasks /End` — loses at most a minute. Writing is best effort: a failing disk is logged at most once an hour, and finished hours wait in memory (up to two days) until it works again. `--demo` never records. When a sensor source is failing — its read raised, or it has returned no temperature three times in a row (a lost GPU driver, an unavailable MSR reader) — a pill in the header names it and hover shows the error.
- **Cooling**: the fan profile selector; each fan group's duty, temperature and RPMs; fan speeds over time; and the selected profile's curves, with a dot for each group's current operating point. Hover over a profile to preview its curves.
- **Lighting**: a mode selector per zone (case fans, RAM, GPU), the zone's status, and the shared chase speed.
- **AI**: pick Strata (and its model), llama.cpp or None; requests to either address also pick it. Then see the server's process, model, context size, live request progress and token speeds, and when it will stop if unused; load or unload the model; GPU memory over time; and recent requests.
@@ -69,7 +71,7 @@ next start.
| Request | Body / result |
| --- | --- |
| `GET /api/state` | Everything live (what the UI polls), including `telemetry.health`: the sensor sources whose latest read failed, each with its error and age |
| `GET /api/state` | Everything live (what the UI polls), including `telemetry.health`: the sensor sources that are failing (latest read raised, or no temperature three reads running), each with its error and age |
| `GET /api/history` | The last 10 minutes of telemetry and fan duty |
| `GET /api/records?days=N` | Hourly min/avg/max rollups for the last N days (1-400), oldest first |
| `GET /api/config` | Fan profiles and LCD theme thresholds |
@@ -263,7 +265,9 @@ last duty. If a top-fan write fails, The Kurgan hands those headers back to the
once; if even that fails, the UI says what duty they are left at. Verify temperatures and fan
rotation under your real workloads. Only SYS_FAN4's tach is wired to the EC, so top-fan stall
detection covers that fan only: a channel whose tach has never been seen turning is left alone
rather than crying wolf.
rather than crying wolf, and the UI shows "no tach reading" for it instead of 0 rpm. If the
top-fan code fails in any unexpected way, those headers go back to the BIOS curve and the case
fans carry on; if the case fans' control loop itself hits an unexpected error, all fans go to 100%.
## Lighting