@intentius/behold 0.29.20 → 0.29.21

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 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
- (each root's plan and apply seconds, the time an approval held the wave at
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
@@ -25080,8 +25080,12 @@ var METRICS_TTL_MS = 3e4;
25080
25080
  var RUN_WINDOW = "3h";
25081
25081
  var DORA_WINDOW = "7d";
25082
25082
  var QUERIES = {
25083
+ waveSeconds: `max by (project, commit, run, wave) (last_over_time(terragucci_stage_duration_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
25084
+ rootInit: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_init_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
25083
25085
  rootPlan: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_plan_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
25084
25086
  rootApply: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_apply_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
25087
+ // A lock wait carries no wave: a root's wave is found from its other timings in the same run.
25088
+ lockWait: `max by (project, commit, run, root) (last_over_time(terragucci_lock_wait_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
25085
25089
  held: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_held_seconds[${RUN_WINDOW}]))`,
25086
25090
  changes: `max by (project, commit, run, wave, action) (last_over_time(terragucci_wave_changes[${RUN_WINDOW}]))`,
25087
25091
  settled: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_settled_seconds[${RUN_WINDOW}]))`,
@@ -25117,7 +25121,7 @@ function parseVector(body) {
25117
25121
  var key = (s) => `${s.labels.commit ?? ""}\0${s.labels.run ?? ""}\0${s.labels.wave ?? ""}`;
25118
25122
  function runOf(a, repo, commit) {
25119
25123
  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) };
25124
+ 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
25125
  const moved = /* @__PURE__ */ new Map();
25122
25126
  const note = (s) => {
25123
25127
  const k = key(s);
@@ -25125,7 +25129,7 @@ function runOf(a, repo, commit) {
25125
25129
  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
25130
  };
25127
25131
  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 });
25132
+ 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
25133
  if (moved.size === 0) return null;
25130
25134
  const commits = /* @__PURE__ */ new Map();
25131
25135
  for (const m of moved.values()) commits.set(m.commit, Math.max(commits.get(m.commit) ?? 0, m.at));
@@ -25141,8 +25145,15 @@ function runOf(a, repo, commit) {
25141
25145
  const out = [];
25142
25146
  for (const [wave, { run: run3 }] of [...waves.entries()].sort((x, y) => x[0] - y[0])) {
25143
25147
  const roots = /* @__PURE__ */ new Map();
25148
+ const put = (root, v) => roots.set(root, { ...roots.get(root) ?? { root }, ...v });
25149
+ for (const s of of(rows.rootInit, wave, run3)) if (s.labels.root) put(s.labels.root, { init_seconds: s.value });
25144
25150
  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
25151
  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 });
25152
+ for (const s of a.lockWait) {
25153
+ const r = s.labels.root;
25154
+ 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 });
25155
+ }
25156
+ const wall = of(rows.waveSeconds, wave, run3)[0];
25146
25157
  const changes = {};
25147
25158
  for (const s of of(rows.changes, wave, run3)) if (s.labels.action && s.value > 0) changes[s.labels.action] = s.value;
25148
25159
  const held = of(rows.held, wave, run3)[0];
@@ -25151,6 +25162,7 @@ function runOf(a, repo, commit) {
25151
25162
  out.push({
25152
25163
  wave,
25153
25164
  run: run3 || null,
25165
+ ...wall ? { seconds: wall.value } : {},
25154
25166
  roots: [...roots.values()].sort((x, y) => x.root.localeCompare(y.root)),
25155
25167
  ...held ? { held_seconds: held.value } : {},
25156
25168
  changes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.20",
3
+ "version": "0.29.21",
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.",
@@ -18,9 +18,10 @@ export const METRICS_POLL_MS = 15_000;
18
18
 
19
19
  const ACTION_WORDS = { create: "created", update: "updated", delete: "deleted", replace: "replaced", forget: "forgotten", import: "imported", move: "moved" };
20
20
 
21
- /** "6.4 s", "48 s", "2 min 5 s", "1 h 20 min", "3 d 4 h". */
21
+ /** "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
22
  export function secondsWords(secs) {
23
23
  if (typeof secs !== "number" || !Number.isFinite(secs) || secs < 0) return null;
24
+ if (secs < 1) return `${Math.max(1, Math.round(secs * 1000))} ms`;
24
25
  if (secs < 10) return `${Math.round(secs * 10) / 10} s`;
25
26
  if (secs < 60) return `${Math.round(secs)} s`;
26
27
  const m = Math.floor(secs / 60);
@@ -50,7 +51,8 @@ export function perWeekWords(n) {
50
51
  /** "2 created, 1 updated", in the order terragucci's actions read; null for none. */
51
52
  export function changeWords(changes) {
52
53
  const parts = Object.entries(changes || {})
53
- .filter(([, n]) => typeof n === "number" && n > 0)
54
+ // Only what changed a resource: a no-op or a read is not a change.
55
+ .filter(([a, n]) => a in ACTION_WORDS && typeof n === "number" && n > 0)
54
56
  .sort((a, b) => Object.keys(ACTION_WORDS).indexOf(a[0]) - Object.keys(ACTION_WORDS).indexOf(b[0]))
55
57
  .map(([a, n]) => `${n} ${ACTION_WORDS[a] || a}`);
56
58
  return parts.length ? parts.join(", ") : null;
@@ -75,9 +77,11 @@ export function metricsModel(answer) {
75
77
  for (const w of answer.run.waves) {
76
78
  const rows = [];
77
79
  for (const r of w.roots || []) {
80
+ const init = secondsWords(r.init_seconds);
81
+ const lock = r.lock_wait_seconds > 0 ? secondsWords(r.lock_wait_seconds) : null;
78
82
  const plan = secondsWords(r.plan_seconds);
79
83
  const apply = secondsWords(r.apply_seconds);
80
- const parts = [plan && `plan ${plan}`, apply && `apply ${apply}`].filter(Boolean);
84
+ const parts = [init && `init ${init}`, lock && `lock wait ${lock}`, plan && `plan ${plan}`, apply && `apply ${apply}`].filter(Boolean);
81
85
  if (parts.length) rows.push([r.root, parts.join(" · "), r.root]);
82
86
  }
83
87
  const held = secondsWords(w.held_seconds);
@@ -86,7 +90,9 @@ export function metricsModel(answer) {
86
90
  if (since) rows.push(["Waiting since", since]);
87
91
  const changed = changeWords(w.changes);
88
92
  if (changed) rows.push(["Applied", changed]);
89
- if (rows.length) waves.push({ wave: w.wave, head: `Wave ${w.wave}`, rows });
93
+ // The wave's job time leads: the binary's own runs are a small part of it.
94
+ const took = secondsWords(w.seconds);
95
+ if (rows.length || took) waves.push({ wave: w.wave, head: `Wave ${w.wave}`, took: took ? `${took} in all` : null, rows });
90
96
  }
91
97
  if (waves.length) {
92
98
  const c = answer.run.commit ? ` · ${String(answer.run.commit).slice(0, 8)}` : "";
@@ -152,10 +158,12 @@ body.k-has-metrics.k-notyet #view-pane { grid-row: 1; }
152
158
  .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
159
  .k-metrics-waves { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; }
154
160
  .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); }
161
+ .k-metrics-wave-head { display: flex; gap: 0.7em; align-items: baseline; font: 700 0.85em var(--font-mono); color: var(--fg); }
162
+ .k-metrics-took { margin-left: auto; font: 600 1.05em var(--font-ui); color: var(--fg); font-variant-numeric: tabular-nums; }
156
163
  .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
164
  .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; }
165
+ .k-metrics-rows dt.k-metrics-root + dd { padding-left: 0.8em; white-space: normal; }
166
+ .k-metrics-part { white-space: nowrap; }
159
167
  .k-metrics-rows dt { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
160
168
  .k-metrics-rows dt.k-metrics-root { font-family: var(--font-mono); color: var(--fg); }
161
169
  .k-metrics-rows dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -177,7 +185,13 @@ function rowsEl(doc, rows, cls = "k-metrics-rows") {
177
185
  const dt = el(doc, "dt", root ? "k-metrics-root" : null, label);
178
186
  if (root) dt.dataset.kRoot = root;
179
187
  dt.title = label;
180
- dl.append(dt, el(doc, "dd", null, value));
188
+ const dd = el(doc, "dd");
189
+ // A root's timings wrap between parts, never inside one ("apply 58 ms").
190
+ value.split(" · ").forEach((part, i) => {
191
+ if (i) dd.append(" · ");
192
+ dd.append(el(doc, "span", "k-metrics-part", part));
193
+ });
194
+ dl.append(dt, dd);
181
195
  }
182
196
  return dl;
183
197
  }
@@ -203,7 +217,10 @@ export function renderMetrics(host, model, { open = true, onToggle = () => {}, d
203
217
  for (const w of model.run.waves) {
204
218
  const li = el(doc, "li", "k-metrics-wave");
205
219
  li.dataset.kWave = String(w.wave);
206
- li.append(el(doc, "div", "k-metrics-wave-head", w.head), rowsEl(doc, w.rows));
220
+ const head = el(doc, "div", "k-metrics-wave-head", w.head);
221
+ if (w.took) head.append(el(doc, "span", "k-metrics-took", w.took));
222
+ li.append(head);
223
+ if (w.rows.length) li.append(rowsEl(doc, w.rows));
207
224
  list.appendChild(li);
208
225
  }
209
226
  body.appendChild(list);
@@ -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: 6.4, apply_seconds: 2.1 }], changes: { update: 1 }, settled_at: 1000 },
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 6.4 s · apply 2.1 s", "network"], ["Applied", "1 updated"]] },
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", () => {