@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.
- package/AGENTS.md +155 -4
- package/demos.json +15 -0
- package/dist/cli.js +2440 -998
- package/example-three-cloud/README.md +38 -0
- package/example-three-cloud/aws/chant.config.ts +8 -0
- package/example-three-cloud/aws/src/site.ts +20 -0
- package/example-three-cloud/azure/chant.config.ts +1 -0
- package/example-three-cloud/azure/src/site.ts +19 -0
- package/example-three-cloud/chant.workspace.json +10 -0
- package/example-three-cloud/dns/chant.config.ts +1 -0
- package/example-three-cloud/dns/ops/front-door.op.ts +21 -0
- package/example-three-cloud/dns/src/route53.ts +54 -0
- package/example-three-cloud/gcp/chant.config.ts +1 -0
- package/example-three-cloud/gcp/src/site.ts +19 -0
- package/example-three-cloud/package-lock.json +715 -0
- package/example-three-cloud/package.json +16 -0
- package/example-three-cloud/scripts/emulators-up.sh +46 -0
- package/example-three-cloud/scripts/front-door.ts +400 -0
- package/package.json +4 -2
- package/web/app.js +250 -23
- package/web/composite-members.js +21 -0
- package/web/composite-members.test.js +25 -0
- package/web/decision-points.js +70 -0
- package/web/decision-points.test.js +87 -0
- package/web/dots-kiosk.js +4 -1
- package/web/dots-live.test.js +10 -0
- package/web/dots.js +41 -4
- package/web/export-note.js +35 -0
- package/web/export-note.test.js +45 -0
- package/web/health-marks.js +146 -0
- package/web/health-marks.test.js +67 -0
- package/web/index.html +52 -0
- package/web/kiosk-runs.js +51 -5
- package/web/kiosk-runs.test.js +42 -1
- package/web/kiosk-source.js +23 -0
- package/web/kiosk-source.test.js +19 -1
- package/web/kiosk-track.js +9 -5
- package/web/kiosk-track.test.js +12 -2
- package/web/kiosk.html +26 -3
- package/web/kiosk.js +28 -6
- package/web/local-run.js +276 -0
- package/web/local-run.test.js +46 -0
- package/web/sql-yodeler-lane.js +1 -1
- package/web/terragucci-timeline.js +5 -4
- package/web/terragucci-timeline.test.js +1 -1
- package/web/trunk-lane.js +54 -5
- package/web/trunk-lane.test.js +86 -3
- package/web/view-url.js +25 -0
- package/web/view-url.test.js +24 -1
- package/web/why.js +1 -1
- package/web/why.test.js +1 -1
- package/web/workspace-gates.js +35 -18
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { indexWords } from "./kiosk-runs.js";
|
|
5
|
+
import { askBody, ciPlanRows, compareHeads, offerView } from "./local-run.js";
|
|
6
|
+
|
|
7
|
+
// behold#685: the "Run locally" tab's words. The CI runs are the run index
|
|
8
|
+
// fixture as GET /api/chant/ci/runs answers it (src/ci-run-index.ts ciRunOf).
|
|
9
|
+
const INDEX = JSON.parse(readFileSync(join(import.meta.dirname, "..", "src", "__fixtures__", "chant-demo", "reports", "runs", "index.json"), "utf8"));
|
|
10
|
+
const asRuns = { doc: { schema: "demo.runs/v1", runs: INDEX.runs.map((r) => ({ id: r.runId, job: r.job, pull: r.pr, commit: r.commit, member: r.member ?? null, status: r.status === "ok" ? "success" : "failure" })) } };
|
|
11
|
+
|
|
12
|
+
describe("what the tab offers (behold#685)", () => {
|
|
13
|
+
it("offers plan when behold says so, and says why when it does not", () => {
|
|
14
|
+
const on = offerView({ offer: { jobs: ["plan"], refusal: null, apply: "behold runs plan jobs locally, never apply", env: "prod", members: ["app"], ciIndex: true } });
|
|
15
|
+
expect(on).toMatchObject({ can: true, refusal: null, env: "prod", members: ["app"], ciIndex: true });
|
|
16
|
+
expect(on.apply).toMatch(/never apply/);
|
|
17
|
+
const old = offerView({ offer: { jobs: [], refusal: { error: "Local CI run needs chant 0.124.32 or newer. This project has chant 0.124.31.", remedy: "Upgrade @intentius/chant to 0.124.32 or newer in the project." }, apply: "x", env: null, members: [], ciIndex: false } });
|
|
18
|
+
expect(old).toMatchObject({ can: false, refusal: "Local CI run needs chant 0.124.32 or newer. This project has chant 0.124.31.", remedy: "Upgrade @intentius/chant to 0.124.32 or newer in the project." });
|
|
19
|
+
expect(offerView({ error: "behold is serving a public, read-only view" }).can).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
it("lists CI's plan jobs of a pull request, never an apply", () => {
|
|
22
|
+
const rows = ciPlanRows(asRuns);
|
|
23
|
+
expect(rows.map((r) => r.text)).toEqual(["plan of #775 at 9b1e3f0c · web · succeeded", "plan of #774 at 47f4df6d · succeeded", "plan of #773 at 6d4a48da · succeeded"]);
|
|
24
|
+
expect(rows[0]).toMatchObject({ commit: "9b1e3f0c2d4a5b6c7d8e9f00112233445566778a", pr: 775, member: "web" });
|
|
25
|
+
expect(ciPlanRows({ doc: null, absent: "no index" })).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("the ask", () => {
|
|
30
|
+
it("is a plan with a commit and its pull request, and the rest only when given", () => {
|
|
31
|
+
expect(askBody({ commit: " 4843c95 ", pr: "7", env: "", base: "", member: "", forge: "" })).toEqual({ body: { job: "plan", commit: "4843c95", pr: 7 } });
|
|
32
|
+
expect(askBody({ commit: "4843c95", pr: "7", env: "prod", base: "8923f55", member: "app", forge: "github" })).toEqual({ body: { job: "plan", commit: "4843c95", pr: 7, env: "prod", base: "8923f55", member: "app", forge: "github" } });
|
|
33
|
+
expect(askBody({ commit: "main", pr: "7" }).error).toMatch(/sha/);
|
|
34
|
+
expect(askBody({ commit: "4843c95", pr: "" }).error).toMatch(/pull request's number/);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("the two halves", () => {
|
|
39
|
+
it("names where each ran, and says so when chant did not run it locally", () => {
|
|
40
|
+
expect(compareHeads({ doc: { base: "8923f557a020", env: "prod", where: { forge: "local", runtime: "local" } } })).toEqual({ local: "This machine · chant ci run plan --local · base 8923f557 · prod", ci: "CI · from chant's run index" });
|
|
41
|
+
expect(compareHeads({ doc: { base: "8923f557a020", env: "prod", where: { forge: "chant", runtime: "ci" } } }).local).toMatch(/chant said it ran on chant$/);
|
|
42
|
+
});
|
|
43
|
+
it("puts the member and chant's failure code beside a local run's status, as for CI's", () => {
|
|
44
|
+
expect(indexWords({ from: "chant-ci-local", member: "app", failure: "command-failed" })).toEqual(["app", "failed: command-failed"]);
|
|
45
|
+
});
|
|
46
|
+
});
|
package/web/sql-yodeler-lane.js
CHANGED
|
@@ -36,7 +36,7 @@ export function yodelGateCard(env, g, now = new Date()) {
|
|
|
36
36
|
const facts = [];
|
|
37
37
|
if (g.pending) facts.push(`asked ${clock(g.pending.timestamp, now)}, ${ago(g.pending.timestamp, now)}`);
|
|
38
38
|
if (g.approval) {
|
|
39
|
-
const how = [g.approval.signed ? "signed" : "
|
|
39
|
+
const how = [g.approval.signed ? "signed" : "", g.approval.via ? `via ${g.approval.via}` : "", g.approval.pr !== undefined ? `PR #${g.approval.pr}` : "", g.approval.relayedBy ? `relayed by ${g.approval.relayedBy}` : ""].filter(Boolean).join(", ");
|
|
40
40
|
facts.push(`approved by ${g.approval.by} (${how}) ${clock(g.approval.at, now)}, ${ago(g.approval.at, now)}`);
|
|
41
41
|
}
|
|
42
42
|
if (g.applied) facts.push(`applied ${clock(g.applied.at, now)}, ${ago(g.applied.at, now)}${g.applied.result ? "" : " (outcome not recorded)"}`);
|
|
@@ -34,11 +34,12 @@ export function toneOf(entry) {
|
|
|
34
34
|
return "ok";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** One entry as a line: "approved wave-2 by dana
|
|
37
|
+
/** One entry as a line: "approved wave-2 by dana · plan 4be1…". */
|
|
38
38
|
export function entryLine(entry) {
|
|
39
39
|
const what = KIND_WORDS[entry.kind] || entry.kind;
|
|
40
40
|
const by = entry.who ? ` by ${entry.who}` : "";
|
|
41
|
-
|
|
41
|
+
// Signing is opt-in: an unsigned approval is the normal case and goes unmarked.
|
|
42
|
+
const result = entry.result && entry.result !== entry.kind && entry.result !== "unsigned" ? `: ${entry.result}` : "";
|
|
42
43
|
const digest = entry.digest ? ` · plan ${entry.digest.replace(/^(jcs1-)?sha256:/, "").slice(0, 12)}` : "";
|
|
43
44
|
return `${what} ${entry.what}${by}${result}${digest}`;
|
|
44
45
|
}
|
|
@@ -131,12 +132,12 @@ const HISTORY_WORDS = {
|
|
|
131
132
|
"override-spent": "override spent",
|
|
132
133
|
};
|
|
133
134
|
|
|
134
|
-
/** One ledger entry as a line: "approved wave-2 by dana
|
|
135
|
+
/** One ledger entry as a line: "approved wave-2 by dana · plan 4be1…". */
|
|
135
136
|
export function historyLine(entry) {
|
|
136
137
|
const what = entry.kind === "revoked" ? `${entry.subject || "approval"} revoked` : HISTORY_WORDS[entry.kind] || entry.kind;
|
|
137
138
|
const op = entry.op && entry.op !== "tf-apply" ? ` (${entry.op})` : "";
|
|
138
139
|
const by = entry.actor ? ` by ${entry.actor}` : "";
|
|
139
|
-
const seal = entry.seal && (entry.kind === "approved" || entry.kind === "override-recorded") ? `: ${entry.seal}` : "";
|
|
140
|
+
const seal = entry.seal && entry.seal !== "unsigned" && (entry.kind === "approved" || entry.kind === "override-recorded") ? `: ${entry.seal}` : "";
|
|
140
141
|
const digest = entry.digest ? ` · plan ${entry.digest.replace(/^(jcs1-)?sha256:/, "").slice(0, 12)}` : "";
|
|
141
142
|
return `${what} ${entry.gate}${op}${by}${seal}${digest}`;
|
|
142
143
|
}
|
|
@@ -19,7 +19,7 @@ const answer = {
|
|
|
19
19
|
describe("the timeline lane (#506)", () => {
|
|
20
20
|
it("words an entry by its kind, who and result", () => {
|
|
21
21
|
expect(entryLine(answer.entries[0])).toBe("apply wave-2: waiting · plan 2e0fba16ce38");
|
|
22
|
-
expect(entryLine(answer.entries[1])).toBe("approved wave-1 by dana
|
|
22
|
+
expect(entryLine(answer.entries[1])).toBe("approved wave-1 by dana");
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it("draws refusals and failures as failed, waits as pending", () => {
|
package/web/trunk-lane.js
CHANGED
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
// draws it on the graph (#681). Between the two, the releases cut from those
|
|
8
8
|
// commits (#692): each with its cut, a config-only mark, a revoked mark with
|
|
9
9
|
// the rollback line, where it runs and waits, and the environment it is
|
|
10
|
-
// promoted to next.
|
|
10
|
+
// promoted to next. An environment chant reads as mixed (#731) says so, with
|
|
11
|
+
// each component's release and state and chant's redeploy and rollback lines,
|
|
12
|
+
// shown to copy and never run. Nothing here is behold's own state.
|
|
11
13
|
|
|
12
14
|
import { ago, clock } from "./terragucci.js";
|
|
13
15
|
import { approveAffordance, HOST_APPROVES, overrideCard } from "./workspace-gates.js";
|
|
16
|
+
import { HOST_ANSWERS } from "./decision-points.js";
|
|
14
17
|
|
|
15
18
|
const short = (s) => (s ? String(s).replace(/^(jcs1-)?sha256:/, "").slice(0, 12) : "");
|
|
16
19
|
const sha7 = (s) => (s ? String(s).slice(0, 7) : "");
|
|
@@ -116,7 +119,8 @@ const releaseName = (r) => (r ? r.label || short(r.releaseDigest) : "");
|
|
|
116
119
|
export function signatureWords(sig) {
|
|
117
120
|
if (!sig) return null;
|
|
118
121
|
if (sig.status === "verified") return { text: "signed", title: sig.reason || "chant verified the cut's signature." };
|
|
119
|
-
|
|
122
|
+
// Signing is opt-in: a cut without a signature is the normal case and goes unmarked.
|
|
123
|
+
if (sig.status === "unsigned") return null;
|
|
120
124
|
return { text: "signature does not count", title: sig.reason || "" };
|
|
121
125
|
}
|
|
122
126
|
|
|
@@ -168,6 +172,35 @@ export function releaseRow(r, now = new Date()) {
|
|
|
168
172
|
};
|
|
169
173
|
}
|
|
170
174
|
|
|
175
|
+
/**
|
|
176
|
+
* One member's mixed state in an environment (#731), as lines: a head, what
|
|
177
|
+
* each component runs and whether it settled, then chant's redeploy lines and
|
|
178
|
+
* its rollback line, which behold shows and does not run.
|
|
179
|
+
*/
|
|
180
|
+
export function mixedLines(m, env, now = new Date()) {
|
|
181
|
+
const unsettled = m.components.filter((c) => c.state !== "settled");
|
|
182
|
+
const ran = [...new Set(m.components.map((c) => (c.release ? releaseName(c.release) : null)).filter(Boolean))];
|
|
183
|
+
const head = unsettled.length
|
|
184
|
+
? { text: `mixed: ${plural(unsettled.length, "component")} of ${m.member} not settled`, title: "A promote, rollback or redeploy left them failed or gated, and chant has recorded nothing for them since, so what they run is not known." }
|
|
185
|
+
: { text: `mixed: ${m.member} runs ${ran.join(" and ")}`, title: "Its components run different releases." };
|
|
186
|
+
const components = m.components.map((c) => {
|
|
187
|
+
const runs = c.release ? `runs ${releaseName(c.release)}` : c.digest ? `runs ${short(c.digest)}` : "no deploy record";
|
|
188
|
+
if (!c.attempt || c.state === "settled") return { text: `${c.component} ${runs}`, title: c.release ? `release ${c.release.releaseDigest}` : "", unsettled: false };
|
|
189
|
+
const what = `${c.attempt.verb}${c.attempt.release ? ` of ${releaseName(c.attempt.release)}` : ""}`;
|
|
190
|
+
return {
|
|
191
|
+
text: `${c.component} ${runs} · ${c.state} in ${what}, run ${c.attempt.runId}`,
|
|
192
|
+
title: `${c.state === "gated" ? "Stopped at its gate" : "Failed"} in ${what}, run ${c.attempt.runId} ${clock(c.attempt.timestamp, now)}. The ledger's record is older than that run, so what ${c.component} runs is not known.`,
|
|
193
|
+
unsettled: true,
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
const where = `Run in ${m.dir}. behold does not run it.`;
|
|
197
|
+
const commands = [
|
|
198
|
+
...m.redeploy.map((l) => ({ label: "redeploy", line: l, title: `Puts back the release the ledger records for the component. ${where}` })),
|
|
199
|
+
...(m.rollback ? [{ label: "roll back", line: m.rollback, title: `Restores the newest release ${env} ran that is kept and not revoked. ${where}` }] : []),
|
|
200
|
+
].map((c) => ({ ...c, text: `${c.label}: ${c.line}` }));
|
|
201
|
+
return { head, components, commands };
|
|
202
|
+
}
|
|
203
|
+
|
|
171
204
|
/** A release gate chant reads as superseded, as a line in its environment. */
|
|
172
205
|
export function supersededLine(g, a) {
|
|
173
206
|
const r = ((a && a.releases) || []).find((x) => x.releaseDigest === g.releaseDigest);
|
|
@@ -185,7 +218,8 @@ export function laneGateCard(g, answer, { embed = false } = {}) {
|
|
|
185
218
|
}
|
|
186
219
|
const facts = [];
|
|
187
220
|
facts.push(g.gitSha ? `for ${sha7(g.gitSha)}${g.commitState ? ` (${g.commitState})` : ""}` : "commit unknown");
|
|
188
|
-
|
|
221
|
+
// #472: a gate that asks a decision point counts no approvals; its point's quorum decides.
|
|
222
|
+
facts.push(g.answer ? `waits on decision point ${g.answer.point}` : `${g.approvals.length} of ${plural(g.needed, "approval")}`);
|
|
189
223
|
if (g.runId) facts.push(`run ${g.runId}`);
|
|
190
224
|
if (g.releaseDigest) facts.push(`release ${short(g.releaseDigest)}`);
|
|
191
225
|
if (g.approvals.length) facts.push(`approved by ${g.approvals.map((a) => a.principal).join(", ")}`);
|
|
@@ -198,7 +232,8 @@ export function laneGateCard(g, answer, { embed = false } = {}) {
|
|
|
198
232
|
};
|
|
199
233
|
// #681: the change set is a link that draws it on the graph.
|
|
200
234
|
if (g.changeSet) card.changeSet = { text: `change set ${short(g.changeSet)}`, title: `Draw this change set on the graph, as a preview.\n${show}` };
|
|
201
|
-
|
|
235
|
+
// #472: a gate that waits on a decision point is answered, not approved, and never here.
|
|
236
|
+
if (embed) card.note = g.answer ? HOST_ANSWERS : HOST_APPROVES;
|
|
202
237
|
else Object.assign(card, approveAffordance(g, answer));
|
|
203
238
|
return card;
|
|
204
239
|
}
|
|
@@ -225,9 +260,11 @@ export function laneView(a, now = new Date(), opts = {}) {
|
|
|
225
260
|
: null,
|
|
226
261
|
environments: (a.environments || []).map((e) => ({
|
|
227
262
|
env: e.env,
|
|
228
|
-
heading: e.canary ?
|
|
263
|
+
heading: `${e.env}${[e.canary ? "canary" : "", e.mixed && e.mixed.length ? "mixed" : ""].filter(Boolean).map((t) => ` (${t})`).join("")}`,
|
|
229
264
|
refusal: e.refusal ? `not read: ${e.refusal.error}` : null,
|
|
230
265
|
runs: e.refusal ? [] : runsLines(e, now),
|
|
266
|
+
// #731: absent from an answer before it, and empty below its floor.
|
|
267
|
+
mixed: (e.mixed || []).map((m) => mixedLines(m, e.env, now)),
|
|
231
268
|
superseded: (e.superseded || []).map((g) => supersededLine(g, a)),
|
|
232
269
|
gates: (e.waiting || []).filter((g) => g.state === "pending" || g.override).map((g) => laneGateCard(g, a, opts)),
|
|
233
270
|
})),
|
|
@@ -360,6 +397,18 @@ export function renderTrunkLane(host, a, now, ui) {
|
|
|
360
397
|
host.appendChild(eh);
|
|
361
398
|
if (e.refusal) line("tg-refusal", e.refusal);
|
|
362
399
|
for (const r of e.runs) line(r.revoked ? "lane-runs lane-runs-revoked" : "lane-runs", r.text, r.title);
|
|
400
|
+
for (const m of e.mixed) {
|
|
401
|
+
line("lane-mixed", m.head.text, m.head.title);
|
|
402
|
+
for (const c of m.components) line(c.unsettled ? "lane-mixed-component lane-mixed-unsettled" : "lane-mixed-component", c.text, c.title);
|
|
403
|
+
// The line alone selects as one piece, so it copies without its label.
|
|
404
|
+
for (const l of m.commands) {
|
|
405
|
+
const d = line("lane-command", `${l.label}: `, l.title);
|
|
406
|
+
const cmd = document.createElement("span");
|
|
407
|
+
cmd.className = "lane-command-line";
|
|
408
|
+
cmd.textContent = l.line;
|
|
409
|
+
d.appendChild(cmd);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
363
412
|
for (const g of e.superseded) line("lane-superseded", g.text, g.title);
|
|
364
413
|
for (const g of e.gates) {
|
|
365
414
|
const box = document.createElement("div");
|
package/web/trunk-lane.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { commitRow, laneGateCard, laneLegend, laneView, releaseColumnNote, releaseRow, renderTrunkLane, runsLines, signatureWords, supersededLine, UNDECIDED_NOTE, whereWords, workWords } from "./trunk-lane.js";
|
|
2
|
+
import { commitRow, laneGateCard, laneLegend, laneView, mixedLines, 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";
|
|
@@ -130,6 +130,8 @@ describe("an environment's lane (#680)", () => {
|
|
|
130
130
|
expect(laneGateCard({ ...gate, op: "release", releaseDigest: "jcs1-sha256:1a23268fa8b1fc419cffde4c1780f4387ff0346495f97bd9e22b0508bef99f9d" }, answer).facts).toBe("for a14610e (green) · 0 of 1 approval · run run-9 · release 1a23268fa8b1");
|
|
131
131
|
expect(laneGateCard({ ...gate, gitSha: undefined, commitState: null, changeSet: undefined }, answer)).toMatchObject({ facts: "commit unknown · 0 of 1 approval · run run-9" });
|
|
132
132
|
expect(laneGateCard({ ...gate, changeSet: undefined }, answer).changeSet).toBeUndefined();
|
|
133
|
+
// #472: a gate that waits on a decision point counts no approvals.
|
|
134
|
+
expect(laneGateCard({ ...gate, changeSet: undefined, answer: { point: "apply-approval", id: "q1", path: "answers/q1.md" } }, answer).facts).toBe("for a14610e (green) · waits on decision point apply-approval · run run-9");
|
|
133
135
|
expect(laneGateCard(gate, answer, { embed: true }).button).toBeUndefined();
|
|
134
136
|
});
|
|
135
137
|
it("lays the environments out in the order the answer gives", () => {
|
|
@@ -147,10 +149,12 @@ describe("the release column (#692)", () => {
|
|
|
147
149
|
it("names each release with its commit, its cut and its signature check", () => {
|
|
148
150
|
const v2 = releaseRow(releases[1], NOW);
|
|
149
151
|
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"
|
|
152
|
+
expect(v2.facts.map((f) => f.text)).toEqual(["cut by github:alice 2d ago"]);
|
|
151
153
|
expect(releaseRow(releases[0], NOW).facts.map((f) => f.text)).toEqual(["cut by github:alice 25h ago", "signature does not count"]);
|
|
152
154
|
expect(signatureWords({ status: "verified", reason: "" }).text).toBe("signed");
|
|
153
155
|
expect(signatureWords(null)).toBeNull();
|
|
156
|
+
// Signing is opt-in: an unsigned cut goes unmarked.
|
|
157
|
+
expect(signatureWords({ status: "unsigned", reason: "the cut carries no signature" })).toBeNull();
|
|
154
158
|
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
159
|
});
|
|
156
160
|
|
|
@@ -213,7 +217,7 @@ describe("the release column (#692)", () => {
|
|
|
213
217
|
const rows = host.children.filter((c) => c.className === "lane-release");
|
|
214
218
|
expect(rows.map((r) => r.dataset.release)).toEqual([R3, R2, R1]);
|
|
215
219
|
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
|
|
220
|
+
expect(text(rows[1])).toBe("v2 · web · cut from a14610e · config-onlycut by github:alice 2d agoruns in staging · waits in prod");
|
|
217
221
|
expect(text(rows[0])).toContain(`roll back: ${ROLLBACK}`);
|
|
218
222
|
expect(host.children.findIndex((c) => c.className === "lane-release")).toBeGreaterThan(host.children.findIndex((c) => c.className === "lane-commit"));
|
|
219
223
|
expect(host.children.find((c) => c.className === "lane-superseded").textContent).toBe("web/release/promote superseded: release v3 is revoked (test failed)");
|
|
@@ -222,3 +226,82 @@ describe("the release column (#692)", () => {
|
|
|
222
226
|
}
|
|
223
227
|
});
|
|
224
228
|
});
|
|
229
|
+
|
|
230
|
+
// #731: staging after the promote of v3 there deployed api and failed on web,
|
|
231
|
+
// as the recorded src/__fixtures__/trunk-lane/status-staging.json gives it.
|
|
232
|
+
const REDEPLOY = "chant components redeploy staging --component web";
|
|
233
|
+
const mixed = {
|
|
234
|
+
member: "web",
|
|
235
|
+
dir: "web",
|
|
236
|
+
components: [
|
|
237
|
+
{ component: "api", release: { releaseDigest: R3, label: "v3" }, digest: "sha256:4b5e57f6eb2f", state: "settled", attempt: null },
|
|
238
|
+
{ component: "web", release: { releaseDigest: R2, label: "v2" }, digest: "sha256:4b5e57f6eb2f", state: "failed", attempt: { verb: "promote", runId: "run-3", timestamp: "2026-10-04T12:00:00Z", release: { releaseDigest: R3, label: "v3" } } },
|
|
239
|
+
],
|
|
240
|
+
redeploy: [REDEPLOY],
|
|
241
|
+
rollback: ROLLBACK,
|
|
242
|
+
};
|
|
243
|
+
const mixedAnswer = { ...column, mixedEnvironments: { read: true, floor: "0.124.29" }, environments: [{ ...column.environments[0], mixed: [mixed] }, { ...column.environments[1], mixed: [] }] };
|
|
244
|
+
|
|
245
|
+
describe("a mixed environment (#731)", () => {
|
|
246
|
+
it("says which components are not settled, what each runs, and chant's redeploy and rollback lines", () => {
|
|
247
|
+
const m = mixedLines(mixed, "staging", NOW);
|
|
248
|
+
expect(m.head.text).toBe("mixed: 1 component of web not settled");
|
|
249
|
+
expect(m.components.map((c) => [c.text, c.unsettled])).toEqual([
|
|
250
|
+
["api runs v3", false],
|
|
251
|
+
["web runs v2 · failed in promote of v3, run run-3", true],
|
|
252
|
+
]);
|
|
253
|
+
expect(m.components[1].title).toContain("what web runs is not known");
|
|
254
|
+
expect(m.commands.map((c) => c.text)).toEqual([`redeploy: ${REDEPLOY}`, `roll back: ${ROLLBACK}`]);
|
|
255
|
+
expect(m.commands.map((c) => c.line)).toEqual([REDEPLOY, ROLLBACK]);
|
|
256
|
+
expect(m.commands[0].title).toContain("Run in web. behold does not run it.");
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("words a mix of settled releases, a gated component with no record, and no rollback line", () => {
|
|
260
|
+
const settled = mixedLines({ ...mixed, components: [mixed.components[0], { ...mixed.components[1], state: "settled", attempt: null }], redeploy: [], rollback: null }, "staging", NOW);
|
|
261
|
+
expect(settled.head.text).toBe("mixed: web runs v3 and v2");
|
|
262
|
+
expect(settled.commands).toEqual([]);
|
|
263
|
+
const gated = mixedLines({ ...mixed, components: [{ component: "api", release: null, digest: null, state: "gated", attempt: { verb: "redeploy", runId: "r", timestamp: "2026-10-04T12:00:00Z", release: null } }], redeploy: [], rollback: null }, "staging", NOW);
|
|
264
|
+
expect(gated.components[0].text).toBe("api no deploy record · gated in redeploy, run r");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("heads the environment as mixed, and an answer without mixed draws as before", () => {
|
|
268
|
+
expect(laneView(mixedAnswer, NOW).environments.map((e) => [e.heading, e.mixed.length])).toEqual([
|
|
269
|
+
["staging (mixed)", 1],
|
|
270
|
+
["prod", 0],
|
|
271
|
+
]);
|
|
272
|
+
expect(laneView(column, NOW).environments.map((e) => [e.heading, e.mixed])).toEqual([
|
|
273
|
+
["staging", []],
|
|
274
|
+
["prod", []],
|
|
275
|
+
]);
|
|
276
|
+
expect(laneView({ ...mixedAnswer, environments: [{ ...mixedAnswer.environments[0], canary: true }] }, NOW).environments[0].heading).toBe("staging (canary) (mixed)");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("draws the mix under what the environment runs, each line as text to copy", () => {
|
|
280
|
+
const make = (tag) => {
|
|
281
|
+
const el = { tag, children: [], dataset: {}, className: "", textContent: "", title: "", listeners: {} };
|
|
282
|
+
Object.defineProperty(el, "childNodes", { get: () => el.children });
|
|
283
|
+
el.appendChild = (c) => (el.children.push(c), c);
|
|
284
|
+
el.append = (...cs) => cs.forEach((c) => el.children.push(c));
|
|
285
|
+
el.replaceChildren = () => (el.children = []);
|
|
286
|
+
el.addEventListener = (k, f) => (el.listeners[k] = f);
|
|
287
|
+
return el;
|
|
288
|
+
};
|
|
289
|
+
const saved = globalThis.document;
|
|
290
|
+
globalThis.document = { createElement: make, createTextNode: (t) => ({ tag: "#text", textContent: t, children: [] }) };
|
|
291
|
+
try {
|
|
292
|
+
const host = make("div");
|
|
293
|
+
renderTrunkLane(host, mixedAnswer, NOW, {});
|
|
294
|
+
const at = host.children.findIndex((c) => c.tag === "h3" && c.textContent === "staging (mixed)");
|
|
295
|
+
const next = host.children.findIndex((c, i) => i > at && c.tag === "h3");
|
|
296
|
+
const lane = host.children.slice(at + 1, next);
|
|
297
|
+
expect(lane.map((c) => c.className)).toEqual(["lane-runs lane-runs-revoked", "lane-runs", "lane-mixed", "lane-mixed-component", "lane-mixed-component lane-mixed-unsettled", "lane-command", "lane-command"]);
|
|
298
|
+
const commands = lane.filter((c) => c.className === "lane-command");
|
|
299
|
+
expect(commands.map((c) => [c.textContent, c.children[0].className, c.children[0].textContent])).toEqual([
|
|
300
|
+
["redeploy: ", "lane-command-line", REDEPLOY],
|
|
301
|
+
["roll back: ", "lane-command-line", ROLLBACK],
|
|
302
|
+
]);
|
|
303
|
+
} finally {
|
|
304
|
+
globalThis.document = saved;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
package/web/view-url.js
CHANGED
|
@@ -172,6 +172,31 @@ export function refusalLine(refused) {
|
|
|
172
172
|
return "from the link: " + refused.map((r) => `${r.key}=${r.value} not opened, ${r.reason}`).join("; ");
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* #827: the view a static export opens on, `behold export --open-env` and
|
|
177
|
+
* `--open-zoom`, as its manifest's `opening` carries them. A link's own query
|
|
178
|
+
* wins over it, key by key, so a shared link still opens where it points.
|
|
179
|
+
* Only a string `env` and `zoom` are taken; settleView checks them as it
|
|
180
|
+
* checks a link's.
|
|
181
|
+
*/
|
|
182
|
+
export function withOpening(opening, want) {
|
|
183
|
+
const o = {};
|
|
184
|
+
if (opening && typeof opening === "object") {
|
|
185
|
+
if (typeof opening.env === "string" && opening.env) o.env = opening.env;
|
|
186
|
+
if (typeof opening.zoom === "string" && opening.zoom) o.zoom = opening.zoom;
|
|
187
|
+
}
|
|
188
|
+
return { ...o, ...(want || {}) };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** #827: the env a load with no `env` parameter gives: the export's opening
|
|
192
|
+
* env when it names one, else the env behold was started with. writeViewQuery
|
|
193
|
+
* takes it as `defaults.env`, so picking the source graph in such a bundle
|
|
194
|
+
* writes `env=` and a reload keeps it. */
|
|
195
|
+
export function defaultEnv(opening, currentEnv) {
|
|
196
|
+
if (opening && typeof opening.env === "string" && opening.env) return opening.env;
|
|
197
|
+
return currentEnv || null;
|
|
198
|
+
}
|
|
199
|
+
|
|
175
200
|
function listOr(xs) {
|
|
176
201
|
const a = (xs || []).filter(Boolean);
|
|
177
202
|
if (!a.length) return "nothing";
|
package/web/view-url.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { readViewQuery, writeViewQuery, settleView, settlePlace, refusalLine, isEnvName } from "./view-url.js";
|
|
2
|
+
import { readViewQuery, writeViewQuery, settleView, settlePlace, refusalLine, isEnvName, withOpening, defaultEnv } from "./view-url.js";
|
|
3
3
|
|
|
4
4
|
describe("readViewQuery (#475)", () => {
|
|
5
5
|
it("reads the view keys and nothing else", () => {
|
|
@@ -134,3 +134,26 @@ describe("run (#569)", () => {
|
|
|
134
134
|
expect(writeViewQuery("", { run: "none" })).toBe("?run=none");
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
|
+
|
|
138
|
+
describe("an export's opening view (#827)", () => {
|
|
139
|
+
it("opens on the manifest's env and zoom when the link names neither", () => {
|
|
140
|
+
expect(withOpening({ env: "frozen", zoom: "composites" }, readViewQuery(""))).toEqual({ env: "frozen", zoom: "composites" });
|
|
141
|
+
});
|
|
142
|
+
it("lets the link's own query win, key by key", () => {
|
|
143
|
+
expect(withOpening({ env: "frozen", zoom: "composites" }, readViewQuery("?zoom=resources"))).toEqual({ env: "frozen", zoom: "resources" });
|
|
144
|
+
// env= in a link is the source graph, and still wins over the opening env.
|
|
145
|
+
expect(withOpening({ env: "frozen" }, readViewQuery("?env="))).toEqual({ env: null });
|
|
146
|
+
});
|
|
147
|
+
it("is nothing for a bundle that chose no view, or a live serve with no manifest", () => {
|
|
148
|
+
expect(withOpening(undefined, readViewQuery("?member=dns"))).toEqual({ member: "dns" });
|
|
149
|
+
expect(withOpening(null, {})).toEqual({});
|
|
150
|
+
expect(withOpening({ env: 3, zoom: "", node: "x" }, {})).toEqual({});
|
|
151
|
+
});
|
|
152
|
+
it("makes the opening env the default a reload falls back to", () => {
|
|
153
|
+
expect(defaultEnv({ env: "frozen" }, null)).toBe("frozen");
|
|
154
|
+
expect(defaultEnv(undefined, "prod")).toBe("prod");
|
|
155
|
+
expect(defaultEnv({ zoom: "composites" }, null)).toBe(null);
|
|
156
|
+
// the source graph in such a bundle is written env=, so a reload keeps it
|
|
157
|
+
expect(writeViewQuery("", { zoom: "composites", env: null }, { env: defaultEnv({ env: "frozen" }, null) })).toBe("?zoom=composites&env=");
|
|
158
|
+
});
|
|
159
|
+
});
|
package/web/why.js
CHANGED
|
@@ -178,7 +178,7 @@ export function chainView(answer) {
|
|
|
178
178
|
// The ci tag.
|
|
179
179
|
const t = c.tag;
|
|
180
180
|
if (t.state === "revoked" && t.revoked) row("ci tag", t.revoked.tag, ["revoked", t.revoked.phase ? `phase ${t.revoked.phase} failed` : null, t.revoked.tagged].filter(Boolean).join(" · "), t.revoked.source);
|
|
181
|
-
else if (t.state === "green" && t.green) row("ci tag", t.green.tag, [t.green.signer ? `signed by ${t.green.signer}` :
|
|
181
|
+
else if (t.state === "green" && t.green) row("ci tag", t.green.tag, [t.green.signer ? `signed by ${t.green.signer}` : null, t.green.tagged].filter(Boolean).join(" · "), t.green.source);
|
|
182
182
|
else row("ci tag", "no green tag", t.ignored.length ? t.ignored.map((x) => `${x.tag} is ${x.status}: ${x.reason}`).join("; ") : "", null, true);
|
|
183
183
|
|
|
184
184
|
// The release that shipped it, and the gate resolution that let it through.
|
package/web/why.test.js
CHANGED
|
@@ -115,7 +115,7 @@ describe("chainView (#682)", () => {
|
|
|
115
115
|
expect(rows[1].source).toBeNull();
|
|
116
116
|
expect(rows[1].meta).toBe("the commit fell in its window, which does not link them");
|
|
117
117
|
expect(rows[2].source.open).toBe(`git show refs/tags/ci/green/${LINKED}`);
|
|
118
|
-
expect(rows[2].meta).toBe("
|
|
118
|
+
expect(rows[2].meta).toBe("");
|
|
119
119
|
expect(rows[3].meta).toBe("cut from this commit · cut by alice at 2026-10-16T10:00:00.000Z");
|
|
120
120
|
expect(rows[3].source.open).toBe(`git show chant/lifecycle:_members/delivery/_releases/${DIGEST.replace(/:/g, "_")}.json`);
|
|
121
121
|
expect(rows[4].meta).toBe("prod-release in prod");
|
package/web/workspace-gates.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
// running behold. A gate that needs a signed approval gets a button only when
|
|
9
9
|
// behold holds that person's key.
|
|
10
10
|
|
|
11
|
+
import { HOST_ANSWERS, loosePointTitle, placePoints, pointLines } from "./decision-points.js";
|
|
12
|
+
|
|
11
13
|
/** Where the approver's name came from, in the words a button's tooltip uses. */
|
|
12
14
|
const SOURCE_WORDS = {
|
|
13
15
|
header: "from your sign-in",
|
|
@@ -21,37 +23,52 @@ export const HOST_APPROVES = "approve in the host that framed this graph";
|
|
|
21
23
|
/**
|
|
22
24
|
* Cards for a gates answer. `embed` is whether behold is framed; `member`
|
|
23
25
|
* narrows to one member's gates when a host opened behold on it (the rest are
|
|
24
|
-
* counted, not hidden without a word).
|
|
26
|
+
* counted, not hidden without a word). `points` is the points answer (#472):
|
|
27
|
+
* each open question is drawn on the card of the gate that waits on it, and
|
|
28
|
+
* one no waiting gate names gets a card of its own after the gates.
|
|
25
29
|
*/
|
|
26
|
-
export function gateCards(answer, { embed = false, member = null } = {}) {
|
|
30
|
+
export function gateCards(answer, { embed = false, member = null, points = null } = {}) {
|
|
27
31
|
const all = (answer && answer.gates) || [];
|
|
28
32
|
const shown = member ? all.filter((g) => g.member === member) : all;
|
|
33
|
+
const { byGate, loose } = placePoints((points && points.points) || [], all);
|
|
29
34
|
const cards = shown.map((g) => {
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
if (g.planDigest) facts.push(`plan ${shortDigest(g.planDigest)}`);
|
|
34
|
-
if (g.approvals.length) facts.push(`approved by ${g.approvals.map((a) => a.principal).join(", ")}`);
|
|
35
|
-
const card = {
|
|
36
|
-
key: g.key,
|
|
37
|
-
member: g.member,
|
|
38
|
-
title: `${g.member}: ${g.op} waits at gate ${g.gate}`,
|
|
39
|
-
facts: facts.join(" · "),
|
|
40
|
-
command: g.approve,
|
|
41
|
-
};
|
|
42
|
-
if (embed) card.note = HOST_APPROVES;
|
|
43
|
-
else Object.assign(card, approveAffordance(g, answer));
|
|
35
|
+
const card = gateCard(g, answer, embed);
|
|
36
|
+
const asks = byGate.get(g.key);
|
|
37
|
+
if (asks) card.points = asks.map((p) => pointLines(p, { embed }));
|
|
44
38
|
return card;
|
|
45
39
|
});
|
|
40
|
+
for (const p of loose) cards.push({ key: `point/${p.id}`, member: null, ...pointLines(p, { embed }), title: loosePointTitle(p), point: true });
|
|
46
41
|
const elsewhere = all.length - shown.length;
|
|
47
|
-
return { cards, elsewhere, refusal: (answer && answer.refusal) || null };
|
|
42
|
+
return { cards, elsewhere, refusal: (answer && answer.refusal) || null, pointsRefusal: (points && points.refusal) || null };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function gateCard(g, answer, embed) {
|
|
46
|
+
if (g.override) return overrideCard(g);
|
|
47
|
+
// #472: a gate that asks a decision point counts no approvals; its point's quorum decides.
|
|
48
|
+
const facts = g.answer ? [] : [`${g.approvals.length} of ${g.needed} approval${g.needed === 1 ? "" : "s"}`];
|
|
49
|
+
if (g.env) facts.push(`env ${g.env}`);
|
|
50
|
+
if (g.planDigest) facts.push(`plan ${shortDigest(g.planDigest)}`);
|
|
51
|
+
if (g.approvals.length) facts.push(`approved by ${g.approvals.map((a) => a.principal).join(", ")}`);
|
|
52
|
+
const card = {
|
|
53
|
+
key: g.key,
|
|
54
|
+
member: g.member,
|
|
55
|
+
title: g.answer ? `${g.member}: ${g.op} waits at gate ${g.gate} on decision point ${g.answer.point}` : `${g.member}: ${g.op} waits at gate ${g.gate}`,
|
|
56
|
+
facts: facts.join(" · "),
|
|
57
|
+
command: g.approve,
|
|
58
|
+
};
|
|
59
|
+
if (embed) card.note = g.answer ? HOST_ANSWERS : HOST_APPROVES;
|
|
60
|
+
else Object.assign(card, approveAffordance(g, answer));
|
|
61
|
+
return card;
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
/**
|
|
51
65
|
* #690: the button, or the note in its place, for a standalone card. The label
|
|
52
|
-
* says who the approval is recorded as before the click.
|
|
66
|
+
* says who the approval is recorded as before the click. A gate that waits on
|
|
67
|
+
* a decision point gets no button (#472): `chant approve` refuses it, and the
|
|
68
|
+
* question is answered elsewhere.
|
|
53
69
|
*/
|
|
54
70
|
export function approveAffordance(g, answer) {
|
|
71
|
+
if (g.answer) return { note: `waits on decision point ${g.answer.point}, which behold doesn't answer. Run ${g.approve}` };
|
|
55
72
|
const refusal = answer && answer.approverRefusal;
|
|
56
73
|
if (refusal) return { note: `can't approve here: ${refusal.error}. Run ${g.approve}` };
|
|
57
74
|
const id = (answer && answer.approverIdentity) || null;
|