@intentius/behold 0.29.43 → 0.29.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +77 -0
- package/dist/cli.js +4065 -1918
- package/package.json +1 -1
- package/web/app.js +1469 -74
- package/web/carve-narration.js +33 -1
- package/web/chant-live-pace.js +138 -0
- package/web/chant-live-pace.test.js +116 -0
- package/web/chant-pr-marks.js +417 -39
- package/web/chant-pr-marks.test.js +208 -4
- package/web/collision-marks.js +124 -0
- package/web/collision-marks.test.js +89 -0
- package/web/cone.js +269 -0
- package/web/cone.test.js +213 -0
- package/web/dots-live.test.js +151 -1
- package/web/dots-lod.js +20 -0
- package/web/dots-lod.test.js +19 -1
- package/web/dots-scene.js +110 -10
- package/web/dots.js +144 -31
- package/web/embed.js +1 -1
- package/web/event-help-modal.js +98 -3
- package/web/event-help-modal.test.js +85 -1
- package/web/feature-flags.js +143 -0
- package/web/feature-flags.test.js +96 -0
- package/web/index.html +33 -0
- package/web/kiosk-carve.js +59 -6
- package/web/kiosk-demo-frame.test.js +27 -0
- package/web/kiosk-event-help-ui.js +186 -20
- package/web/kiosk-event-help.js +175 -15
- package/web/kiosk-event-help.test.js +58 -1
- package/web/kiosk-highlight.test.js +249 -0
- package/web/kiosk-metrics.js +4 -3
- package/web/kiosk-runs.js +8 -5
- package/web/kiosk-shot.js +157 -3
- package/web/kiosk-shot.test.js +223 -1
- package/web/kiosk-source.js +43 -0
- package/web/kiosk-source.test.js +39 -0
- package/web/kiosk-story-gate.test.js +44 -0
- package/web/kiosk-track.js +312 -0
- package/web/kiosk-track.test.js +148 -0
- package/web/kiosk-unknown-step.test.js +58 -0
- package/web/kiosk-vendor.js +73 -4
- package/web/kiosk-vendor.test.js +103 -3
- package/web/kiosk-watch.js +154 -1
- package/web/kiosk-watch.test.js +53 -1
- package/web/kiosk.html +57 -22
- package/web/kiosk.js +583 -53
- package/web/kiosk.test.js +2 -1
- package/web/small-stage.test.js +150 -0
- package/web/terragucci-blocked.test.js +192 -0
- package/web/terragucci-change.js +197 -17
- package/web/terragucci-components-live.js +189 -13
- package/web/terragucci-live-pace.js +92 -0
- package/web/terragucci-wave-results.test.js +125 -0
- package/web/terralith.html +7 -7
- package/web/tg-outside.js +124 -0
- package/web/tg-outside.test.js +100 -0
- package/web/tg-read-pills.js +145 -0
- package/web/tg-read-pills.test.js +158 -0
- package/web/theme.js +13 -1
- package/web/theme.test.js +21 -1
- package/web/tooltip.js +19 -7
- package/web/tooltip.test.js +15 -0
- package/web/tours/terralith.json +4 -4
- package/web/trunk-lane.test.js +1 -1
- package/web/view-url.js +8 -2
- package/web/why.js +129 -1
- package/web/why.test.js +113 -1
package/web/terragucci-change.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
// run view without the composed fields draws as before.
|
|
22
22
|
|
|
23
23
|
import { ago, clock, hrefOf } from "./terragucci.js";
|
|
24
|
+
import { coneFact, coneOf, coneResourceLines, fallbackWhy } from "./cone.js";
|
|
24
25
|
|
|
25
26
|
export const STATE_WORDS = {
|
|
26
27
|
"not-started": "queued",
|
|
@@ -54,6 +55,9 @@ export function changeStage(answer, progress) {
|
|
|
54
55
|
*/
|
|
55
56
|
export function readEdges(answer, progress) {
|
|
56
57
|
const stage = changeStage(answer, progress);
|
|
58
|
+
// Two choudoufu roots: the reader reads the estate's outputs (terraform_estate_outputs); there is no state file to read.
|
|
59
|
+
const bin = (answer && answer.binaries) || {};
|
|
60
|
+
const estate = (from, to) => (bin[from] === "choudoufu" && bin[to] === "choudoufu" ? { estate: true } : {});
|
|
57
61
|
if (stage === "pull-request") {
|
|
58
62
|
const run = answer.pull_request.compose && answer.pull_request.compose.wave;
|
|
59
63
|
return answer.pull_request.reads.map((r) => ({
|
|
@@ -64,6 +68,7 @@ export function readEdges(answer, progress) {
|
|
|
64
68
|
unknown: r.unknown || [],
|
|
65
69
|
...(r.why ? { why: r.why } : {}),
|
|
66
70
|
...(r.composed && run !== undefined ? { composed: run } : {}),
|
|
71
|
+
...estate(r.root, r.upstream),
|
|
67
72
|
stage,
|
|
68
73
|
}));
|
|
69
74
|
}
|
|
@@ -78,6 +83,7 @@ export function readEdges(answer, progress) {
|
|
|
78
83
|
unknown: [],
|
|
79
84
|
stage,
|
|
80
85
|
wave: r.wave,
|
|
86
|
+
...estate(r.root, up),
|
|
81
87
|
// #568 step 3: both ends in one composed run: the read is inside it.
|
|
82
88
|
...(r.composed && runOf.get(up) === r.composed.wave ? { composed: r.composed.wave } : {}),
|
|
83
89
|
})),
|
|
@@ -94,7 +100,7 @@ export function readLine(e) {
|
|
|
94
100
|
const unknown = e.unknown.length ? `, read before known, known once ${e.to}'s part of the run applies: ${list(e.unknown)}` : "";
|
|
95
101
|
return `${e.from} reads ${e.to}${via}, in wave ${e.composed}'s composed run${unknown}`;
|
|
96
102
|
}
|
|
97
|
-
const what = e.outputs === "planned" ? `${e.to}'s planned outputs` : `${e.to}'s state as it stands`;
|
|
103
|
+
const what = e.outputs === "planned" ? `${e.to}'s planned outputs` : e.estate ? `${e.to}'s outputs as they stand` : `${e.to}'s state as it stands`;
|
|
98
104
|
const unknown = e.unknown.length ? `, read before known, known after ${e.to} applies: ${list(e.unknown)}` : "";
|
|
99
105
|
const why = e.why ? ` (${e.why})` : "";
|
|
100
106
|
return `${e.from} reads ${what}${via}${unknown}${why}`;
|
|
@@ -446,6 +452,127 @@ export const STATE_TONE = {
|
|
|
446
452
|
unchanged: "idle",
|
|
447
453
|
};
|
|
448
454
|
|
|
455
|
+
/** behold#741: the tone chant's blocked cards carry (web/chant-pr-marks.js), on a story's blocked root. */
|
|
456
|
+
export const BLOCKED_TONE = "wait";
|
|
457
|
+
|
|
458
|
+
const sameCommit = (a, b) => !!a && !!b && (a.startsWith(b) || b.startsWith(a));
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* behold#741 (terragucci#1161): the roots the run view's run blocked, each
|
|
462
|
+
* with its wave and the root whose failure held it (`by`), from the wave
|
|
463
|
+
* reports' `waves[].blocked` (/api/terragucci's `blocked`, report minor 41)
|
|
464
|
+
* when they are of the run view's commit. A wave the run view says is
|
|
465
|
+
* `blocked` holds every root of it, by the root its report names, or by
|
|
466
|
+
* nobody named when its report is not read yet. Empty for older reports
|
|
467
|
+
* and run views, which carry neither: they read exactly as before.
|
|
468
|
+
*/
|
|
469
|
+
export function blockedOf(answer, progress) {
|
|
470
|
+
const out = new Map();
|
|
471
|
+
const run = progress && !progress.error && progress.run && progress.run.present ? progress.run : null;
|
|
472
|
+
const b = answer && !answer.error && answer.blocked && answer.blocked.roots && typeof answer.blocked.roots === "object" ? answer.blocked : null;
|
|
473
|
+
// A wave the run view has not started yet has no report to block anything (a paced view holds it there too).
|
|
474
|
+
const notStarted = new Set((progress && Array.isArray(progress.states) ? progress.states : []).filter((w) => w.state === "not-started").map((w) => w.number));
|
|
475
|
+
if (b && (!run || !run.commit || sameCommit(b.commit, run.commit))) {
|
|
476
|
+
for (const [root, x] of Object.entries(b.roots)) if (x && typeof x.by === "string" && x.by && !(Number.isInteger(x.wave) && notStarted.has(x.wave))) out.set(root, { wave: Number.isInteger(x.wave) ? x.wave : null, by: x.by });
|
|
477
|
+
}
|
|
478
|
+
for (const w of progress && Array.isArray(progress.states) ? progress.states : []) {
|
|
479
|
+
if (w.state !== "blocked") continue;
|
|
480
|
+
for (const root of w.roots || []) if (!out.has(root)) out.set(root, { wave: w.number, by: null });
|
|
481
|
+
}
|
|
482
|
+
return out;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* behold#741: each root's own apply outcome in its wave (`applied`,
|
|
487
|
+
* `unchanged` or `failed`, with the error), from the wave reports
|
|
488
|
+
* (/api/terragucci's `outcomes`) of the run view's commit, for a wave the run
|
|
489
|
+
* view has started. Empty for reports without one.
|
|
490
|
+
*/
|
|
491
|
+
export function outcomesOf(answer, progress) {
|
|
492
|
+
const out = new Map();
|
|
493
|
+
const run = progress && !progress.error && progress.run && progress.run.present ? progress.run : null;
|
|
494
|
+
const o = answer && !answer.error && answer.outcomes && answer.outcomes.roots && typeof answer.outcomes.roots === "object" ? answer.outcomes : null;
|
|
495
|
+
if (!o || (run && run.commit && !sameCommit(o.commit, run.commit))) return out;
|
|
496
|
+
const notStarted = new Set((progress && Array.isArray(progress.states) ? progress.states : []).filter((w) => w.state === "not-started").map((w) => w.number));
|
|
497
|
+
for (const [root, x] of Object.entries(o.roots)) {
|
|
498
|
+
if (!x || !["applied", "unchanged", "failed"].includes(x.outcome)) continue;
|
|
499
|
+
if (Number.isInteger(x.wave) && notStarted.has(x.wave)) continue;
|
|
500
|
+
out.set(root, { wave: Number.isInteger(x.wave) ? x.wave : null, outcome: x.outcome, ...(typeof x.error === "string" && x.error ? { error: x.error } : {}) });
|
|
501
|
+
}
|
|
502
|
+
return out;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** behold#741: "blocked by cluster-a", or "blocked" when the report names no root. */
|
|
506
|
+
export const blockedWords = (x) => (x && x.by ? `blocked by ${x.by}` : "blocked");
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* behold#741: a wave's outcome as its header says it once some of its roots
|
|
510
|
+
* are blocked: "3 applied, 6 blocked by cluster-a", "6 blocked by cluster-a"
|
|
511
|
+
* when none ran, with each blocker named when there are several. Null when
|
|
512
|
+
* none of its roots is blocked.
|
|
513
|
+
*/
|
|
514
|
+
export function blockedHeader(roots, blocked, state) {
|
|
515
|
+
const held = roots.filter((r) => blocked.has(r));
|
|
516
|
+
if (!held.length) return null;
|
|
517
|
+
const by = [...new Set(held.map((r) => blocked.get(r).by).filter(Boolean))].sort();
|
|
518
|
+
const words = `${held.length} blocked${by.length ? ` by ${and(by)}` : ""}`;
|
|
519
|
+
const ran = roots.length - held.length;
|
|
520
|
+
if (!ran || state === "blocked") return words;
|
|
521
|
+
return state === "applied" ? `${ran} applied, ${words}` : `${ran} ${STATE_WORDS[state] || state}, ${words}`;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* behold#751: a wave's result as its own report says it (/api/terragucci's
|
|
526
|
+
* `results`, by commit), for the commit the run that applied it is of. A
|
|
527
|
+
* wave's job is no witness to it: terragucci ends the job of a wave that
|
|
528
|
+
* applied what it planned and blocked the rest as a failure (terragucci#1161),
|
|
529
|
+
* so the commit status isn't green while roots are unapplied. `after` is when
|
|
530
|
+
* the job started: a report finished before it is an earlier run's on the
|
|
531
|
+
* commit, and says nothing of this one. Null without a report of the wave,
|
|
532
|
+
* where the job's status is all there is.
|
|
533
|
+
*/
|
|
534
|
+
export function waveResultOf(answer, commit, wave, { after = null } = {}) {
|
|
535
|
+
const all = answer && !answer.error && answer.results && typeof answer.results === "object" ? answer.results : null;
|
|
536
|
+
if (!all || typeof commit !== "string" || !commit || !Number.isInteger(wave)) return null;
|
|
537
|
+
const key = Object.keys(all).find((c) => sameCommit(c, commit));
|
|
538
|
+
const r = key && Array.isArray(all[key]) ? all[key].find((x) => x && x.wave === wave && typeof x.state === "string") : null;
|
|
539
|
+
if (!r) return null;
|
|
540
|
+
const done = Date.parse(r.finished);
|
|
541
|
+
const start = after ? Date.parse(after) : NaN;
|
|
542
|
+
if (Number.isFinite(done) && Number.isFinite(start) && done < start) return null;
|
|
543
|
+
return r;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** behold#751: whether a wave's report says the wave itself failed (a root of its own failed, or the wave was refused). */
|
|
547
|
+
export const resultFailed = (r) => !!r && (r.state === "failed" || r.state === "refused");
|
|
548
|
+
|
|
549
|
+
/** behold#751: whether a wave's report says it held roots back: some blocked, or the whole wave. */
|
|
550
|
+
export const resultBlocked = (r) => !!r && (r.state === "blocked" || (Array.isArray(r.blocked) && r.blocked.length > 0));
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* behold#751: a wave's result in words, from its report: "applied 6, 6
|
|
554
|
+
* blocked by cluster-a" for a wave that applied what it planned and blocked
|
|
555
|
+
* the rest, "6 blocked by cluster-a" for one that ran nothing, "1 failed, 1
|
|
556
|
+
* applied" for one a root of its own failed, else its state ("applied").
|
|
557
|
+
*/
|
|
558
|
+
export function resultWords(r) {
|
|
559
|
+
if (!r) return null;
|
|
560
|
+
const held = Array.isArray(r.blocked) ? r.blocked : [];
|
|
561
|
+
const by = [...new Set(held.map((b) => b && b.by).filter(Boolean))].sort();
|
|
562
|
+
const blocked = held.length ? `${held.length} blocked${by.length ? ` by ${and(by)}` : ""}` : null;
|
|
563
|
+
const ran = (Array.isArray(r.applied) ? r.applied.length : 0) + (Array.isArray(r.unchanged) ? r.unchanged.length : 0);
|
|
564
|
+
if (r.state === "applied") return blocked ? `applied ${ran}, ${blocked}` : "applied";
|
|
565
|
+
if (r.state === "blocked") return blocked || "blocked";
|
|
566
|
+
if (r.state === "failed") {
|
|
567
|
+
const failed = Array.isArray(r.failed) ? r.failed.length : 0;
|
|
568
|
+
return failed ? `${failed} failed${ran ? `, ${ran} applied` : ""}${blocked ? `, ${blocked}` : ""}` : "failed";
|
|
569
|
+
}
|
|
570
|
+
return STATE_WORDS[r.state] || r.state;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** behold#751: the tone a wave's result is drawn in: blocked's for one that held roots back, bad for a failure. */
|
|
574
|
+
export const resultTone = (r) => (resultFailed(r) ? "bad" : resultBlocked(r) ? BLOCKED_TONE : r && r.state === "applied" ? "ok" : "idle");
|
|
575
|
+
|
|
449
576
|
/**
|
|
450
577
|
* #569 review: whether a root of a run-view wave plans a change. A root its
|
|
451
578
|
* wave planned without a change (`changed`, the roots whose plan changes a
|
|
@@ -479,12 +606,13 @@ const MEMBER_STATE = { applied: "applied", partial: "failed", failed: "failed",
|
|
|
479
606
|
* run that failed part way takes its own part's outcome: what applied says
|
|
480
607
|
* applied.
|
|
481
608
|
*/
|
|
482
|
-
export function rootStates(answer, progress) {
|
|
609
|
+
export function rootStates(answer, progress, { story = false } = {}) {
|
|
483
610
|
const stage = changeStage(answer, progress);
|
|
484
611
|
const roots = {};
|
|
485
612
|
const known = (answer && answer.roots ? answer.roots.map((r) => r.path) : []).filter(Boolean);
|
|
486
613
|
if (stage === "pull-request") {
|
|
487
614
|
const pr = answer.pull_request;
|
|
615
|
+
const cone = coneOf(pr);
|
|
488
616
|
for (const w of pr.waves) {
|
|
489
617
|
const c = w.composed;
|
|
490
618
|
const members = c ? c.members.map((m) => m.root) : [];
|
|
@@ -502,25 +630,45 @@ export function rootStates(answer, progress) {
|
|
|
502
630
|
else if (w.review_digest || w.set_digest) facts.push(`plan ${short(w.review_digest || w.set_digest)}`);
|
|
503
631
|
if (c && c.held_by_unknown && c.held_by_unknown.includes(root)) facts.push("reads a value unknown when planned");
|
|
504
632
|
if (w.waits) facts.push("will wait for an approval");
|
|
505
|
-
|
|
633
|
+
// Report minor 34: a cone plan says its size, or why choudoufu planned the whole estate, on the root's own box.
|
|
634
|
+
const cr = cone ? cone.roots.find((x) => x.root === root) : null;
|
|
635
|
+
const cf = cr && (cr.kind === "cone" || cr.kind === "full") ? coneFact(cr) : null;
|
|
636
|
+
const said = cr && cr.kind === "cone" ? `planned · ${cf}` : cf || "planned";
|
|
637
|
+
const lines = cr ? coneResourceLines(cr) : [];
|
|
638
|
+
roots[root] = { wave: w.number, state: "planned", tone: STATE_TONE.planned, words: `wave ${w.number} · ${said}${c ? ", composed" : ""}`, facts: cf ? [cf, ...(fallbackWhy(cr) ? [fallbackWhy(cr)] : []), ...facts] : facts, ...(cr ? { cone: cr.kind } : {}), ...(lines.length ? { lines } : {}) };
|
|
506
639
|
}
|
|
507
640
|
}
|
|
508
|
-
|
|
641
|
+
// With a cone view, a root the pull request's plan holds nothing of is said to be not planned.
|
|
642
|
+
for (const root of known) if (!roots[root]) roots[root] = { wave: null, state: "outside", tone: STATE_TONE.outside, words: cone ? "not planned" : "unchanged", facts: [], ...(cone ? { cone: "not-planned" } : {}) };
|
|
509
643
|
return { stage, roots };
|
|
510
644
|
}
|
|
511
645
|
if (stage === "apply") {
|
|
512
646
|
const composedOf = new Map(progress.reads.filter((r) => r.composed).map((r) => [r.root, r.composed.wave]));
|
|
647
|
+
// behold#741: the roots the run blocked; none for reports and run views before terragucci#1161.
|
|
648
|
+
// Only on a kiosk telling a chapter-carrying scenario (`story`): every other view reads the states exactly as before.
|
|
649
|
+
const blocked = story ? blockedOf(answer, progress) : new Map();
|
|
650
|
+
const outcomes = story ? outcomesOf(answer, progress) : new Map();
|
|
513
651
|
for (const w of progress.states) {
|
|
514
652
|
const c = w.composed;
|
|
515
653
|
const inRun = [...composedOf].filter(([, n]) => n === w.number).map(([r]) => r);
|
|
516
654
|
for (const root of [...new Set([...w.roots, ...(c ? c.roots : []), ...inRun])]) {
|
|
517
|
-
|
|
655
|
+
// A blocked root never planned, so its wave's `changed` leaves it out: it is blocked, not unchanged.
|
|
656
|
+
const held = blocked.get(root);
|
|
657
|
+
if (held) {
|
|
658
|
+
roots[root] = { wave: w.number, state: "blocked", tone: BLOCKED_TONE, words: `wave ${w.number} · ${blockedWords(held)}`, facts: [held.by ? `did not run: ${held.by} did not apply, and this depends on it` : "did not run: something it depends on did not apply"], ...(held.by ? { blockedBy: held.by } : {}) };
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
// behold#741: a root's own outcome in its wave, where the report says it: cluster-b applied beside a failed cluster-a.
|
|
662
|
+
// Only once its wave has settled as the (paced) run view shows it: never ahead of the play.
|
|
663
|
+
const own = ["applied", "failed", "refused", "blocked"].includes(w.state) ? outcomes.get(root) : undefined;
|
|
664
|
+
if (!rootChanges(w, root) || (own && own.outcome === "unchanged")) {
|
|
518
665
|
roots[root] = { wave: w.number, state: "unchanged", tone: STATE_TONE.unchanged, words: `wave ${w.number} · unchanged`, facts: [] };
|
|
519
666
|
continue;
|
|
520
667
|
}
|
|
521
668
|
const m = c && c.members ? c.members.find((x) => x.root === root) : null;
|
|
522
|
-
const state = m && m.apply ? MEMBER_STATE[m.apply] || w.state : w.state;
|
|
669
|
+
const state = m && m.apply ? MEMBER_STATE[m.apply] || w.state : own ? own.outcome : w.state;
|
|
523
670
|
const facts = [];
|
|
671
|
+
if (own && own.outcome === "failed" && own.error) facts.push(`failed: ${own.error}`);
|
|
524
672
|
if (state === "waiting" && w.digest) facts.push(`approve plan ${short(w.digest)}`);
|
|
525
673
|
if (state === "waiting" && c && c.unknown && c.unknown.includes(root)) facts.push("read a value unknown when planned");
|
|
526
674
|
const totals = totalsLine(w.totals);
|
|
@@ -535,7 +683,7 @@ export function rootStates(answer, progress) {
|
|
|
535
683
|
if (before.length) facts.push(`wave ${list(before)} stays applied`);
|
|
536
684
|
}
|
|
537
685
|
const words = `wave ${w.number} · ${STATE_WORDS[state] || state}${composedHere ? ", composed" : ""}`;
|
|
538
|
-
roots[root] = { wave: w.number, state, tone: STATE_TONE[state] || "idle", words, facts };
|
|
686
|
+
roots[root] = { wave: w.number, state, tone: STATE_TONE[state] || "idle", words, facts, ...(own && own.outcome === "failed" && own.error ? { error: own.error } : {}) };
|
|
539
687
|
}
|
|
540
688
|
}
|
|
541
689
|
for (const root of known) if (!roots[root]) roots[root] = { wave: null, state: "outside", tone: STATE_TONE.outside, words: "not in this run", facts: [] };
|
|
@@ -550,7 +698,7 @@ export function readLabel(e) {
|
|
|
550
698
|
return `reads ${e.to} in wave ${e.composed}'s composed run${e.unknown.length ? `: ${list(e.unknown)} known once ${e.to}'s part applies` : ""}`;
|
|
551
699
|
}
|
|
552
700
|
if (e.outputs === "planned") return e.unknown.length ? `reads ${list(e.unknown)} from ${e.to}, set when ${e.to} applies` : `reads ${e.to}'s planned outputs`;
|
|
553
|
-
return `reads ${e.to}'s applied state`;
|
|
701
|
+
return e.estate ? `reads ${e.to}'s outputs` : `reads ${e.to}'s applied state`;
|
|
554
702
|
}
|
|
555
703
|
|
|
556
704
|
/**
|
|
@@ -582,36 +730,68 @@ export function planFitsPin(pr, pin) {
|
|
|
582
730
|
* nothing is in flight; at `pull-…` only that pull request's plan, so another
|
|
583
731
|
* cycle's plan is never drawn as this one's. Anything else draws them as read.
|
|
584
732
|
*/
|
|
585
|
-
export function pinnedAnswer(answer, run) {
|
|
733
|
+
export function pinnedAnswer(answer, run, pull = null) {
|
|
586
734
|
if (!answer || answer.error) return answer;
|
|
587
735
|
const pin = pullPin(run);
|
|
588
736
|
if (run === "base" || (pin && !planFitsPin(answer.pull_request, pin))) return { ...answer, pull_request: null };
|
|
737
|
+
// A commit's run is the merge of the cycle's pull request (`pull`): another cycle's plan is never drawn for it.
|
|
738
|
+
if (pull && pinsCommit(run) && !mergedPull(answer.pull_request, pull)) return { ...answer, pull_request: null };
|
|
589
739
|
return answer;
|
|
590
740
|
}
|
|
591
741
|
|
|
742
|
+
/** Whether a pull request's plan is the one numbered `pull`. */
|
|
743
|
+
const mergedPull = (pr, pull) => !!pr && !!pr.run && String(pr.run.pull_request) === String(pull);
|
|
744
|
+
|
|
592
745
|
/**
|
|
593
746
|
* #569: the sentence above the boxes when the pin holds the view off every
|
|
594
|
-
* plan and run: the base,
|
|
595
|
-
*
|
|
747
|
+
* plan and run: the base, a pull request whose plan isn't written yet, or a
|
|
748
|
+
* merge whose run hasn't started and whose pull request's plan isn't read yet.
|
|
749
|
+
* Null when the view draws a plan or a run, and viewCaption says which.
|
|
596
750
|
*/
|
|
597
|
-
export function pinnedCaption(answer, run) {
|
|
751
|
+
export function pinnedCaption(answer, run, pull = null, progress = null) {
|
|
598
752
|
if (run === "base") return "Nothing in flight: the states went back to the base";
|
|
599
753
|
const pin = pullPin(run);
|
|
600
|
-
if (!pin
|
|
754
|
+
if (!pin) {
|
|
755
|
+
const ran = progress && !progress.error && progress.run && progress.run.present;
|
|
756
|
+
if (pull && pinsCommit(run) && !ran && !(answer && !answer.error && mergedPull(answer.pull_request, pull))) return `Pull request #${pull} is merged; the merge's run shows here once it starts`;
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
if (answer && !answer.error && planFitsPin(answer.pull_request, pin)) return null;
|
|
601
760
|
if (pin.pull === null) return "The pull request isn't open yet; its plan shows here once the plan job writes it";
|
|
602
761
|
return `Pull request #${pin.pull} is being planned; its plan shows here once the plan job writes it`;
|
|
603
762
|
}
|
|
604
763
|
|
|
605
|
-
/**
|
|
606
|
-
|
|
764
|
+
/**
|
|
765
|
+
* What the frame pinned to `run` still waits for, so it reads again soon:
|
|
766
|
+
* `plan`, the reports, while the pin's pull request's plan (or, for a merge,
|
|
767
|
+
* the cycle's pull request) isn't in them; `run`, the run view, while a
|
|
768
|
+
* merge's isn't written. Pure.
|
|
769
|
+
*/
|
|
770
|
+
export function pinWaits(answer, progress, run, pull = null) {
|
|
771
|
+
const read = !!answer && !answer.error;
|
|
772
|
+
const ran = !!progress && !progress.error && !!progress.run && !!progress.run.present;
|
|
773
|
+
const pin = pullPin(run);
|
|
774
|
+
const plan = read && !!run && run !== "base" && (pin ? !planFitsPin(answer.pull_request, pin) : !!pull && pinsCommit(run) && !ran && !mergedPull(answer.pull_request, pull));
|
|
775
|
+
return { plan, run: !!run && pinsCommit(run) && !ran };
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Which run the view's marks come from, dated: "the plan of pull request #201
|
|
780
|
+
* at 03:11 UTC, before the merge". `merged`: the view is pinned to the merge,
|
|
781
|
+
* whose run hasn't started yet, so the plan is said as what the merge's run
|
|
782
|
+
* follows. A run of a pull request planned as a cone says the merge plans each
|
|
783
|
+
* estate in full.
|
|
784
|
+
*/
|
|
785
|
+
export function viewCaption(answer, progress, now = new Date(), { merged = false } = {}) {
|
|
607
786
|
const stage = changeStage(answer, progress);
|
|
608
787
|
if (stage === "pull-request") {
|
|
609
788
|
const r = answer.pull_request.run;
|
|
610
|
-
return `the plan of pull request #${r.pull_request} at ${clock(r.finished, now)}, before the merge`;
|
|
789
|
+
return merged ? `the plan of pull request #${r.pull_request} at ${clock(r.finished, now)}; the merge's run starts next` : `the plan of pull request #${r.pull_request} at ${clock(r.finished, now)}, before the merge`;
|
|
611
790
|
}
|
|
612
791
|
if (stage === "apply") {
|
|
613
792
|
const r = progress.run;
|
|
614
|
-
|
|
793
|
+
const full = !!(answer && !answer.error && coneOf(answer.pull_request));
|
|
794
|
+
return full ? `the merge's run (${r.commit.slice(0, 8)}), planning each estate in full, as of ${clock(r.updated, now)}` : `the run of merge ${r.commit.slice(0, 8)}, as of ${clock(r.updated, now)}`;
|
|
615
795
|
}
|
|
616
796
|
return null;
|
|
617
797
|
}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
// wave that failed says the waves before it stay applied, and nothing here is
|
|
12
12
|
// all-or-nothing.
|
|
13
13
|
|
|
14
|
-
import { pinsCommit, rootStates } from "./terragucci-change.js";
|
|
14
|
+
import { BLOCKED_TONE, blockedHeader, blockedOf, pinsCommit, resultFailed, resultTone, resultWords, rootStates, totalsLine, waveResultOf } from "./terragucci-change.js";
|
|
15
|
+
import { shortReason } from "./chant-pr-marks.js";
|
|
16
|
+
import { rootNames } from "./cone.js";
|
|
15
17
|
|
|
16
18
|
/** A job's status as its wave box says it. A job held at a terragucci gate is never a failure. */
|
|
17
19
|
export const JOB_WORDS = {
|
|
@@ -38,6 +40,10 @@ export const SHORT_WORDS = {
|
|
|
38
40
|
failed: "failed",
|
|
39
41
|
unchanged: "unchanged",
|
|
40
42
|
outside: "not in this run",
|
|
43
|
+
// behold#741 (terragucci#1161): a root an upstream that did not apply held.
|
|
44
|
+
blocked: "blocked",
|
|
45
|
+
// behold#741: a story's later pull request (the fix) leaves out what landed before it.
|
|
46
|
+
"applied-earlier": "applied earlier",
|
|
41
47
|
};
|
|
42
48
|
|
|
43
49
|
const sameSha = (a, b) => !!a && !!b && (a.startsWith(b) || b.startsWith(a));
|
|
@@ -104,6 +110,20 @@ export function waveStatus(status, state) {
|
|
|
104
110
|
return { status: state, words: WAVE_WORDS[state], tone: toneOf(state), run: status.superseded };
|
|
105
111
|
}
|
|
106
112
|
|
|
113
|
+
/**
|
|
114
|
+
* behold#751: a wave's job status, unless the job failed and the wave's own
|
|
115
|
+
* report (`result`, terragucci-change.js waveResultOf) says the wave did not:
|
|
116
|
+
* terragucci ends the job of a wave that applied what it planned and blocked
|
|
117
|
+
* the rest as a failure (terragucci#1161), so the commit status isn't green
|
|
118
|
+
* while roots are unapplied. Then the box says what the report does, "applied
|
|
119
|
+
* 6, 6 blocked by cluster-a", in its tone (`report`). A wave the report says
|
|
120
|
+
* failed, and a job with no report of its wave, keep the job's status.
|
|
121
|
+
*/
|
|
122
|
+
export function reportStatus(status, result) {
|
|
123
|
+
if (!status || status.status !== "failure" || !result || resultFailed(result)) return status;
|
|
124
|
+
return { status: result.state === "blocked" ? "blocked" : "done", words: resultWords(result), tone: resultTone(result), report: true, ...(status.run ? { run: status.run } : {}) };
|
|
125
|
+
}
|
|
126
|
+
|
|
107
127
|
/** A status's words in a narrow box, where the full words cross an edge (behold#693): "held" for a wave held at its gate. */
|
|
108
128
|
export function statusShort(status) {
|
|
109
129
|
if (!status) return null;
|
|
@@ -135,56 +155,212 @@ export function waveOfKey(key) {
|
|
|
135
155
|
* (component -> job and wave) and `roots` (component -> the root it applies;
|
|
136
156
|
* a component without one is taken to be its root's name).
|
|
137
157
|
*/
|
|
138
|
-
export function componentMarks(answer, progress, facets, { runs = null, pin = null } = {}) {
|
|
158
|
+
export function componentMarks(answer, progress, facets, { runs = null, pin = null, story = null } = {}) {
|
|
139
159
|
const jobs = facets && Array.isArray(facets.jobs) ? facets.jobs : [];
|
|
140
160
|
const rootOf = (c) => (facets && facets.roots && facets.roots[c]) || c;
|
|
141
|
-
|
|
161
|
+
// behold#741: blocked roots and each root's own outcome are a story's alone; every other view reads as before.
|
|
162
|
+
const states = rootStates(answer, progress, { story: !!story });
|
|
142
163
|
const stage = states.stage;
|
|
143
164
|
const commit = runsCommit(pin, progress);
|
|
144
165
|
const cards = {};
|
|
166
|
+
// behold#741: a kiosk telling a chapter-carrying scenario (`story`): what landed earlier in the cycle, and what a
|
|
167
|
+
// failure left, carry over to the next pull request's cards (the fix) where its plan says nothing of them.
|
|
168
|
+
const earlier = story && story.earlier instanceof Set ? story.earlier : new Set();
|
|
169
|
+
const lastStates = story && story.lastStates ? story.lastStates : null;
|
|
145
170
|
for (const j of jobs) {
|
|
146
171
|
const root = rootOf(j.component);
|
|
147
|
-
|
|
172
|
+
let st = states.roots[root];
|
|
173
|
+
if (story && (!st || st.state === "unchanged" || st.state === "outside")) {
|
|
174
|
+
const last = lastStates && stage !== "apply" ? lastStates[root] : null;
|
|
175
|
+
if (last && (last.state === "failed" || last.state === "blocked")) st = { wave: st ? st.wave : j.wave, state: last.state, tone: last.state === "failed" ? "bad" : "wait", words: last.words || SHORT_WORDS[last.state], facts: [], ...(last.blockedBy ? { blockedBy: last.blockedBy } : {}) };
|
|
176
|
+
else if (earlier.has(root)) st = { wave: st ? st.wave : j.wave, state: "applied-earlier", tone: "ok", words: "applied earlier", facts: [] };
|
|
177
|
+
}
|
|
148
178
|
if (!st) continue;
|
|
179
|
+
const facts = [...st.facts];
|
|
180
|
+
// behold#741: a story's plan says each root's own counts, from the plan report.
|
|
181
|
+
const counts = story && stage === "pull-request" && st.state === "planned" && answer.pull_request.counts ? totalsLine(answer.pull_request.counts[root]) : null;
|
|
182
|
+
if (counts) facts.push(`plans ${counts}`);
|
|
183
|
+
// behold#741: a story's failed root says its error the way chant's cards do: "failed: <its specific part>",
|
|
184
|
+
// a shorter middle form for a narrow card, and the whole error in the tooltip.
|
|
185
|
+
const reason = st.state === "failed" && st.error ? shortReason(st.error) : null;
|
|
149
186
|
cards[j.component] = {
|
|
150
187
|
root,
|
|
151
188
|
wave: j.wave ?? st.wave,
|
|
152
189
|
state: st.state,
|
|
153
190
|
tone: st.tone,
|
|
154
|
-
words: st.words.replace(/^wave \d+ · /, ""),
|
|
155
|
-
|
|
156
|
-
|
|
191
|
+
words: reason ? `failed: ${reason}` : st.words.replace(/^wave \d+ · /, ""),
|
|
192
|
+
...(reason ? { mid: `failed: ${shortReason(st.error, 16)}`, reason } : {}),
|
|
193
|
+
short: st.cone === "not-planned" ? "not planned" : st.cone === "cone" || st.cone === "full" ? "planned" : SHORT_WORDS[st.state] || st.state,
|
|
194
|
+
facts,
|
|
195
|
+
...(st.blockedBy ? { blockedBy: st.blockedBy } : {}),
|
|
196
|
+
// Report minor 34: the cone's resources, short lines inside the card's body.
|
|
197
|
+
...(st.lines ? { lines: st.lines } : {}),
|
|
198
|
+
...(st.cone ? { cone: st.cone } : {}),
|
|
157
199
|
};
|
|
158
200
|
}
|
|
201
|
+
// behold#741: a wave's header once some of its roots are blocked (terragucci#1161); none for older reports.
|
|
202
|
+
const blocked = story && stage === "apply" ? blockedOf(answer, progress) : new Map();
|
|
159
203
|
const waves = {};
|
|
160
204
|
const waveNumbers = [...new Set(jobs.map((j) => j.wave).filter((n) => typeof n === "number"))].sort((a, b) => a - b);
|
|
161
205
|
for (const n of waveNumbers) {
|
|
162
206
|
const jobName = jobs.find((j) => j.wave === n).jobName;
|
|
163
207
|
const members = jobs.filter((j) => j.wave === n).map((j) => cards[j.component]).filter(Boolean);
|
|
164
208
|
const w = waveState(answer, progress, stage, n);
|
|
165
|
-
|
|
209
|
+
// behold#751: a job that failed while its wave's report says the wave applied (and blocked the rest) reads as the report says.
|
|
210
|
+
const status = commit ? reportStatus(waveStatus(jobStatus(runs, commit, jobName), w), waveResultOf(answer, commit, n)) : null;
|
|
211
|
+
// The wave's job ended well and the run view never started a root: the wave applied nothing to it. Say so,
|
|
212
|
+
// never "queued" under a box that says the job succeeded.
|
|
213
|
+
if (stage === "apply" && status && status.status === "success") for (const m of members) settleMember(m, progress, n);
|
|
166
214
|
const facts = [];
|
|
167
|
-
|
|
215
|
+
// behold#736: a cone's fact is its root's (each card's first), so the wave's box names whose it is: "cluster-a: 1
|
|
216
|
+
// of 5 blocks, as a cone", "app-01 to app-06 planned in full: empty cone" for a wave of several estates.
|
|
217
|
+
const coneSaid = new Map();
|
|
218
|
+
for (const m of members) if ((m.cone === "cone" || m.cone === "full") && m.facts[0]) coneSaid.set(m.facts[0], [...(coneSaid.get(m.facts[0]) || []), m]);
|
|
219
|
+
for (const [f, ms] of coneSaid) facts.push(ms[0].cone === "full" ? `${rootNames(ms.map((m) => m.root))} ${f}` : `${rootNames(ms.map((m) => m.root))}: ${f}`);
|
|
220
|
+
for (const m of members) for (const f of m.facts) if (!facts.includes(f) && !coneSaid.has(f)) facts.push(f);
|
|
168
221
|
// The plan a waiting wave is approved for first, as it's what the approval
|
|
169
222
|
// names; then, for a wave that failed, the waves before it that stay applied.
|
|
170
223
|
const rank = (f) => (/^approve plan /.test(f) ? 0 : / stays applied$/.test(f) ? 1 : 2);
|
|
171
224
|
facts.sort((a, b) => rank(a) - rank(b));
|
|
225
|
+
// behold#741: "3 applied, 6 blocked by cluster-a", or "blocked by cluster-a" for a wave none of whose roots ran:
|
|
226
|
+
// its job exits 1 for the roots it held, which is no failure of the wave's own.
|
|
227
|
+
const wr = stage === "apply" && progress && Array.isArray(progress.states) ? progress.states.find((x) => x.number === n) : null;
|
|
228
|
+
let header = wr && blocked.size ? blockedHeader(wr.roots || [], blocked, w) : null;
|
|
229
|
+
let headerTone = w === "blocked" ? BLOCKED_TONE : toneOf(w);
|
|
230
|
+
// behold#741: a story's failed wave says how each root came out, as chant's does: "1 failed, 1 applied", the
|
|
231
|
+
// failure's reason first among its facts, shorter forms of it for a narrow box.
|
|
232
|
+
const failedHere = story && w === "failed" ? members.filter((m) => m.state === "failed") : [];
|
|
233
|
+
const factShort = [];
|
|
234
|
+
if (failedHere.length) {
|
|
235
|
+
const applied = members.filter((m) => m.state === "applied").length;
|
|
236
|
+
header = `${failedHere.length} failed${applied ? `, ${applied} applied` : ""}`;
|
|
237
|
+
headerTone = "bad";
|
|
238
|
+
facts.unshift(...failedHere.map((m) => (m.reason ? `${m.root} failed: ${m.reason}` : `${m.root} failed`)));
|
|
239
|
+
const first = failedHere[0];
|
|
240
|
+
if (first.reason) factShort.push(`${first.root} failed: ${shortReason(first.reason, 36)}`, `${first.root} failed`);
|
|
241
|
+
}
|
|
242
|
+
const shown = header ? { status: w === "blocked" ? "blocked" : w === "failed" ? "failed" : "done", words: header, tone: headerTone, ...(status && status.run ? { run: status.run } : {}) } : status;
|
|
172
243
|
waves[n] = {
|
|
173
244
|
number: n,
|
|
174
245
|
job: jobName,
|
|
175
246
|
state: w,
|
|
176
247
|
// A re-run held at its gate (behold#693) tones the box as its title says.
|
|
177
|
-
tone:
|
|
178
|
-
status,
|
|
179
|
-
title: waveTitle(jobName,
|
|
248
|
+
tone: header ? headerTone : shown && ((shown.held && shown.status === "waiting") || shown.report) ? shown.tone : w ? toneOf(w) : shown ? shown.tone : "idle",
|
|
249
|
+
status: shown,
|
|
250
|
+
title: waveTitle(jobName, shown),
|
|
180
251
|
facts,
|
|
252
|
+
...(factShort.length ? { factShort } : {}),
|
|
181
253
|
};
|
|
182
254
|
}
|
|
183
|
-
return { stage, cards, waves, commit };
|
|
255
|
+
if (!story) return { stage, cards, waves, commit };
|
|
256
|
+
// behold#741: the chant kiosk's look for a chapter-carrying scenario: the wedge, and the bigger card and wave words.
|
|
257
|
+
const needs = rootNeeds(answer, progress, stage, jobs, rootOf);
|
|
258
|
+
const reach = tgReachOf(cards, { stage, answer, needs, earlier });
|
|
259
|
+
return { stage, cards, waves, commit, needs, ...(reach ? { reach } : {}), ...(story.kiosk ? { statusRight: true, cardFont: 15, waveFont: 18 } : {}) };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A card still `not-started` in a wave whose job succeeded: `unchanged` when
|
|
264
|
+
* the run view's wave says it changed nothing (its totals, or `changed`
|
|
265
|
+
* leaving the root out); else the wave's report isn't read yet, and the card
|
|
266
|
+
* says so ("wave done, reading its report") until the report decides, never
|
|
267
|
+
* that the root was skipped. Changes the card in place; any other card is
|
|
268
|
+
* left as it is.
|
|
269
|
+
*/
|
|
270
|
+
export function settleMember(card, progress, n) {
|
|
271
|
+
if (!card || card.state !== "not-started") return card;
|
|
272
|
+
const w = progress && Array.isArray(progress.states) ? progress.states.find((x) => x.number === n) : null;
|
|
273
|
+
const moved = w && w.totals ? Object.entries(w.totals).some(([a, k]) => a !== "no-op" && a !== "read" && typeof k === "number" && k > 0) : null;
|
|
274
|
+
const unchanged = (w && Array.isArray(w.changed) && !w.changed.includes(card.root)) || moved === false;
|
|
275
|
+
card.state = unchanged ? "unchanged" : "reading";
|
|
276
|
+
card.tone = "idle";
|
|
277
|
+
card.words = unchanged ? "unchanged" : "wave done, reading its report";
|
|
278
|
+
card.short = unchanged ? "unchanged" : "reading its report";
|
|
279
|
+
card.facts = [unchanged ? "its wave applied no change to it" : "its wave's job ended; its report says what it applied, once read", ...card.facts];
|
|
280
|
+
return card;
|
|
184
281
|
}
|
|
185
282
|
|
|
186
283
|
const toneOf = (state) => ({ planned: "plan", waiting: "wait", applying: "busy", applied: "ok", failed: "bad", refused: "bad" })[state] || "idle";
|
|
187
284
|
|
|
285
|
+
/**
|
|
286
|
+
* behold#741: each component's upstream components, from the plan report's
|
|
287
|
+
* reads and dependencies while a pull request plans (`upstreams`), and from
|
|
288
|
+
* the run view's reads from the merge on: the edges terragucci layers its
|
|
289
|
+
* waves by (rootOrder).
|
|
290
|
+
*/
|
|
291
|
+
export function rootNeeds(answer, progress, stage, jobs, rootOf) {
|
|
292
|
+
const compsOf = new Map();
|
|
293
|
+
for (const j of jobs) {
|
|
294
|
+
const r = rootOf(j.component);
|
|
295
|
+
compsOf.set(r, [...(compsOf.get(r) || []), j.component]);
|
|
296
|
+
}
|
|
297
|
+
const ups = {};
|
|
298
|
+
if (stage === "pull-request" && answer && answer.pull_request) {
|
|
299
|
+
const pr = answer.pull_request;
|
|
300
|
+
for (const [root, us] of Object.entries(pr.upstreams || {})) ups[root] = [...us];
|
|
301
|
+
for (const r of pr.reads || []) ups[r.root] = [...new Set([...(ups[r.root] || []), r.upstream])];
|
|
302
|
+
} else if (progress && Array.isArray(progress.reads)) {
|
|
303
|
+
for (const r of progress.reads) ups[r.root] = [...new Set([...(ups[r.root] || []), ...(r.reads || [])])];
|
|
304
|
+
}
|
|
305
|
+
const needs = {};
|
|
306
|
+
for (const [root, us] of Object.entries(ups)) {
|
|
307
|
+
const from = compsOf.get(root) || [root];
|
|
308
|
+
const to = us.flatMap((u) => compsOf.get(u) || [u]);
|
|
309
|
+
for (const c of from) needs[c] = [...new Set([...(needs[c] || []), ...to])].filter((x) => x !== c).sort();
|
|
310
|
+
}
|
|
311
|
+
return needs;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** The components downstream of `roots` along `needs` (a component -> what it needs), within `within` when given. */
|
|
315
|
+
function downstreamOf(roots, needs, within = null) {
|
|
316
|
+
const out = new Set();
|
|
317
|
+
const users = {};
|
|
318
|
+
for (const [c, ds] of Object.entries(needs)) for (const d of ds) (users[d] = users[d] || []).push(c);
|
|
319
|
+
const walk = (n) => {
|
|
320
|
+
for (const u of users[n] || []) {
|
|
321
|
+
if (out.has(u) || roots.includes(u) || (within && !within.has(u))) continue;
|
|
322
|
+
out.add(u);
|
|
323
|
+
walk(u);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
for (const r of roots) walk(r);
|
|
327
|
+
return [...out];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* behold#741: what a change reaches, for app.js drawReach, as chant's
|
|
332
|
+
* reachOf (web/chant-pr-marks.js) says it, from terragucci's reports:
|
|
333
|
+
*
|
|
334
|
+
* - once a root failed: the failed root(s), covering the cards they block,
|
|
335
|
+
* "6 blocked";
|
|
336
|
+
* - while a pull request's plan stands: the changed root(s) (the plan's
|
|
337
|
+
* blast roots, else the planned roots that read no other planned one) as
|
|
338
|
+
* the apex, covering the planned roots downstream of them, "reaches 15
|
|
339
|
+
* roots", or for a later pull request of the cycle "the fix reaches 7";
|
|
340
|
+
* - nothing from the merge on, until a failure.
|
|
341
|
+
*/
|
|
342
|
+
export function tgReachOf(cards, { stage, answer, needs = {}, earlier = new Set() } = {}) {
|
|
343
|
+
const failed = Object.entries(cards).filter(([, c]) => c.state === "failed").map(([id]) => id);
|
|
344
|
+
if (failed.length && stage === "apply") {
|
|
345
|
+
const failedRoots = new Set(failed.map((id) => cards[id].root));
|
|
346
|
+
const held = new Set(Object.entries(cards).filter(([, c]) => c.state === "blocked" && (!c.blockedBy || failedRoots.has(c.blockedBy))).map(([id]) => id));
|
|
347
|
+
for (const d of downstreamOf(failed, needs)) if (cards[d] && cards[d].state === "blocked") held.add(d);
|
|
348
|
+
if (!held.size) return null;
|
|
349
|
+
const names = [...held].sort();
|
|
350
|
+
return { key: `failed|${failed.sort().join(",")}|${names.length}`, roots: failed, covered: names, tone: "bad", label: `${names.length} blocked` };
|
|
351
|
+
}
|
|
352
|
+
if (stage !== "pull-request" || !answer || !answer.pull_request) return null;
|
|
353
|
+
const members = new Set(Object.entries(cards).filter(([, c]) => c.state === "planned").map(([id]) => id));
|
|
354
|
+
if (!members.size) return null;
|
|
355
|
+
const blast = answer.pull_request.blast && Array.isArray(answer.pull_request.blast.roots) ? new Set(answer.pull_request.blast.roots) : null;
|
|
356
|
+
const changed = blast ? [...members].filter((id) => blast.has(cards[id].root) && !(needs[id] || []).some((d) => members.has(d) && blast.has(cards[d].root))) : [];
|
|
357
|
+
const roots = (changed.length ? changed : [...members].filter((id) => !(needs[id] || []).some((d) => members.has(d)))).sort();
|
|
358
|
+
if (!roots.length) return null;
|
|
359
|
+
const covered = [...new Set([...roots, ...downstreamOf(roots, needs, members)])].sort();
|
|
360
|
+
const fix = earlier.size > 0;
|
|
361
|
+
return { key: `plan|${roots.join(",")}|${covered.length}|${fix ? "fix" : "change"}`, roots, covered, tone: "plan", label: fix ? `the fix reaches ${covered.length}` : `reaches ${covered.length} ${covered.length === 1 ? "root" : "roots"}` };
|
|
362
|
+
}
|
|
363
|
+
|
|
188
364
|
/** A wave's own state: the run view's once merged, `planned` while a pull request plans it. */
|
|
189
365
|
function waveState(answer, progress, stage, n) {
|
|
190
366
|
if (stage === "apply") {
|