feat(health): report permanently rejected site audit rows on the site health report (ScadaBridge#69)

SiteAuditBacklogSnapshot gains an optional trailing RejectedCount (gauge of
Rejected forward-state rows, read from the site store), carried on the wire as
SiteAuditBacklogSnapshotDto.rejected_count = 4 (additive; old sites read as 0,
old central ignores it). Health page shows an 'Audit rows rejected' badge.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 12:46:34 -05:00
parent 3ae3f1bcef
commit 0eac956d25
10 changed files with 263 additions and 100 deletions
@@ -466,6 +466,38 @@ public class CentralControlDtoMapperTests
Assert.Equal(0d, roundTripped.ScriptOldestBusyAgeSeconds);
}
/// <summary>Verifies that the backlog's rejected-row count survives the wire round trip (Gitea #69).</summary>
[Fact]
public void SiteHealthReport_RoundTrip_BacklogRejectedCount_Survives()
{
var original = FullyPopulatedHealthReport() with
{
SiteAuditBacklog = new SiteAuditBacklogSnapshot(5, null, 4096, RejectedCount: 3),
};
var roundTripped = CentralControlDtoMapper.FromDto(Wire(CentralControlDtoMapper.ToDto(original)));
Assert.Equal(3, roundTripped.SiteAuditBacklog!.RejectedCount);
}
/// <summary>
/// Backward compatibility: a backlog DTO from a pre-#69 site (no rejected_count field on the wire)
/// decodes to RejectedCount 0.
/// </summary>
[Fact]
public void SiteHealthReport_FromDto_BacklogWithoutRejectedCount_DefaultsToZero()
{
var dto = CentralControlDtoMapper.ToDto(FullyPopulatedHealthReport() with
{
SiteAuditBacklog = new SiteAuditBacklogSnapshot(5, null, 4096),
});
dto.SiteAuditBacklog.RejectedCount = 0; // proto3 default == field absent on the wire
var roundTripped = CentralControlDtoMapper.FromDto(Wire(dto));
Assert.Equal(0, roundTripped.SiteAuditBacklog!.RejectedCount);
}
/// <summary>Verifies that a backlog report with an empty queue keeps a null oldest-pending value.</summary>
[Fact]
public void SiteHealthReport_RoundTrip_BacklogWithEmptyQueue_KeepsNullOldestPending()