fix(disk-health): one physical disk must be evaluated once per run (R-335)
gates / gates (push) Successful in 9s

Found on live hardware two hours after the v0.215.0 deploy, by noticing the
release's own positive observable disagreed with its own persisted artefact:
the check logged '3 disk(s) evaluated' while disk-health-state.json held two
records. demo-hp's c11-scratch and felhom-backup are the same NVMe and share
a durable id, so one disk was walked twice per run.

Not cosmetic. The loop writes a disk's record before the next entry reads it,
so the second copy of an aliased disk consumed the FIRST copy's write as its
prior: the disk sustained against ITSELF and reached Hiba on a first sighting,
defeating truth-table row 6 — the rule that separates a one-hour benign
excursion from a false critical. It would also have emitted two identical
events for one drive. Latent on demo-hp only because all counters are zero.

Each diskKey is now evaluated once per run. Both entries stay marked seen so
neither looks like a disappeared disk, and the card still renders both rows —
the dedup is about state and alerts, not display.

Red-proof run and reverted: deleting the guard makes the first sighting emit
Kind:2 (Hiba-from-sectors) at 8 sectors.
This commit is contained in:
2026-08-14 10:30:22 +02:00
parent 8144a70a72
commit 90f2545679
3 changed files with 102 additions and 0 deletions
+15
View File
@@ -201,6 +201,21 @@ func (s *Server) RunDiskHealthCheck(ctx context.Context) error {
continue
}
key := diskKey(d)
// ONE physical disk can appear as SEVERAL storage entries — on demo-hp the same NVMe is both
// `c11-scratch` and `felhom-backup`, and both resolve to the same durable id. They must be
// evaluated ONCE per run, for two reasons:
//
// 1. Correctness. The loop writes this run's record before the next entry reads it, so the
// second copy of the same disk would consume the FIRST copy's write as its prior — i.e.
// the disk would sustain against itself and reach Hiba on a FIRST sighting, defeating the
// entire sustain rule (truth-table row 6).
// 2. One disk, one alert. Two entries would otherwise emit two identical events.
//
// Found on live hardware after the v0.215.0 deploy: the check logged "3 disk(s) evaluated"
// while the persisted state held two records. Pinned by TestDiskCheck_SameDiskTwiceIsEvaluatedOnce.
if seen[key] {
continue
}
seen[key] = true
prev := s.diskHealth.records[key]
prior := s.priorFor(key)