@intentius/behold 0.29.49 → 0.29.51

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.
Files changed (52) hide show
  1. package/AGENTS.md +155 -4
  2. package/demos.json +15 -0
  3. package/dist/cli.js +2440 -998
  4. package/example-three-cloud/README.md +38 -0
  5. package/example-three-cloud/aws/chant.config.ts +8 -0
  6. package/example-three-cloud/aws/src/site.ts +20 -0
  7. package/example-three-cloud/azure/chant.config.ts +1 -0
  8. package/example-three-cloud/azure/src/site.ts +19 -0
  9. package/example-three-cloud/chant.workspace.json +10 -0
  10. package/example-three-cloud/dns/chant.config.ts +1 -0
  11. package/example-three-cloud/dns/ops/front-door.op.ts +21 -0
  12. package/example-three-cloud/dns/src/route53.ts +54 -0
  13. package/example-three-cloud/gcp/chant.config.ts +1 -0
  14. package/example-three-cloud/gcp/src/site.ts +19 -0
  15. package/example-three-cloud/package-lock.json +715 -0
  16. package/example-three-cloud/package.json +16 -0
  17. package/example-three-cloud/scripts/emulators-up.sh +46 -0
  18. package/example-three-cloud/scripts/front-door.ts +400 -0
  19. package/package.json +4 -2
  20. package/web/app.js +250 -23
  21. package/web/composite-members.js +21 -0
  22. package/web/composite-members.test.js +25 -0
  23. package/web/decision-points.js +70 -0
  24. package/web/decision-points.test.js +87 -0
  25. package/web/dots-kiosk.js +4 -1
  26. package/web/dots-live.test.js +10 -0
  27. package/web/dots.js +41 -4
  28. package/web/export-note.js +35 -0
  29. package/web/export-note.test.js +45 -0
  30. package/web/health-marks.js +146 -0
  31. package/web/health-marks.test.js +67 -0
  32. package/web/index.html +52 -0
  33. package/web/kiosk-runs.js +51 -5
  34. package/web/kiosk-runs.test.js +42 -1
  35. package/web/kiosk-source.js +23 -0
  36. package/web/kiosk-source.test.js +19 -1
  37. package/web/kiosk-track.js +9 -5
  38. package/web/kiosk-track.test.js +12 -2
  39. package/web/kiosk.html +26 -3
  40. package/web/kiosk.js +28 -6
  41. package/web/local-run.js +276 -0
  42. package/web/local-run.test.js +46 -0
  43. package/web/sql-yodeler-lane.js +1 -1
  44. package/web/terragucci-timeline.js +5 -4
  45. package/web/terragucci-timeline.test.js +1 -1
  46. package/web/trunk-lane.js +54 -5
  47. package/web/trunk-lane.test.js +86 -3
  48. package/web/view-url.js +25 -0
  49. package/web/view-url.test.js +24 -1
  50. package/web/why.js +1 -1
  51. package/web/why.test.js +1 -1
  52. package/web/workspace-gates.js +35 -18
package/web/dots-kiosk.js CHANGED
@@ -267,6 +267,9 @@ export function resourceCounts(migration) {
267
267
  /** The Tip for a migration that has just finished. */
268
268
  export function liveEndTip(migration, t) {
269
269
  const c = resourceCounts(migration);
270
+ // An adoption only stamps and a retag only moves: the count it has none of is left out (#711), not said as a 0.
271
+ const parts = [c.moved ? `${fmt(c.moved)} moved` : null, c.stamped ? `${fmt(c.stamped)} stamped` : null].filter(Boolean);
272
+ const what = parts.length ? parts.join(" and ").replace(/^(\S+) (moved|stamped)/, "$1 resources $2") : "0 resources moved";
270
273
  return {
271
274
  key: `end:${migration.name}`,
272
275
  at: t,
@@ -274,6 +277,6 @@ export function liveEndTip(migration, t) {
274
277
  estate: null,
275
278
  tone: c.refused ? "bad" : "ok",
276
279
  title: `${migration.name}: done`,
277
- text: `${migration.name} is done: ${fmt(c.moved)} resources moved and ${fmt(c.stamped)} stamped by tag writes alone, none recreated${c.refused ? `; ${c.refused} refused, left where they were` : ""}.`,
280
+ text: `${migration.name} is done: ${what} by tag writes alone, none recreated${c.refused ? `; ${c.refused} refused, left where they were` : ""}.`,
278
281
  };
279
282
  }
@@ -116,6 +116,16 @@ describe("the live carve as a show (#715)", () => {
116
116
  expect(done.focus).toEqual({ kind: "all" });
117
117
  expect(liveEndTip(m, 0).key).toBe("end:carve");
118
118
  });
119
+
120
+ it("says an adoption's end in stamps alone, with no 0 moved (#711)", () => {
121
+ const line = (address, outcome) => ({ at: "2026-10-20T10:00:00Z", estate_from: "", estate_to: "tl7-shared", address, live_id: address, outcome });
122
+ const adopt = { name: "adopt", counts: { moved: 0, stamped: 2, refused: 0, skipped: 0, left: 0 }, lines: [line("a", "stamped"), line("b", "stamped")] };
123
+ expect(liveEndTip(adopt, 0).text).toBe("adopt is done: 2 resources stamped by tag writes alone, none recreated.");
124
+ const split = { name: "split", counts: { moved: 1, stamped: 0, refused: 0, skipped: 0, left: 0 }, lines: [line("a", "moved")] };
125
+ expect(liveEndTip(split, 0).text).toBe("split is done: 1 resources moved by tag writes alone, none recreated.");
126
+ const both = { name: "m", counts: { moved: 1, stamped: 2, refused: 0, skipped: 0, left: 0 }, lines: [line("a", "moved"), line("b", "stamped"), line("c", "stamped")] };
127
+ expect(liveEndTip(both, 0).text).toBe("m is done: 1 resources moved and 2 stamped by tag writes alone, none recreated.");
128
+ });
119
129
  });
120
130
 
121
131
  describe("the gate, in the page (#715)", () => {
package/web/dots.js CHANGED
@@ -166,6 +166,7 @@ function addStyle() {
166
166
  .dots-on > svg { position: relative; z-index: 1; background: transparent; }
167
167
  /* Once the cards are out of the paint a touch lands on the host: a pinch there is the camera's, never the page's zoom. */
168
168
  .dots-on { touch-action: none; }
169
+ html.kiosk-touch .dots-on { touch-action: pan-x pan-y; }
169
170
  .dots-on > svg > rect[fill^="url(#pin-"] { display: none; }
170
171
  .dots-on > svg [data-node-id], .dots-on > svg rect[data-group-id], .dots-on > svg text { opacity: var(--dots-card-a, 1); }
171
172
  #dots-canvas { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
@@ -182,13 +183,14 @@ function addStyle() {
182
183
  .dots-rail-mark:hover i, .dots-rail-mark:focus-visible i { border-color: var(--focus); }
183
184
  .dots-rail-mark:disabled { cursor: default; color: var(--muted); }
184
185
  .dots-rail-mark:disabled:hover i { border-color: var(--muted); }
185
- .dots-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: calc(100% - 24px); pointer-events: none; }
186
+ /* behold#729: the pane's whole width less a gutter, so the caption can use it; a box centred at left 50% could never be wider than half the pane. */
187
+ .dots-bottom { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
186
188
  .dots-bottom > * { pointer-events: auto; }
187
189
  .dots-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: calc(100% - 24px); background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; box-sizing: border-box; }
188
190
  .dots-bar button, .dots-bar select { background: var(--well); color: var(--fg); border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; font: inherit; cursor: pointer; }
189
191
  .dots-bar input[type=range] { width: min(320px, 40vw); accent-color: var(--focus); }
190
192
  .dots-time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 12em; }
191
- .dots-caption { padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--fg); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; box-sizing: border-box; }
193
+ .dots-caption { padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--fg); max-width: min(72ch, 100%); text-align: center; box-sizing: border-box; }
192
194
  .dots-kiosk .dots-caption { display: none; }
193
195
  /* #715: a live carve has no playback head: it plays as it is written. */
194
196
  .dots-live .dots-bar { display: none; }
@@ -1042,6 +1044,31 @@ function landedIds() {
1042
1044
  return out;
1043
1045
  }
1044
1046
 
1047
+ /**
1048
+ * A selected dot's tip follows the dot as the camera moves (the director reframes the boxes at each chapter), hides
1049
+ * while the dot is not drawn, and goes with the selection when a new read's scene no longer holds the dot.
1050
+ */
1051
+ function followSelected() {
1052
+ if (!S || !S.selected || !S.tip) return;
1053
+ const i = S.idx.get(S.selected);
1054
+ if (i === undefined) {
1055
+ S.selected = null;
1056
+ S.tip.style.display = "none";
1057
+ S.tipAt = null;
1058
+ if (S.provLink) S.provLink.hidden = true;
1059
+ return;
1060
+ }
1061
+ if (!S.pvis[i]) {
1062
+ S.tip.style.display = "none";
1063
+ S.tipAt = null;
1064
+ return;
1065
+ }
1066
+ const at = `${Math.round(S.px[i])},${Math.round(S.py[i])},${Math.round(S.ph[i])}`;
1067
+ if (at === S.tipAt && S.tip.style.display === "block") return;
1068
+ S.tipAt = at;
1069
+ showTip(S.selected, S.px[i], S.py[i] + S.ph[i], S.py[i] - S.ph[i]);
1070
+ }
1071
+
1045
1072
  /** Select a dot: its tip stays up, and its provenance is read out in the live region, for a reader without a pointer. */
1046
1073
  function selectDot(id) {
1047
1074
  if (!S) return;
@@ -1279,6 +1306,7 @@ function polyline(ctx, pts) {
1279
1306
  }
1280
1307
 
1281
1308
  function draw(dt) {
1309
+ followSelected();
1282
1310
  const { ctx, canvas, scene, pitch: P, origin: O, col } = S;
1283
1311
  const cam = camera();
1284
1312
  const dpr = window.devicePixelRatio || 1;
@@ -2019,10 +2047,19 @@ function viewerHold() {
2019
2047
  */
2020
2048
  function watchViewer() {
2021
2049
  const host = S.host;
2050
+ // The kiosk on a phone: one finger scrolls the page (web/app.js kioskTouch), so only a second finger has the camera.
2051
+ const phone = () => document.documentElement.classList.contains("kiosk-touch");
2052
+ // A tap's compatibility mousedown carries no pointerType: on a phone it is the tap.
2053
+ const pressed = (e) => {
2054
+ if (!(phone() && (e.pointerType === "touch" || e.type === "mousedown"))) viewerHold();
2055
+ };
2022
2056
  const dragging = (e) => {
2023
- if (e.buttons) viewerHold();
2057
+ if (e.buttons && !(phone() && e.pointerType === "touch")) viewerHold();
2058
+ };
2059
+ const touched = (e) => {
2060
+ if (!phone() || e.touches.length >= 2) viewerHold();
2024
2061
  };
2025
- for (const [ev, f] of [["wheel", viewerHold], ["pointerdown", viewerHold], ["mousedown", viewerHold], ["touchstart", viewerHold], ["touchmove", viewerHold], ["pointermove", dragging]]) {
2062
+ for (const [ev, f] of [["wheel", viewerHold], ["pointerdown", pressed], ["mousedown", pressed], ["touchstart", touched], ["touchmove", touched], ["pointermove", dragging]]) {
2026
2063
  host.addEventListener(ev, f, { passive: true });
2027
2064
  S.off.push(() => host.removeEventListener(ev, f));
2028
2065
  }
@@ -0,0 +1,35 @@
1
+ // #824: the line an export shows at its foot, from `behold export --note`.
2
+ // The manifest carries it as `note`; a static page draws it under the graph,
3
+ // where the three-cloud demo's page says how to run the estate yourself.
4
+ // Plain text, with a span in backticks drawn as code. Nothing else is markup:
5
+ // the text is set as text, never as HTML.
6
+
7
+ /** The note split into runs of plain text and code, in order. An unclosed
8
+ * backtick is kept as text. */
9
+ export function noteSegments(text) {
10
+ const out = [];
11
+ const re = /`([^`]+)`/g;
12
+ let at = 0;
13
+ for (let m = re.exec(text); m; m = re.exec(text)) {
14
+ if (m.index > at) out.push({ code: false, text: text.slice(at, m.index) });
15
+ out.push({ code: true, text: m[1] });
16
+ at = m.index + m[0].length;
17
+ }
18
+ if (at < text.length) out.push({ code: false, text: text.slice(at) });
19
+ return out;
20
+ }
21
+
22
+ /** The note a manifest carries, or null when it carries none. */
23
+ export function manifestNote(manifest) {
24
+ const note = manifest && typeof manifest.note === "string" ? manifest.note.trim() : "";
25
+ return note || null;
26
+ }
27
+
28
+ /** Fill `el` with the note and show it; hide it when there is no note. */
29
+ export function renderExportNote(el, doc, manifest) {
30
+ const note = manifestNote(manifest);
31
+ el.textContent = "";
32
+ el.hidden = !note;
33
+ if (!note) return;
34
+ for (const seg of noteSegments(note)) el.appendChild(seg.code ? Object.assign(doc.createElement("code"), { textContent: seg.text }) : doc.createTextNode(seg.text));
35
+ }
@@ -0,0 +1,45 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { manifestNote, noteSegments, renderExportNote } from "./export-note.js";
3
+
4
+ // #824: the line under an exported page.
5
+ describe("an export's note", () => {
6
+ it("splits backticked spans out as code", () => {
7
+ expect(noteSegments("Run this yourself: `npx @intentius/behold demo three-cloud`")).toEqual([
8
+ { code: false, text: "Run this yourself: " },
9
+ { code: true, text: "npx @intentius/behold demo three-cloud" },
10
+ ]);
11
+ expect(noteSegments("`a` and `b`.")).toEqual([
12
+ { code: true, text: "a" },
13
+ { code: false, text: " and " },
14
+ { code: true, text: "b" },
15
+ { code: false, text: "." },
16
+ ]);
17
+ });
18
+
19
+ it("keeps an unclosed backtick as text", () => {
20
+ expect(noteSegments("run `this")).toEqual([{ code: false, text: "run `this" }]);
21
+ });
22
+
23
+ it("reads the note from the manifest, and nothing when it has none", () => {
24
+ expect(manifestNote({ note: " hi " })).toBe("hi");
25
+ expect(manifestNote({})).toBe(null);
26
+ expect(manifestNote(null)).toBe(null);
27
+ expect(manifestNote({ note: 3 })).toBe(null);
28
+ });
29
+
30
+ it("sets the note as text, never as markup", () => {
31
+ const made = [];
32
+ const doc = {
33
+ createElement: (tag) => ({ tag, textContent: "" }),
34
+ createTextNode: (text) => ({ text }),
35
+ };
36
+ const el = { hidden: true, textContent: "old", appendChild: (n) => made.push(n) };
37
+ renderExportNote(el, doc, { note: "<b>x</b> `y`" });
38
+ expect(el.hidden).toBe(false);
39
+ expect(made).toEqual([{ text: "<b>x</b> " }, { tag: "code", textContent: "y" }]);
40
+
41
+ renderExportNote(el, doc, {});
42
+ expect(el.hidden).toBe(true);
43
+ expect(el.textContent).toBe("");
44
+ });
45
+ });
@@ -0,0 +1,146 @@
1
+ // #825: runtime health and rotation on the graph. Pure words and colours from
2
+ // /api/health; app.js draws them.
3
+ //
4
+ // Health is what `chant lifecycle health` says about a declared thing that
5
+ // serves: a Route 53 health check, an ECS service, a Container App, a Cloud
6
+ // Run service. It is not drift, so it never touches the card's fill: a tag
7
+ // under the card says the state, and an unhealthy card gets a solid ring in
8
+ // the degraded colour. A check chant could not read is a hole, a dashed ring
9
+ // in the neutral colour with chant's reason, never drawn as unhealthy.
10
+ //
11
+ // A Route 53 record whose health check is unhealthy is out of rotation: the
12
+ // record and its edges are dimmed and its tag says which check took it out.
13
+ // A check that is unknown or was not read leaves the record's rotation
14
+ // unknown, said in words, and nothing is dimmed.
15
+
16
+ /** The colour of each state, from the drift legend's tokens. */
17
+ export const HEALTH_COLOR = {
18
+ healthy: "var(--managed)",
19
+ unhealthy: "var(--degraded)",
20
+ unknown: "var(--muted)",
21
+ unobserved: "var(--neutral)",
22
+ absent: "var(--muted)",
23
+ };
24
+
25
+ /** The word for each state on a card and in the legend. */
26
+ export const HEALTH_WORD = {
27
+ healthy: "healthy",
28
+ unhealthy: "unhealthy",
29
+ unknown: "health unknown",
30
+ unobserved: "health not read",
31
+ absent: "not deployed",
32
+ };
33
+
34
+ /** The note on what health is, for the legend's tooltip. */
35
+ export const HEALTH_NOTE =
36
+ "From chant lifecycle health: whether a declared health check or service is serving, read apart from drift. A check chant could not read is shown as not read, never as unhealthy. A Route 53 record is out of rotation when the health check its HealthCheckId names is unhealthy.";
37
+
38
+ /** Whether the answer has anything to draw. */
39
+ export function healthUsable(a) {
40
+ return !!a && !a.error && !a.refusal && !!a.nodes;
41
+ }
42
+
43
+ /** The legend's first line: what was read, or why it wasn't. */
44
+ export function healthHeader(a) {
45
+ if (!a || a.error) return { text: `health not read${a && a.error ? `: ${a.error}` : ""}`, title: "", tone: "refusal" };
46
+ if (a.refusal) return { text: `health not read: ${a.refusal.error}`, title: [a.refusal.remedy, a.degraded ? `Without it, ${a.degraded}.` : ""].filter(Boolean).join("\n"), tone: "refusal" };
47
+ const n = Object.keys(a.nodes).length;
48
+ if (!n) return { text: "nothing declared here has a health read", title: HEALTH_NOTE, tone: "quiet" };
49
+ return { text: `health · ${a.env}`, title: HEALTH_NOTE, tone: "quiet" };
50
+ }
51
+
52
+ /** The legend's rows: one per state that occurs, with its count, then the records out of rotation. */
53
+ export function healthLegendRows(a) {
54
+ if (!healthUsable(a)) return [];
55
+ const c = a.counts || {};
56
+ const rows = [];
57
+ for (const k of ["healthy", "unhealthy", "unknown", "unobserved", "absent"]) {
58
+ if (c[k]) rows.push({ color: HEALTH_COLOR[k], text: HEALTH_WORD[k], count: String(c[k]) });
59
+ }
60
+ if (c.outOfRotation) rows.push({ color: HEALTH_COLOR.unhealthy, text: "records out of rotation", count: String(c.outOfRotation), dashed: true });
61
+ return rows;
62
+ }
63
+
64
+ /** Members whose read was refused, as lines under the legend. */
65
+ export function memberLines(a) {
66
+ if (!a || !Array.isArray(a.members)) return [];
67
+ return a.members.filter((m) => m.refusal).map((m) => ({ text: `${m.member ? `${m.member}: ` : ""}health not read: ${m.refusal.error}`, title: m.refusal.remedy || "" }));
68
+ }
69
+
70
+ /** The tooltip of one node's health. */
71
+ function healthTitle(id, h) {
72
+ if (h.state === "unobserved") return [`${id}: chant could not read its health (${h.reason}).`, h.detail || "", "This is a hole, not a verdict: the check may be fine."].filter(Boolean).join("\n");
73
+ if (h.state === "absent") return `${id}: the provider says it is not deployed.`;
74
+ return [`${id}: ${h.state}`, h.detail, h.checkedAt ? `checked ${h.checkedAt}` : "", `read ${h.observedAt}`].filter(Boolean).join("\n");
75
+ }
76
+
77
+ /**
78
+ * The marks to draw, per node id in `ids` that has health or a rotation:
79
+ * `tag` (the line under the card), `color`, `ring` (`solid`, `dashed` or
80
+ * none), `dim` (the record is out of rotation) and `title`.
81
+ */
82
+ export function healthMarks(a, ids) {
83
+ const out = {};
84
+ if (!healthUsable(a)) return out;
85
+ const want = new Set(ids);
86
+ for (const [id, h] of Object.entries(a.nodes)) {
87
+ if (!want.has(id)) continue;
88
+ const word = h.state === "unobserved" ? `${HEALTH_WORD.unobserved}: ${h.reason}` : HEALTH_WORD[h.state] || h.state;
89
+ out[id] = {
90
+ tag: word,
91
+ color: HEALTH_COLOR[h.state] || "var(--muted)",
92
+ ring: h.state === "unhealthy" ? "solid" : h.state === "unobserved" ? "dashed" : null,
93
+ dim: false,
94
+ title: healthTitle(id, h),
95
+ };
96
+ }
97
+ for (const [id, r] of Object.entries(a.rotation || {})) {
98
+ if (!want.has(id) || out[id]) continue;
99
+ out[id] = {
100
+ tag: r.line,
101
+ color: r.inRotation === false ? HEALTH_COLOR.unhealthy : r.inRotation === true ? HEALTH_COLOR.healthy : HEALTH_COLOR.unknown,
102
+ ring: null,
103
+ dim: r.inRotation === false,
104
+ title: rotationTitle(r),
105
+ };
106
+ }
107
+ return out;
108
+ }
109
+
110
+ function rotationTitle(r) {
111
+ if (r.inRotation === false) return `${r.record} is out of rotation: Route 53 stops answering with it while ${r.check} is unhealthy.`;
112
+ if (r.inRotation === true) return `${r.record} is in rotation: ${r.check} is healthy.`;
113
+ return `${r.record}: rotation unknown. behold has no verdict for ${r.check}, so it does not guess.`;
114
+ }
115
+
116
+ /** Whether an edge between two ids is drawn dimmed: when either end is a record out of rotation. */
117
+ export function dimEdge(a, from, to) {
118
+ if (!healthUsable(a) || !a.rotation) return false;
119
+ const out = (id) => !!a.rotation[id] && a.rotation[id].inRotation === false;
120
+ return out(from) || out(to);
121
+ }
122
+
123
+ /** The inspect pane's rows for one node: label and value pairs. */
124
+ export function healthRows(a, nodeId) {
125
+ if (!healthUsable(a)) return [];
126
+ const rows = [];
127
+ const h = a.nodes[nodeId];
128
+ if (h) {
129
+ if (h.state === "unobserved") {
130
+ rows.push(["state", HEALTH_WORD.unobserved], ["reason", h.reason]);
131
+ if (h.detail) rows.push(["detail", h.detail]);
132
+ } else if (h.state === "absent") {
133
+ rows.push(["state", HEALTH_WORD.absent]);
134
+ } else {
135
+ rows.push(["state", h.state], ["detail", h.detail]);
136
+ if (h.checkedAt) rows.push(["checked", h.checkedAt]);
137
+ rows.push(["read", h.observedAt]);
138
+ }
139
+ if (h.type) rows.push(["type", h.type]);
140
+ }
141
+ const r = a.rotation && a.rotation[nodeId];
142
+ if (r) rows.push(["rotation", r.inRotation === false ? "out" : r.inRotation === true ? "in" : "unknown"], ["health check", r.check], ["why", r.line]);
143
+ const routed = Object.values(a.rotation || {}).filter((x) => x.check === nodeId);
144
+ for (const x of routed) rows.push(["guards", `${x.record} (${x.inRotation === false ? "out of rotation" : x.inRotation === true ? "in rotation" : "rotation unknown"})`]);
145
+ return rows;
146
+ }
@@ -0,0 +1,67 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { describe, expect, it } from "vitest";
4
+ import { healthCounts, nodeHealthOf, rotationOf } from "../src/runtime-health.ts";
5
+ import { dimEdge, HEALTH_COLOR, healthHeader, healthLegendRows, healthMarks, healthRows, memberLines } from "./health-marks.js";
6
+
7
+ // #825: the marks drawn from what chant printed for the #823 prototype
8
+ // (src/__fixtures__/health): the dns member against a floci whose Azure
9
+ // check fails, and the azure member with nothing behind it (a hole).
10
+ const FIX = join(import.meta.dirname, "..", "src", "__fixtures__", "health");
11
+ const read = (f) => JSON.parse(readFileSync(join(FIX, f), "utf8"));
12
+ const nodes = { ...nodeHealthOf(read("dns-health.json"), "dns"), ...nodeHealthOf(read("azure-health.json"), "azure") };
13
+ const rotation = rotationOf(read("dns-graph-ir.json"), nodes, "dns");
14
+ const answer = { env: "prod", nodes, rotation, counts: healthCounts(nodes, rotation), members: [{ member: "dns" }, { member: "gcp", refusal: { error: "Runtime health needs chant 0.124.33 or newer.", remedy: "Upgrade." } }] };
15
+ const ids = ["dns/awsCheck", "dns/azureCheck", "dns/azureRecord", "dns/awsRecord", "azure/app", "dns/zone"];
16
+
17
+ describe("health marks (#825)", () => {
18
+ it("tags each card with its state, rings the unhealthy one solid and the hole dashed", () => {
19
+ const m = healthMarks(answer, ids);
20
+ expect(m["dns/awsCheck"]).toMatchObject({ tag: "healthy", color: HEALTH_COLOR.healthy, ring: null, dim: false });
21
+ expect(m["dns/azureCheck"]).toMatchObject({ tag: "unhealthy", color: "var(--degraded)", ring: "solid" });
22
+ expect(m["dns/azureCheck"].title).toMatch(/0\/8 checkers healthy/);
23
+ expect(m["azure/app"]).toMatchObject({ tag: "health not read: read-failed", color: "var(--neutral)", ring: "dashed" });
24
+ expect(m["azure/app"].title).toMatch(/not a verdict/);
25
+ expect(m["dns/zone"]).toBeUndefined();
26
+ });
27
+
28
+ it("dims the record out of rotation and its edges, and only that one", () => {
29
+ const m = healthMarks(answer, ids);
30
+ expect(m["dns/azureRecord"]).toMatchObject({ tag: "out of rotation: azureCheck unhealthy", dim: true });
31
+ expect(m["dns/awsRecord"]).toMatchObject({ tag: "in rotation: awsCheck healthy", dim: false });
32
+ expect(dimEdge(answer, "dns/azureRecord", "dns/azureCheck")).toBe(true);
33
+ expect(dimEdge(answer, "dns/azureRecord", "dns/zone")).toBe(true);
34
+ expect(dimEdge(answer, "dns/awsRecord", "dns/awsCheck")).toBe(false);
35
+ });
36
+
37
+ it("dims nothing when the check was not read", () => {
38
+ const unread = nodeHealthOf(read("dns-unobserved.json"), "dns");
39
+ const rot = rotationOf(read("dns-graph-ir.json"), unread, "dns");
40
+ const a = { env: "prod", nodes: unread, rotation: rot, counts: healthCounts(unread, rot) };
41
+ expect(Object.values(healthMarks(a, ids)).some((x) => x.dim)).toBe(false);
42
+ expect(healthMarks(a, ids)["dns/azureRecord"].tag).toBe("rotation unknown: azureCheck not read");
43
+ });
44
+
45
+ it("gives the inspect pane the detail, checkedAt and what a check guards", () => {
46
+ expect(healthRows(answer, "dns/azureCheck")).toEqual([
47
+ ["state", "unhealthy"],
48
+ ["detail", "0/8 checkers healthy; last: Failure: DNS resolution failed for w825-nowhere.invalid."],
49
+ ["checked", "2026-10-21T04:48:42.977269840Z"],
50
+ ["read", "2026-10-21T04:48:58.414Z"],
51
+ ["type", "AWS::Route53::HealthCheck"],
52
+ ["guards", "dns/azureRecord (out of rotation)"],
53
+ ]);
54
+ expect(healthRows(answer, "dns/azureRecord")).toEqual([["rotation", "out"], ["health check", "dns/azureCheck"], ["why", "out of rotation: azureCheck unhealthy"]]);
55
+ expect(healthRows(answer, "azure/app")).toEqual([["state", "health not read"], ["reason", "read-failed"], ["detail", "fetch failed"], ["type", "Microsoft.App/containerApps"]]);
56
+ });
57
+
58
+ it("words the legend, a refused member, and a refusal", () => {
59
+ expect(healthHeader(answer).text).toBe("health · prod");
60
+ expect(healthLegendRows(answer).map((r) => [r.text, r.count])).toEqual([["healthy", "2"], ["unhealthy", "1"], ["health not read", "1"], ["records out of rotation", "1"]]);
61
+ expect(memberLines(answer)).toEqual([{ text: "gcp: health not read: Runtime health needs chant 0.124.33 or newer.", title: "Upgrade." }]);
62
+ const refused = { refusal: { error: "Runtime health needs chant 0.124.33 or newer.", remedy: "Upgrade." }, degraded: "the graph draws no health marks" };
63
+ expect(healthHeader(refused)).toMatchObject({ tone: "refusal" });
64
+ expect(healthMarks(refused, ids)).toEqual({});
65
+ expect(healthMarks({ error: "not in this static export" }, ids)).toEqual({});
66
+ });
67
+ });
package/web/index.html CHANGED
@@ -86,6 +86,7 @@
86
86
  #app #inspect { grid-row: 2; grid-column: 1; border-left: 0; border-top: 1px solid var(--rule); max-height: 45vh; }
87
87
  #app #inspect-resize { display: none; }
88
88
  #app #nowline { grid-column: 1; grid-row: 3; }
89
+ #app #export-note { grid-column: 1; grid-row: 4; }
89
90
  }
90
91
  #graph { grid-row: 1; grid-column: 1; overflow: auto; position: relative; }
91
92
  #inspect { grid-row: 1; grid-column: 2; border-left: 1px solid var(--rule); background: var(--panel);
@@ -128,6 +129,7 @@
128
129
  the "⤢ fit" button resets. behold also adds a selection highlight. */
129
130
  #graph svg { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none;
130
131
  user-select: none; -webkit-user-select: none; }
132
+ html.kiosk-touch #graph svg { touch-action: pan-x pan-y; }
131
133
  #graph svg.grabbing { cursor: grabbing; }
132
134
  /* Edge hover-highlight — trace a single edge through an overlapping bundle.
133
135
  pinhole already paints a fat transparent hit-path per edge (pointer-events
@@ -206,6 +208,10 @@
206
208
  #ws-gates .ws-gate-title { font-weight: 600; }
207
209
  #ws-gates .ws-gate-facts, #ws-gates .ws-gate-note { color: var(--muted); font-size: var(--t-caption); }
208
210
  #ws-gates .ws-gate button { margin-top: var(--s1); }
211
+ /* #472: an open decision point, inside its gate's card or on its own. Never a button. */
212
+ #ws-gates .ws-gate .ws-point { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--rule); }
213
+ #ws-gates .ws-point-question { font-size: var(--t-caption); }
214
+ #ws-gates .ws-point-command { display: block; margin-top: var(--s1); font-size: var(--t-caption); overflow-wrap: anywhere; user-select: all; }
209
215
  /* #526: SQL Yodeler's report and drift, from files, dated. Never a fill. */
210
216
  #panel-body #tab-yodel.active { display: flex; flex-direction: column; gap: var(--s1); font-size: var(--t-caption); }
211
217
  #tab-yodel h3 { margin: var(--s3) 0 0; font-size: var(--t-caption); }
@@ -284,6 +290,40 @@
284
290
  #tab-trunk .ws-gate-facts, #tab-trunk .ws-gate-note { color: var(--muted); overflow-wrap: anywhere; }
285
291
  #tab-trunk a { color: inherit; }
286
292
  #tab-trunk .lane-change-set { color: var(--pending); }
293
+ /* behold#685: a plan run locally, beside CI's, in the runs pane's run view (web/kiosk-runs.js renderRun; kiosk.html's rules, scoped). */
294
+ #panel-body #tab-local-runs.active { display: flex; flex-direction: column; gap: var(--s1); font-size: var(--t-caption); }
295
+ #tab-local-runs h3 { margin: var(--s3) 0 0; font-size: var(--t-caption); }
296
+ #tab-local-runs .tg-legend { color: var(--muted); overflow-wrap: anywhere; }
297
+ #tab-local-runs .tg-refusal { color: var(--degraded); font-weight: 600; overflow-wrap: anywhere; }
298
+ #tab-local-runs .lr-form { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: end; }
299
+ #tab-local-runs .lr-field { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
300
+ #tab-local-runs .lr-field input { font: var(--t-caption) var(--font-mono); width: 12ch; }
301
+ #tab-local-runs .lr-field input[name="commit"], #tab-local-runs .lr-field input[name="base"] { width: 16ch; }
302
+ #tab-local-runs .lr-ci-row { display: flex; gap: var(--s3); align-items: center; border-top: 1px solid var(--rule); padding-top: 3px; }
303
+ #tab-local-runs .lr-ci-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
304
+ #tab-local-runs .lr-run { cursor: pointer; border-top: 1px solid var(--rule); padding-top: 3px; font-family: var(--font-mono); }
305
+ #tab-local-runs .lr-run.lr-selected { background: var(--active); }
306
+ #tab-local-runs .lr-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--s3); margin-top: var(--s2); }
307
+ #tab-local-runs .lr-half { border: 1px solid var(--rule); border-radius: 6px; min-width: 0; }
308
+ #tab-local-runs .lr-half-head { font-weight: 600; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
309
+ #tab-local-runs .r-head { padding: var(--s2) var(--s3); }
310
+ #tab-local-runs .r-head-title { display: flex; gap: var(--s2); align-items: center; font-weight: 600; }
311
+ #tab-local-runs .r-head-sub, #tab-local-runs .r-head-meta, #tab-local-runs .r-label, #tab-local-runs .r-note, #tab-local-runs .r-dur, #tab-local-runs .r-steps-word { color: var(--muted); }
312
+ #tab-local-runs .r-head-sub { overflow-wrap: anywhere; }
313
+ #tab-local-runs .r-label { display: block; font-weight: 600; padding: var(--s2) var(--s3) 0; }
314
+ #tab-local-runs .r-jobs { list-style: none; margin: 0; padding: 0; }
315
+ #tab-local-runs .r-job, #tab-local-runs .r-step-line, #tab-local-runs .r-steps-head { display: flex; gap: var(--s2); align-items: center; padding: 2px var(--s3); cursor: pointer; }
316
+ #tab-local-runs .r-job-name, #tab-local-runs .r-steps-job { font-family: var(--font-mono); font-weight: 600; }
317
+ #tab-local-runs .r-dur { margin-left: auto; white-space: nowrap; }
318
+ #tab-local-runs .r-icon { width: 1em; height: 1em; flex: none; }
319
+ #tab-local-runs .r-ok { color: var(--managed); } #tab-local-runs .r-bad { color: var(--degraded); } #tab-local-runs .r-wait, #tab-local-runs .r-busy { color: var(--foreign); } #tab-local-runs .r-idle { color: var(--neutral); }
320
+ #tab-local-runs .r-caret { color: var(--muted); width: 0.8em; }
321
+ #tab-local-runs .r-open > .r-step-line, #tab-local-runs .r-job.r-selected { background: var(--active); }
322
+ #tab-local-runs .r-log { margin: 2px var(--s3) var(--s2) 1.6em; padding: var(--s2) 0; background: var(--surface-box, transparent); border: 1px solid var(--rule); border-radius: 6px; font: 0.95em/1.45 var(--font-mono); overflow-x: auto; max-height: 20em; overflow-y: auto; white-space: pre-wrap; }
323
+ #tab-local-runs .r-log-line { display: grid; grid-template-columns: 3em 1fr; gap: var(--s3); padding-right: var(--s3); }
324
+ #tab-local-runs .r-ln { color: var(--muted); text-align: right; user-select: none; }
325
+ #tab-local-runs .r-log-cut, #tab-local-runs .r-log-setup { color: var(--muted); padding-left: 4em; font-style: italic; }
326
+ #tab-local-runs a { color: inherit; }
287
327
  /* #692: the release column. */
288
328
  #tab-trunk .lane-release { border-top: 1px solid var(--rule); padding-top: 3px; }
289
329
  #tab-trunk .lane-release .lane-where { overflow-wrap: anywhere; }
@@ -291,6 +331,12 @@
291
331
  #tab-trunk .lane-revoked-why { color: var(--degraded); overflow-wrap: anywhere; }
292
332
  #tab-trunk .lane-rollback { font-family: var(--font-mono); color: var(--muted); overflow-wrap: anywhere; }
293
333
  #tab-trunk .lane-runs-revoked, #tab-trunk .lane-superseded { color: var(--degraded); overflow-wrap: anywhere; }
334
+ /* #731: a mixed environment, and chant's lines that settle it. */
335
+ #tab-trunk .lane-mixed { color: var(--pending); font-weight: 600; overflow-wrap: anywhere; }
336
+ #tab-trunk .lane-mixed-component { color: var(--muted); padding-left: var(--s3); overflow-wrap: anywhere; }
337
+ #tab-trunk .lane-mixed-unsettled { color: var(--degraded); }
338
+ #tab-trunk .lane-command { font-family: var(--font-mono); color: var(--muted); padding-left: var(--s3); overflow-wrap: anywhere; }
339
+ #tab-trunk .lane-command-line { user-select: all; }
294
340
  /* #681: a gate's change set, previewed on the graph. */
295
341
  #panel-body #tab-change-set.active { display: flex; flex-direction: column; gap: var(--s1); font-size: var(--t-caption); }
296
342
  #tab-change-set h3 { margin: var(--s3) 0 0; font-size: var(--t-caption); }
@@ -786,6 +832,11 @@
786
832
  wears the managed edge its new owner paints everything with. */
787
833
  #graph [data-node-id].carved rect:first-of-type { stroke: var(--managed); stroke-width: 2; }
788
834
 
835
+ /* #824: behold export --note, the line a static page shows at its foot (web/export-note.js). */
836
+ #export-note { grid-column: 1 / 3; grid-row: 3; margin: 0; padding: var(--s3) var(--s4); border-top: 1px solid var(--rule);
837
+ background: var(--panel); color: var(--ink2); font: var(--t-body)/1.45 var(--font-ui); text-align: center; }
838
+ #export-note[hidden] { display: none; }
839
+ #export-note code { white-space: nowrap; font-family: var(--font-mono); color: var(--fg); background: var(--well); padding: 1px var(--s1); border-radius: var(--r-ctl); }
789
840
  #nowline { grid-column: 1 / 3; grid-row: 2; margin: 0; max-height: 160px; overflow: auto; display: none;
790
841
  background: var(--well); border-top: 1px solid var(--rule); padding: var(--s3) var(--s4);
791
842
  font: var(--t-caption)/1.6 var(--font-mono); color: var(--fg); white-space: pre-wrap; }
@@ -928,6 +979,7 @@
928
979
  </aside>
929
980
  <button id="inspect-reopen" title="Show inspect panel">Inspect ‹</button>
930
981
  <pre id="nowline"></pre>
982
+ <p id="export-note" hidden></p>
931
983
  </div>
932
984
  <!-- The floating control panel (see the #panel CSS comment above). The
933
985
  View tab keeps stable slots (#panel-zoom / #panel-viewtools /
package/web/kiosk-runs.js CHANGED
@@ -281,6 +281,39 @@ export function placeWords(run, scenarios, titles = {}, names = {}) {
281
281
  return [sc, run.cycle !== null && run.cycle !== undefined ? `cycle ${run.cycle}` : null].filter(Boolean).join(" · ");
282
282
  }
283
283
 
284
+ /**
285
+ * behold#815: what chant's run index says of a run beside its trigger: its
286
+ * workspace member, why it failed, and who signed its record. A run nobody
287
+ * signed says nothing of it (signing is opt-in, chant#4156). An apply that
288
+ * exited 3 says its plan moved or waits, never that it failed, with the
289
+ * refusal that says so or (#818, chant#4165) its exit code. Empty for a run
290
+ * from anywhere else.
291
+ */
292
+ export function indexWords(run) {
293
+ // behold#685: a plan behold ran locally (src/ci-local-run.ts) says the same of itself.
294
+ if (!run || (run.from !== "ci-run-index" && run.from !== "chant-ci-local")) return [];
295
+ // The status beside it already says failed: chant's reason is added only when it says more than that.
296
+ const why = run.moved ? `${run.moved} (${run.heldBy || run.failure})` : run.failure && run.failure !== "failed" ? `failed: ${run.failure}` : null;
297
+ return [run.member || null, why, typeof run.signer === "string" && run.signer ? `signed by ${run.signer}` : null].filter(Boolean);
298
+ }
299
+
300
+ /**
301
+ * behold#815: where a run of chant's run index says it ran, as a link: its
302
+ * runOrigin's URL, named by the URL's own host (a Forgejo run is recorded as
303
+ * forge `github`, so the forge's name is never taken from the record). Null
304
+ * without an http(s) URL.
305
+ */
306
+ export function originLink(run) {
307
+ if (!run || run.from !== "ci-run-index" || typeof run.origin !== "string") return null;
308
+ let u;
309
+ try {
310
+ u = new URL(run.origin);
311
+ } catch {
312
+ return null;
313
+ }
314
+ return u.protocol === "http:" || u.protocol === "https:" ? { href: u.href, text: `the run on ${u.host}` } : null;
315
+ }
316
+
284
317
  /**
285
318
  * behold#571: a runner's or an action's set-up line, not terragucci's own:
286
319
  * git's hints, the checkout's `[command]` lines and groups, the runner's
@@ -414,13 +447,14 @@ export function statusIcon(status) {
414
447
  }
415
448
 
416
449
  /** The sidebar: the live run pinned, then the recent ones. `pick(id)` selects one; nothing here writes. */
417
- export function renderSidebar(host, index, selectedId, { now = new Date(), scenarios = {}, titles = {}, names = {}, pick = () => {}, merged = null, replay = false, chant = false } = {}) {
450
+ export function renderSidebar(host, index, selectedId, { now = new Date(), scenarios = {}, titles = {}, names = {}, pick = () => {}, merged = null, replay = false, chant = false, from = null } = {}) {
418
451
  host.replaceChildren();
419
452
  const head = el("div", "r-side-head");
420
453
  head.appendChild(el("div", "r-side-title", "Runs"));
421
454
  // behold#571: a tool's page replays an earlier cycle's runs, and says so.
422
455
  // behold#752: chant's demo's runs are built from chant's run events, not copied from the forge.
423
- head.appendChild(el("div", "r-side-note", replay ? "The replayed cycle's runs, newest first." : chant ? "From chant's run events, newest first." : "From the forge, newest first."));
456
+ // behold#815: `from` names where else they come from (chant's run index).
457
+ head.appendChild(el("div", "r-side-note", replay ? "The replayed cycle's runs, newest first." : from || (chant ? "From chant's run events, newest first." : "From the forge, newest first.")));
424
458
  host.appendChild(head);
425
459
  if (!index || index.error || index.absent || !index.doc) {
426
460
  host.appendChild(el("p", "r-note", index ? index.absent || index.error : "Reading the runs…"));
@@ -445,7 +479,7 @@ export function renderSidebar(host, index, selectedId, { now = new Date(), scena
445
479
  li.appendChild(statusIcon(r.status));
446
480
  const body = el("div", "r-run-body");
447
481
  body.appendChild(el("div", "r-run-title", triggerWords(r)));
448
- const place = placeWords(r, scenarios, named, names);
482
+ const place = [placeWords(r, scenarios, named, names), ...indexWords(r)].filter(Boolean).join(" · ");
449
483
  if (place) body.appendChild(el("div", "r-run-place", place));
450
484
  const meta = el("div", "r-run-meta");
451
485
  meta.append(
@@ -525,13 +559,24 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
525
559
  const meta = el("div", "r-head-meta");
526
560
  const bits = [
527
561
  `#${run.id}`,
528
- run.status === "waiting" ? "held at a terragucci gate, waiting for an approval" : STATUS_WORDS[run.status] || run.status,
562
+ // A run of chant's index whose plan moved says why on its own (indexWords): "held" is all the status adds.
563
+ run.status === "waiting" ? (run.moved ? "held" : `held at a ${run.from === "ci-run-index" ? "" : "terragucci "}gate, waiting for an approval`) : STATUS_WORDS[run.status] || run.status,
529
564
  run.ref ? `on ${run.ref}` : null,
530
565
  run.commit ? `commit ${run.commit.slice(0, 8)}` : null,
566
+ ...indexWords(run),
531
567
  run.started_at ? `started ${agoWords(run.started_at, now)}` : null,
532
568
  durationWords(run.started_at, run.ended_at, now),
533
569
  ].filter(Boolean);
534
570
  meta.textContent = bits.join(" · ");
571
+ // behold#815: the forge's own run, when chant's run index names one.
572
+ const link = originLink(run);
573
+ if (link) {
574
+ const a = el("a", "r-origin", link.text);
575
+ a.href = link.href;
576
+ a.target = "_blank";
577
+ a.rel = "noopener noreferrer";
578
+ meta.append(" · ", a);
579
+ }
535
580
  head.appendChild(meta);
536
581
  host.appendChild(head);
537
582
 
@@ -831,6 +876,7 @@ export function startRuns(
831
876
  replay = () => false,
832
877
  hideLine = null,
833
878
  // behold#752: where the live runs are read: terragucci's copies of forge runs, or chant's demo's runs built from its run events.
879
+ // behold#815: or chant's run index, whose `from` is the sidebar's line.
834
880
  urls = { runs: "/api/terragucci/runs", run: (id) => `/api/terragucci/runs/${id}` },
835
881
  } = {},
836
882
  ) {
@@ -880,7 +926,7 @@ export function startRuns(
880
926
  }
881
927
  // One merged read of the selected run for both the sidebar and its page.
882
928
  const merged = ans && ans.doc ? mergeRun(entry, ans.doc) : null;
883
- renderSidebar(side, s.index, id, { now: shown(), scenarios, titles: titles(), names: names(), pick, merged, replay: replay(), chant: urls.runs.startsWith("/api/chant/") });
929
+ renderSidebar(side, s.index, id, { now: shown(), scenarios, titles: titles(), names: names(), pick, merged, replay: replay(), chant: urls.runs.startsWith("/api/chant/"), from: urls.from || null });
884
930
  // The redraw replaces the scrollers: keep where a viewer left them.
885
931
  const old = main.querySelector(".r-log");
886
932
  const oldSteps = main.querySelector(".r-steps");