Preserve health during empty-server monitoring handoff (Refs #148)

This commit is contained in:
2026-10-12 19:02:54 -04:00
parent 2f52dcb1ef
commit f91ec4d152
6 changed files with 224 additions and 6 deletions
+16 -2
View File
@@ -132,8 +132,22 @@ export async function observeRun(run: TestRun, plan: BetaPlan): Promise<void> {
const m = readMetrics(run);
const row = getServer(run.server);
const server = row ? serverObservation(row) : null;
const timestamp =
let timestamp =
server?.status_source === 'telemetry' ? server.last_seen_at : server?.last_checked_at;
let source = server?.status_source;
// Telemetry owns the displayed roster until it expires, but a newer
// successful RCON reply is already health evidence during the handoff.
const rconSeen = server?.rcon_status?.last_seen_at;
if (
server?.health === 'online' &&
server.status_source === 'telemetry' &&
rconSeen &&
Date.parse(rconSeen) > Date.parse(timestamp ?? '') &&
Date.parse(rconSeen) <= Date.now()
) {
timestamp = rconSeen;
source = 'rcon';
}
const sample = Date.parse(timestamp ?? '');
const freshSample =
Number.isFinite(sample) &&
@@ -149,7 +163,7 @@ export async function observeRun(run: TestRun, plan: BetaPlan): Promise<void> {
evidence(run, `sample:${sample}`, 'status-sample', {
healthy,
checkedAt: timestamp,
source: server?.status_source
source
});
if (before !== m.wasHealthy)
evidence(run, `health:${at}`, 'health', { healthy, reason: server?.last_error ?? null });