@intentius/behold 0.29.21 → 0.29.23

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/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 newest2 = (best) => !best || new Date(r.timestamp).getTime() >= new Date(best.timestamp).getTime();
20719
+ const newest3 = (best) => !best || new Date(r.timestamp).getTime() >= new Date(best.timestamp).getTime();
20720
20720
  if (samePlanDigest(r.planDigest, planDigest)) {
20721
- if (newest2(matched)) matched = r;
20722
- } else if (newest2(mismatched)) {
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 newest2 = /* @__PURE__ */ new Map();
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 = newest2.get(p.gate);
20963
- if (!before || time(p.timestamp) >= time(before.timestamp)) newest2.set(p.gate, p);
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 [...newest2.values()].map((p) => {
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 (estateProject) {
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: estateProject ? "estate" : "index"
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,6 +25083,8 @@ 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 = {
25083
25089
  waveSeconds: `max by (project, commit, run, wave) (last_over_time(terragucci_stage_duration_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
25084
25090
  rootInit: `max by (project, commit, run, wave, root) (last_over_time(terragucci_root_init_seconds{stage="tf-apply"}[${RUN_WINDOW}]))`,
@@ -25090,10 +25096,11 @@ var QUERIES = {
25090
25096
  changes: `max by (project, commit, run, wave, action) (last_over_time(terragucci_wave_changes[${RUN_WINDOW}]))`,
25091
25097
  settled: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_settled_seconds[${RUN_WINDOW}]))`,
25092
25098
  waiting: `max by (project, commit, run, wave) (last_over_time(terragucci_wave_waiting_since_seconds[${RUN_WINDOW}]))`,
25093
- deployments: `max by (project) (last_over_time(terragucci_dora_deployments_per_week[${DORA_WINDOW}]))`,
25094
- leadTime: `max by (project) (last_over_time(terragucci_dora_lead_time_seconds{segment="total"}[${DORA_WINDOW}]))`,
25095
- failureRate: `max by (project) (last_over_time(terragucci_dora_change_failure_ratio[${DORA_WINDOW}]))`,
25096
- restore: `max by (project) (last_over_time(terragucci_dora_restore_seconds[${DORA_WINDOW}]))`
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")
25097
25104
  };
25098
25105
  var REPO = /^(?:[A-Za-z0-9][A-Za-z0-9._-]{0,99}\/)?[A-Za-z0-9._-]{1,100}$/;
25099
25106
  var COMMIT = /^[0-9a-f]{7,64}$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.21",
3
+ "version": "0.29.23",
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
@@ -21,6 +21,7 @@ import { renderLane } from "./terragucci-lifecycle.js";
21
21
  import { renderReleases } from "./releases.js";
22
22
  import { renderYodelLane } from "./sql-yodeler-lane.js";
23
23
  import { initTerragucciEstate } from "./terragucci-estate.js";
24
+ import { noStateFill } from "./frame-fill.js";
24
25
  import { componentMarks as tgComponentMarks, runsCommit as tgRunsCommit, waveOfKey as tgWaveOfKey } from "./terragucci-components-live.js";
25
26
  import { FORGES, MARK, componentsForge, forgeOfName, iconSvg, markLink, markTitle, waveJobUrl } from "./forge-mark.js";
26
27
  import { TOOLS, orderTools } from "./tool-mark.js";
@@ -32,7 +33,7 @@ import { edgeKey, edgeLabel, edgeLegend, edgeTitle, isCiKind, viaIndex } from ".
32
33
  import { readCostLine } from "./read-cost.js";
33
34
  import { mountHistoryPicker } from "./history-picker.js";
34
35
  import { applyMemberFrame, pendingLine, stillPending } from "./pending.js";
35
- import { initTheme, setTheme, mountThemePicker, readableOn, colorForCategory, onThemeChange, getTokens, getTheme, pinTokensFor } from "./theme.js";
36
+ import { initTheme, setTheme, mountThemePicker, readableOn, inkOn, colorForCategory, onThemeChange, getTokens, getTheme, pinTokensFor } from "./theme.js";
36
37
  // #399 M2 / #401 M4 of #397: the colour-by modes' arithmetic and the
37
38
  // provenance badge's wording — every decision the behaviour overlay makes,
38
39
  // pure and unit-tested beside the file. This module owns the fetches, the SVG
@@ -203,9 +204,13 @@ function colourPlan(graphIr) {
203
204
  // #569 review: a terragucci repo's view with no drift read draws each root's
204
205
  // wave state on its box, so the cards wear the neutral ground: colour there
205
206
  // means a wave's state, never a category hue that reads as an error.
206
- if (mode === "drift" && tokens && tgStatesDrawn(graphIr)) {
207
+ // behold#571: in the kiosk's frame a card's state is its outline, bar and
208
+ // words, never its fill, so a card with no state yet (before the pull
209
+ // request's first plan, or reports that name another checkout) wears the
210
+ // same neutral ground, not a category hue that reads as an error.
211
+ if (mode === "drift" && tokens && (tgStatesDrawn(graphIr) || noStateFill({ frame: !!embedOpts.bare, live: graphIr.nodes.some((n) => n.attrs && n.attrs._status) }))) {
207
212
  const neutral = theme ? pinTokensFor(theme).neutralFill : tokens.neutral;
208
- return { mode, fillOf: () => ({ fill: neutral, unpriced: false }) };
213
+ return { mode, neutral: true, fillOf: () => ({ fill: neutral, unpriced: false }) };
209
214
  }
210
215
  if (mode === "drift" || !tokens) {
211
216
  return { mode, fillOf: (id) => ({ fill: colorForCategory(kindOf.get(id)), unpriced: false }) };
@@ -242,7 +247,8 @@ function recolorNodesByCategory(ir) {
242
247
  const kind = kindOf.get(id);
243
248
  if (!kind) continue;
244
249
  const paint = plan.fillOf(id);
245
- const cat = paint.fill, ink = readableOn(cat);
250
+ // behold#571: on the neutral card ground, the ink that reads best on it (theme.js inkOn).
251
+ const cat = paint.fill, ink = plan.neutral ? inkOn(cat) : readableOn(cat);
246
252
  // #399: an unpriced card is marked, not merely coloured — a hex cannot be
247
253
  // read back out into "the engine did not price this", and the legend's
248
254
  // unpriced count has to agree with what is on the canvas.
@@ -4415,7 +4421,7 @@ function renderTerragucciPanel() {
4415
4421
  head.textContent = lg.text;
4416
4422
  head.title = lg.title;
4417
4423
  host.appendChild(head);
4418
- const est = estateLine(a);
4424
+ const est = estateLine(a, now);
4419
4425
  if (est) {
4420
4426
  const line = document.createElement("div");
4421
4427
  line.className = "tg-estate";
@@ -0,0 +1,16 @@
1
+ // behold#571: the kiosk frame's card fill. In the frame a card's state is its
2
+ // outline, its bar and its words (web/app.js drawTgReads), never its fill, so
3
+ // every card there wears the theme's neutral card ground (pinTokensFor's
4
+ // `neutralFill`, the ground frameInks makes each state's words readable on).
5
+ // That holds for a card with no state yet, too: before a pull request's first
6
+ // plan, or when the reports name another checkout. Left to the category
7
+ // palette, such a card took the theme's hue for its kind, which in Sea Shells
8
+ // and others is a crimson that reads as "broken".
9
+ //
10
+ // Outside the frame, and on a graph that carries a live read (`_status`),
11
+ // the fill stays the category hue it always was.
12
+
13
+ /** Whether the cards take the neutral fill: in the kiosk's frame, on a graph with no live read. */
14
+ export function noStateFill({ frame = false, live = false } = {}) {
15
+ return !!frame && !live;
16
+ }
@@ -0,0 +1,34 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { noStateFill } from "./frame-fill.js";
3
+ import { contrast, frameInks, inkOn, pinTokensFor, tokensFor } from "./theme.js";
4
+ import { THEMES } from "./themes.js";
5
+
6
+ // behold#571: a card in the kiosk's frame with no state yet wears the neutral
7
+ // card ground, never its category hue (crimson in Sea Shells, which read as
8
+ // "broken"), and stays readable on it in every theme.
9
+ describe("the kiosk frame's card fill (behold#571)", () => {
10
+ it("is the neutral ground in the frame, on a graph with no live read", () => {
11
+ expect(noStateFill({ frame: true })).toBe(true);
12
+ expect(noStateFill({ frame: true, live: true })).toBe(false);
13
+ expect(noStateFill({ frame: false })).toBe(false);
14
+ });
15
+
16
+ it("was Sea Shells' crimson before, and is its neutral card ground now", () => {
17
+ const th = THEMES["Sea Shells"];
18
+ const fill = pinTokensFor(th).neutralFill;
19
+ expect(fill).not.toBe(tokensFor(th).degraded);
20
+ expect(contrast(fill, "#b8304a")).toBeGreaterThan(1.5);
21
+ });
22
+
23
+ it("keeps a card's name and every state's words readable on it, in every theme (frameInks)", () => {
24
+ const short = [];
25
+ for (const th of Object.values(THEMES)) {
26
+ const fill = pinTokensFor(th).neutralFill;
27
+ const name = inkOn(fill);
28
+ if (contrast(name, fill) < 4.5) short.push(`${th.name} name ${name} on ${fill}: ${contrast(name, fill).toFixed(2)}`);
29
+ const inks = frameInks(th).card;
30
+ for (const [s, c] of Object.entries(inks)) if (contrast(c, fill) < 4.5) short.push(`${th.name} ${s} ${c} on ${fill}`);
31
+ }
32
+ expect(short).toEqual([]);
33
+ });
34
+ });
@@ -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";
@@ -67,9 +71,10 @@ export function clockWords(unix) {
67
71
 
68
72
  /**
69
73
  * What the pane shows, from one /api/metrics answer, or null for no pane:
70
- * `{ 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.
71
76
  */
72
- export function metricsModel(answer) {
77
+ export function metricsModel(answer, delivery = null) {
73
78
  if (!answer || answer.error) return null;
74
79
  let run = null;
75
80
  if (answer.run && Array.isArray(answer.run.waves)) {
@@ -113,7 +118,8 @@ export function metricsModel(answer) {
113
118
  if (!run && !dora) return null;
114
119
  const n = run ? run.waves.length : 0;
115
120
  const count = [n ? `${n} ${n === 1 ? "wave" : "waves"}` : null, dora ? `${dora.length} delivery` : null].filter(Boolean).join(" · ");
116
- return { count, run, dora };
121
+ const note = dora && typeof delivery === "string" && delivery.trim() ? delivery.trim() : null;
122
+ return { count, run, dora, ...(note ? { note } : {}) };
117
123
  }
118
124
 
119
125
  /** The viewer's fold: true open, false folded, null when they never chose. */
@@ -168,6 +174,7 @@ body.k-has-metrics.k-notyet #view-pane { grid-row: 1; }
168
174
  .k-metrics-rows dt.k-metrics-root { font-family: var(--font-mono); color: var(--fg); }
169
175
  .k-metrics-rows dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
170
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; }
171
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; } }
172
179
  @media (max-width: 600px) { #k-metrics, body.k-has-metrics #k-metrics { order: 2; margin: 0.6em 16px 0; max-height: none; } }
173
180
  `;
@@ -227,6 +234,7 @@ export function renderMetrics(host, model, { open = true, onToggle = () => {}, d
227
234
  }
228
235
  if (model.dora) {
229
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));
230
238
  const box = el(doc, "div", "k-metrics-dora");
231
239
  box.appendChild(rowsEl(doc, model.dora));
232
240
  body.appendChild(box);
@@ -282,7 +290,7 @@ export function startMetrics(host, { tool = null, fetchJson = defaultFetch, stor
282
290
  const demo = await fetchJson("/api/terragucci/demo");
283
291
  const cycle = tool && !(demo && demo.demo && demo.demo.tool === tool) ? await fetchJson(`/api/terragucci/cycles/${tool}`) : null;
284
292
  const target = metricsTarget(demo, cycle, tool);
285
- 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;
286
294
  if (JSON.stringify(next) !== JSON.stringify(model)) {
287
295
  model = next;
288
296
  draw();
@@ -70,6 +70,16 @@ describe("kiosk metrics: what the pane shows", () => {
70
70
  const onlyDora = metricsModel({ run: null, dora: { from: "dora.json", restore_seconds: 600 } });
71
71
  expect(onlyDora).toEqual({ count: "1 delivery", run: null, dora: [["Time to restore", "10 min"]] });
72
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
+ });
73
83
  });
74
84
 
75
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
  }
@@ -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
  });
package/web/theme.js CHANGED
@@ -44,6 +44,10 @@ export function contrast(a, b) {
44
44
  const A = relLuminance(a), B = relLuminance(b);
45
45
  return (Math.max(A, B) + 0.05) / (Math.min(A, B) + 0.05);
46
46
  }
47
+ // behold#571: white or black, whichever reads better on `bg` by the real ratio
48
+ // above. readableOn's quick coin-flip picks white on a mid-tone ground where
49
+ // black reads better (Grass's and Blue Dolphin's neutral card).
50
+ export function inkOn(bg) { return contrast("#ffffff", bg) >= contrast("#000000", bg) ? "#ffffff" : "#000000"; }
47
51
  export function hexToOklch(hex) {
48
52
  const [R, G, B] = hexToRgb(hex).map(s2l);
49
53
  const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B);