@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
package/web/app.js
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// renderPanelView never rewrites, so the select mounts once and survives re-renders).
|
|
11
11
|
import "./view-repo.js"; // behold#571: first, so every read carries the page's ?repo=
|
|
12
12
|
import { createRefreshQueue } from "./refresh-queue.js";
|
|
13
|
-
import {
|
|
13
|
+
import { indexCompositeMembers } from "./composite-members.js";
|
|
14
|
+
import { readViewQuery, writeViewQuery, settleView, settlePlace, refusalLine, withOpening, defaultEnv } from "./view-url.js";
|
|
14
15
|
import { quietCardLines, readEmbed, selectMessage, viewFromMessage, wheelPx, wheelZoomsBare } from "./embed.js";
|
|
15
16
|
import { WORDS as POP_WORDS, cardRoot as popCardRoot, placePopover, popReduce, popState, resourcePopover, rootPopover } from "./kiosk-popover.js";
|
|
16
17
|
import { waveListKey, waveListOf } from "./kiosk-wave-list.js";
|
|
@@ -22,8 +23,10 @@ import { laneElement as tgLane, rootOfCard as tgRootOfCard, historyElement as tg
|
|
|
22
23
|
import { renderLane } from "./terragucci-lifecycle.js";
|
|
23
24
|
import { renderReleases } from "./releases.js";
|
|
24
25
|
import { renderTrunkLane } from "./trunk-lane.js";
|
|
26
|
+
import { startLocalRuns } from "./local-run.js";
|
|
25
27
|
import { entriesFor as csEntriesFor, gapLines as csGapLines, inspectHeading as csInspectHeading, nodeMarks as csNodeMarks, offGraph as csOffGraph, overlayHeader as csHeader, overlayLegend as csLegend, PREVIEW_NOTE as CS_PREVIEW_NOTE } from "./change-set-overlay.js";
|
|
26
28
|
import { collisionFilter as coFilter, collisionHeader as coHeader, collisionMarks as coMarks, collisionsFor as coFor, COLLISION_NOTE as CO_NOTE, FILES_NOTE as CO_FILES_NOTE, FILTER_OFF as CO_FILTER_OFF, FILTER_ON as CO_FILTER_ON, gapLines as coGapLines, hideEdge as coHideEdge, itemRow as coItemRow, nodeRow as coNodeRow, sideLines as coSideLines } from "./collision-marks.js";
|
|
29
|
+
import { dimEdge as hmDimEdge, HEALTH_NOTE as HM_NOTE, healthHeader as hmHeader, healthLegendRows as hmLegendRows, healthMarks as hmMarks, healthRows as hmRows, memberLines as hmMemberLines } from "./health-marks.js";
|
|
27
30
|
import { flagMarks as flFlagMarks, flagRow as flFlagRow, flagsFor as flFlagsFor, flagsHeader as flHeader, gapLines as flGapLines, NODES_NOTE as FL_NODES_NOTE, pickEnv as flPickEnv, STALE_COLOR as FL_STALE_COLOR, TURN_ON_NOTE as FL_TURN_ON_NOTE } from "./feature-flags.js";
|
|
28
31
|
import { renderYodelLane } from "./sql-yodeler-lane.js";
|
|
29
32
|
import { initTerragucciEstate } from "./terragucci-estate.js";
|
|
@@ -118,6 +121,7 @@ import { ehStore, ehStored } from "./event-help-store.js";
|
|
|
118
121
|
// which commit, approved by whom — and, when the ledger's run id cannot be
|
|
119
122
|
// followed, the reason in words rather than a guessed link.
|
|
120
123
|
import { releaseRows } from "./release.js";
|
|
124
|
+
import { renderExportNote } from "./export-note.js";
|
|
121
125
|
import { danglingFor, danglingRows, danglingHeading, DANGLING_EXPLAINED } from "./dangling.js";
|
|
122
126
|
import { comparisonRow, comparisonSummary } from "./cross-env.js";
|
|
123
127
|
// The marker-vs-derived mark on a choudoufu card: how its identity was found.
|
|
@@ -142,6 +146,10 @@ const embedOpts = readEmbed(location.search);
|
|
|
142
146
|
if (embedOpts.theme && !setTheme(embedOpts.theme, { persist: false })) console.warn(`behold: no theme named ${embedOpts.theme}`);
|
|
143
147
|
if (embedOpts.embed) document.documentElement.classList.add("embed");
|
|
144
148
|
if (embedOpts.embed && embedOpts.bare) document.documentElement.classList.add("bare"); // #569: the graph alone, for a kiosk
|
|
149
|
+
// The kiosk on a phone: one finger scrolls the page and two pan or zoom the graph. A one-finger pan held most of the
|
|
150
|
+
// screen, so any scroll over the graph moved it and paused Watch.
|
|
151
|
+
const kioskTouch = () => !!(embedOpts.embed && embedOpts.bare) && typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches;
|
|
152
|
+
if (kioskTouch()) document.documentElement.classList.add("kiosk-touch");
|
|
145
153
|
initPanel({ embed: embedOpts.embed, phone: typeof matchMedia === "function" && matchMedia(INSPECT_PHONE_QUERY).matches });
|
|
146
154
|
mountThemePicker(document.getElementById("panel-theme"));
|
|
147
155
|
|
|
@@ -369,6 +377,9 @@ if (staticMode) {
|
|
|
369
377
|
} catch {
|
|
370
378
|
/* no manifest → apiFetch falls back to a not-captured error */
|
|
371
379
|
}
|
|
380
|
+
// #824: the line `behold export --note` put at the page's foot.
|
|
381
|
+
const noteEl = document.getElementById("export-note");
|
|
382
|
+
if (noteEl) renderExportNote(noteEl, document, manifest);
|
|
372
383
|
}
|
|
373
384
|
|
|
374
385
|
/** Canonical key for a read URL — path + the lens params (whitelisted, sorted)
|
|
@@ -1048,6 +1059,12 @@ function inspect(node) {
|
|
|
1048
1059
|
panel.appendChild(row);
|
|
1049
1060
|
}
|
|
1050
1061
|
}
|
|
1062
|
+
// #825: runtime health from chant lifecycle health, and a record's rotation.
|
|
1063
|
+
const hmInspect = hmAnswer && hmAnswer.env === view.env ? hmRows(hmAnswer, node.id) : [];
|
|
1064
|
+
if (hmInspect.length) {
|
|
1065
|
+
const add = section(`runtime health · ${hmAnswer.env}`);
|
|
1066
|
+
for (const [k, v] of hmInspect) add(k, v);
|
|
1067
|
+
}
|
|
1051
1068
|
// #684: the in-flight work items colliding on this card.
|
|
1052
1069
|
const coRows = coAnswer && coOn ? coFor(coAnswer, node.id) : [];
|
|
1053
1070
|
if (coRows.length) {
|
|
@@ -2599,7 +2616,8 @@ let selectedNodeId = null;
|
|
|
2599
2616
|
let viewUrlReady = false; // nothing is written back until the link has been read
|
|
2600
2617
|
function openFromQuery() {
|
|
2601
2618
|
viewUrlReady = true;
|
|
2602
|
-
|
|
2619
|
+
// #827: a static export can name the view it opens on; the link's own query wins.
|
|
2620
|
+
applyWantedView(withOpening(manifest && manifest.opening, readViewQuery(location.search)));
|
|
2603
2621
|
}
|
|
2604
2622
|
|
|
2605
2623
|
/**
|
|
@@ -2716,17 +2734,46 @@ function loadWorkspaceGates({ force = false } = {}) {
|
|
|
2716
2734
|
// env the view has left never lands under the one it moved to.
|
|
2717
2735
|
const seq = ++wsGates.seq;
|
|
2718
2736
|
wsGates.env = env;
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
.
|
|
2728
|
-
|
|
2729
|
-
|
|
2737
|
+
// #472: the open decision points ride with the gates, so a question lands on
|
|
2738
|
+
// the card of the gate that waits on it in the same paint.
|
|
2739
|
+
const read = (url) =>
|
|
2740
|
+
fetch(url)
|
|
2741
|
+
.then((r) => r.json())
|
|
2742
|
+
.catch(() => null);
|
|
2743
|
+
Promise.all([read(`/api/workspace/gates${env ? `?env=${encodeURIComponent(env)}` : ""}`), read("/api/workspace/points")]).then(([gates, points]) => {
|
|
2744
|
+
if (seq !== wsGates.seq) return;
|
|
2745
|
+
wsGates.answer = gates;
|
|
2746
|
+
wsGates.points = points;
|
|
2747
|
+
paintWorkspaceGates();
|
|
2748
|
+
});
|
|
2749
|
+
}
|
|
2750
|
+
/** #472: one open decision point's lines, inside a gate's card or as its own. */
|
|
2751
|
+
function pointBlock(p) {
|
|
2752
|
+
const box = document.createElement("div");
|
|
2753
|
+
box.className = "ws-point";
|
|
2754
|
+
box.dataset.point = p.id;
|
|
2755
|
+
const title = document.createElement("div");
|
|
2756
|
+
title.className = "ws-gate-title";
|
|
2757
|
+
title.textContent = p.title;
|
|
2758
|
+
const question = document.createElement("div");
|
|
2759
|
+
question.className = "ws-point-question";
|
|
2760
|
+
question.textContent = p.question;
|
|
2761
|
+
const facts = document.createElement("div");
|
|
2762
|
+
facts.className = "ws-gate-facts";
|
|
2763
|
+
facts.textContent = p.facts;
|
|
2764
|
+
const note = document.createElement("div");
|
|
2765
|
+
note.className = "ws-gate-note";
|
|
2766
|
+
note.textContent = p.note;
|
|
2767
|
+
note.title = p.command;
|
|
2768
|
+
box.append(title, question, facts, note);
|
|
2769
|
+
if (p.showCommand) {
|
|
2770
|
+
// Text a person copies; behold never runs it.
|
|
2771
|
+
const line = document.createElement("code");
|
|
2772
|
+
line.className = "ws-point-command";
|
|
2773
|
+
line.textContent = p.command;
|
|
2774
|
+
box.appendChild(line);
|
|
2775
|
+
}
|
|
2776
|
+
return box;
|
|
2730
2777
|
}
|
|
2731
2778
|
function paintWorkspaceGates() {
|
|
2732
2779
|
const host = document.getElementById("ws-gates");
|
|
@@ -2737,8 +2784,14 @@ function paintWorkspaceGates() {
|
|
|
2737
2784
|
host.hidden = true;
|
|
2738
2785
|
return;
|
|
2739
2786
|
}
|
|
2740
|
-
const { cards, elsewhere, refusal } = gateCards(answer, { embed: embedOpts.embed, member: embedOpts.embed ? view.member : null });
|
|
2787
|
+
const { cards, elsewhere, refusal, pointsRefusal } = gateCards(answer, { embed: embedOpts.embed, member: embedOpts.embed ? view.member : null, points: wsGates.points });
|
|
2741
2788
|
for (const c of cards) {
|
|
2789
|
+
if (c.point) {
|
|
2790
|
+
const own = pointBlock(c);
|
|
2791
|
+
own.classList.add("ws-gate");
|
|
2792
|
+
host.appendChild(own);
|
|
2793
|
+
continue;
|
|
2794
|
+
}
|
|
2742
2795
|
const box = document.createElement("div");
|
|
2743
2796
|
box.className = "ws-gate";
|
|
2744
2797
|
box.dataset.gate = c.key;
|
|
@@ -2761,6 +2814,7 @@ function paintWorkspaceGates() {
|
|
|
2761
2814
|
b.title = c.button.title;
|
|
2762
2815
|
box.appendChild(b);
|
|
2763
2816
|
}
|
|
2817
|
+
for (const p of c.points || []) box.appendChild(pointBlock(p));
|
|
2764
2818
|
host.appendChild(box);
|
|
2765
2819
|
}
|
|
2766
2820
|
if (elsewhere) {
|
|
@@ -2776,6 +2830,13 @@ function paintWorkspaceGates() {
|
|
|
2776
2830
|
err.title = refusal.remedy || "";
|
|
2777
2831
|
host.appendChild(err);
|
|
2778
2832
|
}
|
|
2833
|
+
if (pointsRefusal) {
|
|
2834
|
+
const err = document.createElement("div");
|
|
2835
|
+
err.className = "ws-gate ws-gate-note";
|
|
2836
|
+
err.textContent = `decision points unread: ${pointsRefusal.error}`;
|
|
2837
|
+
err.title = pointsRefusal.remedy || "";
|
|
2838
|
+
host.appendChild(err);
|
|
2839
|
+
}
|
|
2779
2840
|
host.hidden = !host.children.length;
|
|
2780
2841
|
}
|
|
2781
2842
|
function approveWorkspaceGate(key, btn) {
|
|
@@ -2908,7 +2969,7 @@ function syncViewUrl() {
|
|
|
2908
2969
|
focus: view.focus,
|
|
2909
2970
|
run: view.run,
|
|
2910
2971
|
};
|
|
2911
|
-
const defaults = { env: (projectInfo && projectInfo.currentEnv)
|
|
2972
|
+
const defaults = { env: defaultEnv(manifest && manifest.opening, projectInfo && projectInfo.currentEnv), lens: savedColourMode };
|
|
2912
2973
|
const next = location.pathname + writeViewQuery(location.search, state, defaults) + location.hash;
|
|
2913
2974
|
if (next === location.pathname + location.search + location.hash) return;
|
|
2914
2975
|
try {
|
|
@@ -3021,6 +3082,7 @@ function renderPanelModel() {
|
|
|
3021
3082
|
} else if (dm) {
|
|
3022
3083
|
host.appendChild(panelMuted("attribute drift not read — the overlay is ownership only. ⌘K → “Re-check live with plan”."));
|
|
3023
3084
|
}
|
|
3085
|
+
renderHealthLegend(host); // #825: runtime health, beside drift and apart from it
|
|
3024
3086
|
// The actionable nodes — foreign (adoptable) and pending (not applied yet).
|
|
3025
3087
|
const attention = ir.nodes.filter((n) => {
|
|
3026
3088
|
const s = n.attrs && n.attrs._status;
|
|
@@ -3623,7 +3685,15 @@ function mountLiveCarve(g, svgEl) {
|
|
|
3623
3685
|
}
|
|
3624
3686
|
if (!on && kioskShot) queueMicrotask(() => applyKioskShot(true));
|
|
3625
3687
|
},
|
|
3626
|
-
})
|
|
3688
|
+
})
|
|
3689
|
+
.then(fitClearOfRail)
|
|
3690
|
+
.catch((err) => console.warn("live carve:", err));
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
/** behold#729: the rail mounts after the graph's first fit; a view still at its fit or shot moves clear of it. */
|
|
3694
|
+
function fitClearOfRail() {
|
|
3695
|
+
if (kioskShot) applyKioskShot(false);
|
|
3696
|
+
else if (vbAtFit) fitGraph();
|
|
3627
3697
|
}
|
|
3628
3698
|
|
|
3629
3699
|
let tgLifecycle = null;
|
|
@@ -5608,7 +5678,7 @@ function kioskShotBox() {
|
|
|
5608
5678
|
}
|
|
5609
5679
|
kioskHeld = null;
|
|
5610
5680
|
document.documentElement.classList.remove("kiosk-held");
|
|
5611
|
-
return shotViewBox(kioskShotTarget(svg, kioskShot), pane, insets);
|
|
5681
|
+
return shotViewBox(kioskShotTarget(svg, kioskShot), pane, { ...insets, right: Math.max(insets.right, railInset(pane)) });
|
|
5612
5682
|
}
|
|
5613
5683
|
/** The whole-graph framing Watch holds on a small stage while the graph and the pane stay (web/kiosk-shot.js heldFrame); null on a bigger one. */
|
|
5614
5684
|
var kioskHeld = null;
|
|
@@ -6080,6 +6150,30 @@ function approveFromLane(key, env, btn) {
|
|
|
6080
6150
|
}
|
|
6081
6151
|
initTrunkLane();
|
|
6082
6152
|
|
|
6153
|
+
// --- behold#685: run a plan job locally ---------------------------------------
|
|
6154
|
+
// chant ci run plan --local at a commit, drawn in the runs pane's run view
|
|
6155
|
+
// beside CI's run of the same job. It starts a command, so it is drawn only
|
|
6156
|
+
// where behold may start one: a served workspace, never in a public view, an
|
|
6157
|
+
// embed, a static export, preview mode or a terragucci or SQL Yodeler repo.
|
|
6158
|
+
async function initLocalRuns() {
|
|
6159
|
+
if (staticMode || publicMode || embedOpts.embed) return;
|
|
6160
|
+
const project = await apiFetch("/api/project").then((r) => r.json()).catch(() => ({}));
|
|
6161
|
+
if (!project.workspace || project.previewMode || project.publicMode || project.terragucci || project.sqlYodeler) return;
|
|
6162
|
+
const host = addPanelTab("local-runs", "Local", "Run a CI plan job on this machine with chant ci run --local, beside CI's run of it.");
|
|
6163
|
+
if (!host) return;
|
|
6164
|
+
host.id = "tab-local-runs";
|
|
6165
|
+
let started = false;
|
|
6166
|
+
const start = () => {
|
|
6167
|
+
if (started) return;
|
|
6168
|
+
started = true;
|
|
6169
|
+
startLocalRuns(host, { fetchJson: (url, init) => fetch(url, init).then((r) => r.json()), events, toast: showToast });
|
|
6170
|
+
};
|
|
6171
|
+
const tab = document.querySelector('#panel-tabs button[data-tab="local-runs"]');
|
|
6172
|
+
if (tab) tab.addEventListener("click", start);
|
|
6173
|
+
if (host.classList.contains("active")) start();
|
|
6174
|
+
}
|
|
6175
|
+
initLocalRuns();
|
|
6176
|
+
|
|
6083
6177
|
// --- #683: feature flags, on or off per environment ---------------------------
|
|
6084
6178
|
// The Flags tab reads /api/workspace/flags when it is opened: each flag of the
|
|
6085
6179
|
// workspace with its owner, work item and value per environment, a flip
|
|
@@ -6394,6 +6488,117 @@ function renderCollisionsTab() {
|
|
|
6394
6488
|
}
|
|
6395
6489
|
initCollisions();
|
|
6396
6490
|
|
|
6491
|
+
// --- #825: runtime health and rotation ---------------------------------------
|
|
6492
|
+
// When the graph shows an environment, /api/health is read once for it (a
|
|
6493
|
+
// static export replays the captured snapshot): per card that has a health
|
|
6494
|
+
// read, healthy, unhealthy or unknown from `chant lifecycle health`, or a hole
|
|
6495
|
+
// with chant's reason when the read failed; and per Route 53 record whose
|
|
6496
|
+
// HealthCheckId names a declared check, its rotation. Health never touches a
|
|
6497
|
+
// card's fill, which stays the drift overlay's. A tag under the card says the
|
|
6498
|
+
// state, an unhealthy card gets a solid ring and a hole a dashed one, and a
|
|
6499
|
+
// record out of rotation is dimmed with its edges. "Re-check live" reads it
|
|
6500
|
+
// again with ?fresh=1.
|
|
6501
|
+
let hmAnswer = null;
|
|
6502
|
+
let hmLoading = null;
|
|
6503
|
+
function syncHealth(m) {
|
|
6504
|
+
// `progressive` is the overlay while members are still reading (#422).
|
|
6505
|
+
const drift = !!m && !!m.env && ["overlay", "progressive", "logical"].includes(m.mode);
|
|
6506
|
+
if (!drift || publicMode) {
|
|
6507
|
+
markHealthCards(null);
|
|
6508
|
+
return;
|
|
6509
|
+
}
|
|
6510
|
+
if (hmAnswer && hmAnswer.env === m.env) {
|
|
6511
|
+
markHealthCards(hmAnswer);
|
|
6512
|
+
return;
|
|
6513
|
+
}
|
|
6514
|
+
loadHealth(m.env, false);
|
|
6515
|
+
}
|
|
6516
|
+
async function loadHealth(env, fresh) {
|
|
6517
|
+
if (publicMode) return;
|
|
6518
|
+
if (hmLoading === env && !fresh) return;
|
|
6519
|
+
hmLoading = env;
|
|
6520
|
+
const answer = await apiFetch(`/api/health?env=${encodeURIComponent(env)}${fresh ? "&fresh=1" : ""}`)
|
|
6521
|
+
.then((r) => r.json())
|
|
6522
|
+
.catch((e) => ({ error: String(e) }));
|
|
6523
|
+
if (hmLoading !== env) return; // a newer env was asked for meanwhile
|
|
6524
|
+
hmLoading = null;
|
|
6525
|
+
hmAnswer = { ...answer, env };
|
|
6526
|
+
if (view.env === env) {
|
|
6527
|
+
markHealthCards(hmAnswer);
|
|
6528
|
+
renderPanel();
|
|
6529
|
+
}
|
|
6530
|
+
}
|
|
6531
|
+
function markHealthCards(a) {
|
|
6532
|
+
const svg = document.querySelector("#graph svg");
|
|
6533
|
+
if (!svg) return;
|
|
6534
|
+
for (const old of svg.querySelectorAll("[data-hm-mark]")) old.remove();
|
|
6535
|
+
for (const d of svg.querySelectorAll("[data-hm-dim]")) {
|
|
6536
|
+
d.removeAttribute("data-hm-dim");
|
|
6537
|
+
d.style.opacity = "";
|
|
6538
|
+
}
|
|
6539
|
+
if (!a) return;
|
|
6540
|
+
const ids = [...svg.querySelectorAll("[data-node-id]")].map((g) => g.getAttribute("data-node-id"));
|
|
6541
|
+
for (const [id, mk] of Object.entries(hmMarks(a, ids))) {
|
|
6542
|
+
const g = svg.querySelector('[data-node-id="' + CSS.escape(id) + '"]');
|
|
6543
|
+
if (!g) continue;
|
|
6544
|
+
const rect = g.querySelector("rect");
|
|
6545
|
+
const box = rect && rect.getBBox ? rect.getBBox() : { x: 0, y: 0, width: 150, height: 60 };
|
|
6546
|
+
if (mk.ring) {
|
|
6547
|
+
const ring = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
6548
|
+
ring.setAttribute("data-hm-mark", "ring");
|
|
6549
|
+
for (const [k, v] of Object.entries({ x: box.x - 3, y: box.y - 3, width: box.width + 6, height: box.height + 6, rx: 8, fill: "none", stroke: mk.color, "stroke-width": 2, "pointer-events": "none" })) ring.setAttribute(k, String(v));
|
|
6550
|
+
if (mk.ring === "dashed") ring.setAttribute("stroke-dasharray", "4 4");
|
|
6551
|
+
g.appendChild(ring);
|
|
6552
|
+
}
|
|
6553
|
+
const tag = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
6554
|
+
tag.setAttribute("data-hm-mark", "tag");
|
|
6555
|
+
tag.setAttribute("x", String(box.x));
|
|
6556
|
+
// Under the card, where the flag tag sits (#683): above it, a card in a
|
|
6557
|
+
// box's top row would run into the box's own header.
|
|
6558
|
+
tag.setAttribute("y", String(box.y + box.height + 13));
|
|
6559
|
+
tag.setAttribute("font-size", "11");
|
|
6560
|
+
tag.setAttribute("font-weight", "700");
|
|
6561
|
+
tag.setAttribute("fill", mk.color);
|
|
6562
|
+
tag.textContent = `● ${mk.tag}`;
|
|
6563
|
+
const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
|
|
6564
|
+
title.textContent = mk.title;
|
|
6565
|
+
tag.appendChild(title);
|
|
6566
|
+
g.appendChild(tag);
|
|
6567
|
+
if (mk.dim) {
|
|
6568
|
+
// The card and its own text go faint; the tag under it stays legible.
|
|
6569
|
+
for (const child of g.children) {
|
|
6570
|
+
if (child.hasAttribute("data-hm-mark")) continue;
|
|
6571
|
+
child.setAttribute("data-hm-dim", "1");
|
|
6572
|
+
child.style.opacity = "0.35";
|
|
6573
|
+
}
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
for (const e of svg.querySelectorAll("g[data-edge-from]")) {
|
|
6577
|
+
if (!hmDimEdge(a, e.getAttribute("data-edge-from"), e.getAttribute("data-edge-to"))) continue;
|
|
6578
|
+
e.setAttribute("data-hm-dim", "1");
|
|
6579
|
+
e.style.opacity = "0.25";
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6582
|
+
/** The Model tab's health legend, under the drift legend. */
|
|
6583
|
+
function renderHealthLegend(host) {
|
|
6584
|
+
if (!hmAnswer || hmAnswer.env !== view.env || publicMode) return;
|
|
6585
|
+
const h = hmHeader(hmAnswer);
|
|
6586
|
+
const heading = panelHeading(h.text);
|
|
6587
|
+
heading.title = h.title || HM_NOTE;
|
|
6588
|
+
if (h.tone === "refusal") heading.style.color = "var(--degraded)";
|
|
6589
|
+
host.appendChild(heading);
|
|
6590
|
+
for (const r of hmLegendRows(hmAnswer)) host.appendChild(panelDotRow(r.color, r.text, r.count));
|
|
6591
|
+
for (const [id, r] of Object.entries(hmAnswer.rotation || {})) {
|
|
6592
|
+
if (r.inRotation !== false) continue;
|
|
6593
|
+
host.appendChild(panelDotRow("var(--degraded)", id, "out of rotation", () => selectNode(id)));
|
|
6594
|
+
}
|
|
6595
|
+
for (const l of hmMemberLines(hmAnswer)) {
|
|
6596
|
+
const p = panelMuted(l.text);
|
|
6597
|
+
p.title = l.title;
|
|
6598
|
+
host.appendChild(p);
|
|
6599
|
+
}
|
|
6600
|
+
}
|
|
6601
|
+
|
|
6397
6602
|
// --- #681: a waiting gate's change set, on the graph -------------------------
|
|
6398
6603
|
// Opened from a gate card's "change set" link in the Trunk tab. The server
|
|
6399
6604
|
// reads the gate from status and the stored change set from chant change-set
|
|
@@ -7141,6 +7346,7 @@ function resetDialCaches() {
|
|
|
7141
7346
|
|
|
7142
7347
|
// Composite → member list, for the inspect pane. Derived once from the base
|
|
7143
7348
|
// (attribute-tier) source graph, where every node carries its `compositeInstance`
|
|
7349
|
+
// (indexed by web/composite-members.js, #828)
|
|
7144
7350
|
// — then a detail-1 composite node lists what it expands to. Cached per lens
|
|
7145
7351
|
// (reset in resetDialCaches); structural, so no live/env call needed.
|
|
7146
7352
|
let compositeMembersCache = null;
|
|
@@ -7150,9 +7356,7 @@ async function getCompositeMembers(instanceId) {
|
|
|
7150
7356
|
try {
|
|
7151
7357
|
const q = lensParams(new URLSearchParams({ detail: "3" }));
|
|
7152
7358
|
const j = await apiFetch(`/api/graph?${q}`).then((r) => r.json());
|
|
7153
|
-
|
|
7154
|
-
if (n.compositeInstance) (compositeMembersCache[n.compositeInstance] ||= []).push({ id: n.id, kind: n.kind });
|
|
7155
|
-
}
|
|
7359
|
+
compositeMembersCache = indexCompositeMembers(j.ir && j.ir.nodes);
|
|
7156
7360
|
} catch {
|
|
7157
7361
|
/* leave the cache empty — the members section shows "(no members found)" */
|
|
7158
7362
|
}
|
|
@@ -8307,7 +8511,9 @@ function render(ir, svg, m) {
|
|
|
8307
8511
|
}
|
|
8308
8512
|
// #712: only the dots preview's meta carries `dots`. #715: a live carve, when the gate opened.
|
|
8309
8513
|
if (svgEl && m && m.dots) {
|
|
8310
|
-
mountDots({ host: g, svg: svgEl, meta: m, vbInit: vbInit.slice(), getVB: () => vb, setVB: (a) => { vb = a.slice(); vbAtFit = false; applyVB(); } })
|
|
8514
|
+
mountDots({ host: g, svg: svgEl, meta: m, vbInit: vbInit.slice(), getVB: () => vb, setVB: (a) => { vb = a.slice(); vbAtFit = false; applyVB(); } })
|
|
8515
|
+
.then(fitClearOfRail)
|
|
8516
|
+
.catch((err) => console.warn("dots preview:", err));
|
|
8311
8517
|
} else if (svgEl && liveCarve) mountLiveCarve(g, svgEl);
|
|
8312
8518
|
else unmountDots();
|
|
8313
8519
|
ensureZoomControls(g);
|
|
@@ -8325,6 +8531,7 @@ function render(ir, svg, m) {
|
|
|
8325
8531
|
if (csAnswer) markChangeSetCards(); // #681: and the change set a gate binds, as a preview
|
|
8326
8532
|
if (flAnswer) markFlagCards(); // #683: and the feature flags of each flagged member
|
|
8327
8533
|
if (coAnswer) markCollisionCards(); // #684: and the nodes two in-flight work items touch
|
|
8534
|
+
syncHealth(m); // #825: and runtime health, with the records out of rotation
|
|
8328
8535
|
applyLayout(); // #228: last, so the hand-placed deltas ride on top of every other pass
|
|
8329
8536
|
drawTgReads(); // #568: after the layout, so the reads lines meet the cards where they now sit
|
|
8330
8537
|
renderDial();
|
|
@@ -8479,6 +8686,21 @@ function panelInsets(pane) {
|
|
|
8479
8686
|
: { left: 0, right: Math.min(cap, Math.max(0, pane.right - r.left)) };
|
|
8480
8687
|
}
|
|
8481
8688
|
|
|
8689
|
+
// behold#729: the dots zoom rail floats on the pane's right edge, so a fit or a
|
|
8690
|
+
// kiosk shot that ignores it leaves the rightmost cards under it. Read at fit
|
|
8691
|
+
// time like the panel: Watch hides it, a held stage and a directing carve fade
|
|
8692
|
+
// it out, and then it covers nothing.
|
|
8693
|
+
const RAIL_GAP = 8;
|
|
8694
|
+
function railInset(pane) {
|
|
8695
|
+
const rail = document.querySelector("#dots-ui .dots-rail");
|
|
8696
|
+
if (!rail) return 0;
|
|
8697
|
+
const cs = getComputedStyle(rail);
|
|
8698
|
+
if (cs.display === "none" || cs.visibility === "hidden" || Number(cs.opacity) === 0) return 0;
|
|
8699
|
+
const r = rail.getBoundingClientRect();
|
|
8700
|
+
if (!r.width || r.bottom <= pane.top || r.top >= pane.bottom || r.left >= pane.right) return 0;
|
|
8701
|
+
return Math.min(pane.width * 0.3, Math.max(0, pane.right - r.left + RAIL_GAP));
|
|
8702
|
+
}
|
|
8703
|
+
|
|
8482
8704
|
/**
|
|
8483
8705
|
* The viewBox that fits the whole graph into the pane's UNCOVERED part.
|
|
8484
8706
|
*
|
|
@@ -8496,7 +8718,8 @@ function fittedViewBox() {
|
|
|
8496
8718
|
const pane = host.getBoundingClientRect();
|
|
8497
8719
|
const [x0, y0, w0, h0] = vbInit;
|
|
8498
8720
|
if (!(pane.width > 0 && pane.height > 0 && w0 > 0 && h0 > 0)) return null;
|
|
8499
|
-
const { left, right } = panelInsets(pane);
|
|
8721
|
+
const { left, right: panelRight } = panelInsets(pane);
|
|
8722
|
+
const right = Math.max(panelRight, railInset(pane));
|
|
8500
8723
|
const band = Math.max(1, pane.width - left - right);
|
|
8501
8724
|
const s = Math.min(band / w0, pane.height / h0);
|
|
8502
8725
|
const vw = pane.width / s;
|
|
@@ -8720,6 +8943,9 @@ function ensureZoomControls(host) {
|
|
|
8720
8943
|
const s = currentSvg();
|
|
8721
8944
|
if (!touch || !vb || !s) return;
|
|
8722
8945
|
const pts = touchPoints(e);
|
|
8946
|
+
// The kiosk on a phone leaves one finger to the page's scroll, until a gesture has had two.
|
|
8947
|
+
if (kioskTouch() && pts.length < 2 && !touch.pinched) return;
|
|
8948
|
+
if (pts.length >= 2) touch.pinched = true;
|
|
8723
8949
|
const r = s.getBoundingClientRect();
|
|
8724
8950
|
e.preventDefault();
|
|
8725
8951
|
if (pts.length >= 2 && touch.pts.length >= 2) {
|
|
@@ -8750,7 +8976,7 @@ function ensureZoomControls(host) {
|
|
|
8750
8976
|
{ passive: false },
|
|
8751
8977
|
);
|
|
8752
8978
|
host.addEventListener("touchend", (e) => {
|
|
8753
|
-
touch = e.touches.length ? { pts: touchPoints(e), moved: !!(touch && touch.moved) } : null;
|
|
8979
|
+
touch = e.touches.length ? { pts: touchPoints(e), moved: !!(touch && touch.moved), pinched: !!(touch && touch.pinched) } : null;
|
|
8754
8980
|
});
|
|
8755
8981
|
let drag = false;
|
|
8756
8982
|
let px = 0;
|
|
@@ -9623,6 +9849,7 @@ async function refresh() {
|
|
|
9623
9849
|
if (!res.ok) throw new Error((await res.json()).error || res.statusText);
|
|
9624
9850
|
const { ir, svg, meta: m, captured } = await res.json();
|
|
9625
9851
|
render(ir, svg, m);
|
|
9852
|
+
if (view.env) loadHealth(view.env, true); // #825: health moves on its own; read it again too
|
|
9626
9853
|
nowline(captured ? "↻ refreshed — new lanes frame" : "↻ refreshed — no change");
|
|
9627
9854
|
} catch (err) {
|
|
9628
9855
|
meta.textContent = prev;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// behold#828: a composites-zoom card's member list. The inspect pane derives it
|
|
2
|
+
// from the attribute-tier graph, where every member carries its
|
|
3
|
+
// `compositeInstance` and `compositeParent`. chant keys a collapsed composite by
|
|
4
|
+
// its instance name, and when two composites share that name (an AWS
|
|
5
|
+
// FargateAlb and a GCP CloudRunServiceComposite both exported as `web`) it
|
|
6
|
+
// names them `<instance>@<CompositeType>` (chant#4178). So each member is
|
|
7
|
+
// listed under both keys, and a card finds its own members whichever id it has.
|
|
8
|
+
//
|
|
9
|
+
// Pure logic, no DOM.
|
|
10
|
+
|
|
11
|
+
/** Member lists by composite id: `<instance>` and `<instance>@<compositeParent>`. */
|
|
12
|
+
export function indexCompositeMembers(nodes) {
|
|
13
|
+
const out = {};
|
|
14
|
+
for (const n of nodes || []) {
|
|
15
|
+
if (!n.compositeInstance) continue;
|
|
16
|
+
const member = { id: n.id, kind: n.kind };
|
|
17
|
+
(out[n.compositeInstance] ||= []).push(member);
|
|
18
|
+
if (n.compositeParent) (out[`${n.compositeInstance}@${n.compositeParent}`] ||= []).push(member);
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { indexCompositeMembers } from "./composite-members.js";
|
|
3
|
+
|
|
4
|
+
const nodes = [
|
|
5
|
+
{ id: "webCluster", kind: "AWS::ECS::Cluster", compositeInstance: "web", compositeParent: "FargateAlb" },
|
|
6
|
+
{ id: "webService", kind: "AWS::ECS::Service", compositeInstance: "web", compositeParent: "FargateAlb" },
|
|
7
|
+
{ id: "GcpwebService", kind: "RunService", compositeInstance: "web", compositeParent: "CloudRunServiceComposite" },
|
|
8
|
+
{ id: "zone", kind: "AWS::Route53::HostedZone" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
describe("indexCompositeMembers (#828)", () => {
|
|
12
|
+
it("lists each of two same-named composites under chant's split id", () => {
|
|
13
|
+
const idx = indexCompositeMembers(nodes);
|
|
14
|
+
expect(idx["web@FargateAlb"].map((m) => m.id)).toEqual(["webCluster", "webService"]);
|
|
15
|
+
expect(idx["web@CloudRunServiceComposite"]).toEqual([{ id: "GcpwebService", kind: "RunService" }]);
|
|
16
|
+
});
|
|
17
|
+
it("keeps the bare instance id for a composite whose name is its own", () => {
|
|
18
|
+
const idx = indexCompositeMembers([{ id: "a", kind: "K", compositeInstance: "app", compositeParent: "Thing" }]);
|
|
19
|
+
expect(idx.app).toEqual([{ id: "a", kind: "K" }]);
|
|
20
|
+
});
|
|
21
|
+
it("leaves out nodes no composite owns", () => {
|
|
22
|
+
expect(Object.values(indexCompositeMembers(nodes)).flat().some((m) => m.id === "zone")).toBe(false);
|
|
23
|
+
expect(indexCompositeMembers(undefined)).toEqual({});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// #472: a workspace's open decision points, drawn where they belong. Pure:
|
|
2
|
+
// app.js fetches /api/workspace/points beside /api/workspace/gates and paints
|
|
3
|
+
// what these return.
|
|
4
|
+
//
|
|
5
|
+
// A gate that asks a decision point (chant#3170) names its open question as
|
|
6
|
+
// `answer.id`, and the point read lists the same id, so the question is drawn
|
|
7
|
+
// on that gate's card. A question no waiting gate names gets a card of its own
|
|
8
|
+
// in the gate strip. behold answers none of them: framed, the host's rail does
|
|
9
|
+
// (arugula-salad/arugula#621); standalone, the card gives chant's line to run.
|
|
10
|
+
|
|
11
|
+
/** The words a framed point card uses where a standalone one gives the line. */
|
|
12
|
+
export const HOST_ANSWERS = "answer it in the rail of the host that framed this graph";
|
|
13
|
+
/** The words a standalone point card puts before chant's line. */
|
|
14
|
+
export const STANDALONE_ANSWERS = "behold doesn't answer decision points. Answer it at the workspace root:";
|
|
15
|
+
|
|
16
|
+
/** Who may answer, in words: `2 people holding maintainer`. */
|
|
17
|
+
export function whoAnswers(quorum) {
|
|
18
|
+
const count = (quorum && quorum.count) || 1;
|
|
19
|
+
const roles = (quorum && quorum.roles) || [];
|
|
20
|
+
return `${count} ${count === 1 ? "person" : "people"}${roles.length ? ` holding ${roles.join(" or ")}` : ""}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const shown = (v) => (typeof v === "boolean" ? (v ? "yes" : "no") : String(v));
|
|
24
|
+
|
|
25
|
+
/** One point as the lines a card draws: the question, who may answer, the facts, and how to answer it elsewhere. */
|
|
26
|
+
export function pointLines(p, { embed = false } = {}) {
|
|
27
|
+
const facts = [];
|
|
28
|
+
if (p.candidates && p.candidates.length) facts.push(`answers: ${p.candidates.map(shown).join(", ")}`);
|
|
29
|
+
facts.push(`${whoAnswers(p.quorum)} may answer`);
|
|
30
|
+
if (p.state === "proposed" && p.model) facts.push(`a model proposes ${shown(p.model.answer)}${p.model.confidence !== null ? ` (${Math.round(p.model.confidence * 100)}%)` : ""}, waiting for a person to confirm it`);
|
|
31
|
+
else if (p.model && p.model.answer !== null) facts.push(`a model answered ${shown(p.model.answer)} below its threshold`);
|
|
32
|
+
if (p.askedBy) facts.push(`asked by steward ${p.askedBy}`);
|
|
33
|
+
if (p.askedOn) facts.push(`asked ${p.askedOn}`);
|
|
34
|
+
if (p.stale) facts.push("the point changed since it was asked");
|
|
35
|
+
return {
|
|
36
|
+
id: p.id,
|
|
37
|
+
title: `decision point ${p.point}: ${p.title}`,
|
|
38
|
+
question: p.question,
|
|
39
|
+
facts: facts.join(" · "),
|
|
40
|
+
command: p.command,
|
|
41
|
+
// Standalone, the card shows `command` after the note, as text to copy.
|
|
42
|
+
note: embed ? HOST_ANSWERS : STANDALONE_ANSWERS,
|
|
43
|
+
showCommand: !embed,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Place each open point: on the card of the waiting gate whose `answer.id`
|
|
49
|
+
* names it (`byGate`, by gate key), or on its own (`loose`). `gates` is the
|
|
50
|
+
* gates answer's list, `points` the points answer's.
|
|
51
|
+
*/
|
|
52
|
+
export function placePoints(points, gates) {
|
|
53
|
+
const byId = new Map();
|
|
54
|
+
for (const g of gates || []) if (g.answer && g.answer.id) byId.set(g.answer.id, g.key);
|
|
55
|
+
const byGate = new Map();
|
|
56
|
+
const loose = [];
|
|
57
|
+
for (const p of points || []) {
|
|
58
|
+
const key = byId.get(p.id);
|
|
59
|
+
if (key) byGate.set(key, [...(byGate.get(key) || []), p]);
|
|
60
|
+
else loose.push(p);
|
|
61
|
+
}
|
|
62
|
+
return { byGate, loose };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The title of a point card that no waiting gate here names. */
|
|
66
|
+
export function loosePointTitle(p) {
|
|
67
|
+
const lines = pointLines(p);
|
|
68
|
+
if (!p.gate) return lines.title;
|
|
69
|
+
return `${lines.title} (asked by gate ${p.gate.op}/${p.gate.gate}${p.gate.env ? ` in ${p.gate.env}` : ""})`;
|
|
70
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { HOST_ANSWERS, placePoints, pointLines, STANDALONE_ANSWERS, whoAnswers } from "./decision-points.js";
|
|
3
|
+
import { gateCards, HOST_APPROVES } from "./workspace-gates.js";
|
|
4
|
+
|
|
5
|
+
const GATE_Q = "staging-apply-ec72c7930446";
|
|
6
|
+
const LOOSE_Q = "launch-tier-1f278d6a8207";
|
|
7
|
+
const command = (id) => `chant workspace points answer ${id} --answer <value> --by <name>`;
|
|
8
|
+
|
|
9
|
+
// What /api/workspace/points answers for src/__fixtures__/decision-points/.
|
|
10
|
+
const points = {
|
|
11
|
+
workspace: true,
|
|
12
|
+
points: [
|
|
13
|
+
{ id: LOOSE_Q, point: "launch-tier", title: "Which tier the launch goes out on", question: "Pick the tier the launch goes out on.", questionType: "choice", candidates: ["small", "large"], subject: "L-7", gate: null, state: "escalated", quorum: { count: 1, roles: [] }, model: null, askedOn: "2026-10-20", askedBy: null, stale: false, path: `answers/${LOOSE_Q}.md`, command: command(LOOSE_Q) },
|
|
14
|
+
{ id: GATE_Q, point: "staging-apply", title: "Apply this plan to staging", question: "Should this plan be applied to staging?", questionType: "noul", candidates: [true, false], subject: "gate:deploy/approve-apply@staging", gate: { op: "deploy", gate: "approve-apply", env: "staging" }, state: "escalated", quorum: { count: 2, roles: ["maintainer"] }, model: null, askedOn: "2026-10-20", askedBy: null, stale: false, path: `answers/${GATE_Q}.md`, command: command(GATE_Q) },
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const gates = {
|
|
19
|
+
workspace: true,
|
|
20
|
+
env: "staging",
|
|
21
|
+
approver: "alex",
|
|
22
|
+
gates: [
|
|
23
|
+
{ key: "web/deploy/approve-apply", member: "web", op: "deploy", gate: "approve-apply", env: "staging", planDigest: null, approvals: [], needed: 1, signed: false, approve: command(GATE_Q), answer: { point: "staging-apply", id: GATE_Q, path: `answers/${GATE_Q}.md` } },
|
|
24
|
+
{ key: "api/ship/go", member: "api", op: "ship", gate: "go", env: "staging", planDigest: null, approvals: [], needed: 1, signed: false, approve: "chant approve ship go --env staging" },
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe("pointLines (#472)", () => {
|
|
29
|
+
it("says the question, who may answer, and gives chant's line standalone", () => {
|
|
30
|
+
const l = pointLines(points.points[1]);
|
|
31
|
+
expect(l).toMatchObject({ title: "decision point staging-apply: Apply this plan to staging", question: "Should this plan be applied to staging?", note: STANDALONE_ANSWERS, command: command(GATE_Q), showCommand: true });
|
|
32
|
+
expect(l.facts).toBe("answers: yes, no · 2 people holding maintainer may answer · asked 2026-10-20");
|
|
33
|
+
});
|
|
34
|
+
it("sends a framed reader to the host's rail", () => {
|
|
35
|
+
expect(pointLines(points.points[1], { embed: true })).toMatchObject({ note: HOST_ANSWERS, showCommand: false });
|
|
36
|
+
});
|
|
37
|
+
it("names a model's proposal waiting for a person", () => {
|
|
38
|
+
const l = pointLines({ ...points.points[0], state: "proposed", model: { answer: "large", confidence: 0.91, threshold: 0.8, model: "m" } });
|
|
39
|
+
expect(l.facts).toContain("a model proposes large (91%), waiting for a person to confirm it");
|
|
40
|
+
});
|
|
41
|
+
it("counts who may answer", () => {
|
|
42
|
+
expect(whoAnswers({ count: 1, roles: [] })).toBe("1 person");
|
|
43
|
+
expect(whoAnswers({ count: 3, roles: ["sre", "owner"] })).toBe("3 people holding sre or owner");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("placePoints (#472)", () => {
|
|
48
|
+
it("puts a question on the gate whose answer names it, and the rest on their own", () => {
|
|
49
|
+
const { byGate, loose } = placePoints(points.points, gates.gates);
|
|
50
|
+
expect([...byGate.keys()]).toEqual(["web/deploy/approve-apply"]);
|
|
51
|
+
expect(byGate.get("web/deploy/approve-apply").map((p) => p.id)).toEqual([GATE_Q]);
|
|
52
|
+
expect(loose.map((p) => p.id)).toEqual([LOOSE_Q]);
|
|
53
|
+
});
|
|
54
|
+
it("puts every question on its own when no gate names one", () => {
|
|
55
|
+
expect(placePoints(points.points, []).loose).toHaveLength(2);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("gate cards with decision points (#472)", () => {
|
|
60
|
+
it("draws the question on its gate, no approve button, and the loose question after the gates", () => {
|
|
61
|
+
const { cards } = gateCards(gates, { points });
|
|
62
|
+
const [asks, plain, loose] = cards;
|
|
63
|
+
expect(asks).toMatchObject({ key: "web/deploy/approve-apply", title: "web: deploy waits at gate approve-apply on decision point staging-apply", facts: "env staging" });
|
|
64
|
+
expect(asks.button).toBeUndefined();
|
|
65
|
+
expect(asks.note).toContain("which behold doesn't answer");
|
|
66
|
+
expect(asks.points.map((p) => p.id)).toEqual([GATE_Q]);
|
|
67
|
+
expect(plain.button).toMatchObject({ label: "Approve as alex" });
|
|
68
|
+
expect(plain.points).toBeUndefined();
|
|
69
|
+
expect(loose).toMatchObject({ key: `point/${LOOSE_Q}`, point: true, title: "decision point launch-tier: Which tier the launch goes out on", command: command(LOOSE_Q) });
|
|
70
|
+
});
|
|
71
|
+
it("framed, sends the point's gate to the rail and keeps the plain gate's note", () => {
|
|
72
|
+
const { cards } = gateCards(gates, { embed: true, points });
|
|
73
|
+
expect(cards[0].note).toBe(HOST_ANSWERS);
|
|
74
|
+
expect(cards[1].note).toBe(HOST_APPROVES);
|
|
75
|
+
expect(cards.some((c) => c.button)).toBe(false);
|
|
76
|
+
expect(cards[0].points[0].showCommand).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
it("names the gate a loose question was asked by when that gate waits elsewhere", () => {
|
|
79
|
+
const { cards } = gateCards({ ...gates, gates: [gates.gates[1]] }, { points });
|
|
80
|
+
expect(cards.find((c) => c.key === `point/${GATE_Q}`).title).toBe("decision point staging-apply: Apply this plan to staging (asked by gate deploy/approve-apply in staging)");
|
|
81
|
+
});
|
|
82
|
+
it("passes the points refusal through, and draws the gates as before without a points answer", () => {
|
|
83
|
+
const refusal = { error: "Decision points needs chant 0.107.0 or newer.", code: "chant-too-old" };
|
|
84
|
+
expect(gateCards(gates, { points: { workspace: true, points: [], refusal } }).pointsRefusal).toEqual(refusal);
|
|
85
|
+
expect(gateCards(gates).cards).toHaveLength(2);
|
|
86
|
+
});
|
|
87
|
+
});
|