@intentius/behold 0.30.1 → 0.31.0

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 (129) hide show
  1. package/AGENTS.md +475 -16
  2. package/README.md +25 -19
  3. package/demos.json +14 -9
  4. package/dist/cli.js +54900 -26771
  5. package/example-carve/README.md +19 -23
  6. package/example-carve/app/package.json +1 -1
  7. package/example-carve/app/src/carved.ts +3 -3
  8. package/example-carve/carve-report.json +1 -1
  9. package/example-carve/{legacy-tf → tf-root}/terraform.tfstate +1 -1
  10. package/example-choudoufu-estate/README.md +7 -0
  11. package/example-choudoufu-estate/chant.workspace.json +1 -1
  12. package/example-choudoufu-estate/scripts/choudoufu-down.sh +2 -1
  13. package/example-choudoufu-estate/scripts/choudoufu-up.sh +10 -3
  14. package/example-terraform-estate/README.md +32 -5
  15. package/example-terraform-estate/chant.workspace.json +1 -1
  16. package/example-terraform-estate/recorded/adoption/platform.json +72 -0
  17. package/example-terraform-estate/recorded/adoption/prod.json +224 -0
  18. package/example-terralith/README.md +1 -1
  19. package/example-three-cloud/README.md +111 -18
  20. package/example-three-cloud/aws/Pulumi.yaml +15 -0
  21. package/example-three-cloud/aws/index.ts +174 -0
  22. package/example-three-cloud/aws/package-lock.json +2725 -0
  23. package/example-three-cloud/aws/package.json +14 -0
  24. package/example-three-cloud/aws/tsconfig.json +17 -0
  25. package/example-three-cloud/azure/main.tf +48 -0
  26. package/example-three-cloud/azure/site.tf +104 -0
  27. package/example-three-cloud/chant.config.json +9 -0
  28. package/example-three-cloud/chant.workspace.json +30 -4
  29. package/example-three-cloud/dns/chant.config.ts +26 -1
  30. package/example-three-cloud/dns/src/records.component.ts +32 -6
  31. package/example-three-cloud/package-lock.json +48 -27
  32. package/example-three-cloud/package.json +8 -6
  33. package/example-three-cloud/scripts/emulators-up.sh +28 -1
  34. package/example-three-cloud/scripts/front-door.ts +679 -86
  35. package/package.json +13 -6
  36. package/web/adopt-pulumi.js +114 -0
  37. package/web/adopt-pulumi.test.js +28 -0
  38. package/web/adopt.js +203 -0
  39. package/web/adopt.test.js +27 -0
  40. package/web/app.js +614 -19
  41. package/web/carve-steps.js +1 -1
  42. package/web/carve-steps.test.js +2 -2
  43. package/web/change-set-overlay.js +12 -5
  44. package/web/change-set-overlay.test.js +22 -0
  45. package/web/drift-stream.js +241 -0
  46. package/web/drift-stream.test.js +146 -0
  47. package/web/edge-weight.d.ts +1 -1
  48. package/web/edge-weight.js +5 -1
  49. package/web/edge-weight.test.js +19 -0
  50. package/web/embed.js +2 -2
  51. package/web/event-help-modal.js +18 -12
  52. package/web/event-help-modal.test.js +28 -1
  53. package/web/graph-query.js +180 -0
  54. package/web/graph-query.test.js +49 -0
  55. package/web/graph.html +107 -0
  56. package/web/index-diff.js +109 -0
  57. package/web/index-diff.test.js +39 -0
  58. package/web/index.html +55 -0
  59. package/web/kiosk-ask-layout.js +85 -0
  60. package/web/kiosk-ask-layout.test.js +83 -0
  61. package/web/kiosk-ask-tips.js +477 -0
  62. package/web/kiosk-ask-tips.test.js +372 -0
  63. package/web/kiosk-ask.js +774 -0
  64. package/web/kiosk-ask.test.js +593 -0
  65. package/web/kiosk-banner.js +108 -0
  66. package/web/kiosk-banner.test.js +72 -0
  67. package/web/kiosk-center-cards.test.js +110 -0
  68. package/web/kiosk-estate-scene.js +267 -0
  69. package/web/kiosk-estate-scene.test.js +21 -0
  70. package/web/kiosk-event-help.js +4 -1
  71. package/web/kiosk-graph-pane.js +63 -0
  72. package/web/kiosk-graph-pane.test.js +105 -0
  73. package/web/kiosk-light-frame.js +197 -0
  74. package/web/kiosk-light.js +547 -0
  75. package/web/kiosk-light.test.js +297 -0
  76. package/web/kiosk-member-kind.test.js +140 -0
  77. package/web/kiosk-metrics.js +7 -4
  78. package/web/kiosk-modal-sticky.test.js +2 -1
  79. package/web/kiosk-popover.js +4 -1
  80. package/web/kiosk-refit.test.js +81 -0
  81. package/web/kiosk-reset.js +49 -0
  82. package/web/kiosk-reset.test.js +11 -0
  83. package/web/kiosk-shot.js +40 -2
  84. package/web/kiosk-shot.test.js +23 -1
  85. package/web/kiosk-side.js +296 -0
  86. package/web/kiosk-side.test.js +249 -0
  87. package/web/kiosk-vendor.js +85 -7
  88. package/web/kiosk-vendor.test.js +9 -9
  89. package/web/kiosk-watch.js +20 -4
  90. package/web/kiosk-watch.test.js +15 -1
  91. package/web/kiosk.html +153 -1
  92. package/web/kiosk.js +252 -27
  93. package/web/kiosk.test.js +25 -1
  94. package/web/member-kind.js +31 -0
  95. package/web/small-stage.test.js +4 -0
  96. package/web/template-apps.js +245 -0
  97. package/web/template-apps.test.js +252 -0
  98. package/web/templates.js +285 -0
  99. package/web/templates.test.js +155 -0
  100. package/web/terragucci-change.js +30 -13
  101. package/web/terragucci-lifecycle.js +112 -62
  102. package/web/terragucci-lifecycle.test.js +29 -1
  103. package/web/terragucci-timeline.js +39 -2
  104. package/web/terragucci-timeline.test.js +42 -1
  105. package/web/tool-mark.js +4 -4
  106. package/web/tool-mark.test.js +1 -1
  107. package/web/vendors/atmos.svg +1 -0
  108. package/web/vendors/chant.svg +1 -0
  109. package/web/vendors/choudoufu.svg +1 -0
  110. package/web/vendors/terragrunt.svg +9 -0
  111. package/web/vendors/terragucci.svg +1 -0
  112. package/example-three-cloud/aws/chant.config.ts +0 -8
  113. package/example-three-cloud/aws/site.component.ts +0 -13
  114. package/example-three-cloud/aws/src/site.ts +0 -27
  115. package/example-three-cloud/azure/chant.config.ts +0 -1
  116. package/example-three-cloud/azure/src/site.component.ts +0 -13
  117. package/example-three-cloud/azure/src/site.ts +0 -18
  118. package/web/vendors/choudoufu-128.png +0 -0
  119. package/web/vendors/choudoufu-64.png +0 -0
  120. /package/example-carve/{legacy-tf → tf-root}/cdn.tf +0 -0
  121. /package/example-carve/{legacy-tf → tf-root}/compute.tf +0 -0
  122. /package/example-carve/{legacy-tf → tf-root}/floci-override.tf.disabled +0 -0
  123. /package/example-carve/{legacy-tf → tf-root}/modules/cdn/main.tf +0 -0
  124. /package/example-carve/{legacy-tf → tf-root}/naming.tf +0 -0
  125. /package/example-carve/{legacy-tf → tf-root}/network.tf +0 -0
  126. /package/example-carve/{legacy-tf → tf-root}/observability.tf +0 -0
  127. /package/example-carve/{legacy-tf → tf-root}/outputs.tf +0 -0
  128. /package/example-carve/{legacy-tf → tf-root}/storage.tf +0 -0
  129. /package/example-carve/{legacy-tf → tf-root}/versions.tf +0 -0
@@ -0,0 +1,108 @@
1
+ // The demo banner: the example's name and act, the live demo's products, and a link to its code. Everything shown is live.
2
+ // Pure: the model from a tool id and the list; web/kiosk.html draws it.
3
+ //
4
+ // Logo policy (web/kiosk-vendor.js): a logo appears only where its owner's published rules allow one. choudoufu's,
5
+ // chant's (the chant repo's docs/public/brand/logo.svg, its face) and terragucci's are ours. Terragrunt's and Atmos's icons, from gruntwork-io/terragrunt (docs/src/assets/icons/terragrunt-icon.svg)
6
+ // and cloudposse/atmos (docs/img/atmos-logo-128.svg), appear on the demos that use those tools (maintainer, 2026-10-24). OpenTofu, Terragrunt and Atmos are shown by name, as text, and link to their official sites.
7
+
8
+ import { vendorOf } from "./kiosk-vendor.js";
9
+
10
+ /** The products a banner may show: the name, the site, and the logo (null where no rule allows one). */
11
+ export const PRODUCTS = {
12
+ choudoufu: { name: "choudoufu", url: "https://intentius.io/choudoufu/", logo: { src: "/vendors/choudoufu.svg" } },
13
+ chant: { name: "chant", url: "https://intentius.io/chant/", logo: { src: "/vendors/chant.svg" } },
14
+ terragucci: { name: "terragucci", url: "https://intentius.io/terragucci/", logo: { src: "/vendors/terragucci.svg" } },
15
+ opentofu: { name: "OpenTofu", url: "https://opentofu.org/", logo: null },
16
+ terragrunt: { name: "Terragrunt", url: "https://terragrunt.com/", logo: { src: "/vendors/terragrunt.svg" } },
17
+ atmos: { name: "Atmos", url: "https://atmos.tools/", logo: { src: "/vendors/atmos.svg" } },
18
+ };
19
+
20
+ /** "I", "II", "III"...: an act's number as the banner writes it. */
21
+ export function actNumeral(n) {
22
+ const r = [["X", 10], ["IX", 9], ["V", 5], ["IV", 4], ["I", 1]];
23
+ let out = "";
24
+ for (let [s, v] of r) while (n >= v) { out += s; n -= v; }
25
+ return out;
26
+ }
27
+
28
+ /**
29
+ * The act the loop is on, "Act I": the scenario's place among its own tool's scenarios (demo.json's `act` and `acts`).
30
+ * Without `act` (an older driver) it falls back to `index` and `scenarios`, which count every tool's scenarios. Null for
31
+ * one act, another tool's run or none.
32
+ */
33
+ export function actOf(tool, demo) {
34
+ const d = demo && demo.demo ? demo.demo : demo;
35
+ if (!d || d.tool !== tool) return null;
36
+ if (d.act !== undefined && d.act !== null) {
37
+ if (!Number.isInteger(d.act) || !Number.isInteger(d.acts) || d.acts < 2 || d.act < 1) return null;
38
+ return `Act ${actNumeral(d.act)}`;
39
+ }
40
+ if (!Number.isInteger(d.index) || !Number.isInteger(d.scenarios) || d.scenarios < 2 || d.index < 1) return null;
41
+ return `Act ${actNumeral(d.index)}`;
42
+ }
43
+
44
+ /** The title every demo shares; the logos beside it say which demo is on. */
45
+ export const BANNER_TITLE = "One plan, one apply, across estates";
46
+
47
+ /** The demo whose tool demo.json names now, when it is a listed demo; else null. */
48
+ export function liveTool(demo) {
49
+ const d = demo && demo.demo ? demo.demo : demo;
50
+ // The base (a reset between scenarios) names the tool that just ran, not the one that is next: it is no demo going live.
51
+ const t = d && typeof d.tool === "string" && d.scenario !== "base" ? d.tool : null;
52
+ const v = t ? vendorOf(t) : null;
53
+ return v && v.code && v.title ? t : null;
54
+ }
55
+
56
+ /** The banner for the live demo `tool`, or null for a tool that is no listed demo. */
57
+ export function bannerModel(tool, act = null) {
58
+ const v = vendorOf(tool);
59
+ if (!v || !v.code || !v.title) return null;
60
+ return {
61
+ tool,
62
+ name: v.heading || BANNER_TITLE,
63
+ act,
64
+ products: (v.products || []).map((id) => PRODUCTS[id]).filter(Boolean),
65
+ code: { label: "See the code", short: "Code", url: v.code },
66
+ };
67
+ }
68
+
69
+ /** Draws the model into `host` (a header element); hides it with no model. Returns whether it shows. */
70
+ export function drawBanner(host, model, doc = document) {
71
+ host.textContent = "";
72
+ host.hidden = !model;
73
+ doc.body.classList.toggle("k-bannered", !!model);
74
+ if (!model) return false;
75
+ const el = (tag, cls, text) => {
76
+ const n = doc.createElement(tag);
77
+ if (cls) n.className = cls;
78
+ if (text !== undefined) n.textContent = text;
79
+ return n;
80
+ };
81
+ const link = (cls, href, ...kids) => {
82
+ const a = el("a", cls);
83
+ a.href = href;
84
+ a.target = "_blank";
85
+ a.rel = "noopener noreferrer";
86
+ a.append(...kids);
87
+ return a;
88
+ };
89
+ const prods = el("span", "kb-products");
90
+ for (const p of model.products) {
91
+ const kids = [];
92
+ if (p.logo) {
93
+ const img = el("img", "kb-logo");
94
+ img.src = p.logo.src;
95
+ if (p.logo.src2x) img.srcset = `${p.logo.src2x} 2x`;
96
+ img.alt = "";
97
+ kids.push(img);
98
+ }
99
+ kids.push(el("span", "kb-pname", p.name));
100
+ prods.appendChild(link("kb-product", p.url, ...kids));
101
+ }
102
+ const code = link("kb-code", model.code.url, el("span", "kb-code-long", model.code.label), el("span", "kb-code-short", model.code.short));
103
+ const name = el("span", "kb-name", model.name);
104
+ if (model.act) name.append(el("span", "kb-act", ` - ${model.act}`));
105
+ host.append(name, prods);
106
+ host.appendChild(code);
107
+ return true;
108
+ }
@@ -0,0 +1,72 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { actNumeral, actOf, PRODUCTS, bannerModel, liveTool } from "./kiosk-banner.js";
3
+ import { VENDORS } from "./kiosk-vendor.js";
4
+
5
+ const ALL = ["choudoufu-compose", "terragrunt-choudoufu", "atmos-choudoufu", "chant-compose"];
6
+
7
+ describe("the demo banner model", () => {
8
+ it("names the example the same for every demo but chant's, which runs across stacks, and Atmos's, which applies each component in turn", () => {
9
+ for (const t of ALL.filter((x) => x !== "chant-compose" && x !== "atmos-choudoufu")) expect(bannerModel(t).name).toBe("One plan, one apply, across estates");
10
+ expect(bannerModel("atmos-choudoufu").name).toBe("One plan across estates");
11
+ expect(bannerModel("chant-compose").name).toBe("One plan, one apply, across stacks");
12
+ });
13
+ it("links the public example tree", () => {
14
+ expect(bannerModel("choudoufu-compose").code.url).toBe("https://github.com/INTENTIUS/terragucci/tree/main/example-demo-choudoufu-compose");
15
+ expect(bannerModel("atmos-choudoufu").code.url).toBe("https://github.com/INTENTIUS/choudoufu/tree/main/examples/demo-atmos");
16
+ expect(bannerModel("terragrunt-choudoufu").code.url).toBe("https://github.com/INTENTIUS/choudoufu/tree/main/examples/demo-terragrunt");
17
+ expect(bannerModel("chant-compose").code.url).toBe("https://github.com/INTENTIUS/chant/tree/main/examples/demo-composed-stacks");
18
+ });
19
+ it("names the demo's own products: every product with its logo, never OpenTofu", () => {
20
+ expect(PRODUCTS.choudoufu.logo.src).toBe("/vendors/choudoufu.svg");
21
+ expect(PRODUCTS.terragucci.logo.src).toBe("/vendors/terragucci.svg");
22
+ expect(PRODUCTS.opentofu.logo).toBeNull();
23
+ expect(PRODUCTS.terragrunt.logo.src).toBe("/vendors/terragrunt.svg");
24
+ expect(PRODUCTS.atmos.logo.src).toBe("/vendors/atmos.svg");
25
+ expect(bannerModel("choudoufu-compose").products.map((p) => p.name)).toEqual(["terragucci", "choudoufu"]);
26
+ expect(bannerModel("terragrunt-choudoufu").products.map((p) => p.name)).toEqual(["Terragrunt", "choudoufu"]);
27
+ expect(bannerModel("atmos-choudoufu").products.map((p) => p.name)).toEqual(["Atmos", "choudoufu"]);
28
+ expect(bannerModel("chant-compose").products).toEqual([{ name: "chant", url: "https://intentius.io/chant/", logo: { src: "/vendors/chant.svg" } }]);
29
+ });
30
+ it("has no switcher and no replay: only the live demo's name, act, products and code", () => {
31
+ for (const t of ALL) expect(bannerModel(t)).not.toHaveProperty("switcher");
32
+ });
33
+ it("follows demo.json's tool: the live demo, else null", () => {
34
+ expect(liveTool({ demo: { tool: "atmos-choudoufu" } })).toBe("atmos-choudoufu");
35
+ expect(liveTool({ tool: "terragrunt-choudoufu" })).toBe("terragrunt-choudoufu");
36
+ expect(liveTool({ demo: { tool: "terraform" } })).toBeNull();
37
+ expect(liveTool(null)).toBeNull();
38
+ expect(liveTool({ demo: { tool: "atmos-choudoufu", scenario: "base" } })).toBeNull();
39
+ });
40
+ it("is none for a page that is no listed demo", () => {
41
+ expect(bannerModel("terraform")).toBeNull();
42
+ expect(bannerModel(null)).toBeNull();
43
+ });
44
+ it("never names another commercial product, nor says atomic or transaction", () => {
45
+ for (const t of ALL) {
46
+ const m = bannerModel(t);
47
+ const text = JSON.stringify(m) + VENDORS[t].credit;
48
+ expect(text).not.toMatch(/atomic|transaction|terraform|pulumi|spacelift|env0|scalr|terramate|cdk/i);
49
+ if (t !== "terragrunt-choudoufu") expect(text).not.toMatch(/gruntwork|terragrunt[^-]/i);
50
+ if (t !== "atmos-choudoufu") expect(text).not.toMatch(/atmos|cloud posse/i);
51
+ if (t !== "choudoufu-compose") expect(text).not.toMatch(/terragucci/i);
52
+ if (t === "chant-compose") expect(text).not.toMatch(/choudoufu|terragrunt|opentofu|terragucci/i);
53
+ }
54
+ });
55
+ });
56
+
57
+ describe("the act after the title", () => {
58
+ it("names the act from demo.json's index for this page's tool, in roman numerals", () => {
59
+ expect(actOf("choudoufu-compose", { demo: { tool: "choudoufu-compose", index: 1, scenarios: 2 } })).toBe("Act I");
60
+ expect(actOf("choudoufu-compose", { tool: "choudoufu-compose", index: 2, scenarios: 2 })).toBe("Act II");
61
+ expect(actOf("choudoufu-compose", { demo: { tool: "other", index: 1, scenarios: 2 } })).toBeNull();
62
+ expect(actOf("choudoufu-compose", { demo: { tool: "choudoufu-compose", index: 1, scenarios: 1 } })).toBeNull();
63
+ expect(actOf("choudoufu-compose", null)).toBeNull();
64
+ expect(actOf("choudoufu-compose", { demo: { tool: "choudoufu-compose", index: 4, scenarios: 6, act: 2, acts: 2 } })).toBe("Act II");
65
+ expect(actOf("choudoufu-compose", { demo: { tool: "choudoufu-compose", index: 4, scenarios: 6, act: 1, acts: 1 } })).toBeNull();
66
+ expect(actNumeral(3)).toBe("III");
67
+ expect(actNumeral(4)).toBe("IV");
68
+ });
69
+ it("carries the act in the model", () => {
70
+ expect(bannerModel("choudoufu-compose", "Act II").act).toBe("Act II");
71
+ });
72
+ });
@@ -0,0 +1,110 @@
1
+ // The ask-mode scene is centred in the graph area, a card's lines follow the rules, and a composed run never counts waves.
2
+ import { describe, expect, it } from "vitest";
3
+ import { cardLines, composedRun, lineState, planOf } from "./kiosk-light.js";
4
+ import { askLayout } from "./kiosk-ask-layout.js";
5
+ import { shotViewBox } from "./kiosk-shot.js";
6
+ import { resultModel } from "./kiosk-watch.js";
7
+ import { ehSnapshot, cycleFacts } from "./kiosk-event-help.js";
8
+ import { metricsModel, steadyModel } from "./kiosk-metrics.js";
9
+
10
+ const scene = (extra = {}) => ({
11
+ roots: [{ path: "network", member: "demo", name: "network" }, { path: "app", member: "demo", name: "app" }],
12
+ cards: {},
13
+ estateScene: {
14
+ roots: [
15
+ { path: "network", member: "demo", name: "network", resources: [{ address: "aws_subnet.subnet_b", action: "create", values: [{ path: "id", unknown: true }, { path: "assign_ipv6_address_on_creation", before: null, after: false }, { path: "cidr_block", before: null, after: "10.0.2.0/24" }] }] },
16
+ { path: "app", member: "demo", name: "app", resources: [{ address: "aws_network_interface.worker", action: "create", values: [{ path: "id", unknown: true }, { path: "subnet_id", unknown: true }] }, { address: "aws_security_group.web", action: "replace", values: [{ path: "description", before: "old", after: "new" }, { path: "name", before: "a", after: "b" }, { path: "vpc_id", before: "v1", after: "v2" }] }] },
17
+ ],
18
+ },
19
+ pull_request: { reads: [{ root: "app", upstream: "network", unknown: ["subnet_id"] }], upstreams: {} },
20
+ ...extra,
21
+ });
22
+ const at = (lines, address) => lines.filter((l) => l.address === address).map((l) => `${l.kind}:${l.path}`);
23
+
24
+ describe("a card's lines (rules in order, at most two)", () => {
25
+ it("leads with id for a created resource, never shows a false default", () => {
26
+ const lines = cardLines(planOf(scene()));
27
+ expect(at(lines, "aws_subnet.subnet_b")).toEqual(["unknown:id"]);
28
+ expect(lines.some((l) => l.path === "assign_ipv6_address_on_creation")).toBe(false);
29
+ });
30
+ it("puts id, then the cross-estate read, then changes; two lines at most", () => {
31
+ const lines = cardLines(planOf(scene()));
32
+ expect(at(lines, "aws_network_interface.worker")).toEqual(["unknown:id", "unknown:subnet_id"]);
33
+ expect(at(lines, "aws_security_group.web")).toHaveLength(2);
34
+ expect(at(lines, "aws_security_group.web").every((l) => l.startsWith("changed:"))).toBe(true);
35
+ });
36
+ it("shows the real value once applied, and 'filled from' only when the report states none", () => {
37
+ const a = scene();
38
+ const plan = planOf(a);
39
+ const sub = cardLines(plan).find((l) => l.address === "aws_network_interface.worker" && l.path === "subnet_id");
40
+ const applied = { states: [{ number: 1, state: "applied", roots: ["network", "app"], composed: { members: [{ root: "network", apply: "applied", state: "written" }, { root: "app", apply: "applied", state: "written" }] } }] };
41
+ expect(lineState(sub, a, null)).toEqual({ state: "unknown", text: "subnet_id: known after apply" });
42
+ expect(lineState(sub, a, applied)).toEqual({ state: "applied", text: "subnet_id: filled from subnet_b" });
43
+ const wrote = { ...a, applied: { "demo/app/aws_network_interface.worker": { values: [{ path: "subnet_id", after: "subnet-123" }] }, "demo/network/aws_subnet.subnet_b": { values: [{ path: "id", after: "subnet-123" }] } } };
44
+ expect(lineState(sub, wrote, applied)).toEqual({ state: "applied", text: "subnet_id: subnet-123" });
45
+ const id = cardLines(plan).find((l) => l.address === "aws_subnet.subnet_b");
46
+ expect(lineState(id, wrote, applied)).toEqual({ state: "applied", text: "id: subnet-123" });
47
+ });
48
+ });
49
+
50
+ describe("the fit centres the scene in the graph area", () => {
51
+ const room = (w, h) => ({ width: w, height: h });
52
+ const stack = () => askLayout([{ id: "n", cards: [{ id: "n1", w: 340, h: 90 }] }, { id: "a", cards: ["a", "b", "c", "d"].map((k) => ({ id: k, w: 340, h: 90 })) }, { id: "e", cards: [{ id: "e1", w: 340, h: 90 }, { id: "e2", w: 340, h: 90 }] }], room(1366, 520));
53
+ it("centres each box on the widest, so unequal boxes do not hug the left", () => {
54
+ const l = stack();
55
+ const widest = Math.max(...Object.values(l.boxes).map((b) => b.w));
56
+ for (const b of Object.values(l.boxes)) expect(b.x + b.w / 2).toBeCloseTo(l.width / 2, 0);
57
+ expect(widest).toBe(l.width);
58
+ for (const [id, c] of Object.entries(l.cards)) expect(c.x).toBeGreaterThanOrEqual(0 + 18 - 0.01 + (id ? 0 : 0));
59
+ });
60
+ it.each([[1366, 768, 520], [1920, 1080, 700], [390, 844, 440]])("puts the stack's centre on the open area's centre at %ix%i", (w, h, open) => {
61
+ const l = stack();
62
+ const target = { x: 0, y: 0, x2: l.width, y2: l.height };
63
+ const pane = { width: w, height: open };
64
+ const vb = shotViewBox(target, pane, { top: 40, right: 0, bottom: 0, left: 0 });
65
+ const s = pane.width / vb[2];
66
+ const cx = (vb[0] + vb[2] / 2 - (target.x + target.x2) / 2) * s;
67
+ expect(Math.abs(cx)).toBeLessThan(1);
68
+ // vertical: the target's centre sits at the middle of what is below the 40px inset.
69
+ const cy = ((target.y + target.y2) / 2 - vb[1]) * s;
70
+ expect(cy).toBeCloseTo(40 + (open - 40) / 2, 0);
71
+ });
72
+ });
73
+
74
+ describe("the event help's applied line", () => {
75
+ it("says one apply for a composed run, all N waves otherwise", () => {
76
+ const run = (composed) => ({ run: { present: true, commit: "c1" }, states: [1, 2, 3].map((n) => ({ number: n, state: "applied", roots: [], ...(composed && n === 1 ? { composed: { members: [] } } : {}) })), reads: [] });
77
+ const d = { cycle: 1, step: "applied", commit: "c1", label: "x", pull: null };
78
+ const text = (p) => cycleFacts(ehSnapshot({ demo: d, progress: p })).find((f) => f.kind === "applied").text;
79
+ expect(text(run(true))).toBe("applied together in one apply");
80
+ expect(text(run(false))).toBe("all 3 waves applied");
81
+ });
82
+ });
83
+
84
+ describe("a composed run never counts or names waves", () => {
85
+ const composedProgress = { run: { present: true, commit: "c1" }, states: [1, 2, 3].map((n) => ({ number: n, state: "applied", roots: [], totals: {}, ...(n === 1 ? { composed: { members: [] } } : {}) })) };
86
+ const demo = { step: "applied", cycle: 1, commit: "c1", label: "Applied." };
87
+ it("reads as one apply", () => {
88
+ const m = resultModel(demo, null, composedProgress);
89
+ expect(m.counts[0]).toBe("applied together in one apply");
90
+ expect(m.waves).toEqual([]);
91
+ expect(m.counts.join(" ")).not.toMatch(/wave/i);
92
+ });
93
+ it("keeps waves for a run that is not composed", () => {
94
+ const plain = { ...composedProgress, states: composedProgress.states.map(({ composed, ...w }) => w) };
95
+ expect(resultModel(demo, null, plain).counts[0]).toBe("3 waves applied");
96
+ });
97
+ it("detects compose.estate, compose.roots and a scene", () => {
98
+ expect(composedRun({ compose: { estate: true } })).toBe(true);
99
+ expect(composedRun({ pull_request: { compose: { roots: ["a", "b"] } } })).toBe(true);
100
+ expect(composedRun({ roots: [] }, null)).toBe(false);
101
+ });
102
+ it("the metrics count does not count waves", () => {
103
+ const answer = { compose: { estate: true }, run: { current: true, waves: [{ wave: 1, seconds: 3, roots: [] }, { wave: 2, seconds: 1, roots: [] }] } };
104
+ const m = metricsModel(answer);
105
+ expect(m.count).not.toMatch(/wave/i);
106
+ expect(steadyModel(m, { ...m, count: "x" }, { same: true }).count).not.toMatch(/wave/i);
107
+ const plain = metricsModel({ run: answer.run });
108
+ expect(plain.count).toBe("2 waves");
109
+ });
110
+ });
@@ -0,0 +1,267 @@
1
+ // behold#940: ask mode's two ways of putting the roots where the room is.
2
+ //
3
+ // askDeltas the graph the page drew, its roots moved into a stack (as layout deltas web/app.js paints);
4
+ // sceneModel a composed choudoufu run: the graph has none of the run's resources (an estate keeps no state
5
+ // file, and the checkout is as of the base), so the scene is drawn from the run's reports;
6
+ // drawScene puts a scene model in the svg, in place of the graph's own boxes, cards and edges.
7
+ //
8
+ // The scene keeps the graph's own hooks (`data-group-id` on a box, `data-node-id` on a card, `data-edge-from`
9
+ // on an edge), so lighting, the reads between roots and the state labels work on it as they do on the graph.
10
+ // The positions come from web/kiosk-ask-layout.js; the first two are pure.
11
+
12
+ import { askLayout, orderRoots } from "./kiosk-ask-layout.js";
13
+ import { applyOf, cardLines, cardTitle } from "./kiosk-light.js";
14
+ import { HOLE_WORDS, KIND_TAGS, memberKinds } from "./member-kind.js";
15
+
16
+ /** What hangs under a card for each unknown value it carries (web/kiosk-light-frame.js drawSlots). */
17
+ export const SLOT_ROW = 26;
18
+ export const CARD_W = 340;
19
+ export const CARD_H = 60;
20
+
21
+ /** How many attribute lines (at most two) each card id carries. */
22
+ export function slotCounts(plan) {
23
+ const out = {};
24
+ for (const s of cardLines(plan)) if (s.cardId) out[s.cardId] = (out[s.cardId] || 0) + 1;
25
+ return out;
26
+ }
27
+
28
+ const upstreamFirst = (roots, edges) => {
29
+ const byPath = new Map(roots.map((r) => [r.path, r]));
30
+ return orderRoots(roots.map((r) => r.path), edges).map((p) => byPath.get(p));
31
+ };
32
+
33
+ /**
34
+ * The deltas that stack the drawn graph's roots. `nodes` maps a card id to `{ rect: { x, y, w, h } }` and `boxes` a
35
+ * box id (`box:<root name>`) to `{ x, y, w0, h0 }`, both as the page drew them. Returns `{ deltas, layout }`, with
36
+ * `deltas[id] = { dx, dy }` (and `dw`, `dh` for a box), or null when no root has a box and cards to move.
37
+ */
38
+ export function askDeltas({ roots, nodes, boxes, extras = {}, edges = [], open }) {
39
+ const ordered = upstreamFirst(roots, edges);
40
+ const input = [];
41
+ for (const r of ordered) {
42
+ const box = boxes.get(`box:${r.name}`);
43
+ const prefix = `${r.member}/${r.name}/`;
44
+ const cards = [...nodes].filter(([id, n]) => id.startsWith(prefix) && n.rect).map(([id, n]) => ({ id, w: n.rect.w, h: n.rect.h + (extras[id] || 0) }));
45
+ if (box && cards.length) input.push({ id: `box:${r.name}`, cards, box });
46
+ }
47
+ if (!input.length) return null;
48
+ const layout = askLayout(input, open);
49
+ const x0 = Math.min(...input.map((r) => r.box.x));
50
+ const y0 = Math.min(...input.map((r) => r.box.y));
51
+ const deltas = {};
52
+ for (const r of input) {
53
+ const b = layout.boxes[r.id];
54
+ deltas[r.id] = { dx: x0 + b.x - r.box.x, dy: y0 + b.y - r.box.y, dw: b.w - r.box.w0, dh: b.h - r.box.h0 };
55
+ for (const c of r.cards) {
56
+ const at = layout.cards[c.id];
57
+ const n = nodes.get(c.id);
58
+ deltas[c.id] = { dx: x0 + at.x - n.rect.x, dy: y0 + at.y - n.rect.y };
59
+ }
60
+ }
61
+ return { deltas, layout };
62
+ }
63
+
64
+ /**
65
+ * A composed choudoufu run's scene: each estate's box and cards from `answer.estateScene`, laid out for `open`, and
66
+ * an edge for each reach the blast radius names. Null when the answer holds no scene.
67
+ *
68
+ * behold#1008: a composed chant run says what each member is (`answer.chant.members`, web/member-kind.js). Each root
69
+ * then carries `kind` (hole, previewed or plain), and a hole with nothing previewed keeps its box with one empty slot
70
+ * (`hole`: where its cards would be, and why there are none).
71
+ */
72
+ export function sceneModel(answer, plan, progress, open) {
73
+ const kinds = memberKinds(answer);
74
+ // Kinds come from answer.chant alone: without it (a composed choudoufu run) a root's `hole` flag is ignored and
75
+ // nothing is marked, so the run draws as it did before behold#1008.
76
+ const isHole = (r) => kinds.size > 0 && (r.hole === true || (kinds.get(r.path) || {}).kind === "hole");
77
+ const scene = answer && answer.estateScene && Array.isArray(answer.estateScene.roots) ? answer.estateScene.roots.filter((r) => (r.resources && r.resources.length) || (r.path && r.name && isHole(r))) : [];
78
+ if (!scene.length) return null;
79
+ const extras = slotCounts(plan);
80
+ const ordered = upstreamFirst(scene, plan.edges);
81
+ const holeSlot = (r) => `${r.member}/${r.name}/~hole`;
82
+ const resourcesOf = (r) => r.resources || [];
83
+ const input = ordered.map((r) => ({
84
+ id: r.path,
85
+ cards: resourcesOf(r).length
86
+ ? r.resources.map((res) => {
87
+ const id = `${r.member}/${r.name}/${res.address}`;
88
+ return { id, w: CARD_W, h: CARD_H + (extras[id] ? extras[id] * SLOT_ROW + 10 : 0) };
89
+ })
90
+ : [{ id: holeSlot(r), w: CARD_W, h: CARD_H }],
91
+ }));
92
+ const layout = askLayout(input, open);
93
+ const roots = ordered.map((r) => {
94
+ const box = layout.boxes[r.path];
95
+ const outcome = applyOf(r.path, progress);
96
+ const done = outcome ? outcome.apply === "applied" || outcome.apply === "no-changes" : null;
97
+ const known = kinds.get(r.path);
98
+ const kind = isHole(r) ? "hole" : known ? known.kind : null;
99
+ return {
100
+ path: r.path,
101
+ name: r.name,
102
+ member: r.member,
103
+ ...box,
104
+ ...(kind ? { kind } : {}),
105
+ ...(!resourcesOf(r).length ? { hole: { ...layout.cards[holeSlot(r)], words: HOLE_WORDS, reasons: known ? known.reasons : [] } } : {}),
106
+ cards: resourcesOf(r).map((res) => {
107
+ const id = `${r.member}/${r.name}/${res.address}`;
108
+ const at = layout.cards[id];
109
+ const { name, type } = cardTitle(res.address);
110
+ // The run view says each estate's part of the apply as it happens; the reports say it once they list it as applied.
111
+ const applied = done === null ? res.state === "applied" : done;
112
+ return { id, address: res.address, name, type, action: res.action, applied, ...at, h: CARD_H };
113
+ }),
114
+ };
115
+ });
116
+ const at = new Map(roots.flatMap((r) => r.cards).map((c) => [c.id, c]));
117
+ const keyOf = new Map();
118
+ for (const r of roots) for (const c of r.cards) keyOf.set(`${r.path}/${c.address}`, c.id);
119
+ const edges = [];
120
+ // Only between roots that sit next to each other: a line past a box to one beyond it crosses what is between.
121
+ const place = new Map(roots.map((r, i) => [r.path, i]));
122
+ for (const [seed, reaches] of plan.reaches) {
123
+ const from = keyOf.get(seed);
124
+ for (const x of reaches || []) {
125
+ const to = keyOf.get(`${x.root}/${x.address}`);
126
+ if (from && to && from !== to && Math.abs(place.get(seed.slice(0, seed.indexOf("/"))) - place.get(x.root)) <= 1 && !edges.some((e) => e.from === from && e.to === to)) edges.push({ from, to, d: edgePath(at.get(from), at.get(to)) });
127
+ }
128
+ }
129
+ return { roots, edges, width: layout.width, height: layout.height, cols: layout.cols };
130
+ }
131
+
132
+ /** The words in a box whose plan is not written yet. */
133
+ export const WAITING_WORDS = "waiting for the plan";
134
+
135
+ /**
136
+ * The scene while the plan is not there to draw (a pull request being planned, the reset between acts): each
137
+ * estate the reports name, upstream on top, with one empty slot where its cards will be. Without it the pane holds
138
+ * dark until the plan job writes the plan, or keeps the last act's cards under the next act's title. Null when the
139
+ * reports name no estate.
140
+ */
141
+ export function waitingModel(answer, plan, open) {
142
+ const scene = answer && answer.estateScene && Array.isArray(answer.estateScene.roots) ? answer.estateScene.roots.filter((r) => r && r.path && r.name) : [];
143
+ if (!scene.length) return null;
144
+ const ordered = upstreamFirst(scene, (plan && plan.edges) || []);
145
+ const slotOf = (r) => `${r.member}/${r.name}/~waiting`;
146
+ const layout = askLayout(ordered.map((r) => ({ id: r.path, cards: [{ id: slotOf(r), w: CARD_W, h: CARD_H }] })), open);
147
+ const roots = ordered.map((r) => ({ path: r.path, name: r.name, member: r.member, ...layout.boxes[r.path], cards: [], waiting: { ...layout.cards[slotOf(r)], words: WAITING_WORDS } }));
148
+ return { roots, edges: [], width: layout.width, height: layout.height, cols: layout.cols, waiting: true };
149
+ }
150
+
151
+ /** A curve from one card's edge to the other's, on the sides that face. */
152
+ export function edgePath(a, b) {
153
+ if (b.y >= a.y + a.h) {
154
+ const x1 = a.x + a.w / 2;
155
+ const y1 = a.y + a.h;
156
+ const x2 = b.x + b.w / 2;
157
+ const y2 = b.y;
158
+ const k = (y2 - y1) / 2;
159
+ return `M ${x1} ${y1} C ${x1} ${y1 + k}, ${x2} ${y2 - k}, ${x2} ${y2}`;
160
+ }
161
+ if (a.y >= b.y + b.h) return edgePath(b, a);
162
+ const right = b.x >= a.x;
163
+ const x1 = right ? a.x + a.w : a.x;
164
+ const x2 = right ? b.x : b.x + b.w;
165
+ const y1 = a.y + a.h / 2;
166
+ const y2 = b.y + b.h / 2;
167
+ const k = Math.abs(x2 - x1) / 2;
168
+ return `M ${x1} ${y1} C ${x1 + (right ? k : -k)} ${y1}, ${x2 + (right ? -k : k)} ${y2}, ${x2} ${y2}`;
169
+ }
170
+
171
+ // ---------------------------------------------------------------------------
172
+ // The svg.
173
+ // ---------------------------------------------------------------------------
174
+
175
+ const NS = "http://www.w3.org/2000/svg";
176
+ const make = (tag, attrs, text) => {
177
+ const n = document.createElementNS(NS, tag);
178
+ for (const [k, v] of Object.entries(attrs || {})) n.setAttribute(k, String(v));
179
+ if (text !== undefined) n.textContent = text;
180
+ return n;
181
+ };
182
+ const tone = (action) => (action === "delete" ? "var(--frame-degraded, var(--degraded))" : action === "update" || action === "replace" ? "var(--frame-pending, var(--pending))" : "var(--frame-managed, var(--managed))");
183
+
184
+ /** Take back the graph's own drawing, drop the scene. */
185
+ export function clearScene(svg) {
186
+ if (!svg) return;
187
+ for (const el of svg.querySelectorAll(":scope > [data-kl-scene]")) el.remove();
188
+ const stash = svg.__klStash;
189
+ if (stash) {
190
+ for (const el of stash) svg.appendChild(el);
191
+ svg.__klStash = null;
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Draw `model` in place of the graph's boxes, cards and edges. The graph's own elements are set aside (kept, to come
197
+ * back with clearScene) the first time; every call after draws the scene again.
198
+ */
199
+ export function drawScene(svg, model) {
200
+ if (!svg || !model) return;
201
+ if (!svg.__klStash) {
202
+ const keep = (el) => /^(defs|style|title|desc)$/i.test(el.tagName);
203
+ svg.__klStash = [...svg.children].filter((el) => !keep(el) && !el.hasAttribute("data-kl-scene"));
204
+ for (const el of svg.__klStash) el.remove();
205
+ }
206
+ for (const el of svg.querySelectorAll(":scope > [data-kl-scene]")) el.remove();
207
+ const scene = make("g", { "data-kl-scene": "1" });
208
+ for (const e of model.edges) {
209
+ const g = make("g", { "data-edge-from": e.from, "data-edge-to": e.to });
210
+ g.appendChild(make("path", { d: e.d, fill: "none", stroke: "var(--muted)", "stroke-width": 2, opacity: 0.45 }));
211
+ scene.appendChild(g);
212
+ }
213
+ for (const r of model.roots) {
214
+ // behold#1008: a hole's box is dashed in the degraded tone; a hole's and a previewed member's carry a tag saying so.
215
+ const g = make("g", { "data-layout-box": `box:${r.name}`, ...(r.kind ? { "data-member-kind": r.kind } : {}) });
216
+ const hole = r.kind === "hole";
217
+ g.appendChild(make("rect", { "data-group-id": r.name, x: r.x, y: r.y, width: r.w, height: r.h, rx: 16, fill: "var(--panel, var(--bg))", "fill-opacity": 0.6, stroke: hole ? "var(--frame-degraded, var(--degraded))" : "var(--frame-neutral, var(--neutral))", "stroke-width": hole ? 2 : 1.5, ...(hole ? { "stroke-dasharray": "10 6" } : {}) }));
218
+ g.appendChild(make("text", { x: r.x + 18, y: r.y + 26, "font-size": 20, "font-weight": 700, "letter-spacing": ".5", fill: "var(--muted)" }, r.name));
219
+ const tag = r.kind && KIND_TAGS[r.kind];
220
+ if (tag) {
221
+ const color = hole ? "var(--frame-degraded, var(--degraded))" : "var(--frame-pending, var(--pending))";
222
+ const w = tag.length * 8.5 + 20;
223
+ const mark = make("g", { "data-kl-kind-mark": r.kind });
224
+ mark.appendChild(make("rect", { x: r.x + r.w - w - 14, y: r.y + 9, width: w, height: 24, rx: 12, fill: "none", stroke: color, "stroke-width": 1.5 }));
225
+ mark.appendChild(make("text", { x: r.x + r.w - w / 2 - 14, y: r.y + 26, "text-anchor": "middle", "font-size": 14, "font-weight": 600, fill: color }, tag));
226
+ g.appendChild(mark);
227
+ }
228
+ scene.appendChild(g);
229
+ if (r.hole) {
230
+ // Where the hole's cards would be: no data-node-id, as the waiting slot has none.
231
+ const h = r.hole;
232
+ const slot = make("g", { "data-kl-hole": r.name });
233
+ slot.appendChild(make("rect", { x: h.x, y: h.y, width: h.w, height: h.h, rx: 12, fill: "none", stroke: "var(--frame-degraded, var(--degraded))", "stroke-width": 1.5, "stroke-dasharray": "6 5" }));
234
+ slot.appendChild(make("text", { x: h.x + h.w / 2, y: h.y + h.h / 2 + 5, "text-anchor": "middle", "font-size": 15, fill: "var(--muted)" }, h.words));
235
+ if (h.reasons && h.reasons.length) slot.appendChild(make("title", {}, h.reasons.join("\n")));
236
+ scene.appendChild(slot);
237
+ }
238
+ if (r.waiting) {
239
+ // No data-node-id: the lighting and the reads look for cards, and this is where they will be, not one of them.
240
+ const w = r.waiting;
241
+ const slot = make("g", { "data-kl-waiting": r.name });
242
+ slot.appendChild(make("rect", { x: w.x, y: w.y, width: w.w, height: w.h, rx: 12, fill: "none", stroke: "var(--frame-neutral, var(--neutral))", "stroke-width": 1.5, "stroke-dasharray": "6 5" }));
243
+ slot.appendChild(make("text", { x: w.x + w.w / 2, y: w.y + w.h / 2 + 5, "text-anchor": "middle", "font-size": 15, fill: "var(--muted)" }, w.words));
244
+ scene.appendChild(slot);
245
+ }
246
+ for (const c of r.cards) {
247
+ const card = make("g", { "data-node-id": c.id, "data-kl-synth": "1" });
248
+ const edge = c.applied ? "var(--frame-managed, var(--managed))" : "var(--frame-pending, var(--pending))";
249
+ card.appendChild(make("rect", { x: c.x, y: c.y, width: c.w, height: c.h, rx: 12, fill: "var(--panel, var(--bg))", stroke: edge, "stroke-width": 2 }));
250
+ card.appendChild(make("rect", { x: c.x, y: c.y, width: 6, height: c.h, rx: 3, fill: tone(c.action) }));
251
+ card.appendChild(make("text", { x: c.x + 20, y: c.y + 27, "font-size": 20, "font-weight": 700, fill: "var(--fg)" }, c.name));
252
+ card.appendChild(make("text", { x: c.x + 20, y: c.y + 47, "font-size": 14, fill: "var(--muted)" }, c.type + (c.action ? ` · ${c.action}` : "")));
253
+ scene.appendChild(card);
254
+ }
255
+ }
256
+ svg.appendChild(scene);
257
+ }
258
+
259
+ /**
260
+ * Whether the scene drawn on `svg` should stay when its data goes missing: it is there, and the graph's own elements
261
+ * set aside under it hold no card to go back to (a composed run's graph has none, so going back is a blank pane).
262
+ */
263
+ export function sceneHoldsOn(svg) {
264
+ if (!svg || !svg.__klStash || !svg.querySelector(":scope > [data-kl-scene]")) return false;
265
+ const own = svg.__klStash.some((el) => (el.hasAttribute && el.hasAttribute("data-node-id")) || (el.querySelector && el.querySelector("[data-node-id]")));
266
+ return !own;
267
+ }
@@ -0,0 +1,21 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { sceneHoldsOn } from "./kiosk-estate-scene.js";
3
+
4
+ // A stand-in for an svg: `scene` is whether a drawn scene sits in it, `stash` the graph's own elements set aside.
5
+ const el = (cards) => ({ hasAttribute: () => false, querySelector: () => (cards ? {} : null) });
6
+ const svg = ({ scene = true, stash = [] } = {}) => ({ __klStash: stash, querySelector: () => (scene ? {} : null) });
7
+
8
+ describe("a scene that stays when its data goes missing", () => {
9
+ it("stays when the graph's own drawing has no cards to go back to (a composed run)", () => {
10
+ expect(sceneHoldsOn(svg({ stash: [el(false)] }))).toBe(true);
11
+ });
12
+ it("goes back to the graph when it has cards of its own", () => {
13
+ expect(sceneHoldsOn(svg({ stash: [el(true)] }))).toBe(false);
14
+ expect(sceneHoldsOn(svg({ stash: [{ hasAttribute: (a) => a === "data-node-id" }] }))).toBe(false);
15
+ });
16
+ it("is not a scene when none is drawn", () => {
17
+ expect(sceneHoldsOn(svg({ scene: false }))).toBe(false);
18
+ expect(sceneHoldsOn({ __klStash: null, querySelector: () => null })).toBe(false);
19
+ expect(sceneHoldsOn(null)).toBe(false);
20
+ });
21
+ });
@@ -15,6 +15,7 @@
15
15
  import { STRIP, matchingPull, matchingRun } from "./kiosk.js";
16
16
  import { defaultStep } from "./kiosk-runs.js";
17
17
  import { traceReadyWords } from "./kiosk-wave-traces.js";
18
+ import { COMPOSED_WORDS, composedRun } from "./kiosk-light.js";
18
19
  import { resultBlocked, resultFailed, resultWords, waveResultOf } from "./terragucci-change.js";
19
20
 
20
21
  export { EH_STORE, ehStore, ehStored } from "./event-help-store.js";
@@ -90,6 +91,8 @@ export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc
90
91
  label: demo.label || "",
91
92
  plan: pr ? { totals: pr.totals || null, roots: pr.roots || [], reads: pr.reads || [] } : null,
92
93
  // behold#751: each wave with its report's result, of the run view's commit.
94
+ // One composed apply across estates: its text never counts or names waves.
95
+ composed: composedRun(answer, run ? progress : null),
93
96
  states: run ? (progress.states || []).map((s) => ({ ...s, result: waveResultOf(answer, run.commit, s.number) })) : [],
94
97
  run: runDoc ? { id: runDoc.id, jobs: jobs.map((j) => ({ name: j.name, status: j.status, wave: waveOfJob(j.name, waves), refusal: j.status === "failure" ? yodelRefusal(jobLines(j)) : null, step: j.steps ? defaultStep(j.steps) : -1, result: resultOf(runDoc.commit, j.name, j.started_at) })) } : null,
95
98
  approval: approval && Array.isArray(approval.rows) ? { wave: approval.wave, rows: approval.rows.filter((r) => r.state === "lit").map((r) => ({ id: r.id, at: r.at || null, actor: r.id === "approved" ? actorOf(r.text) : null, signed: !!(r.seal && /^signed/.test(r.seal.text || "")) })), ...(Array.isArray(approval.chantWaves) ? { chantWaves: approval.chantWaves } : {}) } : null,
@@ -258,7 +261,7 @@ export function cycleFacts(snap) {
258
261
  // A repo with declared waves names its held wave once the run view has it; this is for a repo without them.
259
262
  if (snap.step === "waiting" && !(snap.waves || []).length && !out.some((f) => f.kind === "held")) add({ id: `${c}|held`, kind: "held", text: "the plan waits for an approval", order: 9, critical: true });
260
263
  // The step says the run applied: every wave the run view names, even one a read has not caught up on.
261
- if (snap.step === "applied") add({ id: `${c}|applied`, kind: "applied", text: !states.length ? "the change applied" : states.length === 1 ? "the wave applied" : `all ${states.length} waves applied`, order: 990, critical: true });
264
+ if (snap.step === "applied") add({ id: `${c}|applied`, kind: "applied", text: !states.length ? "the change applied" : snap.composed ? COMPOSED_WORDS : states.length === 1 ? "the wave applied" : `all ${states.length} waves applied`, order: 990, critical: true });
262
265
  if (snap.step === "reset") add({ id: `${c}|reset`, kind: "reset", text: "states back on the base", order: 995 });
263
266
  // One fact per id (a wave's hold is said by the run view and the approval rows alike).
264
267
  const byId = new Map();