Files
werkator/docs/prs/2026-10-03-PR#101-tile-levels.md
miandmhoennig edaa07a6cc
werkator build succeeded after 01:47
werkator/deploy build succeeded after 00:06
Tiles take the verdict's colours, builds tile judges free slots (v1.32.0) (#101)
- Load, CPU pressure, RAM pressure and swap tiles (System page and home rail) are amber/red exactly when the verdict names them; `SystemHealth` rules are now functions both use.
- Builds tile reads `1 of 2 running`: amber with one slot free, red with none (with one slot amber even when idle).
- `GET /api/system` carries `maxConcurrent` (slots in force).
- Disk pressure stays uncoloured (RFC 0004).

PR-doc: `docs/prs/2026-10-03-PR#101-tile-levels.md`

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: mhoennig <michael@hoennig.de>
Reviewed-on: #101
2026-10-03 19:53:17 +02:00

71 lines
3.3 KiB
Markdown

> **WARNING:** This document describes only the change applied in this PR.
> It may already be outdated once the next PR is merged.
> Historic PR-documentation is not maintained along with new PRs — treat it as a snapshot, not as current documentation.
## The Problem
The System page and the home page colour the gauges, and since PR#100 the swap tile.
The other tiles stayed plain: load, CPU pressure, RAM pressure, and the builds tile.
The verdict above them could say "under pressure" because of the load, and no tile showed which one it meant.
The builds tile said how many builds ran, not how many could, so a full executor looked like an idle one.
## Non-Goals
- No new thresholds and no configuration: the tiles take the verdict's rules, which are not host-dependent.
- Disk pressure stays uncoloured: RFC 0004 collects it without judging it, because on a shared host it measures the neighbours first.
## The Scenarios
### Feature: The tiles take the verdict's colours
#### Scenario#101.01: Load and pressure tiles are coloured by the verdict's own rules
So that a tile is amber or red exactly when the verdict names it.
- **Given** snapshots on the calm side of every threshold, at the pressure thresholds, and at the overload thresholds
- **When** the System page and the home rail render them
- **Then** the tiles are calm, amber (load above the threads, CPU pressure from 20 %, RAM pressure from 2 %, swap at half its size), and red (load at twice the threads, RAM pressure from 10 %)
- **And** CPU pressure never turns red, and disk pressure never changes colour
##### Verified by
- [UiViewsUnitTest](../../src/test/kotlin/de/hoennig/werkator/server/UiViewsUnitTest.kt) — Scenario#101.01
#### Scenario#101.02: The builds tile is amber with one slot free and red with none
So that a full executor stands out, and a single slot reads as the tight setting it is.
- **Given** an executor with three slots, and one with a single slot
- **When** builds run
- **Then** the tile is amber with one slot free and red with none
- **And** with a single slot it is amber even while idle
- **And** it reads `2 of 2 running`
##### Verified by
- [UiViewsUnitTest](../../src/test/kotlin/de/hoennig/werkator/server/UiViewsUnitTest.kt) — Scenario#101.02
#### Scenario#101.03: The system endpoint carries the slots
So that `werkator.js` judges the polled builds tile like the server.
- **Given** an executor with two slots
- **When** `GET /api/system` is called
- **Then** it answers `maxConcurrent: 2`
##### Verified by
- [SystemApiControllerRestTest](../../src/test/kotlin/de/hoennig/werkator/server/SystemApiControllerRestTest.kt) — Scenario#101.03
## The Solution
- `SystemHealth` keeps its rules in `loadLevel`, `cpuPressureLevel`, `memoryPressureLevel` and `swapRatioLevel`; `assess` and the tiles both use them.
- `UiFormats.tileLevel` turns a level into the tile's class, `UiFormats.buildSlotsLevel` judges the free slots; `werkator.js` has the twins and the thresholds.
- `BuildExecutor.maxConcurrent` answers the slots in force — `executor.maxConcurrent` takes effect only with a restart — and the configured value before the first build.
- `GET /api/system` carries `maxConcurrent`; the builds tile reads `1 of 2 running`.
- `werkator.css` colours a `level-crit` tile red, like a `level-warn` tile amber.
## Additional Changes
- Version 1.32.0 with its release note.