dashboard: drop the uptime comparison -- it could only fire on a clock step

8ee893e added `up < lastUp` beside the started_at comparison, to catch a restart landing in
the same whole second as the one the page last read. It cannot catch that. uptime_s is
derived, not independent: unix_now() - started_at_, both whole seconds, so started_at +
uptime_s is exactly the wall clock at every poll. Two processes sharing a started_at are
therefore read at increasing wall times and report INCREASING uptimes, so the comparison
never fires in the case it was written for. It fires on genuine restarts, which started_at
already catches, and on a backward NTP step, which is not a restart at all. Net effect: dead
where it was needed, redundant elsewhere, and a false clear of the session extremes on every
clock correction.

The test that "proved" it worked was fed an impossible fixture: started_at 100 with uptime 40
implies the clock read 140, then started_at 100 with uptime 2 implies 102. Time running
backwards is the only way to reach that pair, which is the same mistake the finding it
answered was about -- reasoning from a state the instrument cannot produce. It now asserts
the reachable behaviour instead: a backward uptime with an unchanged started_at is a clock
step and must NOT clear the extremes, since they still belong to the running process.

The collision the comparison tried to close needs a replacement process stamped in the same
second as the one the page last read. The page can only learn started_at once /stats answers,
startup_s after the old process began -- 69 s on this engine -- so a replacement starting
after its predecessor stopped answering is stamped a later second. The bound is startup_s >=
1 s; a model that came up inside a second could collide, and would cost one stale extreme
carrying a true age. That is documented where the comparison used to be.

The acceptance window's use of the same signal is NOT redundant and is untouched: it has no
started_at comparison, so for a tab that stopped polling while a new process drafted past the
old totals, a falling uptime is the only thing that catches the restart.

Verified: dashboard_test 241 checks over 8 cases, extremes.test.js 27, poll_spark.test.js 35,
sched_test 62646 over 184, no failures. Mutation re-run after the revert: deleting poll()'s
detection line, stamping extAtS on every sample, and deadening acceptTriple's age clause each
fail the suite. Behavior is unchanged from the deployed build, which never had the
comparison, so no restart is needed for this.

Authored at: Memoria Qwen 3.8 Flash-Next 125B MoE (level not visible) via Open WebUI
This commit is contained in:
Memoria (Noblistic) authored and StillDeadcode committed 2026-11-03 18:09:49 +01:00
1 parent 638aa3a683
commit 0ac154c803
2 files changed
+23 -18

No files matched your search

+16 -13
View File
@@ -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, lastUp = -1;
let lastActiveC = 0, lastStart = null;
/* 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,19 +3877,22 @@ 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 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();
/* A new engine process is a discontinuity, not a new measurement, and started_at names it.
* It is a whole-second clock, so two processes could share one and the clear would be
* missed. For that, the replacement would have to start within the same second as the one
* the page last read -- and the page can only read it once /stats answers, startup_s after
* the old process began (69 s here). A replacement that starts after its predecessor stopped
* answering is therefore stamped a later second. The guarantee needs startup_s >= 1 s; a
* model that came up inside a second could collide, and the cost would be one stale extreme
* carrying a true age.
*
* uptime_s is NOT a backstop for that case, because it is derived: unix_now() - started_at_,
* both whole seconds, so started_at + uptime_s is exactly the wall clock at every poll. A
* later poll always reports a larger uptime for the same started_at, so a comparison firing
* on a smaller one detects a backward NTP step and nothing else. Checked before update() so
* the new run's samples land in fresh windows. */
if (lastStart !== null && s.started_at !== lastStart) 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;