@intentius/behold 0.29.20 → 0.29.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -1
- package/dist/cli.js +36 -17
- package/package.json +1 -1
- package/web/app.js +1 -1
- package/web/kiosk-metrics.js +37 -12
- package/web/kiosk-metrics.test.js +18 -6
- package/web/terragucci.js +4 -3
- package/web/terragucci.test.js +7 -0
package/AGENTS.md
CHANGED
|
@@ -66,7 +66,9 @@ links a proposed decision to its review in hud.
|
|
|
66
66
|
behold asks a FIXED set of named queries over terragucci's gauges (each a
|
|
67
67
|
constant string, nothing from the request in it), shares one read for 30 s,
|
|
68
68
|
and picks the repo's series out of the answers: one commit's tf-apply waves
|
|
69
|
-
(
|
|
69
|
+
(the wave job's own time first, then each root's init, plan and apply
|
|
70
|
+
seconds and any state lock wait, in milliseconds below a second on the
|
|
71
|
+
kiosk, the time an approval held the wave at
|
|
70
72
|
its gate, the changes it applied, when it started waiting) and the DORA four,
|
|
71
73
|
from terragucci estate's gauges or its `dora.json` beside the reports. It
|
|
72
74
|
answers numbers, never a proxy, and a public serve keeps it (GET). Without
|
package/dist/cli.js
CHANGED
|
@@ -20716,10 +20716,10 @@ function latestResolutionForPlan(records, gate, sinceIso, planDigest) {
|
|
|
20716
20716
|
for (const r of records) {
|
|
20717
20717
|
if (r.gate !== gate) continue;
|
|
20718
20718
|
if (new Date(r.timestamp).getTime() < since) continue;
|
|
20719
|
-
const
|
|
20719
|
+
const newest3 = (best) => !best || new Date(r.timestamp).getTime() >= new Date(best.timestamp).getTime();
|
|
20720
20720
|
if (samePlanDigest(r.planDigest, planDigest)) {
|
|
20721
|
-
if (
|
|
20722
|
-
} else if (
|
|
20721
|
+
if (newest3(matched)) matched = r;
|
|
20722
|
+
} else if (newest3(mismatched)) {
|
|
20723
20723
|
mismatched = r;
|
|
20724
20724
|
}
|
|
20725
20725
|
}
|
|
@@ -20956,13 +20956,13 @@ function overrideCommand(subject, rules, sealed = false) {
|
|
|
20956
20956
|
}
|
|
20957
20957
|
var time = (iso) => new Date(iso).getTime();
|
|
20958
20958
|
function recordedDenials(pending) {
|
|
20959
|
-
const
|
|
20959
|
+
const newest3 = /* @__PURE__ */ new Map();
|
|
20960
20960
|
for (const p of pending) {
|
|
20961
20961
|
if (p.op !== OVERRIDE_OP || !p.planDigest) continue;
|
|
20962
|
-
const before =
|
|
20963
|
-
if (!before || time(p.timestamp) >= time(before.timestamp))
|
|
20962
|
+
const before = newest3.get(p.gate);
|
|
20963
|
+
if (!before || time(p.timestamp) >= time(before.timestamp)) newest3.set(p.gate, p);
|
|
20964
20964
|
}
|
|
20965
|
-
return [...
|
|
20965
|
+
return [...newest3.values()].map((p) => {
|
|
20966
20966
|
const r = p;
|
|
20967
20967
|
return { ...p, plan: typeof r.plan === "string" ? r.plan : "", rules: Array.isArray(r.rules) ? sortedRules(r.rules.filter((x) => typeof x === "string")) : [] };
|
|
20968
20968
|
}).sort((a, b) => a.gate < b.gate ? -1 : a.gate > b.gate ? 1 : 0);
|
|
@@ -23321,9 +23321,11 @@ async function readTerragucci(source2, opts = {}) {
|
|
|
23321
23321
|
if (prRow && prDoc) pullRequest = pullRequestPlan(prDoc, under(prRow.path, "report.html"));
|
|
23322
23322
|
const estateDoc = await readDoc(source2, "estate.json", "estate", v);
|
|
23323
23323
|
const estateProject = estateDoc?.projects.find((p) => p.project === project);
|
|
23324
|
+
const behind = !!estateProject && rows.length > 0 && (Date.parse(rows[0].finished) || 0) > (Date.parse(estateDoc.generated) || 0);
|
|
23325
|
+
const fromEstate = !!estateProject && !behind;
|
|
23324
23326
|
const waiting = [];
|
|
23325
23327
|
const waitingRows = [];
|
|
23326
|
-
if (
|
|
23328
|
+
if (fromEstate) {
|
|
23327
23329
|
for (const w of estateProject.waiting) {
|
|
23328
23330
|
const row = rows.find((r) => r.stage === "tf-apply" && r.commit === w.commit && r.wave === w.wave);
|
|
23329
23331
|
if (row) waitingRows.push({ row, since: w.since });
|
|
@@ -23352,7 +23354,7 @@ async function readTerragucci(source2, opts = {}) {
|
|
|
23352
23354
|
report: under(row.path, "report.html"),
|
|
23353
23355
|
...row.job_url ? { job_url: row.job_url } : {},
|
|
23354
23356
|
command: terragucciApproveCommand(row.wave, digest),
|
|
23355
|
-
from:
|
|
23357
|
+
from: fromEstate ? "estate" : "index"
|
|
23356
23358
|
});
|
|
23357
23359
|
}
|
|
23358
23360
|
return {
|
|
@@ -23372,7 +23374,8 @@ async function readTerragucci(source2, opts = {}) {
|
|
|
23372
23374
|
drifted: estateProject.drifted,
|
|
23373
23375
|
failed: estateProject.failed,
|
|
23374
23376
|
waiting: estateProject.waiting.length,
|
|
23375
|
-
status: estateProject.status
|
|
23377
|
+
status: estateProject.status,
|
|
23378
|
+
...behind ? { behind: true } : {}
|
|
23376
23379
|
}
|
|
23377
23380
|
} : {}
|
|
23378
23381
|
};
|
|
@@ -24702,7 +24705,8 @@ function demoOf(d) {
|
|
|
24702
24705
|
scenarios: positive(d.scenarios),
|
|
24703
24706
|
index: positive(d.index),
|
|
24704
24707
|
tool: text(d.tool),
|
|
24705
|
-
repo: text(d.repo)
|
|
24708
|
+
repo: text(d.repo),
|
|
24709
|
+
delivery: text(d.delivery)
|
|
24706
24710
|
};
|
|
24707
24711
|
}
|
|
24708
24712
|
function terragucciDemoRoute(app, source2, opts = {}) {
|
|
@@ -25079,17 +25083,24 @@ function terragucciRoutes(app, opts, dirs) {
|
|
|
25079
25083
|
var METRICS_TTL_MS = 3e4;
|
|
25080
25084
|
var RUN_WINDOW = "3h";
|
|
25081
25085
|
var DORA_WINDOW = "7d";
|
|
25086
|
+
var DORA_STEP = "1m";
|
|
25087
|
+
var newest2 = (selector) => `last_over_time((max by (project) (${selector}))[${DORA_WINDOW}:${DORA_STEP}])`;
|
|
25082
25088
|
var QUERIES = {
|
|
25089
|
+
waveSeconds: `max by (project, commit, run, wave) (last_over_time(terragucci_stage_duration_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25090
|
+
rootInit: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_init_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25083
25091
|
rootPlan: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_plan_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25084
25092
|
rootApply: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_apply_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25093
|
+
// A lock wait carries no wave: a root's wave is found from its other timings in the same run.
|
|
25094
|
+
lockWait: `max by (project, commit, run, root) (last_over_time(terragucci_lock_wait_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
|
|
25085
25095
|
held: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_held_seconds[${RUN_WINDOW}]))`,
|
|
25086
25096
|
changes: `max by (project, commit, run, wave, action) (last_over_time(terragucci_wave_changes[${RUN_WINDOW}]))`,
|
|
25087
25097
|
settled: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_settled_seconds[${RUN_WINDOW}]))`,
|
|
25088
25098
|
waiting: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_waiting_since_seconds[${RUN_WINDOW}]))`,
|
|
25089
|
-
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25099
|
+
// behold#571: the newest gauge, never the largest over the window, so a rate that fell reads as it is now.
|
|
25100
|
+
deployments: newest2("terragucci_dora_deployments_per_week"),
|
|
25101
|
+
leadTime: newest2(`terragucci_dora_lead_time_seconds{segment="total"}`),
|
|
25102
|
+
failureRate: newest2("terragucci_dora_change_failure_ratio"),
|
|
25103
|
+
restore: newest2("terragucci_dora_restore_seconds")
|
|
25093
25104
|
};
|
|
25094
25105
|
var REPO = /^(?:[A-Za-z0-9][A-Za-z0-9._-]{0,99}\/)?[A-Za-z0-9._-]{1,100}$/;
|
|
25095
25106
|
var COMMIT = /^[0-9a-f]{7,64}$/;
|
|
@@ -25117,7 +25128,7 @@ function parseVector(body) {
|
|
|
25117
25128
|
var key = (s) => `${s.labels.commit ?? ""}\0${s.labels.run ?? ""}\0${s.labels.wave ?? ""}`;
|
|
25118
25129
|
function runOf(a, repo, commit) {
|
|
25119
25130
|
const mine = (xs) => xs.filter((s) => projectIs(s.labels.project, repo) && /^\d+$/.test(s.labels.wave ?? ""));
|
|
25120
|
-
const rows = { ...a, rootPlan: mine(a.rootPlan), rootApply: mine(a.rootApply), held: mine(a.held), changes: mine(a.changes), settled: mine(a.settled), waiting: mine(a.waiting) };
|
|
25131
|
+
const rows = { ...a, waveSeconds: mine(a.waveSeconds), rootInit: mine(a.rootInit), rootPlan: mine(a.rootPlan), rootApply: mine(a.rootApply), held: mine(a.held), changes: mine(a.changes), settled: mine(a.settled), waiting: mine(a.waiting) };
|
|
25121
25132
|
const moved = /* @__PURE__ */ new Map();
|
|
25122
25133
|
const note = (s) => {
|
|
25123
25134
|
const k = key(s);
|
|
@@ -25125,7 +25136,7 @@ function runOf(a, repo, commit) {
|
|
|
25125
25136
|
if (!had || s.value > had.at) moved.set(k, { commit: s.labels.commit ?? "", run: s.labels.run ?? "", wave: Number(s.labels.wave), at: s.value });
|
|
25126
25137
|
};
|
|
25127
25138
|
for (const s of [...rows.settled, ...rows.waiting]) note(s);
|
|
25128
|
-
for (const s of [...rows.rootPlan, ...rows.rootApply]) if (!moved.has(key(s))) moved.set(key(s), { commit: s.labels.commit ?? "", run: s.labels.run ?? "", wave: Number(s.labels.wave), at: 0 });
|
|
25139
|
+
for (const s of [...rows.waveSeconds, ...rows.rootInit, ...rows.rootPlan, ...rows.rootApply]) if (!moved.has(key(s))) moved.set(key(s), { commit: s.labels.commit ?? "", run: s.labels.run ?? "", wave: Number(s.labels.wave), at: 0 });
|
|
25129
25140
|
if (moved.size === 0) return null;
|
|
25130
25141
|
const commits = /* @__PURE__ */ new Map();
|
|
25131
25142
|
for (const m of moved.values()) commits.set(m.commit, Math.max(commits.get(m.commit) ?? 0, m.at));
|
|
@@ -25141,8 +25152,15 @@ function runOf(a, repo, commit) {
|
|
|
25141
25152
|
const out = [];
|
|
25142
25153
|
for (const [wave, { run: run3 }] of [...waves.entries()].sort((x, y) => x[0] - y[0])) {
|
|
25143
25154
|
const roots = /* @__PURE__ */ new Map();
|
|
25155
|
+
const put = (root, v) => roots.set(root, { ...roots.get(root) ?? { root }, ...v });
|
|
25156
|
+
for (const s of of(rows.rootInit, wave, run3)) if (s.labels.root) put(s.labels.root, { init_seconds: s.value });
|
|
25144
25157
|
for (const s of of(rows.rootPlan, wave, run3)) if (s.labels.root) roots.set(s.labels.root, { ...roots.get(s.labels.root) ?? { root: s.labels.root }, plan_seconds: s.value });
|
|
25145
25158
|
for (const s of of(rows.rootApply, wave, run3)) if (s.labels.root) roots.set(s.labels.root, { ...roots.get(s.labels.root) ?? { root: s.labels.root }, apply_seconds: s.value });
|
|
25159
|
+
for (const s of a.lockWait) {
|
|
25160
|
+
const r = s.labels.root;
|
|
25161
|
+
if (r && roots.has(r) && projectIs(s.labels.project, repo) && (s.labels.commit ?? "") === chosen && (s.labels.run ?? "") === run3) put(r, { lock_wait_seconds: s.value });
|
|
25162
|
+
}
|
|
25163
|
+
const wall = of(rows.waveSeconds, wave, run3)[0];
|
|
25146
25164
|
const changes = {};
|
|
25147
25165
|
for (const s of of(rows.changes, wave, run3)) if (s.labels.action && s.value > 0) changes[s.labels.action] = s.value;
|
|
25148
25166
|
const held = of(rows.held, wave, run3)[0];
|
|
@@ -25151,6 +25169,7 @@ function runOf(a, repo, commit) {
|
|
|
25151
25169
|
out.push({
|
|
25152
25170
|
wave,
|
|
25153
25171
|
run: run3 || null,
|
|
25172
|
+
...wall ? { seconds: wall.value } : {},
|
|
25154
25173
|
roots: [...roots.values()].sort((x, y) => x.root.localeCompare(y.root)),
|
|
25155
25174
|
...held ? { held_seconds: held.value } : {},
|
|
25156
25175
|
changes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.22",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
package/web/app.js
CHANGED
|
@@ -4415,7 +4415,7 @@ function renderTerragucciPanel() {
|
|
|
4415
4415
|
head.textContent = lg.text;
|
|
4416
4416
|
head.title = lg.title;
|
|
4417
4417
|
host.appendChild(head);
|
|
4418
|
-
const est = estateLine(a);
|
|
4418
|
+
const est = estateLine(a, now);
|
|
4419
4419
|
if (est) {
|
|
4420
4420
|
const line = document.createElement("div");
|
|
4421
4421
|
line.className = "tg-estate";
|
package/web/kiosk-metrics.js
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
//
|
|
10
10
|
// The pane reads on its own: demo.json for the repo and commit the kiosk is
|
|
11
11
|
// on (on a tool's page, that tool's repo), then the metrics. All GET.
|
|
12
|
+
//
|
|
13
|
+
// The delivery numbers on the demo are the loop's own (terragucci's
|
|
14
|
+
// stack/demo.sh runs terragucci estate after each cycle's audit): demo.json's
|
|
15
|
+
// `delivery` line says so over them, and the section shows no line without one.
|
|
12
16
|
|
|
13
17
|
/** The localStorage key of the viewer's fold. */
|
|
14
18
|
export const METRICS_STORE = "behold.kiosk.metrics";
|
|
@@ -18,9 +22,10 @@ export const METRICS_POLL_MS = 15_000;
|
|
|
18
22
|
|
|
19
23
|
const ACTION_WORDS = { create: "created", update: "updated", delete: "deleted", replace: "replaced", forget: "forgotten", import: "imported", move: "moved" };
|
|
20
24
|
|
|
21
|
-
/** "6.4 s", "48 s", "2 min 5 s", "1 h 20 min", "3 d 4 h". */
|
|
25
|
+
/** "70 ms", "6.4 s", "48 s", "2 min 5 s", "1 h 20 min", "3 d 4 h". Below a second, milliseconds, so 0.07 s never reads as 0.1. */
|
|
22
26
|
export function secondsWords(secs) {
|
|
23
27
|
if (typeof secs !== "number" || !Number.isFinite(secs) || secs < 0) return null;
|
|
28
|
+
if (secs < 1) return `${Math.max(1, Math.round(secs * 1000))} ms`;
|
|
24
29
|
if (secs < 10) return `${Math.round(secs * 10) / 10} s`;
|
|
25
30
|
if (secs < 60) return `${Math.round(secs)} s`;
|
|
26
31
|
const m = Math.floor(secs / 60);
|
|
@@ -50,7 +55,8 @@ export function perWeekWords(n) {
|
|
|
50
55
|
/** "2 created, 1 updated", in the order terragucci's actions read; null for none. */
|
|
51
56
|
export function changeWords(changes) {
|
|
52
57
|
const parts = Object.entries(changes || {})
|
|
53
|
-
|
|
58
|
+
// Only what changed a resource: a no-op or a read is not a change.
|
|
59
|
+
.filter(([a, n]) => a in ACTION_WORDS && typeof n === "number" && n > 0)
|
|
54
60
|
.sort((a, b) => Object.keys(ACTION_WORDS).indexOf(a[0]) - Object.keys(ACTION_WORDS).indexOf(b[0]))
|
|
55
61
|
.map(([a, n]) => `${n} ${ACTION_WORDS[a] || a}`);
|
|
56
62
|
return parts.length ? parts.join(", ") : null;
|
|
@@ -65,9 +71,10 @@ export function clockWords(unix) {
|
|
|
65
71
|
|
|
66
72
|
/**
|
|
67
73
|
* What the pane shows, from one /api/metrics answer, or null for no pane:
|
|
68
|
-
* `{ count, run: { label, waves: [{ head, rows: [[label, value, root?]] }] } | null, dora: [[label, value]] | null }`.
|
|
74
|
+
* `{ count, run: { label, waves: [{ head, rows: [[label, value, root?]] }] } | null, dora: [[label, value]] | null, note? }`.
|
|
75
|
+
* `note` is the line over the delivery numbers, demo.json's `delivery`, when there are numbers and a line.
|
|
69
76
|
*/
|
|
70
|
-
export function metricsModel(answer) {
|
|
77
|
+
export function metricsModel(answer, delivery = null) {
|
|
71
78
|
if (!answer || answer.error) return null;
|
|
72
79
|
let run = null;
|
|
73
80
|
if (answer.run && Array.isArray(answer.run.waves)) {
|
|
@@ -75,9 +82,11 @@ export function metricsModel(answer) {
|
|
|
75
82
|
for (const w of answer.run.waves) {
|
|
76
83
|
const rows = [];
|
|
77
84
|
for (const r of w.roots || []) {
|
|
85
|
+
const init = secondsWords(r.init_seconds);
|
|
86
|
+
const lock = r.lock_wait_seconds > 0 ? secondsWords(r.lock_wait_seconds) : null;
|
|
78
87
|
const plan = secondsWords(r.plan_seconds);
|
|
79
88
|
const apply = secondsWords(r.apply_seconds);
|
|
80
|
-
const parts = [plan && `plan ${plan}`, apply && `apply ${apply}`].filter(Boolean);
|
|
89
|
+
const parts = [init && `init ${init}`, lock && `lock wait ${lock}`, plan && `plan ${plan}`, apply && `apply ${apply}`].filter(Boolean);
|
|
81
90
|
if (parts.length) rows.push([r.root, parts.join(" · "), r.root]);
|
|
82
91
|
}
|
|
83
92
|
const held = secondsWords(w.held_seconds);
|
|
@@ -86,7 +95,9 @@ export function metricsModel(answer) {
|
|
|
86
95
|
if (since) rows.push(["Waiting since", since]);
|
|
87
96
|
const changed = changeWords(w.changes);
|
|
88
97
|
if (changed) rows.push(["Applied", changed]);
|
|
89
|
-
|
|
98
|
+
// The wave's job time leads: the binary's own runs are a small part of it.
|
|
99
|
+
const took = secondsWords(w.seconds);
|
|
100
|
+
if (rows.length || took) waves.push({ wave: w.wave, head: `Wave ${w.wave}`, took: took ? `${took} in all` : null, rows });
|
|
90
101
|
}
|
|
91
102
|
if (waves.length) {
|
|
92
103
|
const c = answer.run.commit ? ` · ${String(answer.run.commit).slice(0, 8)}` : "";
|
|
@@ -107,7 +118,8 @@ export function metricsModel(answer) {
|
|
|
107
118
|
if (!run && !dora) return null;
|
|
108
119
|
const n = run ? run.waves.length : 0;
|
|
109
120
|
const count = [n ? `${n} ${n === 1 ? "wave" : "waves"}` : null, dora ? `${dora.length} delivery` : null].filter(Boolean).join(" · ");
|
|
110
|
-
|
|
121
|
+
const note = dora && typeof delivery === "string" && delivery.trim() ? delivery.trim() : null;
|
|
122
|
+
return { count, run, dora, ...(note ? { note } : {}) };
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
/** The viewer's fold: true open, false folded, null when they never chose. */
|
|
@@ -152,14 +164,17 @@ body.k-has-metrics.k-notyet #view-pane { grid-row: 1; }
|
|
|
152
164
|
.k-metrics-label { margin: 0.35em 0 0.2em; font: 600 0.72em var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
|
|
153
165
|
.k-metrics-waves { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; }
|
|
154
166
|
.k-metrics-wave { background: var(--surface-box); border-radius: 6px; padding: 0.3em 0.6em 0.35em; }
|
|
155
|
-
.k-metrics-wave-head { font: 700 0.85em var(--font-mono); color: var(--fg); }
|
|
167
|
+
.k-metrics-wave-head { display: flex; gap: 0.7em; align-items: baseline; font: 700 0.85em var(--font-mono); color: var(--fg); }
|
|
168
|
+
.k-metrics-took { margin-left: auto; font: 600 1.05em var(--font-ui); color: var(--fg); font-variant-numeric: tabular-nums; }
|
|
156
169
|
.k-metrics-rows { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr); gap: 0.05em 0.7em; margin: 0.1em 0 0; }
|
|
157
170
|
.k-metrics-rows dt.k-metrics-root, .k-metrics-rows dt.k-metrics-root + dd { grid-column: 1 / -1; }
|
|
158
|
-
.k-metrics-rows dt.k-metrics-root + dd { padding-left: 0.8em; }
|
|
171
|
+
.k-metrics-rows dt.k-metrics-root + dd { padding-left: 0.8em; white-space: normal; }
|
|
172
|
+
.k-metrics-part { white-space: nowrap; }
|
|
159
173
|
.k-metrics-rows dt { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
160
174
|
.k-metrics-rows dt.k-metrics-root { font-family: var(--font-mono); color: var(--fg); }
|
|
161
175
|
.k-metrics-rows dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
162
176
|
.k-metrics-dora { background: var(--surface-box); border-radius: 6px; padding: 0.3em 0.6em 0.35em; }
|
|
177
|
+
.k-metrics-note { margin: 0 0 0.3em; color: var(--muted); font-size: 0.92em; line-height: 1.35; }
|
|
163
178
|
@media (max-width: 900px) and (min-width: 601px) { body.k-has-metrics #runs-main, body.k-has-metrics #view-pane { grid-row: auto; } body.k-has-metrics #k-metrics { grid-row: auto; grid-column: auto; } body.k-has-metrics #stage { grid-template-rows: none; } }
|
|
164
179
|
@media (max-width: 600px) { #k-metrics, body.k-has-metrics #k-metrics { order: 2; margin: 0.6em 16px 0; max-height: none; } }
|
|
165
180
|
`;
|
|
@@ -177,7 +192,13 @@ function rowsEl(doc, rows, cls = "k-metrics-rows") {
|
|
|
177
192
|
const dt = el(doc, "dt", root ? "k-metrics-root" : null, label);
|
|
178
193
|
if (root) dt.dataset.kRoot = root;
|
|
179
194
|
dt.title = label;
|
|
180
|
-
|
|
195
|
+
const dd = el(doc, "dd");
|
|
196
|
+
// A root's timings wrap between parts, never inside one ("apply 58 ms").
|
|
197
|
+
value.split(" · ").forEach((part, i) => {
|
|
198
|
+
if (i) dd.append(" · ");
|
|
199
|
+
dd.append(el(doc, "span", "k-metrics-part", part));
|
|
200
|
+
});
|
|
201
|
+
dl.append(dt, dd);
|
|
181
202
|
}
|
|
182
203
|
return dl;
|
|
183
204
|
}
|
|
@@ -203,13 +224,17 @@ export function renderMetrics(host, model, { open = true, onToggle = () => {}, d
|
|
|
203
224
|
for (const w of model.run.waves) {
|
|
204
225
|
const li = el(doc, "li", "k-metrics-wave");
|
|
205
226
|
li.dataset.kWave = String(w.wave);
|
|
206
|
-
|
|
227
|
+
const head = el(doc, "div", "k-metrics-wave-head", w.head);
|
|
228
|
+
if (w.took) head.append(el(doc, "span", "k-metrics-took", w.took));
|
|
229
|
+
li.append(head);
|
|
230
|
+
if (w.rows.length) li.append(rowsEl(doc, w.rows));
|
|
207
231
|
list.appendChild(li);
|
|
208
232
|
}
|
|
209
233
|
body.appendChild(list);
|
|
210
234
|
}
|
|
211
235
|
if (model.dora) {
|
|
212
236
|
body.appendChild(el(doc, "h3", "k-metrics-label", "Delivery (DORA)"));
|
|
237
|
+
if (model.note) body.appendChild(el(doc, "p", "k-metrics-note", model.note));
|
|
213
238
|
const box = el(doc, "div", "k-metrics-dora");
|
|
214
239
|
box.appendChild(rowsEl(doc, model.dora));
|
|
215
240
|
body.appendChild(box);
|
|
@@ -265,7 +290,7 @@ export function startMetrics(host, { tool = null, fetchJson = defaultFetch, stor
|
|
|
265
290
|
const demo = await fetchJson("/api/terragucci/demo");
|
|
266
291
|
const cycle = tool && !(demo && demo.demo && demo.demo.tool === tool) ? await fetchJson(`/api/terragucci/cycles/${tool}`) : null;
|
|
267
292
|
const target = metricsTarget(demo, cycle, tool);
|
|
268
|
-
const next = target ? metricsModel(await fetchJson(metricsUrl(target))) : null;
|
|
293
|
+
const next = target ? metricsModel(await fetchJson(metricsUrl(target)), demo && demo.demo ? demo.demo.delivery : null) : null;
|
|
269
294
|
if (JSON.stringify(next) !== JSON.stringify(model)) {
|
|
270
295
|
model = next;
|
|
271
296
|
draw();
|
|
@@ -12,7 +12,7 @@ const answer = () => ({
|
|
|
12
12
|
commit: C1,
|
|
13
13
|
current: true,
|
|
14
14
|
waves: [
|
|
15
|
-
{ wave: 1, run: "4101", roots: [{ root: "network", plan_seconds:
|
|
15
|
+
{ wave: 1, run: "4101", seconds: 5.36, roots: [{ root: "network", init_seconds: 0.163, plan_seconds: 0.07, apply_seconds: 0.06 }], changes: { update: 1 }, settled_at: 1000 },
|
|
16
16
|
{ wave: 2, run: "4102", roots: [{ root: "app", plan_seconds: 7.2, apply_seconds: 3.4 }], held_seconds: 95, changes: { update: 1, create: 2 }, settled_at: 1200 },
|
|
17
17
|
],
|
|
18
18
|
},
|
|
@@ -21,7 +21,7 @@ const answer = () => ({
|
|
|
21
21
|
|
|
22
22
|
describe("kiosk metrics: the words", () => {
|
|
23
23
|
it("reads seconds with their unit, short", () => {
|
|
24
|
-
expect([6.44, 48.4, 125, 120, 4800, 3600, 97200].map(secondsWords)).toEqual(["6.4 s", "48 s", "2 min 5 s", "2 min", "1 h 20 min", "1 h", "1 d 3 h"]);
|
|
24
|
+
expect([0.07, 0.0004, 0.999, 6.44, 48.4, 125, 120, 4800, 3600, 97200].map(secondsWords)).toEqual(["70 ms", "1 ms", "999 ms", "6.4 s", "48 s", "2 min 5 s", "2 min", "1 h 20 min", "1 h", "1 d 3 h"]);
|
|
25
25
|
expect(secondsWords(undefined)).toBeNull();
|
|
26
26
|
expect(secondsWords(-1)).toBeNull();
|
|
27
27
|
});
|
|
@@ -30,6 +30,8 @@ describe("kiosk metrics: the words", () => {
|
|
|
30
30
|
expect([percentWords(0.1), percentWords(0.0833), percentWords(0)]).toEqual(["10%", "8.3%", "0%"]);
|
|
31
31
|
expect(perWeekWords(4.54)).toBe("4.5 a week");
|
|
32
32
|
expect(changeWords({ update: 1, create: 2, delete: 0 })).toBe("2 created, 1 updated");
|
|
33
|
+
expect(changeWords({ "no-op": 2, read: 1, replace: 1 })).toBe("1 replaced");
|
|
34
|
+
expect(changeWords({ "no-op": 2 })).toBeNull();
|
|
33
35
|
expect(changeWords({})).toBeNull();
|
|
34
36
|
});
|
|
35
37
|
});
|
|
@@ -40,8 +42,8 @@ describe("kiosk metrics: what the pane shows", () => {
|
|
|
40
42
|
expect(m.count).toBe("2 waves · 3 delivery");
|
|
41
43
|
expect(m.run.label).toBe("This run · 9f3c2a71");
|
|
42
44
|
expect(m.run.waves).toEqual([
|
|
43
|
-
{ wave: 1, head: "Wave 1", rows: [["network", "plan
|
|
44
|
-
{ wave: 2, head: "Wave 2", rows: [["app", "plan 7.2 s · apply 3.4 s", "app"], ["Held at the gate", "1 min 35 s"], ["Applied", "2 created, 1 updated"]] },
|
|
45
|
+
{ wave: 1, head: "Wave 1", took: "5.4 s in all", rows: [["network", "init 163 ms · plan 70 ms · apply 60 ms", "network"], ["Applied", "1 updated"]] },
|
|
46
|
+
{ wave: 2, head: "Wave 2", took: null, rows: [["app", "plan 7.2 s · apply 3.4 s", "app"], ["Held at the gate", "1 min 35 s"], ["Applied", "2 created, 1 updated"]] },
|
|
45
47
|
]);
|
|
46
48
|
expect(m.dora).toEqual([["Deploys", "30 a week"], ["Lead time", "15 min"], ["Change failure rate", "10%"]]);
|
|
47
49
|
});
|
|
@@ -56,8 +58,8 @@ describe("kiosk metrics: what the pane shows", () => {
|
|
|
56
58
|
|
|
57
59
|
it("a waiting wave says since when, by the viewer's clock", () => {
|
|
58
60
|
const a = answer();
|
|
59
|
-
a.run.waves = [{ wave: 2, run: "4101", roots: [{ root: "app", plan_seconds: 7.9 }], changes: {}, waiting_since: Date.parse("2026-10-16T14:05:00") / 1000 }];
|
|
60
|
-
expect(metricsModel(a).run.waves[0].rows).toEqual([["app", "plan 7.9 s", "app"], ["Waiting since", "14:05"]]);
|
|
61
|
+
a.run.waves = [{ wave: 2, run: "4101", roots: [{ root: "app", plan_seconds: 7.9, lock_wait_seconds: 1.5 }], changes: {}, waiting_since: Date.parse("2026-10-16T14:05:00") / 1000 }];
|
|
62
|
+
expect(metricsModel(a).run.waves[0].rows).toEqual([["app", "lock wait 1.5 s · plan 7.9 s", "app"], ["Waiting since", "14:05"]]);
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
it("shows no pane for no answer, a refusal, or nothing for the repo; a part with no number is left out", () => {
|
|
@@ -68,6 +70,16 @@ describe("kiosk metrics: what the pane shows", () => {
|
|
|
68
70
|
const onlyDora = metricsModel({ run: null, dora: { from: "dora.json", restore_seconds: 600 } });
|
|
69
71
|
expect(onlyDora).toEqual({ count: "1 delivery", run: null, dora: [["Time to restore", "10 min"]] });
|
|
70
72
|
});
|
|
73
|
+
|
|
74
|
+
it("puts demo.json's delivery line over the delivery numbers, and only when there are numbers (behold#571)", () => {
|
|
75
|
+
const line = "Counted from this demo loop's own runs, where the failure scenario fails on purpose each cycle.";
|
|
76
|
+
expect(metricsModel(answer(), ` ${line}`).note).toBe(line);
|
|
77
|
+
expect(metricsModel(answer(), null).note).toBeUndefined();
|
|
78
|
+
expect(metricsModel(answer(), " ").note).toBeUndefined();
|
|
79
|
+
const noDora = { ...answer(), dora: null };
|
|
80
|
+
expect(metricsModel(noDora, line).note).toBeUndefined();
|
|
81
|
+
expect(metricsModel(noDora, line).dora).toBeNull();
|
|
82
|
+
});
|
|
71
83
|
});
|
|
72
84
|
|
|
73
85
|
describe("kiosk metrics: which repo, and the fold", () => {
|
package/web/terragucci.js
CHANGED
|
@@ -127,12 +127,13 @@ export function waveCards(answer, now = new Date()) {
|
|
|
127
127
|
}));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/** terragucci's own counts, as its estate page shows them, with the page's link. */
|
|
131
|
-
export function estateLine(answer) {
|
|
130
|
+
/** terragucci's own counts, as its estate page shows them, with the page's link. A page older than the newest run says when it was written. */
|
|
131
|
+
export function estateLine(answer, now = new Date()) {
|
|
132
132
|
if (!answer.estate) return null;
|
|
133
133
|
const e = answer.estate;
|
|
134
|
+
const when = e.behind ? `, written ${ago(e.generated, now)}, before the newest run` : "";
|
|
134
135
|
return {
|
|
135
|
-
text: `terragucci's estate page: ${e.drifted} root${e.drifted === 1 ? "" : "s"} drifted · ${e.failed} failed · ${e.waiting} wave${e.waiting === 1 ? "" : "s"} waiting`,
|
|
136
|
+
text: `terragucci's estate page${when}: ${e.drifted} root${e.drifted === 1 ? "" : "s"} drifted · ${e.failed} failed · ${e.waiting} wave${e.waiting === 1 ? "" : "s"} waiting`,
|
|
136
137
|
href: hrefOf(answer, e.html),
|
|
137
138
|
};
|
|
138
139
|
}
|
package/web/terragucci.test.js
CHANGED
|
@@ -93,4 +93,11 @@ describe("a waiting wave is a gate card with a line to copy, never a button (#49
|
|
|
93
93
|
});
|
|
94
94
|
expect(estateLine({})).toBeNull();
|
|
95
95
|
});
|
|
96
|
+
|
|
97
|
+
it("says when a page older than the newest run was written (behold#571)", () => {
|
|
98
|
+
const now = new Date("2026-10-16T08:30:00Z");
|
|
99
|
+
expect(estateLine({ files: "../../", estate: { drifted: 0, failed: 0, waiting: 0, html: "estate.html", generated: "2026-10-16T08:24:00Z", behind: true } }, now).text).toBe(
|
|
100
|
+
"terragucci's estate page, written 6m ago, before the newest run: 0 roots drifted · 0 failed · 0 waves waiting",
|
|
101
|
+
);
|
|
102
|
+
});
|
|
96
103
|
});
|