@intentius/behold 0.29.42 → 0.29.44
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 +77 -0
- package/dist/cli.js +3969 -1918
- package/package.json +1 -1
- package/web/app.js +1463 -80
- package/web/carve-narration.js +33 -1
- package/web/chant-live-pace.js +138 -0
- package/web/chant-live-pace.test.js +116 -0
- package/web/chant-pr-marks.js +417 -39
- package/web/chant-pr-marks.test.js +208 -4
- package/web/collision-marks.js +124 -0
- package/web/collision-marks.test.js +89 -0
- package/web/cone.js +269 -0
- package/web/cone.test.js +213 -0
- package/web/dots-cards.js +362 -0
- package/web/dots-cards.test.js +303 -0
- package/web/dots-live.test.js +151 -1
- package/web/dots-lod.js +20 -0
- package/web/dots-lod.test.js +19 -1
- package/web/dots-scene.js +110 -10
- package/web/dots.js +489 -87
- package/web/embed.js +17 -1
- package/web/embed.test.js +19 -1
- package/web/event-help-modal.js +85 -3
- package/web/event-help-modal.test.js +85 -1
- package/web/feature-flags.js +143 -0
- package/web/feature-flags.test.js +96 -0
- package/web/index.html +33 -0
- package/web/kiosk-carve.js +59 -6
- package/web/kiosk-event-help-ui.js +150 -19
- package/web/kiosk-event-help.js +102 -15
- package/web/kiosk-event-help.test.js +58 -1
- package/web/kiosk-metrics.js +4 -3
- package/web/kiosk-runs.js +8 -5
- package/web/kiosk-shot.js +157 -3
- package/web/kiosk-shot.test.js +223 -1
- package/web/kiosk-source.js +43 -0
- package/web/kiosk-source.test.js +39 -0
- package/web/kiosk-story-gate.test.js +44 -0
- package/web/kiosk-track.js +312 -0
- package/web/kiosk-track.test.js +148 -0
- package/web/kiosk-unknown-step.test.js +58 -0
- package/web/kiosk-vendor.js +71 -4
- package/web/kiosk-vendor.test.js +103 -3
- package/web/kiosk-watch.js +154 -1
- package/web/kiosk-watch.test.js +53 -1
- package/web/kiosk.html +57 -22
- package/web/kiosk.js +566 -53
- package/web/kiosk.test.js +2 -1
- package/web/small-stage.test.js +150 -0
- package/web/terragucci-blocked.test.js +192 -0
- package/web/terragucci-change.js +197 -17
- package/web/terragucci-components-live.js +189 -13
- package/web/terragucci-live-pace.js +92 -0
- package/web/terragucci-wave-results.test.js +125 -0
- package/web/terralith.html +7 -7
- package/web/tg-outside.js +124 -0
- package/web/tg-outside.test.js +100 -0
- package/web/tg-read-pills.js +122 -0
- package/web/tg-read-pills.test.js +117 -0
- package/web/theme.js +13 -1
- package/web/theme.test.js +21 -1
- package/web/tooltip.js +19 -7
- package/web/tooltip.test.js +15 -0
- package/web/tours/terralith.json +4 -4
- package/web/trunk-lane.test.js +1 -1
- package/web/view-url.js +8 -2
- package/web/why.js +129 -1
- package/web/why.test.js +113 -1
package/web/cone.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// A cone plan on the stage (report minor 34). A choudoufu root under a `live`
|
|
2
|
+
// block that a pull request planned with `plan -cone=<base>` plans only the
|
|
3
|
+
// blocks the change touches and the blocks that read them. The server's
|
|
4
|
+
// `pull_request.cone` (src/terragucci-cone.ts) names every root of the
|
|
5
|
+
// estate as the plan treated it: `cone` (its size, and the instances its
|
|
6
|
+
// plan.json planned), `full` (choudoufu's guard planned the whole estate, and
|
|
7
|
+
// why), `planned` (planned with no cone) or `not-planned`.
|
|
8
|
+
//
|
|
9
|
+
// This module decides what lights and what dims, and the one quiet line that
|
|
10
|
+
// says it. Pure: the answer in, plain data out. The frame (web/app.js) lights
|
|
11
|
+
// the SVG's cards and boxes, the dots layer (web/dots.js) its dots and roster
|
|
12
|
+
// cards, and the kiosk (web/kiosk-watch.js, web/kiosk.js) writes the line.
|
|
13
|
+
// A plan with no `cone` has no cone view, and every function here answers
|
|
14
|
+
// null: nothing on the stage changes.
|
|
15
|
+
|
|
16
|
+
/** The pull request's cone view, or null when its plan has none. */
|
|
17
|
+
export function coneOf(pr) {
|
|
18
|
+
const c = pr && pr.cone;
|
|
19
|
+
return c && Array.isArray(c.roots) && c.roots.length ? c : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const n = (v) => Number.isInteger(v) && v >= 0;
|
|
23
|
+
const plural = (k, one, many = `${one}s`) => `${k} ${k === 1 ? one : many}`;
|
|
24
|
+
const stop = (s) => (/[.!?]$/.test(s) ? s : `${s}.`);
|
|
25
|
+
|
|
26
|
+
/** A cone root's size in words: "2 of 16 blocks", else "3 addresses", else null when choudoufu said neither. */
|
|
27
|
+
export function coneSize(r) {
|
|
28
|
+
if (n(r.blocks) && n(r.of)) return `${r.blocks} of ${r.of} blocks`;
|
|
29
|
+
if (n(r.targets)) return plural(r.targets, "address", "addresses");
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* behold#736: a fallback's kind in words, for a card: choudoufu's `empty-cone` is "empty cone". The reason is the
|
|
35
|
+
* tooltip's (fallbackWhy): on fan-out-choudoufu's fix six apps fall back at once, and a card holds a few words.
|
|
36
|
+
* Null for a kind choudoufu didn't name.
|
|
37
|
+
*/
|
|
38
|
+
export function fallbackKind(r) {
|
|
39
|
+
const k = r && r.fallback && typeof r.fallback.kind === "string" ? r.fallback.kind : "";
|
|
40
|
+
return k && k !== "unknown" ? k.replace(/[-_]+/g, " ") : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** behold#736: why choudoufu planned the whole estate, for a fallback's tooltip: "choudoufu planned it in full: <reason>". Null without a reason. */
|
|
44
|
+
export function fallbackWhy(r) {
|
|
45
|
+
return r && r.kind === "full" && r.fallback && r.fallback.reason ? `choudoufu planned it in full: ${r.fallback.reason}` : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** One root's part of the plan in words, for its box: "2 of 16 blocks, as a cone", "planned in full: empty cone" (else its reason), "not planned"; null for a root planned with no cone. */
|
|
49
|
+
export function coneFact(r) {
|
|
50
|
+
if (!r) return null;
|
|
51
|
+
if (r.kind === "cone") {
|
|
52
|
+
const size = coneSize(r);
|
|
53
|
+
return size ? `${size}, as a cone` : "planned as a cone";
|
|
54
|
+
}
|
|
55
|
+
if (r.kind === "full") {
|
|
56
|
+
const why = fallbackKind(r) || (r.fallback && r.fallback.reason) || "";
|
|
57
|
+
return why ? `planned in full: ${why}` : "planned in full";
|
|
58
|
+
}
|
|
59
|
+
if (r.kind === "not-planned") return "not planned";
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The plan line. One root and nothing else: "Planned as a cone: 2 of 16
|
|
65
|
+
* blocks. The rest of the estate was not read." or "Planned in full:
|
|
66
|
+
* <reason>." Several roots: "service-b: 2 of 6 blocks, as a cone · network,
|
|
67
|
+
* service-a: not planned". Null with no cone view.
|
|
68
|
+
*/
|
|
69
|
+
export function coneLine(cone) {
|
|
70
|
+
if (!cone) return null;
|
|
71
|
+
const roots = cone.roots;
|
|
72
|
+
if (roots.length === 1) {
|
|
73
|
+
const r = roots[0];
|
|
74
|
+
if (r.kind === "cone") {
|
|
75
|
+
const size = coneSize(r);
|
|
76
|
+
return `Planned as a cone${size ? `: ${size}` : ""}. The rest of the estate was not read.`;
|
|
77
|
+
}
|
|
78
|
+
if (r.kind === "full") return stop(`Planned in full${r.fallback && r.fallback.reason ? `: ${r.fallback.reason}` : ""}`);
|
|
79
|
+
}
|
|
80
|
+
// behold#736: roots the plan treated alike say it once (fan-out-choudoufu's fix: six apps fall back on an empty
|
|
81
|
+
// cone, eight roots aren't planned), so the line stays one line on a fifteen-estate stage.
|
|
82
|
+
const groups = new Map();
|
|
83
|
+
for (const r of roots) {
|
|
84
|
+
if (r.kind === "not-planned") continue;
|
|
85
|
+
const fact = r.kind === "planned" ? "planned" : coneFact(r);
|
|
86
|
+
const key = `${r.kind}\u0000${fact}`;
|
|
87
|
+
if (!groups.has(key)) groups.set(key, { kind: r.kind, fact, names: [] });
|
|
88
|
+
groups.get(key).names.push(r.root);
|
|
89
|
+
}
|
|
90
|
+
const parts = [];
|
|
91
|
+
const order = { cone: 0, full: 1, planned: 2 };
|
|
92
|
+
for (const g of [...groups.values()].sort((a, b) => order[a.kind] - order[b.kind])) parts.push(g.kind === "full" ? `${rootNames(g.names)} ${g.fact}` : `${rootNames(g.names)}: ${g.fact}`);
|
|
93
|
+
const not = roots.filter((r) => r.kind === "not-planned").map((r) => r.root);
|
|
94
|
+
if (not.length) parts.push(not.length > 3 ? `${not.length} others not planned` : `${not.join(", ")}: not planned`);
|
|
95
|
+
return parts.join(" · ");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** behold#736: a group's roots: up to three by name, more as the first to the last ("app-01 to app-06"). */
|
|
99
|
+
export const rootNames = (list) => {
|
|
100
|
+
if (list.length <= 3) return list.join(", ");
|
|
101
|
+
const sorted = [...list].sort();
|
|
102
|
+
// A run only when it is one: the same name with numbers one after another (app-01 to app-06); else how many.
|
|
103
|
+
const parts = sorted.map((s) => /^(.*?)(\d+)$/.exec(s));
|
|
104
|
+
const run = parts.every((p, i) => p && p[1] === parts[0][1] && Number(p[2]) === Number(parts[0][2]) + i);
|
|
105
|
+
return run ? `${sorted[0]} to ${sorted[sorted.length - 1]}` : `${list.length} estates`;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** A resource's address as a card line says it: the provider's prefix off its type (`aws_iam_role.x` is `iam_role.x`), module calls kept. */
|
|
109
|
+
export function shortAddress(address) {
|
|
110
|
+
return String(address).replace(/(^|\.)(?:aws|google|azurerm|kubernetes)_([a-z0-9_]+\.)/, "$1$2");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The cone's resources as lines inside its root's card: what the plan changes
|
|
115
|
+
* first, then what it only read, at most `max` lines, the rest counted:
|
|
116
|
+
* "iam_role_policy.service · changed", "iam_role.service · read". None for a
|
|
117
|
+
* root that is not a cone, or whose plan.json was not read.
|
|
118
|
+
*/
|
|
119
|
+
export function coneResourceLines(r, max = 2) {
|
|
120
|
+
if (!r || r.kind !== "cone" || !Array.isArray(r.planned) || !r.planned.length) return [];
|
|
121
|
+
const sorted = [...r.planned.filter((p) => p.changed), ...r.planned.filter((p) => !p.changed)];
|
|
122
|
+
const lines = sorted.slice(0, max).map((p) => `${shortAddress(p.address)} · ${p.changed ? "changed" : "read"}`);
|
|
123
|
+
const more = sorted.length - lines.length;
|
|
124
|
+
if (more > 0) lines[lines.length - 1] += ` · and ${more} more`;
|
|
125
|
+
return lines;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A line wrapped to `room` px by `measure(text)`: at spaces, and a word still
|
|
130
|
+
* too wide at its last `.` or `_` that fits (a resource's address), so every
|
|
131
|
+
* part of it reads; never cut. ["iam_role_policy.service", "· changed"].
|
|
132
|
+
*/
|
|
133
|
+
export function wrapWords(text, room, measure) {
|
|
134
|
+
const fits = (t) => measure(t) <= room;
|
|
135
|
+
const out = [];
|
|
136
|
+
let cur = "";
|
|
137
|
+
const push = (w) => {
|
|
138
|
+
const next = cur ? `${cur} ${w}` : w;
|
|
139
|
+
if (fits(next) || !cur) cur = next;
|
|
140
|
+
else {
|
|
141
|
+
out.push(cur);
|
|
142
|
+
cur = w;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
// A lone "·" goes with the word after it, so a line never ends on one.
|
|
146
|
+
const words = [];
|
|
147
|
+
for (const w of String(text).split(" ").filter(Boolean)) {
|
|
148
|
+
if (words.length && words[words.length - 1] === "·") words[words.length - 1] = `· ${w}`;
|
|
149
|
+
else words.push(w);
|
|
150
|
+
}
|
|
151
|
+
for (const word of words) {
|
|
152
|
+
let w = word;
|
|
153
|
+
// A word wider than the whole line: break it after a `.` or `_`, as far along as fits.
|
|
154
|
+
while (!fits(w) && w.length > 1) {
|
|
155
|
+
let at = -1;
|
|
156
|
+
for (let k = w.length - 1; k > 0; k--) if ((w[k - 1] === "." || w[k - 1] === "_") && fits(w.slice(0, k))) {
|
|
157
|
+
at = k;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (at < 0) break;
|
|
161
|
+
if (cur) {
|
|
162
|
+
out.push(cur);
|
|
163
|
+
cur = "";
|
|
164
|
+
}
|
|
165
|
+
out.push(w.slice(0, at));
|
|
166
|
+
w = w.slice(at);
|
|
167
|
+
}
|
|
168
|
+
push(w);
|
|
169
|
+
}
|
|
170
|
+
if (cur) out.push(cur);
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** "3 estates · 1 backend · no state files", when the reports say the estates share choudoufu's live backend; else null. */
|
|
175
|
+
export function backendLine(cone) {
|
|
176
|
+
const b = cone && cone.backend;
|
|
177
|
+
if (!b || !n(b.estates) || b.estates < 1) return null;
|
|
178
|
+
return `${plural(b.estates, "estate")} · 1 backend · no state files`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** An instance address's block path, behold's way (src/terragucci-overlay.ts blockPath): module calls as segments, instance keys dropped. */
|
|
182
|
+
export function blockPath(address) {
|
|
183
|
+
const bare = String(address).replace(/\[(?:"(?:[^"\\]|\\.)*"|[^\]])*\]/g, "");
|
|
184
|
+
const tokens = bare.split(".");
|
|
185
|
+
const segments = [];
|
|
186
|
+
let i = 0;
|
|
187
|
+
while (tokens[i] === "module" && i + 1 < tokens.length) {
|
|
188
|
+
segments.push(`module.${tokens[i + 1]}`);
|
|
189
|
+
i += 2;
|
|
190
|
+
}
|
|
191
|
+
segments.push(tokens.slice(i).join("."));
|
|
192
|
+
return segments.join("/");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The cone view as lights: by root, its kind, and with a cone the planned
|
|
197
|
+
* and changed resources by address and by block path. `{ roots: Map }`, or
|
|
198
|
+
* null with no cone view.
|
|
199
|
+
*/
|
|
200
|
+
export function coneLights(cone) {
|
|
201
|
+
if (!cone) return null;
|
|
202
|
+
const roots = new Map();
|
|
203
|
+
for (const r of cone.roots) {
|
|
204
|
+
const planned = Array.isArray(r.planned) ? r.planned : null;
|
|
205
|
+
const keys = (list) => new Set(list.flatMap((p) => [p.address, blockPath(p.address)]));
|
|
206
|
+
roots.set(r.root, {
|
|
207
|
+
kind: r.kind,
|
|
208
|
+
count: r.kind === "cone" ? coneSize(r) : null,
|
|
209
|
+
planned: planned ? keys(planned) : null,
|
|
210
|
+
changed: planned ? keys(planned.filter((p) => p.changed)) : new Set(),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return { roots };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* How a root's box shows: "lit" (planned: a cone, or in full), "dim" (not
|
|
218
|
+
* planned), or null (no cone view, a root it does not name, or one planned
|
|
219
|
+
* with no cone: drawn as before).
|
|
220
|
+
*/
|
|
221
|
+
export function rootLight(lights, root) {
|
|
222
|
+
const r = lights && lights.roots.get(root);
|
|
223
|
+
if (!r) return null;
|
|
224
|
+
if (r.kind === "cone" || r.kind === "full") return "lit";
|
|
225
|
+
if (r.kind === "not-planned") return "dim";
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* How one resource of a root shows: "changed" (the cone planned it and its
|
|
231
|
+
* plan changes it), "lit" (the cone planned it, or the whole estate was
|
|
232
|
+
* planned), "dim" (in the cone's root but not planned, or in a root the pull
|
|
233
|
+
* request did not plan), or null (drawn as before: no cone view, a root it
|
|
234
|
+
* does not name, a root planned with no cone, or a cone whose plan.json was
|
|
235
|
+
* not read, which lights at its box instead).
|
|
236
|
+
*/
|
|
237
|
+
export function resourceLight(lights, root, address) {
|
|
238
|
+
const r = lights && lights.roots.get(root);
|
|
239
|
+
if (!r) return null;
|
|
240
|
+
if (r.kind === "full") return "lit";
|
|
241
|
+
if (r.kind === "not-planned") return "dim";
|
|
242
|
+
if (r.kind !== "cone" || !r.planned) return null;
|
|
243
|
+
const k = [address, blockPath(address)];
|
|
244
|
+
if (k.some((x) => r.changed.has(x))) return "changed";
|
|
245
|
+
return k.some((x) => r.planned.has(x)) ? "lit" : "dim";
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The root and address a card id names, of the roots the cone view names:
|
|
250
|
+
* `<member>/<root name>/<block path>` (a Terraform member, by `roots`, the
|
|
251
|
+
* answer's `{member, name, path}`), else `<member>/<address>` whose member is
|
|
252
|
+
* the root's directory name (a choudoufu member). Null when it names none.
|
|
253
|
+
*/
|
|
254
|
+
export function cardRoot(id, lights, roots = []) {
|
|
255
|
+
if (!lights || typeof id !== "string") return null;
|
|
256
|
+
for (const r of roots) {
|
|
257
|
+
if (!r || !lights.roots.has(r.path)) continue;
|
|
258
|
+
const prefix = `${r.member}/${r.name}/`;
|
|
259
|
+
if (id.startsWith(prefix)) return { root: r.path, address: id.slice(prefix.length) };
|
|
260
|
+
}
|
|
261
|
+
const slash = id.indexOf("/");
|
|
262
|
+
if (slash < 0) return null;
|
|
263
|
+
const member = id.slice(0, slash);
|
|
264
|
+
for (const path of lights.roots.keys()) {
|
|
265
|
+
const leaf = path.replace(/\/+$/, "").split("/").pop();
|
|
266
|
+
if (member === path || member === leaf) return { root: path, address: id.slice(slash + 1) };
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
package/web/cone.test.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Report minor 34: a cone plan on the stage. The answers are the server's own
|
|
2
|
+
// for the three pull request plans in src/__fixtures__/terragucci-cone (a
|
|
3
|
+
// cone, a fallback, and another binary's plan with no cone field), built by
|
|
4
|
+
// the same functions /api/terragucci answers with.
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { pullRequestPlan } from "../src/terragucci-reports.ts";
|
|
9
|
+
import { coneView, plannedInstances } from "../src/terragucci-cone.ts";
|
|
10
|
+
import { backendLine, blockPath, cardRoot, coneFact, coneLights, coneLine, coneOf, coneResourceLines, fallbackWhy, resourceLight, rootLight, shortAddress } from "./cone.js";
|
|
11
|
+
import { componentMarks } from "./terragucci-components-live.js";
|
|
12
|
+
import { rootStates } from "./terragucci-change.js";
|
|
13
|
+
import { captionModel, coneCaption } from "./kiosk-watch.js";
|
|
14
|
+
import { coneLines } from "./kiosk.js";
|
|
15
|
+
import { coneGlow } from "./dots.js";
|
|
16
|
+
|
|
17
|
+
const FIX = join(import.meta.dirname, "..", "src", "__fixtures__", "terragucci-cone");
|
|
18
|
+
const json = (...p) => JSON.parse(readFileSync(join(FIX, ...p), "utf8"));
|
|
19
|
+
const ROOTS = ["network", "service-a", "service-b"];
|
|
20
|
+
const facts = Object.fromEntries(ROOTS.map((r) => [r, { binary: "choudoufu" }]));
|
|
21
|
+
|
|
22
|
+
/** The pull request stage /api/terragucci answers for a fixture plan, with its cone view when it has one. */
|
|
23
|
+
function prOf(run) {
|
|
24
|
+
const doc = json("runs", run, "report.json");
|
|
25
|
+
const pr = pullRequestPlan(doc, `runs/${run}/report.html`);
|
|
26
|
+
const planned = { "service-b": plannedInstances(json("runs", run, "service-b.plan.json")) };
|
|
27
|
+
const cone = coneView(doc, { roots: ROOTS, planned: run === "pr-cone" ? planned : {}, facts });
|
|
28
|
+
return cone ? { ...pr, cone } : pr;
|
|
29
|
+
}
|
|
30
|
+
const answerOf = (run) => ({ roots: ROOTS.map((path) => ({ member: path, name: path, path })), pull_request: prOf(run) });
|
|
31
|
+
const demo = (step, more = {}) => ({ cycle: 3, scenario: "cone", title: "One change, planned as a cone", step, label: `the ${step} line`, started_at: "2026-10-17T10:01:00Z", next: null, pull: 7, commit: "2222222", about: { changes: "A pull request changes service-b's inline policy." }, ...more });
|
|
32
|
+
|
|
33
|
+
describe("a cone plan's words (minor 34)", () => {
|
|
34
|
+
it("says the cone's size from the report's numbers, the roots it did not plan, and the one backend", () => {
|
|
35
|
+
const cone = coneOf(prOf("pr-cone"));
|
|
36
|
+
expect(coneLine(cone)).toBe("service-b: 2 of 6 blocks, as a cone · network, service-a: not planned");
|
|
37
|
+
expect(backendLine(cone)).toBe("3 estates · 1 backend · no state files");
|
|
38
|
+
expect(coneFact(cone.roots[0])).toBe("2 of 6 blocks, as a cone");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("says plainly that choudoufu planned in full, with the guard's kind on the card and its reason in the tooltip", () => {
|
|
42
|
+
const cone = coneOf(prOf("pr-fallback"));
|
|
43
|
+
expect(coneLine(cone)).toBe("service-b planned in full: provider changed · network, service-a: not planned");
|
|
44
|
+
expect(coneFact(cone.roots[0])).toBe("planned in full: provider changed");
|
|
45
|
+
expect(fallbackWhy(cone.roots[0])).toBe("choudoufu planned it in full: a provider block changed");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("with one root and nothing else, says it in the brief's words", () => {
|
|
49
|
+
expect(coneLine({ roots: [{ root: ".", kind: "cone", blocks: 2, of: 16 }] })).toBe("Planned as a cone: 2 of 16 blocks. The rest of the estate was not read.");
|
|
50
|
+
expect(coneLine({ roots: [{ root: ".", kind: "full", fallback: { kind: "cone-too-large", reason: "the cone is over 30% of the estate's blocks" } }] })).toBe("Planned in full: the cone is over 30% of the estate's blocks.");
|
|
51
|
+
expect(coneLine({ roots: [{ root: ".", kind: "cone", targets: 1 }] })).toBe("Planned as a cone: 1 address. The rest of the estate was not read.");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("a cone plan's lights (minor 34)", () => {
|
|
56
|
+
it("lights what the cone planned, rings what it changes, and dims the rest of its root and the roots it did not plan", () => {
|
|
57
|
+
const L = coneLights(coneOf(prOf("pr-cone")));
|
|
58
|
+
expect(resourceLight(L, "service-b", "aws_iam_role_policy.service_b")).toBe("changed");
|
|
59
|
+
expect(resourceLight(L, "service-b", "aws_iam_role.service_b")).toBe("lit");
|
|
60
|
+
expect(resourceLight(L, "service-b", "aws_sqs_queue.jobs")).toBe("dim");
|
|
61
|
+
expect(resourceLight(L, "network", "aws_vpc.main")).toBe("dim");
|
|
62
|
+
expect(rootLight(L, "service-b")).toBe("lit");
|
|
63
|
+
expect(rootLight(L, "network")).toBe("dim");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("lights every resource of a root planned in full", () => {
|
|
67
|
+
const L = coneLights(coneOf(prOf("pr-fallback")));
|
|
68
|
+
expect(resourceLight(L, "service-b", "aws_sqs_queue.jobs")).toBe("lit");
|
|
69
|
+
expect(rootLight(L, "service-b")).toBe("lit");
|
|
70
|
+
expect(rootLight(L, "service-a")).toBe("dim");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("finds a card's root and address by the stage's node ids, by instance or block path", () => {
|
|
74
|
+
const L = coneLights(coneOf(prOf("pr-cone")));
|
|
75
|
+
const roots = answerOf("pr-cone").roots;
|
|
76
|
+
// A Terraform member: <member>/<root name>/<block path>.
|
|
77
|
+
expect(cardRoot("service-b/service-b/aws_iam_role.service_b", L, roots)).toEqual({ root: "service-b", address: "aws_iam_role.service_b" });
|
|
78
|
+
// A choudoufu member named for the root's directory: <member>/<address>.
|
|
79
|
+
expect(cardRoot("service-b/aws_iam_role_policy.service_b", L, [])).toEqual({ root: "service-b", address: "aws_iam_role_policy.service_b" });
|
|
80
|
+
expect(cardRoot("other/aws_vpc.main", L, [])).toBeNull();
|
|
81
|
+
expect(blockPath('module.svc.aws_iam_role.r["a.b"]')).toBe("module.svc/aws_iam_role.r");
|
|
82
|
+
const Lm = coneLights({ roots: [{ root: "r", kind: "cone", planned: [{ address: 'module.svc.aws_iam_role.r["x"]', changed: false }] }] });
|
|
83
|
+
expect(resourceLight(Lm, "r", "module.svc/aws_iam_role.r")).toBe("lit");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("lights a cone whose plan.json was not read at its box only, its cards as they were", () => {
|
|
87
|
+
const L = coneLights({ roots: [{ root: "service-b", kind: "cone", blocks: 2, of: 6 }] });
|
|
88
|
+
expect(rootLight(L, "service-b")).toBe("lit");
|
|
89
|
+
expect(resourceLight(L, "service-b", "aws_iam_role.service_b")).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("glows a dot or a roster card as the light says", () => {
|
|
93
|
+
expect(coneGlow("changed", "#c80")).toEqual({ colour: "#c80", a: 1, ring: true, dim: false });
|
|
94
|
+
expect(coneGlow("lit", "#c80")).toMatchObject({ ring: false, dim: false });
|
|
95
|
+
expect(coneGlow("dim", "#c80")).toMatchObject({ a: 0, dim: true });
|
|
96
|
+
expect(coneGlow(null, "#c80")).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("a cone plan on the boxes and in the kiosk (minor 34)", () => {
|
|
101
|
+
it("puts the cone's size on its root's box, and says not planned on the others", () => {
|
|
102
|
+
const { roots } = rootStates(answerOf("pr-cone"), null);
|
|
103
|
+
expect(roots["service-b"]).toMatchObject({ state: "planned", words: "wave 1 · planned · 2 of 6 blocks, as a cone", cone: "cone" });
|
|
104
|
+
expect(roots["service-b"].facts[0]).toBe("2 of 6 blocks, as a cone");
|
|
105
|
+
// The cone's resources, two short lines for the card's body: the change first, then what the plan only read.
|
|
106
|
+
expect(roots["service-b"].lines).toEqual(["iam_role_policy.service_b · changed", "iam_role.service_b · read"]);
|
|
107
|
+
expect(roots.network).toMatchObject({ state: "outside", words: "not planned", cone: "not-planned" });
|
|
108
|
+
expect(rootStates(answerOf("pr-fallback"), null).roots["service-b"]).toMatchObject({ words: "wave 1 · planned in full: provider changed", facts: expect.arrayContaining(["choudoufu planned it in full: a provider block changed"]) });
|
|
109
|
+
expect(rootStates(answerOf("pr-fallback"), null).roots["service-b"]).not.toHaveProperty("lines");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("carries the cone onto the components view's cards: the words, the short form, the lines", () => {
|
|
113
|
+
const a = answerOf("pr-cone");
|
|
114
|
+
const facets = { jobs: ["network", "service-a", "service-b"].map((c, i) => ({ component: c, wave: i === 0 ? 1 : 2, jobName: `apply-wave-${i === 0 ? 1 : 2}` })), roots: {} };
|
|
115
|
+
const { cards } = componentMarks(a, null, facets);
|
|
116
|
+
expect(cards["service-b"]).toMatchObject({ words: "planned · 2 of 6 blocks, as a cone", short: "planned", cone: "cone", lines: ["iam_role_policy.service_b · changed", "iam_role.service_b · read"] });
|
|
117
|
+
expect(cards.network).toMatchObject({ words: "not planned", short: "not planned", cone: "not-planned" });
|
|
118
|
+
expect(cards.network).not.toHaveProperty("lines");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("cuts a long cone to two lines and counts the rest", () => {
|
|
122
|
+
const r = { kind: "cone", planned: [{ address: "aws_a.x", changed: false }, { address: "module.m.aws_b.y", changed: true }, { address: "aws_c.z", changed: false }] };
|
|
123
|
+
expect(coneResourceLines(r)).toEqual(["module.m.b.y · changed", "a.x · read · and 1 more"]);
|
|
124
|
+
expect(coneResourceLines({ kind: "full" })).toEqual([]);
|
|
125
|
+
expect(shortAddress("aws_iam_role.service")).toBe("iam_role.service");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("writes the line in Watch's caption and Inspect's notes while the step shows the pull request's plan", () => {
|
|
129
|
+
const a = answerOf("pr-cone");
|
|
130
|
+
const want = { line: "service-b: 2 of 6 blocks, as a cone · network, service-a: not planned", backend: "3 estates · 1 backend · no state files" };
|
|
131
|
+
expect(coneCaption(demo("planned"), a)).toEqual(want);
|
|
132
|
+
expect(captionModel(demo("planned"), { answer: a }).cone).toEqual(want);
|
|
133
|
+
expect(coneLines(demo("planned"), a).map((l) => l.text)).toEqual([want.line, want.backend]);
|
|
134
|
+
// From the merge on, the waves plan in full: no cone line.
|
|
135
|
+
expect(coneCaption(demo("applying"), a)).toBeNull();
|
|
136
|
+
// Another cycle's pull request is never this one's.
|
|
137
|
+
expect(coneCaption(demo("planned", { pull: 8 }), a)).toBeNull();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("changes nothing for a plan with no cone field (another binary)", () => {
|
|
141
|
+
const a = answerOf("pr-plain");
|
|
142
|
+
expect(a.pull_request).not.toHaveProperty("cone");
|
|
143
|
+
expect(coneOf(a.pull_request)).toBeNull();
|
|
144
|
+
expect(coneLights(coneOf(a.pull_request))).toBeNull();
|
|
145
|
+
expect(resourceLight(null, "service-b", "aws_iam_role.service_b")).toBeNull();
|
|
146
|
+
expect(rootLight(null, "network")).toBeNull();
|
|
147
|
+
expect(coneLine(null)).toBeNull();
|
|
148
|
+
expect(backendLine(null)).toBeNull();
|
|
149
|
+
const { roots } = rootStates(a, null);
|
|
150
|
+
expect(roots["service-b"]).toEqual({ wave: 1, state: "planned", tone: "plan", words: "wave 1 · planned", facts: ["plan sha256:bbbbb"] });
|
|
151
|
+
expect(roots.network).toEqual({ wave: null, state: "outside", tone: "idle", words: "unchanged", facts: [] });
|
|
152
|
+
expect(coneCaption(demo("planned"), a)).toBeNull();
|
|
153
|
+
expect(captionModel(demo("planned"), { answer: a }).cone).toBeNull();
|
|
154
|
+
expect(coneLines(demo("planned"), a)).toEqual([]);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// behold#736: the cone on fan-out-choudoufu (terragucci#1167/#1168), fifteen estates. The fix's pull request plan is
|
|
159
|
+
// the stack's own (demo-choudoufu-fanout fe809a32): cluster-a planned as a cone of 1 of 5 blocks, app-01 to app-06
|
|
160
|
+
// planned in full on an empty cone, the other eight not in the plan. Chapter 1's release plans every estate in full.
|
|
161
|
+
describe("a cone on fan-out-choudoufu's fix (behold#736)", () => {
|
|
162
|
+
const FAN = ["network", "cluster-a", "cluster-b", ...Array.from({ length: 12 }, (_, i) => `app-${String(i + 1).padStart(2, "0")}`)];
|
|
163
|
+
const fanFacts = Object.fromEntries(FAN.map((r) => [r, { binary: "choudoufu" }]));
|
|
164
|
+
const doc = json("runs", "fanout-fix", "report.json");
|
|
165
|
+
const fix = (() => {
|
|
166
|
+
const pr = pullRequestPlan(doc, "runs/fanout-fix/report.html");
|
|
167
|
+
const cone = coneView(doc, { roots: FAN, planned: { "cluster-a": plannedInstances(json("runs", "fanout-fix", "cluster-a.plan.json")) }, facts: fanFacts });
|
|
168
|
+
return { roots: FAN.map((path) => ({ member: path, name: path, path })), pull_request: { ...pr, cone } };
|
|
169
|
+
})();
|
|
170
|
+
const facets = { jobs: FAN.map((c) => ({ component: c, wave: c === "network" ? 1 : c.startsWith("cluster") ? 2 : 3, jobName: `apply-wave-${c === "network" ? 1 : c.startsWith("cluster") ? 2 : 3}` })), roots: {} };
|
|
171
|
+
|
|
172
|
+
it("reads cluster-a as a cone with its resource, and each app as planned in full on an empty cone", () => {
|
|
173
|
+
const { roots } = rootStates(fix, null);
|
|
174
|
+
expect(roots["cluster-a"]).toMatchObject({ wave: 2, words: "wave 2 · planned · 1 of 5 blocks, as a cone", cone: "cone", lines: ["sqs_queue.events · changed"] });
|
|
175
|
+
for (const app of ["app-01", "app-06"]) {
|
|
176
|
+
expect(roots[app]).toMatchObject({ wave: 3, words: "wave 3 · planned in full: empty cone", cone: "full" });
|
|
177
|
+
expect(roots[app].facts).toContain("choudoufu planned it in full: the diff reaches no resource, data source or module call");
|
|
178
|
+
expect(roots[app]).not.toHaveProperty("lines");
|
|
179
|
+
}
|
|
180
|
+
expect(roots["app-07"]).toMatchObject({ cone: "not-planned" });
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it("puts it on the story's cards, where what landed earlier in the cycle still says so", () => {
|
|
184
|
+
const story = { kiosk: true, earlier: new Set(["network", "cluster-b", "app-07"]), lastStates: {} };
|
|
185
|
+
const { cards, waves } = componentMarks(fix, null, facets, { story });
|
|
186
|
+
// A wave's box names whose cone it is: a wave holds several estates.
|
|
187
|
+
expect(waves[2].facts[0]).toBe("cluster-a: 1 of 5 blocks, as a cone");
|
|
188
|
+
expect(waves[3].facts[0]).toBe("app-01 to app-06 planned in full: empty cone");
|
|
189
|
+
expect(waves[3].facts).not.toContain("planned in full: empty cone");
|
|
190
|
+
expect(cards["cluster-a"]).toMatchObject({ words: "planned · 1 of 5 blocks, as a cone", short: "planned", lines: ["sqs_queue.events · changed"] });
|
|
191
|
+
expect(cards["app-03"]).toMatchObject({ words: "planned in full: empty cone", short: "planned", cone: "full" });
|
|
192
|
+
// The story's carry-over wins over "not planned": these applied in the cycle's first apply.
|
|
193
|
+
expect(cards.network).toMatchObject({ state: "applied-earlier", words: "applied earlier" });
|
|
194
|
+
expect(cards.network).not.toHaveProperty("cone");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("says the plan in one line however many estates fall back alike", () => {
|
|
198
|
+
expect(coneLine(coneOf(fix.pull_request))).toBe("cluster-a: 1 of 5 blocks, as a cone · app-01 to app-06 planned in full: empty cone · 8 others not planned");
|
|
199
|
+
expect(backendLine(coneOf(fix.pull_request))).toBe("15 estates · 1 backend · no state files");
|
|
200
|
+
// Chapter 1's release: network falls back on a cone too large, the other fourteen plan with no cone; no false run of names.
|
|
201
|
+
const release = { roots: [{ root: "network", kind: "full", fallback: { kind: "cone-too-large", reason: "the cone is over 30% of the estate's blocks" } }, ...FAN.slice(1).map((root) => ({ root, kind: "planned" }))] };
|
|
202
|
+
expect(coneLine(release)).toBe("network planned in full: cone too large · 14 estates: planned");
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("draws chapter 1's release, planned in full with no cone, as before", () => {
|
|
206
|
+
const full = { ...doc, roots: doc.roots.map(({ cone, ...r }) => r) };
|
|
207
|
+
expect(coneView(full, { roots: FAN, facts: fanFacts })).toBeUndefined();
|
|
208
|
+
const pr = pullRequestPlan(full, "runs/fanout-fix/report.html");
|
|
209
|
+
const { roots } = rootStates({ roots: fix.roots, pull_request: pr }, null);
|
|
210
|
+
expect(roots["cluster-a"]).toMatchObject({ words: "wave 2 · planned" });
|
|
211
|
+
expect(roots["cluster-a"]).not.toHaveProperty("cone");
|
|
212
|
+
});
|
|
213
|
+
});
|