From 4d8be7099d5e70e1a5179ad2df1cc39ab5db93d9 Mon Sep 17 00:00:00 2001 From: "Memoria (Noblistic)" Date: Sun, 1 Nov 2026 23:35:13 +0000 Subject: [PATCH] dashboard: a restart that lands in the same second is still a restart The poll compares started_at to decide whether the engine is a new process, and clears the session extremes when it is. started_at is std::time(nullptr) -- whole unix seconds -- so a restart landing in the same second as the previous start leaves it unchanged and the clear never runs. The previous run's extremes then render with an age clause attached, and the age is true: the figure really is that old. What is false is the provenance the age implies, that it belongs to the process now running. A stale figure with an honest number on it is worse than no number at all, because it invites the reader to trust it. Also compare uptime_s, which resets to about zero on any new process. It is the same signal the acceptance window already trusts for the same purpose, so this adds no new assumption: it is wall-clock derived, and a backward NTP step reads as a restart and clears the extremes. That false positive costs a cleared window on one poll, which is what the acceptance window already accepts. Found by an adversarial review pass that reproduced it as `highest 75% - 43.0 s ago` from a dead process. Verified: dashboard_test 241 checks over 8 cases, no failures. The case that holds this is the poll() driver in tests/js/extremes.test.js, which fails if the uptime comparison is removed; it lands in the next commit, so this one is not self-proving on its own. Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI --- core/server/dashboard.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/server/dashboard.cpp b/core/server/dashboard.cpp index 524b5335..03ad0178 100644 --- a/core/server/dashboard.cpp +++ b/core/server/dashboard.cpp @@ -1697,7 +1697,7 @@ function setMetric(key, value, text) { const RECENT_S = 15; /* the `recent` window in seconds, for a figure sampled every poll */ const RECENT_PREFILL_S = 5; /* prefill's is shorter, so a several-second prefill shows up in it */ const extAt = {}, winAt = {}, extAtS = {}; /* extAtS: the poll at which each extreme was set */ -let lastActiveC = 0, lastStart = null; +let lastActiveC = 0, lastStart = null, lastUp = -1; /* A new engine process is a different discontinuity from a quiet minute: the previous run's * requests are gone and its configuration may differ, so nothing from it carries over. Every * other figure already refuses to pool across a restart -- accWindow drops its rings, histIngest @@ -3877,11 +3877,19 @@ async function poll() { const r = await api("stats"); if (!r.ok) throw new Error(r.status); const s = await r.json(); - /* A new engine process: started_at is its identity, so a change is a discontinuity rather - * than a new measurement. Checked before update() so the new run's samples land in fresh - * windows. */ - if (lastStart !== null && s.started_at !== lastStart) newEngineRun(); + /* A new engine process is a discontinuity, not a new measurement. started_at names it, but + * it is a whole-second clock, so a restart landing in the same second as the previous start + * leaves it unchanged -- and the previous run's extremes would then render WITH A TRUE AGE, + * which reads as honest provenance and is not. uptime_s resets to about zero on any new + * process and catches that; it is the same signal accWindow already trusts for the same + * purpose, with the same accepted risk: it is wall-clock derived, so a backward NTP step + * reads as a restart and clears the extremes. Checked before update() so the new run's + * samples land in fresh windows. */ + const up = s.uptime_s; + if (lastStart !== null && (s.started_at !== lastStart || + (typeof up === "number" && up < lastUp))) newEngineRun(); lastStart = s.started_at; + if (typeof up === "number") lastUp = up; const now = performance.now(); update(s, prevAt ? (now - prevAt) / 1000 : 0); prev = s; prevAt = now;