From a3be1c7749db3f3f9dc61e43e250e62016f97cff Mon Sep 17 00:00:00 2001 From: RunTimeAdmin <248247024+RunTimeAdmin@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:44:52 -0600 Subject: [PATCH] Show the services as a row of beacons on the status page A new card at the top of the Status page draws the judgement the page already makes, in three.js, and draws it again each time the page reads. Each service is a beacon whose light is its state: green running, amber look at this, red down, and a hollow violet ring for no answer. The two operators and the event index stand on a glass column: the time since the last epoch finished, or the blocks behind the chain, against rings at the limits status.js applies. A column with no measure read fades out, so it cannot be taken for a good one. A red diamond is a disagreement that can still be rejected. Floor lines run from each service that reads the chain, and from the checker to its disagreements. Pointing at a beacon describes it. Clicking opens where it was read from. status.js publishes what it judged, with the limits and one fact per service in a few words. With no WebGL the card stays hidden, and with reduced motion nothing moves by itself. Co-Authored-By: Claude Fable 5.2 --- site/assets/explorer.css | 27 ++- site/assets/status-scene.js | 375 ++++++++++++++++++++++++++++++++++++ site/assets/status.js | 40 +++- site/status.html | 22 ++- 4 files changed, 451 insertions(+), 13 deletions(-) create mode 100644 site/assets/status-scene.js diff --git a/site/assets/explorer.css b/site/assets/explorer.css index 53651723..8a6d0701 100644 --- a/site/assets/explorer.css +++ b/site/assets/explorer.css @@ -94,6 +94,29 @@ .sim-tip { position: absolute; transform: translate(-50%, -100%); padding: 8px 10px; border-radius: 8px; background: rgba(9, 11, 22, .92); border: 1px solid var(--sig-line-strong); font-size: 12px; line-height: 1.5; color: var(--sig-text-soft); white-space: nowrap; pointer-events: none; } .sim-tip-addr { font-family: var(--sig-font-mono); color: var(--sig-text); } /* Operators page room. */ +/* Status page room. */ +#stSceneCard > .netnote { max-width: 760px; } +.sim-scene.op-scene.st-scene { height: clamp(330px, 36vw, 440px); } +.op-scene.st-scene .sim-tip { left: auto; right: 12px; top: 12px; bottom: auto; transform: none; text-align: left; width: max-content; max-width: min(360px, calc(100% - 24px)); white-space: normal; } +@media (max-width: 900px) { .op-label.status span + span { display: none; } } +@media (max-width: 560px) { .op-scene.st-scene .sim-tip { top: auto; bottom: 10px; } .sim-scene.op-scene.st-scene { height: 420px; } .st-scene .sim-scene-hud b { font-size: 15px; } .st-scene .op-label.scale { font-size: 10px; } } +.st-scene .sim-scene-hud b.pill-ok { color: var(--sig-mint); } +.st-scene .sim-scene-hud b.pill-warn { color: var(--sig-orange); } +.st-scene .sim-scene-hud b.pill-err { color: var(--sig-danger); } +.op-label.scale.left { transform: translate(0, -50%); align-items: flex-start; } +.op-label.scale.right { transform: translate(-100%, -50%); align-items: flex-end; } +.st-none { color: #c5b7ff; } +.op-label.status span { font-size: 12px; } +.op-label.status span + span { color: var(--sig-text-soft); } +.sim-key.k-ok::before { background: var(--sig-mint); } +.sim-key.k-warn::before { background: var(--sig-orange); } +.sim-key.k-down::before { background: #ff5c6c; } +.sim-key.k-none::before { background: transparent; border: 2px solid #c5b7ff; } +.sim-key.k-bead::before { border-radius: 0; background: #ff5c6c; transform: rotate(45deg); width: 7px; height: 7px; } +.sim-key.k-from::before { border-radius: 0; background: transparent; border-top: 2px dashed #ff9db0; width: 14px; height: 0; } +.sim-key.k-gauge::before { border-radius: 2px; background: #9aa6dc; width: 6px; height: 13px; } +.sim-key.k-mark::before { border-radius: 50%; background: transparent; border: 1px solid #fff; width: 10px; height: 5px; } +.sim-key.k-reads::before { border-radius: 0; background: transparent; border-top: 2px dashed var(--sig-cyan); width: 14px; height: 0; } /* Score epochs page room. */ .op-scene.ep-scene .sim-tip { bottom: auto; transform: translate(-50%, -100%); text-align: left; width: max-content; max-width: min(320px, calc(100% - 28px)); } .op-pending { color: var(--sig-orange); } @@ -110,7 +133,7 @@ .sim-key.k-line::before { border-radius: 2px; background: #c5b7ff; width: 14px; height: 2px; } .timeline .ep.flash { outline: 2px solid var(--sig-cyan); outline-offset: 4px; } #epSceneCard > .netnote { max-width: 760px; } -#opSceneCard, #slSceneCard, #epSceneCard { width: min(1180px, calc(100vw - 32px)); margin-left: calc((100% - min(1180px, calc(100vw - 32px))) / 2); } +#opSceneCard, #slSceneCard, #epSceneCard, #stSceneCard { width: min(1180px, calc(100vw - 32px)); margin-left: calc((100% - min(1180px, calc(100vw - 32px))) / 2); } #slSceneCard > .netnote { max-width: 760px; } /* Slashes page room. */ .sl-replay { position: absolute; right: 12px; top: 10px; } @@ -170,7 +193,7 @@ .sim-tiles { grid-template-columns: repeat(2, 1fr); } .sim-scene { height: 340px; } .sim-scene.op-scene { height: 430px; } - #opSceneCard, #slSceneCard, #epSceneCard { padding: 16px; } + #opSceneCard, #slSceneCard, #epSceneCard, #stSceneCard { padding: 16px; } .sim-scene.op-scene.ep-scene { height: 340px; } .op-label.num { font-size: 11px; } .op-label.small { display: none; } diff --git a/site/assets/status-scene.js b/site/assets/status-scene.js new file mode 100644 index 00000000..6e407f61 --- /dev/null +++ b/site/assets/status-scene.js @@ -0,0 +1,375 @@ +// The services as a row of beacons (three.js, vendored), drawn only from what status.js has just +// judged, and drawn again each time it reads. What each thing means: +// a beacon's light the state status.js gave that service: green running, amber look at this, +// red down, and a hollow violet ring for no answer +// a glass column a measure with limits: for an operator, the time since its last epoch +// finished; for the event index, how many blocks it is behind the chain +// the rings on it where that measure counts as late, and as down +// red beads disagreements the checker recorded that can still be rejected +// the floor lines cyan from each service that reads the chain, pink from the checker to its disagreements +// A light breathes slowly and dust drifts; neither says anything. While status.js is reading, the +// corner says so. +// +// Without WebGL nothing is drawn and the card stays hidden: the list below holds all of it. + +import * as THREE from "./vendor/three.module.min.js"; + +// Every feature is a switch here. Turn one off, do not delete it. +const CONFIG = { + breathe: true, // each light swells and fades a little + parallax: true, // the view leans a little toward the pointer + sway: true, // and drifts slowly from side to side + flow: true, // dashes run along the floor lines, toward what is read + dust: true, // motes in the air +}; + +const COLOR = { ok: 0xa3f1c6, attention: 0xffbf7a, unreachable: 0xc5b7ff, down: 0xff5c6c, reads: 0x6fe5ea, from: 0xff9db0 }; +const TALL = 2.3; // a glass column, from empty to its last limit + +function canvasTexture(w, h, draw) { + const c = document.createElement("canvas"); + c.width = w; c.height = h; + draw(c.getContext("2d"), w, h); + const t = new THREE.CanvasTexture(c); + t.colorSpace = THREE.SRGBColorSpace; + return t; +} + +// Draws `data.rows` in `host`. Returns { update, stop }, or null if there is no WebGL. +function start(host, data) { + const LIMITS = data.limits; + let renderer; + try { + renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); + } catch (_) { + return null; + } + const still = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches; + const narrow = host.clientWidth < 560; + renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); + const canvas = renderer.domElement; + canvas.setAttribute("aria-hidden", "true"); + const hud = document.createElement("div"); + hud.className = "sim-scene-hud"; + const tip = document.createElement("div"); + tip.className = "sim-tip u-hidden"; + host.replaceChildren(canvas, hud, tip); + + const scene = new THREE.Scene(); + const camera = new THREE.PerspectiveCamera(narrow ? 26 : 17, 2, 0.1, 200); + scene.add(new THREE.HemisphereLight(0xb9c2ff, 0x10132a, 1.5)); + const sun = new THREE.DirectionalLight(0xffffff, 1.4); + sun.position.set(-5, 8, 9); + scene.add(sun); + + const labels = []; + function addLabel(html, point, cls = "") { + const el = document.createElement("div"); + el.className = `op-label ${cls}`; + el.innerHTML = html; + host.appendChild(el); + labels.push({ el, at: point }); + return el; + } + + // ---- the floor ---- + const glowTex = canvasTexture(128, 128, (g) => { + const r = g.createRadialGradient(64, 64, 0, 64, 64, 64); + r.addColorStop(0, "rgba(255,255,255,.9)"); r.addColorStop(1, "rgba(255,255,255,0)"); + g.fillStyle = r; g.fillRect(0, 0, 128, 128); + }); + const gridTex = canvasTexture(1024, 1024, (g, w) => { + g.strokeStyle = "rgba(154,166,220,.15)"; g.lineWidth = 2; + for (let i = 0; i <= w; i += 64) { g.beginPath(); g.moveTo(i, 0); g.lineTo(i, w); g.stroke(); g.beginPath(); g.moveTo(0, i); g.lineTo(w, i); g.stroke(); } + g.globalCompositeOperation = "destination-out"; + const hole = g.createRadialGradient(w / 2, w / 2, w * 0.15, w / 2, w / 2, w / 2); + hole.addColorStop(0, "rgba(0,0,0,0)"); hole.addColorStop(1, "rgba(0,0,0,1)"); + g.fillStyle = hole; g.fillRect(0, 0, w, w); + }); + scene.add(new THREE.Mesh(new THREE.PlaneGeometry(30, 30).rotateX(-Math.PI / 2), new THREE.MeshBasicMaterial({ map: gridTex, transparent: true, depthWrite: false }))); + + // ---- the beacons ---- + // In a row on a wide screen. On a narrow one the beacons with a column stand in a back row, named + // above their lights, and the others in a front row, named at their feet, so the names fit. + const n = data.rows.length; + const gap = 2.7; + const back = data.rows.map((r, i) => i).filter((i) => data.rows[i].kind !== "divergence" && data.rows[i].kind !== "chain"); + const front = data.rows.map((r, i) => i).filter((i) => !back.includes(i)); + const inFront = (i) => narrow && front.includes(i); + function place(i) { + if (!narrow) return new THREE.Vector3((i - (n - 1) / 2) * gap, 0, 0); + const row = inFront(i) ? front : back; + return new THREE.Vector3((row.indexOf(i) - (row.length - 1) / 2) * (inFront(i) ? 3.6 : 2.3), 0, inFront(i) ? 4.8 : 0); + } + const glass = new THREE.CylinderGeometry(0.27, 0.27, TALL, 28, 1, true).translate(0, TALL / 2, 0); + const core = new THREE.CylinderGeometry(0.2, 0.2, 1, 24).translate(0, 0.5, 0); + const foot = new THREE.CylinderGeometry(0.5, 0.58, 0.16, 32).translate(0, 0.08, 0); + const stand = new THREE.CylinderGeometry(0.16, 0.24, 1, 20).translate(0, 0.5, 0); + const ball = new THREE.SphereGeometry(0.3, 28, 20); + const hoop = new THREE.TorusGeometry(0.3, 0.05, 10, 32); + const mark = new THREE.TorusGeometry(0.29, 0.018, 6, 32).rotateX(Math.PI / 2); + const bead = new THREE.OctahedronGeometry(0.17); + const targets = []; + const posts = data.rows.map((row, i) => { + const at = place(i); + const group = new THREE.Group(); + group.position.copy(at); + scene.add(group); + const base = new THREE.Mesh(foot, new THREE.MeshStandardMaterial({ color: 0x2a315f, roughness: 0.45, metalness: 0.5 })); + group.add(base); + // An operator or the index has a column whether or not it answered this time. + const gauged = row.kind === "primary" || row.kind === "checker" || row.kind === "index"; + // A column is as tall as its last limit: the index has only one, so its column is shorter. + const tall = gauged ? TALL * (LIMITS[row.kind].tall ?? 1) : 0; + const high = gauged ? tall : 1; + let fill = null, tube = null; + const marks = []; + if (gauged) { + tube = new THREE.Mesh(glass, new THREE.MeshStandardMaterial({ color: 0xdfe4ff, transparent: true, opacity: 0.13, roughness: 0.2, metalness: 0.3, side: THREE.DoubleSide, depthWrite: false })); + tube.position.y = 0.16; + tube.scale.y = tall / TALL; + // Unshaded, so it is the same colour as the light above it. + fill = new THREE.Mesh(core, new THREE.MeshBasicMaterial({ color: 0xffffff })); + fill.position.y = 0.16; + group.add(fill, tube); + for (const [where, name] of LIMITS[row.kind].marks) { + const ring = new THREE.Mesh(mark, new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.85 })); + ring.position.y = 0.16 + (where / LIMITS[row.kind].of) * tall; + group.add(ring); + marks.push(ring); + // On a narrow screen there is room to name the rings only at the two ends of the back row: + // to the left of the first column and to the right of the last. The one between has the same rings. + const end = !narrow ? 1 : back.indexOf(i) === 0 ? -1 : back.indexOf(i) === back.length - 1 ? 1 : 0; + if (end) marks.push(addLabel(name, at.clone().add(new THREE.Vector3(0.4 * end, ring.position.y, 0)), end > 0 ? "scale left" : "scale right")); + } + } else { + const pole = new THREE.Mesh(stand, new THREE.MeshStandardMaterial({ color: 0x343c70, roughness: 0.45, metalness: 0.5 })); + pole.position.y = 0.16; + group.add(pole); + } + const top = 0.16 + high + 0.5; + const light = new THREE.Mesh(ball, new THREE.MeshStandardMaterial({ color: 0xffffff, emissive: 0xffffff, emissiveIntensity: 0.9, roughness: 0.3 })); + light.position.y = top; + const ring = new THREE.Mesh(hoop, new THREE.MeshBasicMaterial({ color: 0xffffff })); + ring.position.y = top; + const glow = new THREE.Sprite(new THREE.SpriteMaterial({ map: glowTex, transparent: true, opacity: 0.55, blending: THREE.AdditiveBlending, depthWrite: false })); + glow.position.y = top; + glow.scale.setScalar(1.9); + const pool = new THREE.Mesh(new THREE.PlaneGeometry(4.2, 4.2).rotateX(-Math.PI / 2), new THREE.MeshBasicMaterial({ map: glowTex, transparent: true, opacity: 0.22, blending: THREE.AdditiveBlending, depthWrite: false })); + pool.position.y = 0.012; + group.add(light, ring, glow, pool); + const beads = new THREE.Group(); + beads.position.y = top; + group.add(beads); + // Anything on the beacon finds it. + const reach = new THREE.Mesh(new THREE.CylinderGeometry(0.55, 0.55, top + 0.4, 12).translate(0, (top + 0.4) / 2, 0), new THREE.MeshBasicMaterial({ visible: false })); + reach.userData.post = i; + group.add(reach); + targets.push(reach); + const above = narrow && !inFront(i); + const label = addLabel("", above ? at.clone().setY(top + 0.5) : at.clone().add(new THREE.Vector3(0, 0, 0.75)), above ? "status" : "under status"); + return { row, at, group, fill, tube, marks, tall, light, ring, glow, pool, beads, top, label, seed: i * 1.7 }; + }); + + // The floor lines: each service that reads the chain, and the checker's disagreements. + const dashTex = canvasTexture(64, 8, (g, w, h) => { + const run = g.createLinearGradient(0, 0, w, 0); + run.addColorStop(0, "rgba(255,255,255,.1)"); run.addColorStop(0.7, "rgba(255,255,255,.9)"); run.addColorStop(0.72, "rgba(255,255,255,.1)"); run.addColorStop(1, "rgba(255,255,255,.1)"); + g.fillStyle = run; g.fillRect(0, 0, w, h); + }); + const flows = []; + const find = (kind) => posts.find((p) => p.row.kind === kind); + function line(from, to, bend, color) { + if (!from || !to) return; + const a = from.at, b = to.at, mid = a.clone().lerp(b, 0.5); + mid.z += bend; + const curve = new THREE.QuadraticBezierCurve3(a.clone().setY(0.03), mid.setY(0.03), b.clone().setY(0.03)); + const map = dashTex.clone(); + map.wrapS = THREE.RepeatWrapping; map.repeat.set(Math.max(4, Math.round(a.distanceTo(b) * 1.6)), 1); map.needsUpdate = true; + const tube = new THREE.Mesh(new THREE.TubeGeometry(curve, 40, 0.07, 6), new THREE.MeshBasicMaterial({ map, color, transparent: true, depthWrite: false })); + tube.scale.y = 0.3; + scene.add(tube); + flows.push(map); + } + const chain = find("chain"); + // Each bends a different way, so that in a row they do not run into one track. + line(find("primary"), chain, narrow ? -2.6 : -7, COLOR.reads); + line(find("checker"), chain, narrow ? -1.9 : -4.4, COLOR.reads); + line(find("index"), chain, narrow ? -1.1 : -1.8, COLOR.reads); + line(find("checker"), find("divergence"), narrow ? 1.3 : 2.6, COLOR.from); + + let dust = null; + if (CONFIG.dust) { + const count = 110, pos = new Float32Array(count * 3); + for (let i = 0; i < count; i++) { pos[i * 3] = (Math.random() - 0.5) * 20; pos[i * 3 + 1] = Math.random() * 5; pos[i * 3 + 2] = (Math.random() - 0.5) * 8; } + dust = new THREE.Points(new THREE.BufferGeometry().setAttribute("position", new THREE.BufferAttribute(pos, 3)), + new THREE.PointsMaterial({ map: glowTex, color: 0xaab4ff, size: 0.08, transparent: true, opacity: 0.45, depthWrite: false, blending: THREE.AdditiveBlending })); + scene.add(dust); + } + + // ---- what was read ---- + let dirty = true; + // "No answer" is written in the colour of its ring, not in the red of "down". + const pillOf = (row) => (row.state === "unreachable" ? "st-none" : row.pill); + function update(next) { + hud.innerHTML = `${next.headline}${next.checked}`; + next.rows.forEach((row, i) => { + const p = posts[i]; + if (!p) return; + p.row = row; + const color = COLOR[row.state] ?? COLOR.down; + const answered = row.state !== "unreachable"; + p.light.visible = answered; + p.ring.visible = !answered; + for (const m of [p.light.material]) { m.color.set(color); m.emissive.set(color); } + p.ring.material.color.set(color); + p.glow.material.color.set(color); + p.glow.material.opacity = answered ? 0.55 : 0.2; + p.pool.material.color.set(color); + if (p.fill) { + const known = Number.isFinite(row.gauge); + const part = known ? Math.min(1, Math.max(0, row.gauge / LIMITS[row.kind].of)) : 0; + p.fill.visible = known; + p.fill.scale.y = Math.max(0.02, part * p.tall); + p.fill.material.color.set(color); + // With no measure read, the column and its rings fade out: an empty column would read as a good one. + p.tube.material.opacity = known ? 0.13 : 0.05; + for (const m of p.marks) { + if (m.isMesh) m.material.opacity = known ? 0.85 : 0.15; + else m.classList.toggle("u-hidden", !known); + } + } + p.beads.clear(); + for (let k = 0; k < Math.min(row.beads ?? 0, 12); k++) { + const b = new THREE.Mesh(bead, new THREE.MeshStandardMaterial({ color: COLOR.down, emissive: COLOR.down, emissiveIntensity: 0.7 })); + // In a row over the light, where each can be counted. + const shown = Math.min(row.beads, 12), col = k % 6, line = Math.floor(k / 6); + // On a narrow screen, seen from above, "over" would land on the row behind: there they stand beside the light. + if (narrow) b.position.set(0.55 + col * 0.4, 0, 0.25 + line * 0.4); + else b.position.set((col - (Math.min(6, shown - line * 6) - 1) / 2) * 0.42, 0.62 + line * 0.4, 0); + p.beads.add(b); + } + const [name, state, fact] = p.label.children; + name.textContent = row.name; + state.textContent = row.label; + state.className = pillOf(row); + fact.textContent = row.fact ?? ""; + }); + dirty = true; + } + const reading = () => { const s = hud.querySelector("span"); if (s) s.textContent = "reading…"; }; + + // ---- view ---- + const lean = { x: 0, y: 0, tx: 0, ty: 0 }; + let dist = 16, visible = false, hovered = null, held = null, touch = false, stopped = false; + function resize() { + const w = host.clientWidth, h = host.clientHeight; + if (!w || !h) return; + renderer.setSize(w, h, false); + camera.aspect = w / h; + const half = Math.tan((camera.fov * Math.PI) / 360); + dist = narrow ? Math.max(4.7 / (half * camera.aspect), 4.3 / half) : Math.max((((n - 1) / 2) * gap + 1.9) / (half * camera.aspect), 2.7 / half); + camera.updateProjectionMatrix(); + dirty = true; + } + const point = new THREE.Vector3(); + function draw(t) { + const drift = CONFIG.sway && !still ? Math.sin(t * 0.17) * 0.3 : 0; + // On a narrow screen the view is from higher up, so the front row stands clear of the back one. + camera.position.set(drift + lean.x * 0.7, 2.4 + dist * (narrow ? 0.5 : 0.2) - lean.y * 0.5, dist * (narrow ? 0.86 : 0.97) + (narrow ? 2.3 : 0)); + camera.lookAt(0, narrow ? 1.2 : 1.72, narrow ? 2.3 : 0); + const lit = hovered ?? held; + posts.forEach((p, i) => { + const beat = CONFIG.breathe && !still ? 1 + Math.sin(t * 1.4 + p.seed) * 0.06 : 1; + p.light.scale.setScalar(lit === i ? 1.3 : beat); + p.glow.scale.setScalar((lit === i ? 2.6 : 1.9) * beat); + }); + renderer.render(scene, camera); + for (const l of labels) { + point.copy(l.at).project(camera); + const half = l.el.classList.contains("left") || l.el.classList.contains("right") ? 0 : l.el.offsetWidth / 2 + 4; + l.el.style.left = `${Math.min(host.clientWidth - half, Math.max(half, ((point.x + 1) / 2) * host.clientWidth))}px`; + l.el.style.top = `${((1 - point.y) / 2) * host.clientHeight}px`; + } + tip.classList.toggle("u-hidden", lit === null); + } + + // ---- pointer ---- + const ray = new THREE.Raycaster(), ndc = new THREE.Vector2(); + function pick(ev) { + const b = canvas.getBoundingClientRect(); + ndc.set(((ev.clientX - b.left) / b.width) * 2 - 1, -((ev.clientY - b.top) / b.height) * 2 + 1); + ray.setFromCamera(ndc, camera); + return ray.intersectObjects(targets, false)[0]?.object.userData.post ?? null; + } + function show(i) { + if (i === null) return; + const row = posts[i].row; + tip.innerHTML = `${row.name}: ${row.label}
${row.text}${row.href ? "
Click to open where this was read from." : ""}`; + } + canvas.addEventListener("pointermove", (ev) => { + const b = canvas.getBoundingClientRect(); + if (CONFIG.parallax) { lean.tx = ((ev.clientX - b.left) / b.width) * 2 - 1; lean.ty = ((ev.clientY - b.top) / b.height) * 2 - 1; } + if (ev.pointerType === "mouse") { + const i = pick(ev); + if (i !== hovered) { hovered = i; show(i ?? held); canvas.classList.toggle("pick", i !== null && Boolean(posts[i].row.href)); } + } + dirty = true; + }); + canvas.addEventListener("pointerleave", () => { lean.tx = lean.ty = 0; hovered = null; show(held); canvas.classList.remove("pick"); dirty = true; }); + canvas.addEventListener("pointerdown", (ev) => { touch = ev.pointerType !== "mouse"; }); + canvas.addEventListener("click", (ev) => { + const i = pick(ev); + dirty = true; + // A finger has no hover: the first tap names the beacon, a second tap on it opens it. + if (touch && i !== held) { held = i; show(i); return; } + const href = i === null ? null : posts[i].row.href; + if (!href) { if (i === null) held = null; return; } + if (href.startsWith("http")) window.open(href, "_blank", "noopener"); + else window.location.href = href; + }); + + // ---- frame ---- + let last = null; + function frame(ms) { + if (stopped) return; + requestAnimationFrame(frame); + if (!visible || !canvas.isConnected) { last = null; return; } + const dt = last === null ? 0 : Math.min(0.05, (ms - last) / 1000); + last = ms; + const t = ms / 1000; + lean.x += (lean.tx - lean.x) * Math.min(1, dt * 4); + lean.y += (lean.ty - lean.y) * Math.min(1, dt * 4); + // With reduced motion nothing moves by itself: the room is drawn when something changes. + if (still) { if (!dirty && Math.abs(lean.tx - lean.x) < 0.001 && Math.abs(lean.ty - lean.y) < 0.001) return; } + else { + if (CONFIG.flow) for (const map of flows) map.offset.x -= dt * 0.6; + if (dust) dust.rotation.y = Math.sin(t * 0.05) * 0.05; + } + dirty = false; + draw(t); + } + + resize(); + update(data); + const sized = new ResizeObserver(resize), seen = new IntersectionObserver(([entry]) => { visible = entry.isIntersecting; }); + sized.observe(host); + seen.observe(host); + requestAnimationFrame(frame); + return { update, reading, stop: () => { stopped = true; sized.disconnect(); seen.disconnect(); renderer.dispose(); } }; +} + +// status.js says what it judged each time it has read, and when it starts reading again. +let live = null; +function begin() { + const host = document.getElementById("stScene"), card = document.getElementById("stSceneCard"), data = window.SigvaraStatusScene; + if (!host || !card || !data?.rows?.length) return; + if (live) { live.update(data); return; } + // Shown first, so the room can be measured; hidden again if there is nothing to draw with. + card.classList.remove("u-hidden"); + live = start(host, data); + if (!live) card.classList.add("u-hidden"); +} +document.addEventListener("sigvara-status-scene", begin); +document.addEventListener("sigvara-status-reading", () => live?.reading()); +begin(); diff --git a/site/assets/status.js b/site/assets/status.js index ed7f57a6..51b8c86a 100644 --- a/site/assets/status.js +++ b/site/assets/status.js @@ -59,7 +59,13 @@ : `No epoch has finished since it started ${ago(Number(v.uptimeSeconds) * 1000 || 0)} ago, ${every}.`); if (v.epochRunning === true) said.push("One is running now."); if (v.commit) said.push(`Runs ${X.commitLink(v.commit)}.`); - return { state, text: said.join(" ") }; + // For the room (status-scene.js): the one fact in a few words, and the measure against its limits. + return { + state, text: said.join(" "), + // In minutes, not rounded to hours, so that it agrees with the column it is written under. + fact: ran ? (since < 10 * 3600 * 1000 ? `${Math.round(since / 60000)} min since its last epoch` : `${ago(since)} since its last epoch`) : "no epoch finished yet", + gauge: ran ? since / epochMs : null, + }; } // The event index's /health, against the chain's newest block as this browser read it, so the lag @@ -78,7 +84,11 @@ said.push(lag === null ? "It does not say how far behind the chain it is." : `${plural(lag, "block")} behind the chain, about ${ago(lag * SECONDS_PER_BLOCK * 1000)}.`); if (state === "down" && v.lastError) said.push(`Last error: ${X.esc(v.lastError)}.`); - return { state, text: said.join(" ") }; + return { + state, text: said.join(" "), + fact: lag === null ? "lag not known" : `${plural(lag, "block")} behind`, + gauge: lag, + }; } // The checker's /divergence. As in scripts/check-live.mjs, a record matters while its proposal can @@ -109,12 +119,13 @@ + (open ? `; ${open} can still be rejected.` : "; none can still be rejected.")); } const text = said.join(" "); - return blind || open ? { state: "attention", text } : { state: "ok", label: "none open", text }; + const fact = total === 0 ? "none on record" : `${open} open of ${total} on record`; + return blind || open ? { state: "attention", text, fact, beads: open } : { state: "ok", label: "none open", text, fact, beads: 0 }; } function assessChain(head) { if (head.status === "rejected") return noAnswer(head); - return { state: "ok", label: "answering", text: `Newest block ${Number(head.value).toLocaleString("en-US")}. The RPC is Arc's, not Sigvara's.` }; + return { state: "ok", label: "answering", text: `Newest block ${Number(head.value).toLocaleString("en-US")}. The RPC is Arc's, not Sigvara's.`, fact: `block ${Number(head.value).toLocaleString("en-US")}` }; } // The worst state among the rows, for the line at the top. @@ -148,12 +159,23 @@ + (rows.some((r) => r.state === "unreachable") ? '

No answer can be your connection rather than the service, so try the link from elsewhere before calling it an outage.

' : "") + `
${rows.map((r) => `
${link(r)}
${r.label ?? STATES[r.state].label} ${r.text}
`).join("")}
`; + // The room above (status-scene.js) draws the same judgement. It is a module, so it may load + // before or after this. + const epochs = { of: EPOCHS_DOWN, marks: [[1, "next epoch due"], [EPOCHS_LATE, "late from here"], [EPOCHS_DOWN, "down from here"]] }; + root.SigvaraStatusScene = { + // Where each measure counts as late, and as down: epochs for an operator, blocks for the index. + limits: { primary: epochs, checker: epochs, index: { of: INDEX_LATE_BLOCKS * 1.2, tall: 0.5, marks: [[INDEX_LATE_BLOCKS, "late from here"]] } }, + headline: HEADLINES[worst], pill: STATES[worst].pill, checked: `checked ${X.fmtWhen(Math.floor(Date.now() / 1000))}`, + rows: rows.map((r) => ({ ...r, label: r.label ?? STATES[r.state].label, pill: STATES[r.state].pill })), + }; + document.dispatchEvent(new Event("sigvara-status-scene")); } let reading = false; async function refresh() { if (reading) return; reading = true; + document.dispatchEvent(new Event("sigvara-status-reading")); try { const [primary, checker, divergence, index, head] = await Promise.allSettled([ readEndpoint(`${X.PRIMARY}/health`), @@ -163,11 +185,11 @@ X.blockNumber(), ]); render([ - { name: "Primary oracle", href: `${X.PRIMARY}/health`, ...assessOracle(primary) }, - { name: "Checker", href: `${X.CHECKER}/health`, ...assessOracle(checker) }, - { name: "Disagreements", href: "operators", ...assessDivergence(divergence) }, - { name: "Event index", href: `${X.INDEX}/health`, ...assessIndex(index, head) }, - { name: "Arc testnet RPC", ...assessChain(head) }, + { name: "Primary oracle", kind: "primary", href: `${X.PRIMARY}/health`, ...assessOracle(primary) }, + { name: "Checker", kind: "checker", href: `${X.CHECKER}/health`, ...assessOracle(checker) }, + { name: "Disagreements", kind: "divergence", href: "operators", ...assessDivergence(divergence) }, + { name: "Event index", kind: "index", href: `${X.INDEX}/health`, ...assessIndex(index, head) }, + { name: "Arc testnet RPC", kind: "chain", ...assessChain(head) }, ]); } catch (e) { document.querySelector("#statusCard .card-body").innerHTML = X.failed("the services", e); diff --git a/site/status.html b/site/status.html index dd831b83..0513325a 100644 --- a/site/status.html +++ b/site/status.html @@ -19,7 +19,7 @@ - + @@ -52,6 +52,23 @@

Status

Whether Sigvara's testnet services are running, and what the scores they write add up to. Your browser reads each one from its public endpoint when this page opens, and nothing is kept or summarised in between.

Arc testnet (5042002). Reads only. The Sigvara team runs both oracle operators and the event index, so this is their own report of themselves, and each line links to where it came from. The same limits are checked from outside, on a schedule, by the live checks workflow.

+
+

The services, as last read

+
+
+ Running + Look at this + Down + No answer + Column: time since an operator's last epoch, or blocks the index is behind + Ring: where the next epoch is due, and where the column counts as late, or down + A disagreement that can still be rejected + Reads the chain + Disagreements come from the checker +
+

The same judgement as the list below, drawn again each time the page reads. A low column is good. Point at a beacon, or tap it, to read it; click or tap again to open where it was read from. The lights' slow breathing and the dust mean nothing.

+
+

Right now

Reading…

@@ -78,7 +95,8 @@

The scores

- + +