@intentius/behold 0.29.41 → 0.29.42

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.
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { commitRow, laneGateCard, laneLegend, laneView, runsLines, UNDECIDED_NOTE, whereWords, workWords } from "./trunk-lane.js";
2
+ import { commitRow, laneGateCard, laneLegend, laneView, releaseColumnNote, releaseRow, renderTrunkLane, runsLines, signatureWords, supersededLine, UNDECIDED_NOTE, whereWords, workWords } from "./trunk-lane.js";
3
3
 
4
4
  const NOW = new Date("2026-10-05T10:00:00Z");
5
5
  const C1 = "6828a7f5b398ea48543fe27c018ba302ce2aba14";
@@ -47,6 +47,33 @@ const answer = {
47
47
  releaseRefusals: [],
48
48
  };
49
49
 
50
+ // #692: the release column of the same workspace (src/trunk-lane-fixture.ts):
51
+ // v1 from C1 running in prod, v2 from C2 with v1's image digest running in
52
+ // staging and waiting in prod, v3 from the revoked C3 with a new one.
53
+ const R1 = `jcs1-sha256:${"1".repeat(64)}`;
54
+ const R2 = `jcs1-sha256:${"2".repeat(64)}`;
55
+ const R3 = `jcs1-sha256:${"3".repeat(64)}`;
56
+ const revocation = { tag: `ci/revoked/${C3}`, tagged: "2026-10-05T00:00:00Z", phase: "test", run: run(113, "failure"), signer: null };
57
+ const ROLLBACK = "chant components rollback staging --component api";
58
+ const unsigned = { status: "unsigned", reason: "the cut carries no signature" };
59
+ const releases = [
60
+ { member: "web", releaseDigest: R3, label: "v3", commit: C3, listed: true, artifacts: 1, previous: { releaseDigest: R2, label: "v2" }, configOnly: false, cut: { by: "github:alice", at: "2026-10-04T09:00:00Z", signature: { status: "unverified", reason: "there is no signers file (.chant/allowed_signers) at base to check the cut's signature against" } }, revoked: { ...revocation, rollback: [ROLLBACK] }, runs: [{ env: "staging", components: ["api"] }], waits: [{ env: "prod", gate: "web/release/promote", state: "superseded" }], next: null },
61
+ { member: "web", releaseDigest: R2, label: "v2", commit: C2, listed: true, artifacts: 1, previous: { releaseDigest: R1, label: "v1" }, configOnly: true, cut: { by: "github:alice", at: "2026-10-03T09:00:00Z", signature: unsigned }, revoked: null, runs: [{ env: "staging", components: ["web"] }], waits: [{ env: "prod", gate: "web/web/promote", state: "pending" }], next: "prod" },
62
+ { member: "web", releaseDigest: R1, label: "v1", commit: C1, listed: true, artifacts: 1, previous: null, configOnly: null, cut: { by: "github:alice", at: "2026-10-02T09:00:00Z", signature: unsigned }, revoked: null, runs: [{ env: "prod", components: ["web"] }], waits: [], next: null },
63
+ ];
64
+ const superseded = { key: "web/release/promote", member: "web", op: "release", gate: "promote", env: "prod", releaseDigest: R3, gitSha: C3, runId: "run-12", revoked: revocation };
65
+ const column = {
66
+ ...answer,
67
+ chant: "0.124.29",
68
+ releases,
69
+ releaseColumn: { full: true, floor: "0.124.29" },
70
+ commits: answer.commits.map((c, i) => ({ ...c, cuts: [[], [{ member: "web", releaseDigest: R3, label: "v3" }], [{ member: "web", releaseDigest: R2, label: "v2" }], [{ member: "web", releaseDigest: R1, label: "v1" }]][i] })),
71
+ environments: [
72
+ { ...answer.environments[0], releases: [{ member: "web", label: "v3", releaseDigest: R3, commit: C3, listed: true, components: ["api"], cutBy: "github:alice", cutAt: "2026-10-04T09:00:00Z", approver: null, rollback: [ROLLBACK] }, { ...answer.environments[0].releases[0], rollback: [] }], superseded: [] },
73
+ { ...answer.environments[1], superseded: [superseded] },
74
+ ],
75
+ };
76
+
50
77
  describe("laneLegend (#680)", () => {
51
78
  it("names the branch, the count and the window, and carries the undecided caveat", () => {
52
79
  expect(laneLegend(answer, NOW)).toEqual({ text: "trunk main · 4 commits within 3650d · read just now", title: UNDECIDED_NOTE, tone: "quiet" });
@@ -115,3 +142,83 @@ describe("an environment's lane (#680)", () => {
115
142
  expect(laneView({ ...answer, order: "env", environments: [answer.environments[1]] }, NOW).notes).toEqual(["no member declares a promotion order, so this is prod alone"]);
116
143
  });
117
144
  });
145
+
146
+ describe("the release column (#692)", () => {
147
+ it("names each release with its commit, its cut and its signature check", () => {
148
+ const v2 = releaseRow(releases[1], NOW);
149
+ expect(v2).toMatchObject({ head: "v2 · web", cutFrom: "cut from a14610e" });
150
+ expect(v2.facts.map((f) => f.text)).toEqual(["cut by github:alice 2d ago", "unsigned"]);
151
+ expect(releaseRow(releases[0], NOW).facts.map((f) => f.text)).toEqual(["cut by github:alice 25h ago", "signature does not count"]);
152
+ expect(signatureWords({ status: "verified", reason: "" }).text).toBe("signed");
153
+ expect(signatureWords(null)).toBeNull();
154
+ expect(releaseRow({ ...releases[2], cut: null, artifacts: 0, listed: false }, NOW)).toMatchObject({ cutFrom: "cut from 6828a7f (older than the trunk list)", facts: [{ text: "no cut recorded" }, { text: "no artifact digests" }] });
155
+ });
156
+
157
+ it("marks a config-only release, and not one whose artifacts changed", () => {
158
+ expect(releaseRow(releases[1], NOW).marks).toEqual([{ text: "config-only", cls: "lane-config-only", title: "The same artifact digests as v1: only configuration changed." }]);
159
+ expect(releaseRow(releases[0], NOW).marks.map((m) => m.text)).toEqual(["revoked"]);
160
+ expect(releaseRow(releases[2], NOW).marks).toEqual([]);
161
+ });
162
+
163
+ it("says where a release runs and waits, and where promotion takes it next", () => {
164
+ expect(releaseRow(releases[1], NOW).where.map((w) => w.text)).toEqual(["runs in staging", "waits in prod"]);
165
+ expect(releaseRow({ ...releases[1], waits: [] }, NOW).where.map((w) => w.text)).toEqual(["runs in staging", "next: prod"]);
166
+ expect(releaseRow({ ...releases[1], runs: [], waits: [], next: "staging" }, NOW).where.map((w) => w.text)).toEqual(["next: staging"]);
167
+ expect(releaseRow(releases[2], NOW).where.map((w) => w.text)).toEqual(["runs in prod"]);
168
+ expect(releaseRow({ ...releases[2], runs: [] }, NOW).where.map((w) => w.text)).toEqual(["runs nowhere"]);
169
+ });
170
+
171
+ it("marks a revoked release with what failed and the line that rolls it back, and its gate as superseded", () => {
172
+ const v3 = releaseRow(releases[0], NOW);
173
+ expect(v3.revoked).toEqual({ text: "revoked: test failed", run: { text: "test", href: "https://github.com/acme/app/actions/runs/113", title: "test: failure" }, rollback: [`roll back: ${ROLLBACK}`] });
174
+ expect(v3.where.map((w) => w.text)).toEqual(["runs in staging", "gate in prod superseded"]);
175
+ expect(supersededLine(superseded, column).text).toBe("web/release/promote superseded: release v3 is revoked (test failed)");
176
+ expect(runsLines(column.environments[0], NOW)[0]).toMatchObject({ text: "runs v3, cut from 9c4250f · api · revoked", revoked: true, title: expect.stringContaining(`roll back: ${ROLLBACK}`) });
177
+ const d = { member: "web", component: "api", digest: "sha256:0123456789abcdef", gitSha: C3, listed: true, timestamp: "2026-10-04T10:00:00Z", actor: "ci", approver: null, runId: "r", release: { releaseDigest: R3, label: "v3" }, rollback: ROLLBACK };
178
+ expect(runsLines({ env: "staging", releases: [], deploys: [d] }, NOW)[0]).toMatchObject({ text: "runs api 0123456789ab from release v3, 9c4250f · revoked", revoked: true });
179
+ });
180
+
181
+ it("names the releases cut from each commit", () => {
182
+ expect(commitRow(column.commits[2], NOW).facts.map((f) => f.text)).toEqual(["cut as v2"]);
183
+ expect(commitRow(column.commits[0], NOW).facts.map((f) => f.text)).toEqual(["work task:12"]);
184
+ });
185
+
186
+ it("says when the project's chant is below the column's floor, and nothing at or above it", () => {
187
+ expect(releaseColumnNote(column)).toBeNull();
188
+ const old = { ...column, chant: "0.124.28", releaseColumn: { full: false, floor: "0.124.29" }, releases: releases.map((r) => ({ ...r, revoked: null })) };
189
+ expect(releaseColumnNote(old)).toBe("chant 0.124.28 does not say which releases are revoked; chant 0.124.29 and newer does.");
190
+ expect(laneView(old, NOW).releases.note).toBe(releaseColumnNote(old));
191
+ // An answer from before #692 has no column at all.
192
+ expect(laneView(answer, NOW).releases).toBeNull();
193
+ expect(laneView({ ...column, releases: [] }, NOW).releases.empty).toBe("no release cut yet");
194
+ });
195
+
196
+ it("draws the column between the trunk's commits and the environments' gates", () => {
197
+ const make = (tag) => {
198
+ const el = { tag, children: [], dataset: {}, className: "", textContent: "", title: "", listeners: {} };
199
+ Object.defineProperty(el, "childNodes", { get: () => el.children });
200
+ el.appendChild = (c) => (el.children.push(c), c);
201
+ el.append = (...cs) => cs.forEach((c) => el.children.push(c));
202
+ el.replaceChildren = () => (el.children = []);
203
+ el.addEventListener = (k, f) => (el.listeners[k] = f);
204
+ return el;
205
+ };
206
+ const saved = globalThis.document;
207
+ globalThis.document = { createElement: make, createTextNode: (t) => ({ tag: "#text", textContent: t, children: [] }) };
208
+ try {
209
+ const host = make("div");
210
+ renderTrunkLane(host, column, NOW, {});
211
+ const heads = host.children.filter((c) => c.tag === "h3").map((c) => c.textContent);
212
+ expect(heads).toEqual(["trunk", "releases", "staging", "prod"]);
213
+ const rows = host.children.filter((c) => c.className === "lane-release");
214
+ expect(rows.map((r) => r.dataset.release)).toEqual([R3, R2, R1]);
215
+ const text = (el) => (el.textContent || "") + el.children.map(text).join("");
216
+ expect(text(rows[1])).toBe("v2 · web · cut from a14610e · config-onlycut by github:alice 2d ago · unsignedruns in staging · waits in prod");
217
+ expect(text(rows[0])).toContain(`roll back: ${ROLLBACK}`);
218
+ expect(host.children.findIndex((c) => c.className === "lane-release")).toBeGreaterThan(host.children.findIndex((c) => c.className === "lane-commit"));
219
+ expect(host.children.find((c) => c.className === "lane-superseded").textContent).toBe("web/release/promote superseded: release v3 is revoked (test failed)");
220
+ } finally {
221
+ globalThis.document = saved;
222
+ }
223
+ });
224
+ });