@intentius/behold 0.29.29 → 0.29.30

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/dist/cli.js CHANGED
@@ -26420,6 +26420,7 @@ var KEPT_ATTRIBUTES = [
26420
26420
  "terragucci.gate.held_seconds",
26421
26421
  "terragucci.gate.waiting_since",
26422
26422
  "terragucci.gate.approved_at",
26423
+ "terragucci.wait",
26423
26424
  "process.exit.code",
26424
26425
  "opentofu.resource_instance.address",
26425
26426
  "opentofu.resource_instance.action",
@@ -26507,8 +26508,8 @@ function trimTrace(traceId, body, repo, maxSpans = MAX_SPANS) {
26507
26508
  if (!own || !projectIs(String(own["terragucci.project"]), repo) || spans.length === 0) return null;
26508
26509
  spans.sort((a, b) => a.start - b.start);
26509
26510
  const stage = spans.find((s) => s.parent === null && typeof s.attrs["terragucci.stage"] === "string") ?? spans.find((s) => s.parent === null) ?? spans[0];
26510
- const start = Math.min(...spans.map((s) => s.start));
26511
- const end = Math.max(...spans.map((s) => s.start + s.ms));
26511
+ const start = stage.parent === null ? stage.start : Math.min(...spans.map((s) => s.start));
26512
+ const end = stage.parent === null ? stage.start + stage.ms : Math.max(...spans.map((s) => s.start + s.ms));
26512
26513
  let kept = spans;
26513
26514
  if (spans.length > maxSpans) {
26514
26515
  const byId = new Map(spans.map((s) => [s.id, s]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.29",
3
+ "version": "0.29.30",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
@@ -81,7 +81,7 @@ export function criticalPath(spans) {
81
81
  // A child still running at the point, or starting after it, is not what the point waited on.
82
82
  if (c.start >= t - EPS || end(c) > t + EPS) continue;
83
83
  walk(c, t);
84
- t = c.start;
84
+ t = resumeAt(c, kids);
85
85
  }
86
86
  };
87
87
  for (const s of tops) walk(s, Infinity);
@@ -90,7 +90,18 @@ export function criticalPath(spans) {
90
90
 
91
91
  /** Whether a span is a wait: the wave's gate, or a state lock. */
92
92
  export function isWait(s) {
93
- return s.attrs["terragucci.phase"] === "gate" || s.name === "State lock wait";
93
+ return s.attrs["terragucci.phase"] === "gate" || !!s.attrs["terragucci.wait"] || s.name === "State lock wait";
94
+ }
95
+
96
+ /**
97
+ * Where the critical path goes on from after `s`: its start, or for a wait
98
+ * that holds work of this job (a gate's check after its hold), the start of
99
+ * that work, so what ran before the check stays on the path.
100
+ */
101
+ function resumeAt(s, kids) {
102
+ if (!isWait(s)) return s.start;
103
+ const work = (kids.get(s.id) || []).filter((c) => !isWait(c));
104
+ return work.length ? Math.min(...work.map((c) => c.start)) : s.start;
94
105
  }
95
106
 
96
107
  /** A span's label and the words after it. */
@@ -107,6 +118,8 @@ export function spanWords(s) {
107
118
  return { label: "gate", sub };
108
119
  }
109
120
  if (a["terragucci.phase"]) return { label: String(a["terragucci.phase"]), sub: "" };
121
+ if (a["terragucci.wait"] === "approval") return { label: "held", sub: "for an approval" };
122
+ if (s.name === "check" && s.service === "terragucci") return { label: "check", sub: "this job's decision" };
110
123
  if (a["terragucci.root"] && s.name.startsWith("root ")) return { label: s.name, sub: a["terragucci.status"] ? String(a["terragucci.status"]) : "" };
111
124
  const address = a["opentofu.resource_instance.address"] || a["opentofu.resource.address"];
112
125
  if (address) {
@@ -182,7 +195,8 @@ const STYLE = `
182
195
  .t-row.t-can:hover, .t-row.t-sel { background: var(--active); }
183
196
  .t-name { display: flex; gap: 0.35em; align-items: baseline; min-width: 0; padding-left: calc(var(--d, 0) * 0.85em); }
184
197
  .t-caret { color: var(--muted); width: 0.8em; flex: none; font-size: 0.85em; }
185
- .t-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono); }
198
+ .t-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono); flex: 0 1 auto; min-width: 2.5em; }
199
+ .t-name .t-sub { flex: 0 100 auto; }
186
200
  .t-sub { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9em; }
187
201
  .t-track { position: relative; height: 0.8em; border-radius: 3px; background: color-mix(in srgb, var(--rule) 45%, transparent); }
188
202
  .t-bar { position: absolute; top: 0; bottom: 0; min-width: 2px; border-radius: 3px; background: color-mix(in srgb, var(--muted) 75%, transparent); }
@@ -126,4 +126,26 @@ describe("the waterfall", () => {
126
126
  expect(msWords(6400)).toBe("6.4 s");
127
127
  expect(msWords(125_000)).toBe("2 min 5 s");
128
128
  });
129
+
130
+ it("a gate that spans its hold shows held and check under it, and keeps the plan before the check on the path", () => {
131
+ // The wave began waiting 40 s before this job; the job planned, checked the approval, then applied.
132
+ const spans = [
133
+ sp("s", null, "terragucci tf-apply", 0, 1000, { "terragucci.stage": "tf-apply", "terragucci.wave": 1 }),
134
+ sp("p", "s", "plan", 100, 400, { "terragucci.phase": "plan" }),
135
+ sp("r", "p", "root a", 110, 390, { "terragucci.root": "a" }),
136
+ sp("g", "s", "gate", -40_000, 800, { "terragucci.phase": "gate", "terragucci.gate.status": "approved", "terragucci.gate.held_seconds": 40 }),
137
+ sp("h", "g", "held", -40_000, 0, { "terragucci.wait": "approval", "terragucci.gate.held_seconds": 40 }),
138
+ sp("c", "g", "check", 400, 800),
139
+ sp("a", "s", "apply", 800, 950, { "terragucci.phase": "apply" }),
140
+ ];
141
+ const rows = waterfallRows({ spans });
142
+ const gate = rows.find((r) => r.label === "gate");
143
+ const held = rows.find((r) => r.label === "held");
144
+ expect(gate.width).toBeGreaterThan(0.95);
145
+ expect(held).toMatchObject({ sub: "for an approval", wait: true, critical: true, depth: 2 });
146
+ expect(rows.find((r) => r.label === "check")).toMatchObject({ sub: "this job's decision", wait: false, critical: true });
147
+ expect(rows.find((r) => r.label === "plan").critical).toBe(true);
148
+ expect(rows.find((r) => r.label === "root a").critical).toBe(true);
149
+ });
129
150
  });
151
+