@intentius/behold 0.29.17 → 0.29.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.17",
3
+ "version": "0.29.19",
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
@@ -3489,7 +3489,10 @@ function paintTgProgress() {
3489
3489
  // says which run all of it comes from. `view.focus` brings some roots forward
3490
3490
  // and dims the rest. From the pull request's plan, or from the run view once
3491
3491
  // merged. Not live; redrawn on each render and each read.
3492
- const TG_TONE = { plan: "var(--pending)", wait: "var(--foreign)", busy: "var(--runtime)", ok: "var(--managed)", bad: "var(--degraded)", idle: "var(--neutral)" };
3492
+ // behold#571: the state colours as the frame draws them on cards and boxes, each legible on every ground (theme.js frameInks).
3493
+ const TG_TONE = { plan: "var(--frame-pending, var(--pending))", wait: "var(--frame-foreign, var(--foreign))", busy: "var(--frame-runtime, var(--runtime))", ok: "var(--frame-managed, var(--managed))", bad: "var(--frame-degraded, var(--degraded))", idle: "var(--frame-neutral, var(--neutral))" };
3494
+ /** The same, for words on a card: read on the card's own ground. */
3495
+ const TG_CARD_TONE = Object.fromEntries(Object.entries(TG_TONE).map(([k, v]) => [k, v.replace("--frame-", "--frame-card-")]));
3493
3496
  function drawTgReads() {
3494
3497
  if (embedOpts.bare) queueMicrotask(kioskDecorate); // behold#571: once this draw is done
3495
3498
  watchTgRuns(); // #571: the wave boxes' jobs, while the components zoom is on screen
@@ -3748,7 +3751,7 @@ function drawTgReads() {
3748
3751
  };
3749
3752
  const edgeIn = (r) => edgePoints.filter((p) => p.x >= r.x - 3 && p.x <= r.x2 + 3 && p.y >= r.y - 3 && p.y <= r.y2 + 3).length;
3750
3753
  const defs = svg.querySelector("defs") || svg.insertBefore(make("defs", {}), svg.firstChild);
3751
- for (const [id, color] of [["tg-arrow-unknown", "var(--foreign)"], ["tg-arrow-planned", "var(--pending)"], ["tg-arrow-applied", "var(--focus)"]]) {
3754
+ for (const [id, color] of [["tg-arrow-unknown", "var(--frame-foreign, var(--foreign))"], ["tg-arrow-planned", "var(--frame-pending, var(--pending))"], ["tg-arrow-applied", "var(--frame-focus, var(--focus))"]]) {
3752
3755
  if (svg.querySelector(`#${id}`)) continue;
3753
3756
  const m = make("marker", { id, viewBox: "0 0 10 10", refX: 9, refY: 5, markerWidth: 7, markerHeight: 7, orient: "auto-start-reverse", "data-tg-reads": "marker" });
3754
3757
  m.appendChild(make("path", { d: "M0,0 L10,5 L0,10 z", fill: color }));
@@ -3759,7 +3762,7 @@ function drawTgReads() {
3759
3762
  for (const e of edges) {
3760
3763
  const card = tgReadCardIds(tgAnswer, e).map((id) => svg.querySelector('[data-node-id="' + CSS.escape(id) + '"]')).find(Boolean);
3761
3764
  const kind = e.unknown.length ? "unknown" : e.outputs === "planned" ? "planned" : "applied";
3762
- const color = kind === "unknown" ? "var(--foreign)" : kind === "planned" ? "var(--pending)" : "var(--focus)";
3765
+ const color = kind === "unknown" ? "var(--frame-foreign, var(--foreign))" : kind === "planned" ? "var(--frame-pending, var(--pending))" : "var(--frame-focus, var(--focus))";
3763
3766
  if (card) {
3764
3767
  // The tag on the reader's card, at its bottom right, clear of the card's own "root:" line.
3765
3768
  const rect = card.querySelector("rect");
@@ -3800,7 +3803,11 @@ function drawTgReads() {
3800
3803
  drawn.push({ p0, p1 });
3801
3804
  labels.push({ e, p0, p1, color, kind });
3802
3805
  }
3803
- clearMarksOfReads(svg, drawn); // behold#571: the marks step aside from the read lines
3806
+ // behold#571: the marks step aside from the read lines, and a box lifts its marks off an arrowhead (its box then reaches higher).
3807
+ for (const [rect] of clearMarksOfReads(svg, drawn)) {
3808
+ const now = boxOf(rect);
3809
+ for (const b of boxes) if (now && Math.abs(b.x - now.x) < 0.5 && Math.abs(b.x2 - now.x2) < 0.5 && Math.abs(b.y2 - now.y2) < 0.5) b.y = now.y;
3810
+ }
3804
3811
  // Each read's words beside its line: covering no text, crossing no line,
3805
3812
  // over as few cards and box headers as can be.
3806
3813
  const cardBoxes = cardEls.map((g) => cardBoxOf.get(g)).filter(Boolean);
@@ -3990,7 +3997,7 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
3990
3997
  const words = width(m.words, 12, 700) <= room ? m.words : m.short;
3991
3998
  sub.setAttribute("visibility", "hidden");
3992
3999
  sub.setAttribute("data-tg-hid", "1");
3993
- const t = make("text", { "data-tg-root": "card", x, y, "font-size": 12, "font-weight": 700, fill: quiet ? "var(--muted)" : tone(m.tone) }, words);
4000
+ const t = make("text", { "data-tg-root": "card", x, y, "font-size": 12, "font-weight": 700, fill: quiet ? "var(--frame-card-muted, var(--muted))" : TG_CARD_TONE[m.tone] || TG_CARD_TONE.idle }, words);
3994
4001
  if (m.state === "applying") t.setAttribute("class", "pin-pulse");
3995
4002
  if (!inFocus) t.style.opacity = "0.6";
3996
4003
  t.appendChild(make("title", {}, [`wave ${m.wave} · ${m.words}`, ...m.facts].join("\n") + "\n(from terragucci's reports, not live)"));
@@ -4093,7 +4100,7 @@ function markTerragucciCards() {
4093
4100
  tag.setAttribute("text-anchor", "end");
4094
4101
  tag.setAttribute("font-size", "11");
4095
4102
  tag.setAttribute("font-weight", "600");
4096
- tag.setAttribute("fill", corner.tone === "drift" ? "var(--degraded)" : corner.tone === "wave" ? "var(--pending)" : "var(--muted)");
4103
+ tag.setAttribute("fill", corner.tone === "drift" ? "var(--frame-card-degraded, var(--degraded))" : corner.tone === "wave" ? "var(--frame-card-pending, var(--pending))" : "var(--frame-card-muted, var(--muted))");
4097
4104
  tag.textContent = `${corner.text} · ${markAge(marks)}`;
4098
4105
  const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
4099
4106
  title.setAttribute("data-tg-mark", "title");
@@ -5583,9 +5590,10 @@ function titleRowFits(row, left) {
5583
5590
  /**
5584
5591
  * The marks' own row, just under the title: the box grows upward by a row
5585
5592
  * and its title moves up into it, so no card moves and none is covered. The
5586
- * marks run left to right from the box's left, stepping past an edge where
5587
- * they can, and keep their icons: short of room they run onto another row,
5588
- * and the box grows by that one too. Only at phone width do the icons go
5593
+ * marks stay one cluster, the forge first, at the row's start or end where
5594
+ * no edge crosses it, else at its start with the edge behind. They keep
5595
+ * their icons: short of room the cluster runs onto another row, and the box
5596
+ * grows by that one too. Only at phone width do the icons go
5589
5597
  * first, while one row of names alone holds them.
5590
5598
  */
5591
5599
  function marksOwnRow(row, rect, title, grown = 0) {
@@ -5596,31 +5604,43 @@ function marksOwnRow(row, rect, title, grown = 0) {
5596
5604
  const avoid = (row.getAttribute("data-pm-avoid") || "").split(",").filter(Boolean).map(Number);
5597
5605
  const marks = [...row.querySelectorAll(":scope > .pm-mark")];
5598
5606
  const widths = markWidths(marks);
5599
- // Left to right in rows, a mark that would sit on an edge stepping past it.
5600
- const lay = (icons, step, maxRows) => {
5601
- const xs = [];
5602
- const rowOf = [];
5603
- let r = 0;
5604
- let x = left;
5607
+ // One cluster, the forge first, then the tools: in rows when one row can't hold it, each row's
5608
+ // part together. A part goes at the row's start or its end, whichever an edge doesn't cross
5609
+ // (`clear`); else at the start, any edge passing behind it.
5610
+ const lay = (icons, clear, maxRows) => {
5611
+ const parts = [[]];
5612
+ let used = 0;
5605
5613
  for (let i = 0; i < marks.length; i++) {
5606
5614
  const w = markWidth(marks[i], widths[i], icons);
5607
- const at = (x0) => {
5608
- let p = x0;
5609
- if (step) for (const e of avoid.filter((e) => e > p - 4 && e < p + w + 4).sort((a, b) => a - b)) p = Math.max(p, e + 6);
5610
- return p;
5611
- };
5612
- let p = at(x);
5613
- if (p + w > right && x > left) {
5614
- r++;
5615
- x = left;
5616
- p = at(x);
5615
+ const part = parts[parts.length - 1];
5616
+ const need = used + (part.length ? MARK_STEP : 0) + w;
5617
+ if (part.length && need > right - left) {
5618
+ parts.push([i]);
5619
+ used = w;
5620
+ } else {
5621
+ part.push(i);
5622
+ used = need;
5623
+ }
5624
+ if (w > right - left || parts.length > maxRows) return null;
5625
+ }
5626
+ const xs = [];
5627
+ const rowOf = [];
5628
+ for (const [r, part] of parts.entries()) {
5629
+ const width = part.reduce((s, i) => s + markWidth(marks[i], widths[i], icons), 0) + MARK_STEP * (part.length - 1);
5630
+ const crosses = (x0) => avoid.some((e) => e > x0 - 4 && e < x0 + width + 4);
5631
+ let x0 = left;
5632
+ if (clear) {
5633
+ const spot = [left, right - width].find((x) => !crosses(x));
5634
+ if (spot === undefined) return null;
5635
+ x0 = spot;
5636
+ }
5637
+ for (const i of part) {
5638
+ xs[i] = x0;
5639
+ rowOf[i] = r;
5640
+ x0 += markWidth(marks[i], widths[i], icons) + MARK_STEP;
5617
5641
  }
5618
- if (p + w > right || r >= maxRows) return null;
5619
- xs.push(p);
5620
- rowOf.push(r);
5621
- x = p + w + MARK_STEP;
5622
5642
  }
5623
- return { xs, rowOf, rows: r + 1 };
5643
+ return { xs, rowOf, rows: parts.length };
5624
5644
  };
5625
5645
  // Phone width is the viewer's screen: the kiosk frames this page narrow on a wide one.
5626
5646
  const phone = (() => {
@@ -5682,7 +5702,14 @@ function clearMarksOfReads(svgEl, lines) {
5682
5702
  if (f >= 0 && f <= 1) xs.push(p0.x + (p1.x - p0.x) * f - dx);
5683
5703
  }
5684
5704
  }
5685
- if (!xs.length) continue;
5705
+ if (xs.length) stepAside(row, xs, own);
5706
+ }
5707
+ return liftOffArrowheads(svgEl, lines);
5708
+ }
5709
+
5710
+ /** Lay a row out again clear of `xs` too, or leave it as it was where that doesn't fit. */
5711
+ function stepAside(row, xs, own) {
5712
+ {
5686
5713
  const was = row.getAttribute("data-pm-avoid") || "";
5687
5714
  row.setAttribute("data-pm-avoid", [was, ...xs.map((x) => x.toFixed(1))].filter(Boolean).join(","));
5688
5715
  // The old places, should the new avoidance not fit.
@@ -5699,6 +5726,70 @@ function clearMarksOfReads(svgEl, lines) {
5699
5726
  }
5700
5727
  }
5701
5728
 
5729
+ /** How far a read's arrowhead reaches back from its tip, and how wide it spreads (marker 7 x stroke 3). */
5730
+ const ARROWHEAD = { length: 22, half: 11 };
5731
+
5732
+ /**
5733
+ * No arrowhead sits on a mark. A read that ends in a box whose marks its head
5734
+ * would cover lifts the box's title and marks a row up, the box growing by
5735
+ * that row, so the head lands on open ground just over the card. Returns each
5736
+ * lifted box as [its rect, the rows it grew by].
5737
+ */
5738
+ function liftOffArrowheads(svgEl, lines) {
5739
+ const G = MARK.size + 6;
5740
+ const lifted = [];
5741
+ const hit = (a, b) => a.x < b.x2 && a.x2 > b.x && a.y < b.y2 && a.y2 > b.y;
5742
+ const heads = lines.map(({ p0, p1 }) => {
5743
+ const len = Math.hypot(p1.x - p0.x, p1.y - p0.y) || 1;
5744
+ const bx = p1.x - ((p1.x - p0.x) / len) * ARROWHEAD.length;
5745
+ const by = p1.y - ((p1.y - p0.y) / len) * ARROWHEAD.length;
5746
+ const h = ARROWHEAD.half;
5747
+ return { x: Math.min(p1.x, bx) - h, y: Math.min(p1.y, by) - h, x2: Math.max(p1.x, bx) + h, y2: Math.max(p1.y, by) + h };
5748
+ });
5749
+ for (const row of svgEl.querySelectorAll(".pipeline-marks")) {
5750
+ if (row.style.display === "none") continue;
5751
+ const m = /translate\(\s*([-\d.]+)[\s,]+([-\d.]+)/.exec((row.parentNode.getAttribute && row.parentNode.getAttribute("transform")) || "");
5752
+ const dx = m ? Number(m[1]) : 0;
5753
+ const dy = m ? Number(m[2]) : 0;
5754
+ const boxes = [...row.querySelectorAll(":scope > .pm-mark")]
5755
+ .filter((mk) => mk.style.display !== "none")
5756
+ .map((mk) => {
5757
+ try {
5758
+ const b = mk.getBBox();
5759
+ return { x: b.x + dx - 2, y: b.y + dy - 2, x2: b.x + b.width + dx + 2, y2: b.y + b.height + dy + 2 };
5760
+ } catch {
5761
+ return null;
5762
+ }
5763
+ })
5764
+ .filter(Boolean);
5765
+ if (!heads.some((h) => boxes.some((b) => hit(h, b)))) continue;
5766
+ const rect = svgEl.querySelector(`rect[data-group-id="wave-${row.getAttribute("data-pm-wave")}"]`);
5767
+ const title = row.nextElementSibling && row.nextElementSibling.tagName.toLowerCase() === "text" ? row.nextElementSibling : null;
5768
+ if (!rect) continue;
5769
+ if (!rect.hasAttribute("data-pm-y0")) {
5770
+ rect.setAttribute("data-pm-y0", rect.getAttribute("y"));
5771
+ rect.setAttribute("data-pm-h0", rect.getAttribute("height"));
5772
+ }
5773
+ if (title && !title.hasAttribute("data-pm-ty0")) title.setAttribute("data-pm-ty0", title.getAttribute("y"));
5774
+ const titleCy = title ? Number(title.getAttribute("y")) : null;
5775
+ rect.setAttribute("y", String(Number(rect.getAttribute("y")) - G));
5776
+ rect.setAttribute("height", String(Number(rect.getAttribute("height")) + G));
5777
+ if (title) title.setAttribute("y", String(titleCy - G));
5778
+ row.setAttribute("data-pm-cy", String(Number(row.getAttribute("data-pm-cy")) - G));
5779
+ for (const n of row.querySelectorAll(".pm-icon, .pm-label")) n.setAttribute("y", String(Number(n.getAttribute("y")) - G));
5780
+ // The job's status rides its title's line.
5781
+ if (title) {
5782
+ const tb = title.getBBox();
5783
+ for (const s of svgEl.querySelectorAll('[data-tg-root="wave-status"]')) {
5784
+ const y = Number(s.getAttribute("y"));
5785
+ if (Math.abs(y - (tb.y + tb.height / 2 + G + dy)) < tb.height) s.setAttribute("y", String(y - G));
5786
+ }
5787
+ }
5788
+ lifted.push([rect, G]);
5789
+ }
5790
+ return lifted;
5791
+ }
5792
+
5702
5793
  /** The x's at which the graph's edges cross a band of the svg (`y0`..`y1`), in the svg's own coordinates. */
5703
5794
  function edgeXsIn(svgEl, y0, y1) {
5704
5795
  const xs = [];
@@ -86,7 +86,7 @@ function lineTime(run, f) {
86
86
  }
87
87
 
88
88
  /**
89
- * The panel's model: `{ wave, digest, rows: [{ id, label, state, … }] }`, or
89
+ * The panel's model: `{ wave, digest, run, rows: [{ id, label, state, … }] }`, or
90
90
  * null when the step is not one the panel shows or no wave of the cycle
91
91
  * held. `state` is `lit`, `going` (begun, not done) or `dim`. Inputs:
92
92
  *
@@ -178,7 +178,9 @@ export function approvalModel({ demo, runs = [], history = null, lifecycle = nul
178
178
  });
179
179
  } else Object.assign(spRow, { state: "dim", text: `Once wave ${wave} applies, this approval is used up for good.` });
180
180
 
181
- return { wave, digest, rows: inferBack([reqRow, apRow, rsRow, spRow], { wave, gateRead, spentLine, resumeRuns }) };
181
+ // behold#571: the run the hold is in now, for the panel's head: the resume once there is one, else the run that held the wave.
182
+ const run = resume ? resume.id : holdRun ? holdRun.id : null;
183
+ return { wave, digest, run, rows: inferBack([reqRow, apRow, rsRow, spRow], { wave, gateRead, spentLine, resumeRuns }) };
182
184
  }
183
185
 
184
186
  /** The words a row lit only because a later one is, by row. Each says it was inferred; none invents a time. */
@@ -115,6 +115,8 @@ describe("the approval panel (behold#571)", () => {
115
115
  const m = approvalModel({ demo: demo("applied"), runs: [run(444), resumeless], now: Date.parse("2026-10-15T04:11:00Z") });
116
116
  expect(m.rows.map((r) => r.state)).toEqual(["lit", "lit", "lit", "lit"]);
117
117
  expect(m.rows[2]).toMatchObject({ inferred: true, runId: 445, at: null });
118
+ // behold#571: the run the hold panel's head names: the run that held the wave, with no resume run copied.
119
+ expect(m.run).toBe(444);
118
120
  expect(rowFacts(m.rows[2])).toEqual(["inferred from the rows after it", "run #445"]);
119
121
  expect(m.rows[1]).toMatchObject({ inferred: true, text: "terragucci-admin approved this plan." });
120
122
  expect(inferBack([{ id: "requested", state: "dim" }, { id: "approved", state: "dim" }], { wave: 2 }).map((r) => r.state)).toEqual(["dim", "dim"]);
@@ -2,7 +2,7 @@
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { VENDOR_TOOLS } from "../src/terragucci-demo.ts";
4
4
  import { logRows } from "./kiosk-runs.js";
5
- import { NO_GRAPH_WORDS, SCENARIOS, legendWords, scenarioHead } from "./kiosk.js";
5
+ import { NO_GRAPH_WORDS, SCENARIOS, readingRows, scenarioHead } from "./kiosk.js";
6
6
  import {
7
7
  REPLAY_LAST_HOLD_MS,
8
8
  RUNS_WITH,
@@ -145,7 +145,7 @@ describe("the branding table (behold#571)", () => {
145
145
  it("says on each page who makes the tool and that they don't endorse the demo, naming no other tool or maker", () => {
146
146
  for (const tool of VENDOR_TOOLS) {
147
147
  const v = VENDORS[tool];
148
- const words = [v.name, ...creditLines(tool).map((l) => l.map((s) => s.text).join("")), ...Object.values(notRunWords(v)), legendWords("components", tool), legendWords("resources", tool)];
148
+ const words = [v.name, ...creditLines(tool).map((l) => l.map((s) => s.text).join("")), ...Object.values(notRunWords(v)), ...readingRows("components", tool).map((r) => r.words), ...readingRows("resources", tool).map((r) => r.words)];
149
149
  for (const w of words) expect(namesOther(w, tool), `${tool}: ${w}`).toBe(false);
150
150
  // choudoufu and chant are ours: their credits say so instead.
151
151
  if (tool !== "choudoufu" && tool !== "chant") expect(v.credit).toMatch(/(does not|don't) endorse this demo\./);
@@ -153,7 +153,7 @@ describe("the branding table (behold#571)", () => {
153
153
  expect(VENDORS.choudoufu.credit).toMatch(/AWS and Kubernetes/);
154
154
  expect(VENDORS.choudoufu.credit).not.toMatch(/experimental/i);
155
155
  });
156
- it("links each name in the footer, the tool's to its site and OpenTofu's where its scenarios run on it", () => {
156
+ it("links each name in the credit, the tool's to its site and OpenTofu's where its scenarios run on it", () => {
157
157
  const tf = creditLines("terraform");
158
158
  expect(tf.flat().filter((s) => s.url).map((s) => [s.text, s.url])).toEqual([
159
159
  ["Terraform", VENDORS.terraform.url],
@@ -228,7 +228,7 @@ describe("a tool's page, drawn (behold#571)", () => {
228
228
  };
229
229
  const text = (n) => (n.children && n.children.length ? n.children.map(text).join("") : n.textContent || "");
230
230
  const all = (n) => [n, ...(n.children || []).flatMap(all)];
231
- it("puts the tool's name before the scenario, the banner over it, and the credit in the foot, with no count", async () => {
231
+ it("puts the tool's name before the scenario, the banner over it, and the credit at the lead block's foot, with no count", async () => {
232
232
  const { renderKiosk } = await import("./kiosk.js");
233
233
  const was = globalThis.document;
234
234
  globalThis.document = fakeDocument();
@@ -253,7 +253,11 @@ describe("a tool's page, drawn (behold#571)", () => {
253
253
  expect(text(bar2)).toContain("Big Terraform setups");
254
254
  // No graph of this repo here: one line in the header says so.
255
255
  expect(all(bar).filter((n) => n.className === "k-nograph-note").map(text)).toEqual([NO_GRAPH_WORDS]);
256
- expect(all(foot).filter((n) => n.className === "k-credit").map(text)).toEqual([VENDORS.terragrunt.credit]);
256
+ // behold#571: no footer: the credit is the lead block's last line.
257
+ const lead = all(bar).find((n) => n.className === "k-left k-lead");
258
+ expect(lead.children[lead.children.length - 1].className).toBe("k-credits");
259
+ expect(all(bar).filter((n) => n.className === "k-credit").map(text)).toEqual([VENDORS.terragrunt.credit]);
260
+ expect(foot.children).toEqual([]);
257
261
  } finally {
258
262
  globalThis.document = was;
259
263
  }
@@ -283,6 +287,8 @@ describe("a tool's page, drawn (behold#571)", () => {
283
287
  expect(text(bar)).toContain("This scenario hasn't run yet");
284
288
  const brand = all(bar).find((n) => n.className === "k-brand");
285
289
  expect(brand.href).toBe(VENDORS.choudoufu.url);
290
+ // The credit shows on every tool page, before its first cycle too.
291
+ expect(all(bar).filter((n) => n.className === "k-credit").map(text)).toEqual([VENDORS.choudoufu.credit]);
286
292
  expect(all(brand).some((n) => n.className === "k-brand-logo" && n.src === VENDORS.choudoufu.logo.src)).toBe(true);
287
293
  } finally {
288
294
  globalThis.document = was;