@intentius/behold 0.29.50 → 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/dist/cli.js CHANGED
@@ -146,17 +146,17 @@ var init_read_scheduler = __esm({
146
146
  recordRefused();
147
147
  return Promise.reject(new Error("Chant read queue is full; retry after current reads finish"));
148
148
  }
149
- let resolve38;
149
+ let resolve39;
150
150
  let reject;
151
151
  const promise = new Promise((yes, no) => {
152
- resolve38 = yes;
152
+ resolve39 = yes;
153
153
  reject = no;
154
154
  });
155
155
  job = {
156
156
  key: key3,
157
157
  run: run4,
158
158
  promise,
159
- resolve: resolve38,
159
+ resolve: resolve39,
160
160
  reject,
161
161
  controller: new AbortController(),
162
162
  users: 0,
@@ -170,7 +170,7 @@ var init_read_scheduler = __esm({
170
170
  }
171
171
  const shared2 = job;
172
172
  shared2.users++;
173
- const result = new Promise((resolve38, reject) => {
173
+ const result = new Promise((resolve39, reject) => {
174
174
  let done = false;
175
175
  const finish = (error, value, failed = false) => {
176
176
  if (done) return;
@@ -178,7 +178,7 @@ var init_read_scheduler = __esm({
178
178
  signal?.removeEventListener("abort", abort);
179
179
  shared2.users--;
180
180
  if (failed) reject(error);
181
- else resolve38(value);
181
+ else resolve39(value);
182
182
  };
183
183
  const abort = () => {
184
184
  finish(signal?.reason, void 0, true);
@@ -649,17 +649,17 @@ var init_field_manager = __esm({
649
649
  // node_modules/@intentius/chant-k8s-client/src/concurrency.ts
650
650
  async function mapConcurrent(items, fn, limit = DEFAULT_CONCURRENCY) {
651
651
  const width = Math.max(1, Math.min(limit, items.length));
652
- const results = new Array(items.length);
652
+ const results2 = new Array(items.length);
653
653
  let next = 0;
654
654
  async function worker() {
655
655
  while (true) {
656
656
  const index = next++;
657
657
  if (index >= items.length) return;
658
- results[index] = await fn(items[index], index);
658
+ results2[index] = await fn(items[index], index);
659
659
  }
660
660
  }
661
661
  await Promise.all(Array.from({ length: width }, () => worker()));
662
- return results;
662
+ return results2;
663
663
  }
664
664
  var DEFAULT_CONCURRENCY;
665
665
  var init_concurrency = __esm({
@@ -1066,11 +1066,11 @@ async function createK8sClient(options2 = {}) {
1066
1066
  }
1067
1067
  return void 0;
1068
1068
  }
1069
- async function resolve38(selector, signal) {
1069
+ async function resolve39(selector, signal) {
1070
1070
  return "apiVersion" in selector ? resolveByGvk(selector.apiVersion, selector.kind, signal) : resolveByResourceString(selector.resource, selector.group, signal);
1071
1071
  }
1072
1072
  async function resolveOrThrow(selector, signal) {
1073
- const info = await resolve38(selector, signal);
1073
+ const info = await resolve39(selector, signal);
1074
1074
  if (!info) throw new UnknownResourceError(selectorText(selector));
1075
1075
  return info;
1076
1076
  }
@@ -1082,7 +1082,7 @@ async function createK8sClient(options2 = {}) {
1082
1082
  return parts.join("/");
1083
1083
  }
1084
1084
  async function pathFor(ref2, signal) {
1085
- const info = await resolve38({ apiVersion: ref2.apiVersion, kind: ref2.kind }, signal);
1085
+ const info = await resolve39({ apiVersion: ref2.apiVersion, kind: ref2.kind }, signal);
1086
1086
  if (!info) return void 0;
1087
1087
  return objectPath(info, ref2.name, ref2.namespace);
1088
1088
  }
@@ -1196,8 +1196,8 @@ async function createK8sClient(options2 = {}) {
1196
1196
  const { lines: lines2 } = await openStream(listPath, query, controller.signal, target);
1197
1197
  let expired = false;
1198
1198
  const iterator = lines2[Symbol.asyncIterator]();
1199
- const stopped = new Promise((resolve39) => {
1200
- const finish = () => resolve39({ done: true, value: void 0 });
1199
+ const stopped = new Promise((resolve40) => {
1200
+ const finish = () => resolve40({ done: true, value: void 0 });
1201
1201
  if (controller.signal.aborted) finish();
1202
1202
  else controller.signal.addEventListener("abort", finish, { once: true });
1203
1203
  });
@@ -1224,11 +1224,11 @@ async function createK8sClient(options2 = {}) {
1224
1224
  resourceVersion = await listResourceVersion();
1225
1225
  continue;
1226
1226
  }
1227
- await new Promise((resolve39) => {
1228
- const timer = setTimeout(resolve39, reopenDelayMs);
1227
+ await new Promise((resolve40) => {
1228
+ const timer = setTimeout(resolve40, reopenDelayMs);
1229
1229
  controller.signal.addEventListener("abort", () => {
1230
1230
  clearTimeout(timer);
1231
- resolve39(void 0);
1231
+ resolve40(void 0);
1232
1232
  }, { once: true });
1233
1233
  });
1234
1234
  }
@@ -1346,7 +1346,7 @@ async function createK8sClient(options2 = {}) {
1346
1346
  return {
1347
1347
  provenance,
1348
1348
  defaultNamespace,
1349
- resolve: resolve38,
1349
+ resolve: resolve39,
1350
1350
  read,
1351
1351
  pathFor,
1352
1352
  readIfPresent,
@@ -2193,7 +2193,7 @@ function floorFor(read) {
2193
2193
  if (!f) throw new Error(`no chant floor for the read "${read}" in src/chant-floors.ts`);
2194
2194
  return f;
2195
2195
  }
2196
- var TRAFFIC_FLOOR, NAMESPACE_JOIN_FLOOR, WORKSPACE_CHANT_FLOOR, WHY_CHANT_FLOOR, OPERATOR_LOG_FLOOR, CARVE_STATUS_FLOOR, CI_LIST_CHANT_FLOOR, RELEASE_LIST_CHANT_FLOOR, PROMOTION_ORDER_CHANT_FLOOR, CHANGE_SET_SHOW_CHANT_FLOOR, RUN_EVENTS_CHANT_FLOOR, RELEASE_COLUMN_CHANT_FLOOR, FEATURE_FLAGS_CHANT_FLOOR, WHY_TRACE_CHANT_FLOOR, MIXED_ENVIRONMENT_CHANT_FLOOR, OVERLAP_CHANT_FLOOR, DECISION_POINTS_CHANT_FLOOR, CI_RUN_INDEX_CHANT_FLOOR, CI_REPORT_URL_CHANT_FLOOR, CI_RUN_LOCAL_CHANT_FLOOR, CHANT_FLOORS;
2196
+ var TRAFFIC_FLOOR, NAMESPACE_JOIN_FLOOR, WORKSPACE_CHANT_FLOOR, WHY_CHANT_FLOOR, OPERATOR_LOG_FLOOR, CARVE_STATUS_FLOOR, CI_LIST_CHANT_FLOOR, RELEASE_LIST_CHANT_FLOOR, PROMOTION_ORDER_CHANT_FLOOR, CHANGE_SET_SHOW_CHANT_FLOOR, RUN_EVENTS_CHANT_FLOOR, RELEASE_COLUMN_CHANT_FLOOR, FEATURE_FLAGS_CHANT_FLOOR, WHY_TRACE_CHANT_FLOOR, MIXED_ENVIRONMENT_CHANT_FLOOR, OVERLAP_CHANT_FLOOR, DECISION_POINTS_CHANT_FLOOR, CI_RUN_INDEX_CHANT_FLOOR, CI_REPORT_URL_CHANT_FLOOR, CI_RUN_LOCAL_CHANT_FLOOR, HEALTH_CHANT_FLOOR, CHANT_FLOORS;
2197
2197
  var init_chant_floors = __esm({
2198
2198
  "src/chant-floors.ts"() {
2199
2199
  "use strict";
@@ -2218,6 +2218,7 @@ var init_chant_floors = __esm({
2218
2218
  CI_RUN_INDEX_CHANT_FLOOR = "0.124.31";
2219
2219
  CI_REPORT_URL_CHANT_FLOOR = "0.124.32";
2220
2220
  CI_RUN_LOCAL_CHANT_FLOOR = "0.124.32";
2221
+ HEALTH_CHANT_FLOOR = "0.124.33";
2221
2222
  CHANT_FLOORS = [
2222
2223
  { read: "workspace read contract", floor: WORKSPACE_CHANT_FLOOR, adds: "chant workspace (contract 1)" },
2223
2224
  { read: "why", floor: WHY_CHANT_FLOOR, adds: "graph --intent writes a why (chant#3312)" },
@@ -2238,6 +2239,7 @@ var init_chant_floors = __esm({
2238
2239
  { read: "CI run index", floor: CI_RUN_INDEX_CHANT_FLOOR, adds: "chant ci run --report-url keeps runs/index.json, read by chant ci runs (chant#4098, chant#4114)" },
2239
2240
  { read: "declared CI report URL", floor: CI_REPORT_URL_CHANT_FLOOR, adds: "workspace ls ci.reportUrl, the declaration's report URL (chant#4160)", degraded: "the runs pane reads chant's run index only when serve is given --ci-report-url" },
2240
2241
  { read: "local CI run", floor: CI_RUN_LOCAL_CHANT_FLOOR, adds: "chant ci run --local (chant#4161)" },
2242
+ { read: "runtime health", floor: HEALTH_CHANT_FLOOR, adds: "chant lifecycle health --json, a chant-health/v1 document (chant#4177)", degraded: "the graph draws no health marks and no record out of rotation" },
2241
2243
  { read: "decision points", floor: DECISION_POINTS_CHANT_FLOOR, adds: "a gate that asks a decision point, read with chant workspace points --open (chant#3170)", degraded: "the gate strip draws no open decision points, and says which chant adds them" }
2242
2244
  ];
2243
2245
  }
@@ -5766,7 +5768,7 @@ function chantBin(projectDir) {
5766
5768
  return resolveChant(projectDir).bin;
5767
5769
  }
5768
5770
  function isScheduledRead(args) {
5769
- return args[0] === "graph" || args[0] === "components" && args[1] === "status" || args[0] === "lifecycle" && ["diff", "plan"].includes(args[1]) || args[0] === "helm" && ["renders", "diff"].includes(args[1]) || args[0] === "run" && args[1] === "status" || args[0] === "operator" && ["status", "log"].includes(args[1]) || isIntentRead(args);
5771
+ return args[0] === "graph" || args[0] === "components" && args[1] === "status" || args[0] === "lifecycle" && ["diff", "plan", "health"].includes(args[1]) || args[0] === "helm" && ["renders", "diff"].includes(args[1]) || args[0] === "run" && args[1] === "status" || args[0] === "operator" && ["status", "log"].includes(args[1]) || isIntentRead(args);
5770
5772
  }
5771
5773
  function isIntentRead(args) {
5772
5774
  return args[0] === "workspace" && args[1] === "graph" && args[2] === "--intent";
@@ -8678,6 +8680,9 @@ var init_declaration_schema = __esm({
8678
8680
  green: {
8679
8681
  $ref: "#/$defs/ciGreen"
8680
8682
  },
8683
+ workflow: {
8684
+ $ref: "#/$defs/ciWorkflow"
8685
+ },
8681
8686
  reportUrl: {
8682
8687
  type: "string",
8683
8688
  minLength: 1,
@@ -8736,6 +8741,14 @@ var init_declaration_schema = __esm({
8736
8741
  description: "A deploy counts as failed when, within this many days after it, the commit it deployed is revoked or the environment is rolled back from it. The default is 7."
8737
8742
  }
8738
8743
  }
8744
+ },
8745
+ security: {
8746
+ type: "array",
8747
+ uniqueItems: true,
8748
+ description: "The security groups the workspace opts into (#4168), for every member; a member's own security adds to them. With none, a security feature the workspace has not turned on never refuses, warns or hides anything. verified-releases: release publish and promote --release take only a verified release. supply-chain: a publish without OIDC provenance warns, and a target with no SBOM source is refused. who-ran-it: ci tick needs a runner key. review-rules: pr-apply requires a forge review. isolated-runners: an apply job requires a runner-start statement. workspace check reports what a declared group lacks (WSP161 to WSP165). Added in schema 1 by chant 0.124.33, so a declaration that uses it sets minReader to 0.124.33 or newer.",
8749
+ items: {
8750
+ enum: ["verified-releases", "supply-chain", "who-ran-it", "review-rules", "isolated-runners"]
8751
+ }
8739
8752
  }
8740
8753
  },
8741
8754
  patternProperties: {
@@ -8983,10 +8996,31 @@ var init_declaration_schema = __esm({
8983
8996
  minLength: 1,
8984
8997
  description: "Where an embedded member's files come from. Versions live in the lock."
8985
8998
  },
8999
+ ci: {
9000
+ type: "object",
9001
+ additionalProperties: false,
9002
+ patternProperties: {
9003
+ "^x-": true
9004
+ },
9005
+ description: "This member's own CI settings (#4168 step 6). Added in schema 1 by chant 0.124.34, so a declaration that uses it sets minReader to 0.124.34 or newer.",
9006
+ properties: {
9007
+ workflow: {
9008
+ $ref: "#/$defs/ciWorkflow"
9009
+ }
9010
+ }
9011
+ },
8986
9012
  travel: {
8987
9013
  type: "boolean",
8988
9014
  description: "Whether the member goes with an export (#2524 D10, #2552). chant workspace export writes only members that set travel to true into the export member, and refuses to name one that does not. Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer."
8989
9015
  },
9016
+ security: {
9017
+ type: "array",
9018
+ uniqueItems: true,
9019
+ description: "The security groups this member opts into, added to the declaration's top-level security (#4168). A release, publish or pull-request job of this member runs under both lists. Added in schema 1 by chant 0.124.33, so a declaration that uses it sets minReader to 0.124.33 or newer.",
9020
+ items: {
9021
+ enum: ["verified-releases", "supply-chain", "who-ran-it", "review-rules", "isolated-runners"]
9022
+ }
9023
+ },
8990
9024
  because: {
8991
9025
  type: "string",
8992
9026
  minLength: 1,
@@ -10020,6 +10054,14 @@ var init_declaration_schema = __esm({
10020
10054
  $ref: "#/$defs/ciPhaseName"
10021
10055
  }
10022
10056
  },
10057
+ preMerge: {
10058
+ type: "array",
10059
+ uniqueItems: true,
10060
+ description: "The phases that must pass before the branch moves (#4168 4.4), by name: the quick checks a pull request's checks, a merge queue, chant ci serve landing a branch, or chant ci run --local give before a change lands. Each must be a declared phase. The trunk-curated workflow needs at least one. Added in schema 1 by chant 0.124.34, so a declaration that uses it sets minReader to 0.124.34 or newer.",
10061
+ items: {
10062
+ $ref: "#/$defs/ciPhaseName"
10063
+ }
10064
+ },
10023
10065
  signedSince: {
10024
10066
  type: "string",
10025
10067
  pattern: "^[0-9a-f]{40}([0-9a-f]{24})?$",
@@ -10038,6 +10080,10 @@ var init_declaration_schema = __esm({
10038
10080
  },
10039
10081
  additionalProperties: false
10040
10082
  },
10083
+ ciWorkflow: {
10084
+ enum: ["trunk-curated", "trunk-curated+apply-on-merge"],
10085
+ description: "A prescribed delivery workflow (#4168). trunk-curated: a merge records the plan and deploys nothing; releases are cut from green commits and promoted through each member's environments, gated in the last. trunk-curated+apply-on-merge: the same, with the apply on merge turned back on. chant workspace check reports what a member under one still lacks (WSP151), and chant ci init writes it. At the top level for every member, or on a member, which wins. Added in schema 1 by chant 0.124.34, so a declaration that uses it sets minReader to 0.124.34 or newer."
10086
+ },
10041
10087
  ciPhaseName: {
10042
10088
  type: "string",
10043
10089
  pattern: "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
@@ -10062,6 +10108,13 @@ var init_declaration_schema = __esm({
10062
10108
  "fail"
10063
10109
  ],
10064
10110
  description: "What a check run that finished as skipped counts as. fail (the default): it never passes. pass: it passes, for a job a path filter runs only on some commits."
10111
+ },
10112
+ build: {
10113
+ enum: [
10114
+ "every",
10115
+ "newest"
10116
+ ],
10117
+ description: "Added by #4169, read by chant 0.124.33 and newer. Which first-parent commits of the branch the phase runs on. every (the default): each one. newest: only the newest commit when a runner frees. Under either, a run that was cancelled leaves the commit unbuilt rather than red. Under newest, a commit a newer run superseded is unbuilt too, and a red commit starts a bisect over the unbuilt commits back to the last one the phase passed on. chant ci workflow writes the triggers and concurrency of the workflows holding a phase that sets build, and leaves them alone for a phase that does not."
10065
10118
  }
10066
10119
  },
10067
10120
  patternProperties: {
@@ -10717,7 +10770,7 @@ function compareVersions(a, b) {
10717
10770
  if (mb[4] === void 0) return -1;
10718
10771
  return ma[4] < mb[4] ? -1 : 1;
10719
10772
  }
10720
- function validator2() {
10773
+ function validator3() {
10721
10774
  if (compiled) return compiled;
10722
10775
  const Ajv = loadAjv2020();
10723
10776
  compiled = new Ajv({ allErrors: true, strict: true }).compile(declaration_schema_default);
@@ -10792,7 +10845,7 @@ function parseDeclaration(text3, file, reader2 = readerVersion(), options2 = {})
10792
10845
  at2("/minReader")
10793
10846
  );
10794
10847
  }
10795
- const validate2 = validator2();
10848
+ const validate2 = validator3();
10796
10849
  if (!validate2(raw)) {
10797
10850
  const errors = (validate2.errors ?? []).filter((e) => !SUMMARY_KEYWORDS.has(e.keyword));
10798
10851
  errors.sort((a, b) => b.instancePath.split("/").length - a.instancePath.split("/").length);
@@ -10854,6 +10907,8 @@ function parseDeclaration(text3, file, reader2 = readerVersion(), options2 = {})
10854
10907
  upstream: e.upstream ?? null,
10855
10908
  because: e.because ?? null,
10856
10909
  travel: e.travel === true,
10910
+ security: [...e.security ?? []],
10911
+ ciWorkflow: e.ci?.workflow ?? null,
10857
10912
  suppress,
10858
10913
  pointer
10859
10914
  };
@@ -10985,6 +11040,7 @@ function parseDeclaration(text3, file, reader2 = readerVersion(), options2 = {})
10985
11040
  ci,
10986
11041
  retention: retentionOf(obj.retention),
10987
11042
  metrics: metricsOf(obj.metrics),
11043
+ security: [...obj.security ?? []],
10988
11044
  file
10989
11045
  };
10990
11046
  written.set(declaration, raw);
@@ -11047,18 +11103,20 @@ function retentionOf(raw) {
11047
11103
  function ciOf(raw, at2) {
11048
11104
  if (raw === void 0) return null;
11049
11105
  const block = raw;
11106
+ const workflow = block.workflow !== void 0 ? { workflow: block.workflow } : {};
11050
11107
  let reportUrl = null;
11051
11108
  if (block.reportUrl !== void 0) {
11052
11109
  const target = parseReportUrl(block.reportUrl, "ci.reportUrl");
11053
11110
  if ("error" in target) throw new WorkspaceReadError2("declaration-invalid", target.error, at2("/ci/reportUrl"));
11054
11111
  reportUrl = target.url;
11055
11112
  }
11056
- if (block.green === void 0) return { green: null, reportUrl };
11113
+ if (block.green === void 0) return { green: null, ...workflow, reportUrl };
11057
11114
  const g = block.green;
11058
11115
  const phases = Object.entries(g.phases).map(([name, p]) => ({
11059
11116
  name,
11060
11117
  runs: [...Array.isArray(p) ? p : p.runs],
11061
11118
  skipped: Array.isArray(p) ? "fail" : p.skipped ?? "fail",
11119
+ ...!Array.isArray(p) && p.build !== void 0 ? { build: p.build } : {},
11062
11120
  pointer: `/ci/green/phases/${pointerToken(name)}`
11063
11121
  }));
11064
11122
  for (const [i, name] of g.require.entries()) {
@@ -11069,7 +11127,15 @@ function ciOf(raw, at2) {
11069
11127
  at2(`/ci/green/require/${i}`)
11070
11128
  );
11071
11129
  }
11072
- return { green: { branch: g.branch, window: g.window ?? DEFAULT_CI_WINDOW, phases, require: [...g.require], signedSince: g.signedSince ?? null, source: g.source ?? "checks", pointer: "/ci/green" }, reportUrl };
11130
+ for (const [i, name] of (g.preMerge ?? []).entries()) {
11131
+ if (phases.some((p) => p.name === name)) continue;
11132
+ throw new WorkspaceReadError2(
11133
+ "declaration-invalid",
11134
+ `ci.green.preMerge names the phase ${JSON.stringify(name)}, which ci.green.phases does not declare; declared phases: ${phases.map((p) => p.name).join(", ")}`,
11135
+ at2(`/ci/green/preMerge/${i}`)
11136
+ );
11137
+ }
11138
+ return { green: { branch: g.branch, window: g.window ?? DEFAULT_CI_WINDOW, phases, require: [...g.require], ...g.preMerge !== void 0 ? { preMerge: [...g.preMerge] } : {}, signedSince: g.signedSince ?? null, source: g.source ?? "checks", pointer: "/ci/green" }, ...workflow, reportUrl };
11073
11139
  }
11074
11140
  function agentsOf(raw, members, at2) {
11075
11141
  const agents = (raw ?? []).map((a, i) => {
@@ -11482,8 +11548,8 @@ var init_declaration = __esm({
11482
11548
  });
11483
11549
 
11484
11550
  // src/cli.ts
11485
- import { resolve as resolve37, dirname as dirname23, join as join60 } from "node:path";
11486
- import { realpathSync as realpathSync3, existsSync as existsSync38, readFileSync as readFileSync48, rmSync as rmSync4 } from "node:fs";
11551
+ import { resolve as resolve38, dirname as dirname23, join as join61 } from "node:path";
11552
+ import { realpathSync as realpathSync3, existsSync as existsSync39, readFileSync as readFileSync49, rmSync as rmSync4 } from "node:fs";
11487
11553
  import { fileURLToPath as fileURLToPath15 } from "node:url";
11488
11554
  import { spawn as spawn10, spawnSync as spawnSync4 } from "node:child_process";
11489
11555
 
@@ -11821,6 +11887,12 @@ var SKIP_KEYS = /* @__PURE__ */ new Set([
11821
11887
  "generation",
11822
11888
  "finalizers"
11823
11889
  ]);
11890
+ function cloudOf(kind) {
11891
+ if (kind.startsWith("AWS::")) return "aws";
11892
+ if (kind.startsWith("Microsoft.")) return "azure";
11893
+ if (kind.startsWith("GCP::")) return "gcp";
11894
+ return void 0;
11895
+ }
11824
11896
  function joinable(v) {
11825
11897
  return v.length >= MIN_NAME_LEN && v.length <= MAX_NAME_LEN && !/\s/.test(v);
11826
11898
  }
@@ -11864,12 +11936,16 @@ function addValueMatchEdges(ir) {
11864
11936
  if (owner.size === 0) return ir;
11865
11937
  const declared2 = /* @__PURE__ */ new Set();
11866
11938
  for (const e of ir.edges) declared2.add(`${e.from}\0${e.to}`);
11939
+ const kindOf2 = new Map(nodes.map((n) => [n.id, n.kind]));
11867
11940
  const added = /* @__PURE__ */ new Set();
11868
11941
  for (const a of nodes) {
11942
+ const from = cloudOf(a.kind);
11869
11943
  for (const { path, value } of stringLeaves(a.attrs)) {
11870
11944
  if (!joinable(value)) continue;
11871
11945
  const b = owner.get(value);
11872
11946
  if (!b || b === a.id) continue;
11947
+ const to = cloudOf(kindOf2.get(b) ?? "");
11948
+ if (from && to && from !== to) continue;
11873
11949
  const key3 = `${a.id}\0${b}`;
11874
11950
  if (declared2.has(key3) || added.has(key3)) continue;
11875
11951
  added.add(key3);
@@ -14523,16 +14599,16 @@ function dotsIr(show) {
14523
14599
  return { ir, order };
14524
14600
  }
14525
14601
  function dotsPreviewRoutes(app, opts) {
14526
- const cache6 = /* @__PURE__ */ new Map();
14602
+ const cache7 = /* @__PURE__ */ new Map();
14527
14603
  const graphOf = (name) => {
14528
- const hit = cache6.get(name);
14604
+ const hit = cache7.get(name);
14529
14605
  if (hit) return hit;
14530
14606
  const src = readDotsSource(opts, name);
14531
14607
  const show = showOf(src);
14532
14608
  const { ir, order } = dotsIr(show);
14533
14609
  const { svg } = renderGrid(ir, order, show.source);
14534
14610
  const out = { ir, svg, count: order.length, kind: src.kind };
14535
- cache6.set(name, out);
14611
+ cache7.set(name, out);
14536
14612
  return out;
14537
14613
  };
14538
14614
  app.get("/api/dots/sources", (c) => c.json({ default: DEFAULT_DOTS_SOURCE, sources: ["terralith", ...listRecordings(opts.recordings).map((r) => `carve:${r}`)] }));
@@ -14586,8 +14662,8 @@ import { serve } from "@hono/node-server";
14586
14662
  import { fileURLToPath as fileURLToPath13 } from "node:url";
14587
14663
  import { execFile as execFile6 } from "node:child_process";
14588
14664
  import { promisify as promisify3 } from "node:util";
14589
- import { existsSync as existsSync35, readFileSync as readFileSync44 } from "node:fs";
14590
- import { basename as basename7, dirname as dirname20, join as join56, relative as relative12, resolve as resolve34, sep as sep10 } from "node:path";
14665
+ import { existsSync as existsSync36, readFileSync as readFileSync45 } from "node:fs";
14666
+ import { basename as basename7, dirname as dirname20, join as join57, relative as relative12, resolve as resolve35, sep as sep10 } from "node:path";
14591
14667
 
14592
14668
  // src/recents.ts
14593
14669
  import { readFileSync as readFileSync6, writeFileSync, mkdirSync, existsSync as existsSync4 } from "node:fs";
@@ -14829,19 +14905,19 @@ function finishPipelineProgress(state, exitCode) {
14829
14905
  }
14830
14906
 
14831
14907
  // src/gh-run.ts
14832
- var defaultGhExec = (args) => new Promise((resolve38) => {
14908
+ var defaultGhExec = (args) => new Promise((resolve39) => {
14833
14909
  let out = "";
14834
14910
  let proc;
14835
14911
  try {
14836
14912
  proc = spawn3("gh", args, { stdio: ["ignore", "pipe", "pipe"] });
14837
14913
  } catch {
14838
- resolve38({ code: 127, out: "" });
14914
+ resolve39({ code: 127, out: "" });
14839
14915
  return;
14840
14916
  }
14841
14917
  proc.stdout.on("data", (d) => out += d);
14842
14918
  proc.stderr.on("data", (d) => out += d);
14843
- proc.on("error", () => resolve38({ code: 127, out }));
14844
- proc.on("close", (code) => resolve38({ code: code ?? 1, out }));
14919
+ proc.on("error", () => resolve39({ code: 127, out }));
14920
+ proc.on("close", (code) => resolve39({ code: code ?? 1, out }));
14845
14921
  });
14846
14922
  async function ghReady(exec = defaultGhExec) {
14847
14923
  const { code, out } = await exec(["auth", "status"]);
@@ -16416,8 +16492,276 @@ import { join as join17, resolve as resolve11 } from "node:path";
16416
16492
 
16417
16493
  // src/workspace-reader.ts
16418
16494
  init_chant();
16419
- init_chant_floors();
16420
16495
  import { resolve as resolve10 } from "node:path";
16496
+
16497
+ // src/runtime-health.ts
16498
+ import { Ajv2020 } from "ajv/dist/2020.js";
16499
+
16500
+ // src/health-schema/health.schema.json
16501
+ var health_schema_default = {
16502
+ $schema: "https://json-schema.org/draft/2020-12/schema",
16503
+ $id: "https://intentius.io/chant/schemas/health/v1/health.schema.json",
16504
+ title: "chant-health/v1",
16505
+ description: "What `chant lifecycle health <env> --json` prints (#4177): whether each declared resource that has a health read is up, read separately from drift. Every entity a read applies to lands in exactly one of `entities` (read, with a state), `unobserved` (the read failed, never folded into unhealthy) or `absent` (the provider says it is not deployed). Entity names are the graph's node ids. A single-stack project puts `lexicons` at the top level; a multi-stack one nests them under `stacks`. Written by the first chant release after 0.124.32. Readers ignore fields they do not know; a field is only ever added within a version.",
16506
+ type: "object",
16507
+ required: [
16508
+ "schema",
16509
+ "chantVersion",
16510
+ "environment",
16511
+ "observedAt",
16512
+ "summary"
16513
+ ],
16514
+ properties: {
16515
+ schema: {
16516
+ const: "chant-health/v1"
16517
+ },
16518
+ chantVersion: {
16519
+ type: "string",
16520
+ description: "The chant that ran the read."
16521
+ },
16522
+ environment: {
16523
+ type: "string",
16524
+ description: "The environment named on the command line."
16525
+ },
16526
+ observedAt: {
16527
+ type: "string",
16528
+ description: "When the command started reading, ISO 8601 UTC."
16529
+ },
16530
+ summary: {
16531
+ type: "object",
16532
+ required: [
16533
+ "healthy",
16534
+ "unhealthy",
16535
+ "unknown",
16536
+ "unobserved",
16537
+ "absent"
16538
+ ],
16539
+ description: "Counts over every lexicon and stack.",
16540
+ properties: {
16541
+ healthy: {
16542
+ type: "integer",
16543
+ minimum: 0
16544
+ },
16545
+ unhealthy: {
16546
+ type: "integer",
16547
+ minimum: 0
16548
+ },
16549
+ unknown: {
16550
+ type: "integer",
16551
+ minimum: 0
16552
+ },
16553
+ unobserved: {
16554
+ type: "integer",
16555
+ minimum: 0
16556
+ },
16557
+ absent: {
16558
+ type: "integer",
16559
+ minimum: 0
16560
+ }
16561
+ }
16562
+ }
16563
+ },
16564
+ oneOf: [
16565
+ {
16566
+ required: [
16567
+ "lexicons"
16568
+ ],
16569
+ properties: {
16570
+ lexicons: {
16571
+ $ref: "#/$defs/byLexicon"
16572
+ }
16573
+ }
16574
+ },
16575
+ {
16576
+ required: [
16577
+ "stacks"
16578
+ ],
16579
+ properties: {
16580
+ stacks: {
16581
+ type: "object",
16582
+ description: "Per stack name, the same per-lexicon results.",
16583
+ additionalProperties: {
16584
+ $ref: "#/$defs/byLexicon"
16585
+ }
16586
+ }
16587
+ }
16588
+ }
16589
+ ],
16590
+ $defs: {
16591
+ byLexicon: {
16592
+ type: "object",
16593
+ description: "Per lexicon name, that lexicon's read. A lexicon with no applicable entity is left out.",
16594
+ additionalProperties: {
16595
+ $ref: "#/$defs/read"
16596
+ }
16597
+ },
16598
+ read: {
16599
+ type: "object",
16600
+ required: [
16601
+ "entities",
16602
+ "unobserved",
16603
+ "absent"
16604
+ ],
16605
+ properties: {
16606
+ entities: {
16607
+ type: "object",
16608
+ additionalProperties: {
16609
+ $ref: "#/$defs/entry"
16610
+ }
16611
+ },
16612
+ unobserved: {
16613
+ type: "object",
16614
+ additionalProperties: {
16615
+ $ref: "#/$defs/hole"
16616
+ }
16617
+ },
16618
+ absent: {
16619
+ type: "array",
16620
+ items: {
16621
+ type: "string"
16622
+ },
16623
+ description: "Entity names the provider says are not deployed."
16624
+ }
16625
+ }
16626
+ },
16627
+ entry: {
16628
+ type: "object",
16629
+ required: [
16630
+ "type",
16631
+ "state",
16632
+ "detail",
16633
+ "observedAt"
16634
+ ],
16635
+ properties: {
16636
+ type: {
16637
+ type: "string",
16638
+ description: "Entity type, such as AWS::ECS::Service."
16639
+ },
16640
+ state: {
16641
+ enum: [
16642
+ "healthy",
16643
+ "unhealthy",
16644
+ "unknown"
16645
+ ],
16646
+ description: "healthy and unhealthy are what the provider reported. unknown means the read succeeded and the answer decides neither way: a rollout in progress, a service scaled to zero, a condition pending."
16647
+ },
16648
+ detail: {
16649
+ type: "string",
16650
+ description: "One short line saying why, in the provider's terms."
16651
+ },
16652
+ observedAt: {
16653
+ type: "string",
16654
+ description: "When chant read it, ISO 8601."
16655
+ },
16656
+ checkedAt: {
16657
+ type: "string",
16658
+ description: "When the provider last checked or changed the state, when it says, ISO 8601."
16659
+ }
16660
+ }
16661
+ },
16662
+ hole: {
16663
+ type: "object",
16664
+ required: [
16665
+ "reason"
16666
+ ],
16667
+ description: "A read that failed. Never counted as unhealthy.",
16668
+ properties: {
16669
+ type: {
16670
+ type: "string"
16671
+ },
16672
+ reason: {
16673
+ enum: [
16674
+ "read-failed",
16675
+ "no-credentials",
16676
+ "no-binding",
16677
+ "unsupported-kind",
16678
+ "filtered"
16679
+ ]
16680
+ },
16681
+ detail: {
16682
+ type: "string"
16683
+ },
16684
+ queried: {
16685
+ type: "string",
16686
+ description: "The address the read was issued against, when the lexicon reports it."
16687
+ }
16688
+ }
16689
+ }
16690
+ }
16691
+ };
16692
+
16693
+ // src/runtime-health.ts
16694
+ var HEALTH_SCHEMA = "chant-health/v1";
16695
+ var HEALTH_SCHEMA_ID = health_schema_default.$id;
16696
+ var isRecord8 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
16697
+ var isString = (v) => typeof v === "string";
16698
+ function readerHealthSchema() {
16699
+ const schema = structuredClone(health_schema_default);
16700
+ schema.$defs.hole.properties.reason = { type: "string" };
16701
+ return schema;
16702
+ }
16703
+ var validator;
16704
+ function healthProblems(doc) {
16705
+ if (!validator) validator = new Ajv2020({ strict: false, allErrors: true }).compile(readerHealthSchema());
16706
+ if (validator(doc)) return [];
16707
+ return (validator.errors ?? []).map((e) => `${e.instancePath || "the document"} ${e.message ?? "does not match"}`);
16708
+ }
16709
+ function results(doc) {
16710
+ if (doc.lexicons) return Object.values(doc.lexicons).map((result) => ({ result }));
16711
+ return Object.entries(doc.stacks ?? {}).flatMap(([stack, byLexicon]) => Object.values(byLexicon).map((result) => ({ stack, result })));
16712
+ }
16713
+ function nodeHealthOf(doc, prefix) {
16714
+ const out = {};
16715
+ for (const { stack, result: r } of results(doc)) {
16716
+ const id = (name) => {
16717
+ const local = stack ? `${stack}::${name}` : name;
16718
+ return prefix ? `${prefix}/${local}` : local;
16719
+ };
16720
+ for (const [name, e] of Object.entries(r.entities)) out[id(name)] = { ...e };
16721
+ for (const [name, h] of Object.entries(r.unobserved)) out[id(name)] = { state: "unobserved", reason: h.reason, ...h.type ? { type: h.type } : {}, ...h.detail ? { detail: h.detail } : {} };
16722
+ for (const name of r.absent) out[id(name)] = { state: "absent" };
16723
+ }
16724
+ return out;
16725
+ }
16726
+ function healthCounts(nodes, rotation) {
16727
+ const c = { healthy: 0, unhealthy: 0, unknown: 0, unobserved: 0, absent: 0, outOfRotation: 0 };
16728
+ for (const n of Object.values(nodes)) c[n.state]++;
16729
+ c.outOfRotation = Object.values(rotation).filter((r) => r.inRotation === false).length;
16730
+ return c;
16731
+ }
16732
+ var HEALTH_CHECK_ATTR = "HealthCheckId";
16733
+ var RECORD_KIND = "AWS::Route53::RecordSet";
16734
+ function recordChecks(graph) {
16735
+ const out = /* @__PURE__ */ new Map();
16736
+ const ids = new Set(graph.nodes.map((n) => n.id));
16737
+ for (const e of graph.edges) if (e.viaAttr === HEALTH_CHECK_ATTR && ids.has(e.to)) out.set(e.from, { check: e.to, declared: true });
16738
+ for (const n of graph.nodes) {
16739
+ if (out.has(n.id) || n.kind !== RECORD_KIND) continue;
16740
+ const v = n.attrs?.[HEALTH_CHECK_ATTR];
16741
+ if (isRecord8(v) && isString(v.$ref)) {
16742
+ const target = v.$ref.split(".")[0];
16743
+ if (ids.has(target)) out.set(n.id, { check: target, declared: true });
16744
+ } else if (isString(v) && v) out.set(n.id, { check: v, declared: ids.has(v) });
16745
+ }
16746
+ return out;
16747
+ }
16748
+ function rotationOf(graph, health, prefix) {
16749
+ const id = (name) => prefix ? `${prefix}/${name}` : name;
16750
+ const out = {};
16751
+ for (const [record, { check, declared: declared2 }] of recordChecks(graph)) {
16752
+ const checkId = declared2 ? id(check) : check;
16753
+ const h = declared2 ? health[checkId] : void 0;
16754
+ const checkState = h ? h.state : "none";
16755
+ const name = declared2 ? check : `health check ${check}`;
16756
+ const inRotation = checkState === "unhealthy" ? false : checkState === "healthy" ? true : null;
16757
+ const line = inRotation === false ? `out of rotation: ${name} unhealthy` : inRotation === true ? `in rotation: ${name} healthy` : `rotation unknown: ${!declared2 ? `${name} is not declared here` : checkState === "none" ? `no health read for ${name}` : checkState === "unobserved" ? `${name} not read` : checkState === "absent" ? `${name} not deployed` : `${name} unknown`}`;
16758
+ out[id(record)] = { record: id(record), check: checkId, checkState, inRotation, line };
16759
+ }
16760
+ return out;
16761
+ }
16762
+
16763
+ // src/workspace-reader.ts
16764
+ init_chant_floors();
16421
16765
  var WORKSPACE_CONTRACT = 1;
16422
16766
  var JSON_FLAGS = {
16423
16767
  ls: ["--json"],
@@ -16436,8 +16780,10 @@ var TRUNK_READS = ["ci list", "release list"];
16436
16780
  var CHANGE_SET_READ = "change-set show";
16437
16781
  var POINTS_READ = "points --open";
16438
16782
  var CI_RUNS_READ = "ci runs";
16783
+ var HEALTH_READ = "lifecycle health";
16784
+ var NO_HEALTH_READ = /no configured lexicon has a health read|no health read in this lexicon/i;
16439
16785
  var OUTSIDE_WORKSPACE = [...TRUNK_READS, CHANGE_SET_READ, CI_RUNS_READ];
16440
- var isRecord8 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
16786
+ var isRecord9 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
16441
16787
  function readArgv(command, args) {
16442
16788
  return ["workspace", ...command.split(" "), ...args, ...JSON_FLAGS[command]];
16443
16789
  }
@@ -16460,6 +16806,37 @@ function changeSetArgv(digest, member) {
16460
16806
  function pointsArgv() {
16461
16807
  return ["workspace", ...POINTS_READ.split(" "), "--json"];
16462
16808
  }
16809
+ function healthArgv(env) {
16810
+ return [...HEALTH_READ.split(" "), env, "--json"];
16811
+ }
16812
+ function healthDocumentOf(run4, shown) {
16813
+ const remedy = `Run \`${shown}\` to see what it says.`;
16814
+ const said4 = run4.stderr.trim().split("\n").slice(-3).join(" ");
16815
+ if (!run4.stdout.trim()) {
16816
+ if (NO_HEALTH_READ.test(run4.stderr)) throw new WorkspaceReadError({ error: `${shown} found no lexicon with a health read.`, code: "health-none", remedy: "aws, azure and gcp have one (chant#4177)." });
16817
+ throw new WorkspaceReadError({ error: `${shown} printed nothing (exit ${run4.status ?? "killed"})${said4 ? `: ${said4}` : ""}`, code: "lifecycle-health", remedy });
16818
+ }
16819
+ let doc;
16820
+ try {
16821
+ doc = JSON.parse(run4.stdout);
16822
+ } catch {
16823
+ throw new WorkspaceReadError({ error: `${shown} printed something that is not JSON.`, code: "lifecycle-health", remedy });
16824
+ }
16825
+ if (isRecord9(doc) && doc.schema !== HEALTH_SCHEMA) {
16826
+ throw new WorkspaceReadError({
16827
+ error: `${shown} wrote ${doc.schema === void 0 ? "a document with no schema" : `a ${JSON.stringify(doc.schema)} document`}; behold reads ${HEALTH_SCHEMA}.`,
16828
+ code: "health-schema",
16829
+ remedy: doc.schema === void 0 ? "Upgrade the project's chant." : "Upgrade behold: this chant writes a health document it does not know."
16830
+ });
16831
+ }
16832
+ const problems = healthProblems(doc);
16833
+ if (problems.length) {
16834
+ const more = problems.length > 3 ? ` (and ${problems.length - 3} more)` : "";
16835
+ throw new WorkspaceReadError({ error: `${shown} wrote a health document behold cannot read: ${problems.slice(0, 3).join("; ")}${more}.`, code: "health-schema", remedy });
16836
+ }
16837
+ if (run4.status !== 0) throw new WorkspaceReadError({ error: `${shown} could not build the project (exit ${run4.status ?? "killed"})${said4 ? `: ${said4}` : ""}`, code: "lifecycle-health", remedy });
16838
+ return doc;
16839
+ }
16463
16840
  function documentOf(run4, shown, code, command) {
16464
16841
  if (!run4.stdout.trim()) {
16465
16842
  const said4 = run4.stderr.trim().split("\n").slice(-3).join(" ");
@@ -16471,7 +16848,7 @@ function documentOf(run4, shown, code, command) {
16471
16848
  } catch {
16472
16849
  throw new WorkspaceReadError({ error: `${shown} printed something that is not JSON.`, code, remedy: `Run \`${shown}\` in the workspace root to see what it says.` });
16473
16850
  }
16474
- if (!isRecord8(doc)) throw new WorkspaceReadError({ error: `${shown} printed JSON that is not an object.`, code, remedy: `Run \`${shown}\` in the workspace root.` });
16851
+ if (!isRecord9(doc)) throw new WorkspaceReadError({ error: `${shown} printed JSON that is not an object.`, code, remedy: `Run \`${shown}\` in the workspace root.` });
16475
16852
  const refused2 = contractRefusal(doc, command);
16476
16853
  if (refused2) throw new WorkspaceReadError(refused2);
16477
16854
  return doc;
@@ -16484,7 +16861,7 @@ function ciRunIndexOf(text3, where) {
16484
16861
  } catch {
16485
16862
  throw new WorkspaceReadError({ error: `${where} is not JSON.`, code: "ci-runs", remedy });
16486
16863
  }
16487
- if (!isRecord8(doc)) throw new WorkspaceReadError({ error: `${where} is JSON that is not an object.`, code: "ci-runs", remedy });
16864
+ if (!isRecord9(doc)) throw new WorkspaceReadError({ error: `${where} is JSON that is not an object.`, code: "ci-runs", remedy });
16488
16865
  const refused2 = contractRefusal(doc, CI_RUNS_READ);
16489
16866
  if (refused2) throw new WorkspaceReadError(refused2);
16490
16867
  return doc;
@@ -16507,6 +16884,11 @@ function workspaceReader(chant) {
16507
16884
  async readPoints() {
16508
16885
  const argv = pointsArgv();
16509
16886
  return documentOf(await chant.run(argv), `chant ${argv.join(" ")}`, "workspace-points", POINTS_READ);
16887
+ },
16888
+ async readHealth(env, dir) {
16889
+ const argv = healthArgv(env);
16890
+ const run4 = await chant.run(argv, dir !== void 0 ? { dir } : void 0);
16891
+ return healthDocumentOf(run4, `chant ${argv.join(" ")}${dir !== void 0 ? ` (in ${dir})` : ""}`);
16510
16892
  }
16511
16893
  };
16512
16894
  }
@@ -16533,24 +16915,24 @@ function hasDeclaration(dir) {
16533
16915
  return findDeclaration(dir) !== void 0;
16534
16916
  }
16535
16917
  var refuse5 = (error, code, remedy) => ({ ok: false, refusal: { error, code, remedy } });
16536
- var isRecord9 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
16918
+ var isRecord10 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
16537
16919
  function workspaceFromLs(doc, root) {
16538
16920
  const contract = contractRefusal(doc, "ls");
16539
16921
  if (contract) return { ok: false, refusal: contract };
16540
- if (isRecord9(doc.error)) {
16922
+ if (isRecord10(doc.error)) {
16541
16923
  const code = String(doc.error.code ?? "unknown");
16542
16924
  return refuse5(`chant could not read the workspace declaration in ${root}: ${code}: ${String(doc.error.message ?? "")}`, code, "`chant workspace check` names the problem and where it is.");
16543
16925
  }
16544
16926
  const ws = doc.workspace;
16545
- if (!isRecord9(ws) || typeof ws.name !== "string" || !Array.isArray(doc.members)) {
16927
+ if (!isRecord10(ws) || typeof ws.name !== "string" || !Array.isArray(doc.members)) {
16546
16928
  return refuse5("That is not a workspace ls document: it has no `workspace` and `members`.", "workspace-ls", "Run `chant workspace ls --json` in the workspace root.");
16547
16929
  }
16548
16930
  const members = [];
16549
16931
  for (const m of doc.members) {
16550
- if (!isRecord9(m) || typeof m.name !== "string" || typeof m.dir !== "string" || typeof m.kind !== "string") {
16932
+ if (!isRecord10(m) || typeof m.name !== "string" || typeof m.dir !== "string" || typeof m.kind !== "string") {
16551
16933
  return refuse5("A member in the workspace ls document has no name, dir or kind.", "workspace-ls", "Run `chant workspace ls --json` in the workspace root.");
16552
16934
  }
16553
- const reason = isRecord9(m.reason) ? { code: String(m.reason.code), message: String(m.reason.message ?? "") } : null;
16935
+ const reason = isRecord10(m.reason) ? { code: String(m.reason.code), message: String(m.reason.message ?? "") } : null;
16554
16936
  members.push({
16555
16937
  name: m.name,
16556
16938
  dir: m.dir,
@@ -16567,7 +16949,7 @@ function workspaceFromLs(doc, root) {
16567
16949
  };
16568
16950
  }
16569
16951
  function declaredReportUrl(doc) {
16570
- if (!isRecord9(doc.ci) || typeof doc.ci.reportUrl !== "string") return void 0;
16952
+ if (!isRecord10(doc.ci) || typeof doc.ci.reportUrl !== "string") return void 0;
16571
16953
  if (!meetsFloor(typeof doc.chant === "string" ? doc.chant : void 0, CI_REPORT_URL_CHANT_FLOOR)) return void 0;
16572
16954
  return /^(?:s3|file):\/\/./.test(doc.ci.reportUrl) ? doc.ci.reportUrl : void 0;
16573
16955
  }
@@ -16651,7 +17033,7 @@ var WorkspaceMemberError = class extends Error {
16651
17033
  };
16652
17034
  function stripRefs(value, prefix) {
16653
17035
  if (Array.isArray(value)) return value.map((v) => stripRefs(v, prefix));
16654
- if (!isRecord9(value)) return value;
17036
+ if (!isRecord10(value)) return value;
16655
17037
  const out = {};
16656
17038
  for (const [k, v] of Object.entries(value)) {
16657
17039
  out[k] = k === "$ref" && typeof v === "string" && v.startsWith(prefix) ? v.slice(prefix.length) : stripRefs(v, prefix);
@@ -16661,16 +17043,16 @@ function stripRefs(value, prefix) {
16661
17043
  function memberIrFromGraphDocument(doc, member) {
16662
17044
  const contract = contractRefusal(doc, "graph");
16663
17045
  if (contract) throw new Error(`${contract.error} ${contract.remedy}`);
16664
- if (isRecord9(doc.error)) throw new Error(`chant workspace graph: ${String(doc.error.code)}: ${String(doc.error.message ?? "")}`);
16665
- const entry = Array.isArray(doc.members) ? doc.members.find((m) => isRecord9(m) && m.name === member) : void 0;
16666
- if (!isRecord9(entry)) throw new Error(`chant workspace graph did not list member ${member}`);
17046
+ if (isRecord10(doc.error)) throw new Error(`chant workspace graph: ${String(doc.error.code)}: ${String(doc.error.message ?? "")}`);
17047
+ const entry = Array.isArray(doc.members) ? doc.members.find((m) => isRecord10(m) && m.name === member) : void 0;
17048
+ if (!isRecord10(entry)) throw new Error(`chant workspace graph did not list member ${member}`);
16667
17049
  if (entry.status !== "composed") {
16668
- const r = isRecord9(entry.reason) ? entry.reason : {};
17050
+ const r = isRecord10(entry.reason) ? entry.reason : {};
16669
17051
  throw new WorkspaceMemberError(member, { code: String(r.code ?? entry.status), message: String(r.message ?? "") });
16670
17052
  }
16671
17053
  const p = `${member}/`;
16672
17054
  const un = (id) => typeof id === "string" && id.startsWith(p) ? id.slice(p.length) : String(id);
16673
- const mine = (x) => isRecord9(x) && x.member === member;
17055
+ const mine = (x) => isRecord10(x) && x.member === member;
16674
17056
  const nodes = (Array.isArray(doc.nodes) ? doc.nodes : []).filter(mine).map((n) => {
16675
17057
  const { member: _m, ...rest } = n;
16676
17058
  const out = { ...rest, id: un(n.id), attrs: stripRefs(n.attrs ?? {}, p) };
@@ -16684,9 +17066,9 @@ function memberIrFromGraphDocument(doc, member) {
16684
17066
  });
16685
17067
  const own = new Set(nodes.map((n) => n.id));
16686
17068
  const groups = {};
16687
- if (isRecord9(doc.groups)) {
17069
+ if (isRecord10(doc.groups)) {
16688
17070
  for (const [key3, table] of Object.entries(doc.groups)) {
16689
- if (key3 === "byMember" || !isRecord9(table)) continue;
17071
+ if (key3 === "byMember" || !isRecord10(table)) continue;
16690
17072
  const scoped = key3 === "byStack" || key3 === "byContainer" || key3 === "byWave" || key3 === "byPipeline";
16691
17073
  for (const [k, ids] of Object.entries(table)) {
16692
17074
  if (scoped && !k.startsWith(p)) continue;
@@ -16703,15 +17085,15 @@ function memberIrFromGraphDocument(doc, member) {
16703
17085
  const { member: _m, ...rest } = i;
16704
17086
  return { ...rest, node: un(i.node) };
16705
17087
  });
16706
- const dangling = (Array.isArray(doc.dangling) ? doc.dangling : []).filter((d) => isRecord9(d) && (d.member === member || d.member === void 0 && typeof d.from === "string" && d.from.startsWith(p))).map((d) => {
17088
+ const dangling = (Array.isArray(doc.dangling) ? doc.dangling : []).filter((d) => isRecord10(d) && (d.member === member || d.member === void 0 && typeof d.from === "string" && d.from.startsWith(p))).map((d) => {
16707
17089
  const { member: _m, ...rest } = d;
16708
17090
  return { ...rest, from: un(d.from) };
16709
17091
  }).filter((d) => own.has(d.from));
16710
17092
  const ir = { version: 1, nodes, edges, groups, exports, imports };
16711
17093
  if (dangling.length) ir.dangling = dangling;
16712
- if (isRecord9(entry.meta)) ir.meta = entry.meta;
17094
+ if (isRecord10(entry.meta)) ir.meta = entry.meta;
16713
17095
  if (entry.pipeline !== void 0) ir.pipeline = entry.pipeline;
16714
- if (isRecord9(doc.derivedAttrs)) ir.derivedAttrs = doc.derivedAttrs;
17096
+ if (isRecord10(doc.derivedAttrs)) ir.derivedAttrs = doc.derivedAttrs;
16715
17097
  return ir;
16716
17098
  }
16717
17099
  function workspaceGraphArgs(root, member, opts) {
@@ -16800,15 +17182,15 @@ function estateReadPool(members, env = process.env) {
16800
17182
  return Math.max(1, Math.min(readConcurrency(env), members));
16801
17183
  }
16802
17184
  async function mapPool(items, width, fn) {
16803
- const results = new Array(items.length);
17185
+ const results2 = new Array(items.length);
16804
17186
  let next = 0;
16805
17187
  const worker = async () => {
16806
17188
  for (let i = next++; i < items.length; i = next++) {
16807
- results[i] = await fn(items[i], i);
17189
+ results2[i] = await fn(items[i], i);
16808
17190
  }
16809
17191
  };
16810
17192
  await Promise.all(Array.from({ length: Math.max(1, Math.min(width, items.length)) }, () => worker()));
16811
- return results;
17193
+ return results2;
16812
17194
  }
16813
17195
  function estateMembers(projectDirs) {
16814
17196
  const names = estateMemberNames(projectDirs);
@@ -16956,10 +17338,10 @@ function joinNamespaceBindings(members, isDir = realIsDir) {
16956
17338
  if (!winner || tied) continue;
16957
17339
  const prev = best.get(winner.dir);
16958
17340
  if (prev === "ambiguous") continue;
16959
- const join61 = { dir: winner.dir, namespace: b.namespace, path: b.path, declaredBy: b.declaredBy };
16960
- if (!prev) best.set(winner.dir, { score: winner.score, join: join61 });
17341
+ const join62 = { dir: winner.dir, namespace: b.namespace, path: b.path, declaredBy: b.declaredBy };
17342
+ if (!prev) best.set(winner.dir, { score: winner.score, join: join62 });
16961
17343
  else if (prev.join.namespace !== b.namespace) best.set(winner.dir, "ambiguous");
16962
- else if (winner.score > prev.score) best.set(winner.dir, { score: winner.score, join: join61 });
17344
+ else if (winner.score > prev.score) best.set(winner.dir, { score: winner.score, join: join62 });
16963
17345
  }
16964
17346
  return [...best.values()].filter((v) => v !== "ambiguous").map((v) => v.join);
16965
17347
  }
@@ -17235,6 +17617,11 @@ var AZURE_HEADLINE_KINDS = /* @__PURE__ */ new Set([
17235
17617
  "Microsoft.ContainerService/managedClusters",
17236
17618
  "Microsoft.ContainerInstance/containerGroups",
17237
17619
  "Microsoft.Web/sites",
17620
+ // Container Apps (#826): the app is the workload card, and its managed
17621
+ // environment is a card beside it the way an AKS cluster is, joined by the
17622
+ // app's `managedEnvironmentId` reference.
17623
+ "Microsoft.App/containerApps",
17624
+ "Microsoft.App/managedEnvironments",
17238
17625
  // network edge
17239
17626
  "Microsoft.Network/publicIPAddresses",
17240
17627
  "Microsoft.Network/loadBalancers",
@@ -17310,7 +17697,7 @@ function vnetCidr(node) {
17310
17697
  function projectAzureLogical(ir, env) {
17311
17698
  const azure = ir.nodes.filter((n) => n.lexicon === "azure");
17312
17699
  if (azure.length === 0) return { ir: { nodes: [], edges: [], groups: {} }, byContainer: {} };
17313
- const componentOf = componentNamer(azure);
17700
+ const componentOf = componentNamer(azure, ir.groups);
17314
17701
  const byId = new Map(azure.map((n) => [n.id, n]));
17315
17702
  const byName = /* @__PURE__ */ new Map();
17316
17703
  for (const n of azure) {
@@ -17487,7 +17874,7 @@ function collectRefs(v, out) {
17487
17874
  function projectGcpLogical(ir, env) {
17488
17875
  const gcp = ir.nodes.filter((n) => n.lexicon === "gcp");
17489
17876
  if (gcp.length === 0) return { ir: { nodes: [], edges: [], groups: {} }, byContainer: {} };
17490
- const componentOf = componentNamer(gcp);
17877
+ const componentOf = componentNamer(gcp, ir.groups);
17491
17878
  const byId = new Map(gcp.map((n) => [n.id, n]));
17492
17879
  const project = declaredProject(gcp) ?? env;
17493
17880
  const PROJECT_TITLE = project ? `project ${project}` : "project";
@@ -17930,6 +18317,9 @@ var NO_CONTRACT_KINDS = /* @__PURE__ */ new Set([
17930
18317
  "AWS::Logs::LogGroup",
17931
18318
  "AWS::SecretsManager::Secret",
17932
18319
  "AWS::SSM::Parameter",
18320
+ // every record in a zone references it, so records in one zone are not
18321
+ // thereby connected (three latency records for one name, say)
18322
+ "AWS::Route53::HostedZone",
17933
18323
  // containment fabric
17934
18324
  "AWS::EC2::VPC",
17935
18325
  "AWS::EC2::Subnet",
@@ -17952,8 +18342,13 @@ function dirSegments(node) {
17952
18342
  const parts = (node.sourceLoc?.file ?? "").split("/");
17953
18343
  return parts.slice(0, -1).filter((s) => s.length > 0);
17954
18344
  }
17955
- function componentNamer(nodes) {
17956
- const all = nodes.map(dirSegments).filter((d) => d.length > 0);
18345
+ function componentNamer(nodes, groups) {
18346
+ const memberOf = memberNamer(groups);
18347
+ const segments = (node) => {
18348
+ const member = memberOf(node);
18349
+ return member ? [member, ...dirSegments(node)] : dirSegments(node);
18350
+ };
18351
+ const all = nodes.map(segments).filter((d) => d.length > 0);
17957
18352
  let shared2 = 0;
17958
18353
  if (all.length > 0) {
17959
18354
  const first = all[0];
@@ -17964,10 +18359,19 @@ function componentNamer(nodes) {
17964
18359
  }
17965
18360
  }
17966
18361
  return (node) => {
17967
- const dirs = dirSegments(node);
18362
+ const dirs = segments(node);
17968
18363
  return dirs[shared2] ?? dirs[dirs.length - 1] ?? "other";
17969
18364
  };
17970
18365
  }
18366
+ function memberNamer(groups) {
18367
+ const byStack = groups?.byStack;
18368
+ if (!byStack) return () => void 0;
18369
+ const member = /* @__PURE__ */ new Map();
18370
+ for (const [stack, ids] of Object.entries(byStack)) {
18371
+ for (const id of ids) if (id.startsWith(`${stack}/`)) member.set(id, stack);
18372
+ }
18373
+ return (node) => member.get(node.id);
18374
+ }
17971
18375
  function collectRefs3(v, out) {
17972
18376
  if (!v || typeof v !== "object") return;
17973
18377
  const ref2 = v.$ref;
@@ -18097,14 +18501,37 @@ function retainCrossLensEdges(ir, projections, nodes, edges, byContainer) {
18097
18501
  }
18098
18502
  return false;
18099
18503
  };
18100
- for (const e of ir.edges) {
18101
- if (e.from === e.to || !cards.has(e.from) || !cards.has(e.to)) continue;
18102
- if (perLens.some((ids) => ids.has(e.from) && ids.has(e.to))) continue;
18504
+ const retain = (e) => {
18505
+ if (e.from === e.to || !cards.has(e.from) || !cards.has(e.to)) return;
18506
+ if (perLens.some((ids) => ids.has(e.from) && ids.has(e.to))) return;
18103
18507
  const key3 = pairKey(e.from, e.to);
18104
- if (drawn.has(key3)) continue;
18105
- if (nests(e.from, e.to) || nests(e.to, e.from)) continue;
18508
+ if (drawn.has(key3)) return;
18509
+ if (nests(e.from, e.to) || nests(e.to, e.from)) return;
18106
18510
  drawn.add(key3);
18107
18511
  edges.push(e);
18512
+ };
18513
+ for (const e of ir.edges) retain(e);
18514
+ const kindOf2 = new Map(ir.nodes.map((n) => [n.id, n.kind]));
18515
+ const out = /* @__PURE__ */ new Map();
18516
+ for (const e of ir.edges) (out.get(e.from) ?? out.set(e.from, []).get(e.from)).push(e);
18517
+ for (const start of cards) {
18518
+ const lens = perLens.filter((ids) => ids.has(start));
18519
+ const seen = /* @__PURE__ */ new Set([start]);
18520
+ let frontier = [...out.get(start) ?? []];
18521
+ for (let depth = 0; depth < 4 && frontier.length; depth++) {
18522
+ const next = [];
18523
+ for (const e of frontier) {
18524
+ if (seen.has(e.to)) continue;
18525
+ seen.add(e.to);
18526
+ if (cards.has(e.to)) {
18527
+ if (depth > 0 && !lens.some((ids) => ids.has(e.to))) retain({ from: start, to: e.to, kind: "ref", ...e.viaAttr ? { viaAttr: e.viaAttr } : {} });
18528
+ continue;
18529
+ }
18530
+ if (NO_CONTRACT_KINDS.has(kindOf2.get(e.to) ?? "")) continue;
18531
+ next.push(...out.get(e.to) ?? []);
18532
+ }
18533
+ frontier = next;
18534
+ }
18108
18535
  }
18109
18536
  }
18110
18537
  function placeHelmReleases(nodes, byContainer, boxes) {
@@ -18147,7 +18574,7 @@ function nestReleaseBoxes(byContainer) {
18147
18574
  }
18148
18575
  function projectLogical(ir) {
18149
18576
  const aws = ir.nodes.filter((n) => n.lexicon === "aws" && !isExample(n));
18150
- const componentOf = componentNamer(aws);
18577
+ const componentOf = componentNamer(aws, ir.groups);
18151
18578
  const byId = new Map(aws.map((n) => [n.id, n]));
18152
18579
  const refOut = enrichedRefs(ir, aws, byId);
18153
18580
  const vpcIds = new Set(aws.filter((n) => n.kind === "AWS::EC2::VPC").map((n) => n.id));
@@ -18574,7 +19001,7 @@ import { basename as basename4, join as join30 } from "node:path";
18574
19001
  import { fileURLToPath as fileURLToPath6 } from "node:url";
18575
19002
 
18576
19003
  // src/run-events.ts
18577
- import { Ajv2020 } from "ajv/dist/2020.js";
19004
+ import { Ajv2020 as Ajv20202 } from "ajv/dist/2020.js";
18578
19005
 
18579
19006
  // src/run-event-schema/run-event.schema.json
18580
19007
  var run_event_schema_default = {
@@ -18876,15 +19303,15 @@ var run_event_schema_default = {
18876
19303
  // src/run-events.ts
18877
19304
  var RUN_EVENT_SCHEMA_ID = run_event_schema_default.$id;
18878
19305
  var RUN_EVENT_CONTRACT = 1;
18879
- var isRecord10 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18880
- var validator;
19306
+ var isRecord11 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
19307
+ var validator2;
18881
19308
  function validate(v) {
18882
- if (!validator) {
18883
- const ajv = new Ajv2020({ strict: false, allErrors: false });
18884
- validator = ajv.compile(run_event_schema_default);
19309
+ if (!validator2) {
19310
+ const ajv = new Ajv20202({ strict: false, allErrors: false });
19311
+ validator2 = ajv.compile(run_event_schema_default);
18885
19312
  }
18886
- if (validator(v)) return null;
18887
- const e = validator.errors?.[0];
19313
+ if (validator2(v)) return null;
19314
+ const e = validator2.errors?.[0];
18888
19315
  return e ? `${e.instancePath || "the event"} ${e.message ?? "does not match"}` : "does not match the schema";
18889
19316
  }
18890
19317
  function readRunLine(line) {
@@ -18896,7 +19323,7 @@ function readRunLine(line) {
18896
19323
  } catch {
18897
19324
  return null;
18898
19325
  }
18899
- if (!isRecord10(parsed)) return null;
19326
+ if (!isRecord11(parsed)) return null;
18900
19327
  if (parsed.$schema === RUN_EVENT_SCHEMA_ID || "contract" in parsed && "runId" in parsed && "seq" in parsed) {
18901
19328
  if (parsed.contract !== RUN_EVENT_CONTRACT) {
18902
19329
  return { kind: "refused", reason: `a run event with contract ${JSON.stringify(parsed.contract)}; behold reads contract ${RUN_EVENT_CONTRACT}` };
@@ -18956,7 +19383,7 @@ function legacyRunLine(v) {
18956
19383
  const one = legacyStepRecord(v);
18957
19384
  if (one) return [one];
18958
19385
  if (typeof v.op === "string" && Array.isArray(v.records)) {
18959
- const all = v.records.filter(isRecord10).map(legacyStepRecord).filter((r) => r !== null);
19386
+ const all = v.records.filter(isRecord11).map(legacyStepRecord).filter((r) => r !== null);
18960
19387
  return all.length ? all : null;
18961
19388
  }
18962
19389
  return null;
@@ -20247,7 +20674,7 @@ var NodeRuntimeAdapter = class {
20247
20674
  return (0, import_picomatch.default)(pattern)(filePath);
20248
20675
  }
20249
20676
  async spawn(cmd, opts) {
20250
- return new Promise((resolve38) => {
20677
+ return new Promise((resolve39) => {
20251
20678
  const child = execFile2(
20252
20679
  cmd[0],
20253
20680
  cmd.slice(1),
@@ -20257,7 +20684,7 @@ var NodeRuntimeAdapter = class {
20257
20684
  ...opts?.env ? { env: { ...process.env, ...opts.env } } : {}
20258
20685
  },
20259
20686
  (err, stdout, stderr) => {
20260
- resolve38({
20687
+ resolve39({
20261
20688
  stdout: stdout ?? "",
20262
20689
  stderr: stderr ?? "",
20263
20690
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -21315,22 +21742,22 @@ function fetchable(url, checkout) {
21315
21742
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(url) || /^[^/]+@[^:/]+:/.test(url) || isAbsolute4(url)) return url;
21316
21743
  return resolve17(checkout, url);
21317
21744
  }
21318
- async function fetchIntoCache(git3, origin, cache6) {
21319
- assertScratch(basename3(cache6));
21320
- return serially(cache6, async () => {
21321
- if (!existsSync18(join28(cache6, "HEAD"))) {
21322
- if (existsSync18(cache6) && readdirSync13(cache6).length > 0) return { ok: false, error: `${cache6} exists and is not behold's lifecycle cache; behold leaves it alone` };
21323
- mkdirSync4(cache6, { recursive: true });
21324
- const init = await git3(["init", "--bare", "-q", cache6]);
21325
- if (init.code !== 0) return { ok: false, error: `could not make the cache ${cache6}: ${init.stderr.trim()}` };
21745
+ async function fetchIntoCache(git3, origin, cache7) {
21746
+ assertScratch(basename3(cache7));
21747
+ return serially(cache7, async () => {
21748
+ if (!existsSync18(join28(cache7, "HEAD"))) {
21749
+ if (existsSync18(cache7) && readdirSync13(cache7).length > 0) return { ok: false, error: `${cache7} exists and is not behold's lifecycle cache; behold leaves it alone` };
21750
+ mkdirSync4(cache7, { recursive: true });
21751
+ const init = await git3(["init", "--bare", "-q", cache7]);
21752
+ if (init.code !== 0) return { ok: false, error: `could not make the cache ${cache7}: ${init.stderr.trim()}` };
21326
21753
  }
21327
- const f = await git3(["--git-dir", cache6, "fetch", "-q", "--no-tags", origin, `+refs/heads/${LIFECYCLE_BRANCH}:${CACHE_REF}`]);
21754
+ const f = await git3(["--git-dir", cache7, "fetch", "-q", "--no-tags", origin, `+refs/heads/${LIFECYCLE_BRANCH}:${CACHE_REF}`]);
21328
21755
  if (f.code !== 0) {
21329
21756
  if (/couldn't find remote ref|could not find remote ref/i.test(f.stderr)) return { ok: true, found: false };
21330
21757
  return { ok: false, error: redact(f.stderr.trim() || `git fetch exited ${f.code}`) };
21331
21758
  }
21332
- const b = await git3(["--git-dir", cache6, "fetch", "-q", "--no-tags", "--depth=1", origin, `+HEAD:${CACHE_BASE_REF}`]);
21333
- const sha = b.code === 0 ? (await git3(["--git-dir", cache6, "rev-parse", "--verify", "-q", `${CACHE_BASE_REF}^{commit}`])).stdout.trim() : "";
21759
+ const b = await git3(["--git-dir", cache7, "fetch", "-q", "--no-tags", "--depth=1", origin, `+HEAD:${CACHE_BASE_REF}`]);
21760
+ const sha = b.code === 0 ? (await git3(["--git-dir", cache7, "rev-parse", "--verify", "-q", `${CACHE_BASE_REF}^{commit}`])).stdout.trim() : "";
21334
21761
  return { ok: true, found: true, ...sha ? { base: sha } : {} };
21335
21762
  });
21336
21763
  }
@@ -21421,10 +21848,10 @@ async function readLifecycle(checkout, opts = {}) {
21421
21848
  } else {
21422
21849
  const from = fetchable(url, checkout);
21423
21850
  origin = redact(from);
21424
- const cache6 = cacheDir(from, opts.cacheRoot);
21851
+ const cache7 = cacheDir(from, opts.cacheRoot);
21425
21852
  let f;
21426
21853
  try {
21427
- f = await fetchIntoCache(git3, from, cache6);
21854
+ f = await fetchIntoCache(git3, from, cache7);
21428
21855
  } catch (e) {
21429
21856
  f = { ok: false, error: e instanceof Error ? e.message : String(e) };
21430
21857
  }
@@ -21432,7 +21859,7 @@ async function readLifecycle(checkout, opts = {}) {
21432
21859
  return { ...base, found: false, via: "fetch", origin, fetch: { ok: true }, ...empty, note: `${origin} has no ${LIFECYCLE_BRANCH} branch: no wave has asked for an approval and no root is locked yet.` };
21433
21860
  }
21434
21861
  if (f.ok) {
21435
- const lane2 = await readAt(git3, ["--git-dir", cache6], cache6, CACHE_REF, f.base, now, spec2, checkout);
21862
+ const lane2 = await readAt(git3, ["--git-dir", cache7], cache7, CACHE_REF, f.base, now, spec2, checkout);
21436
21863
  if (lane2) return { ...base, found: true, via: "fetch", origin, fetch: { ok: true }, ...lane2, note: `${LIFECYCLE_BRANCH} as fetched from ${origin} at ${base.read.at}.` };
21437
21864
  fetchError = `fetched ${LIFECYCLE_BRANCH}, but behold's cache could not read it`;
21438
21865
  } else {
@@ -21539,10 +21966,10 @@ async function readHistory(checkout, opts = {}) {
21539
21966
  } else {
21540
21967
  const from = fetchable(url, checkout);
21541
21968
  origin = redact(from);
21542
- const cache6 = cacheDir(from, opts.cacheRoot);
21969
+ const cache7 = cacheDir(from, opts.cacheRoot);
21543
21970
  let f;
21544
21971
  try {
21545
- f = await fetchIntoCache(git3, from, cache6);
21972
+ f = await fetchIntoCache(git3, from, cache7);
21546
21973
  } catch (e) {
21547
21974
  f = { ok: false, error: e instanceof Error ? e.message : String(e) };
21548
21975
  }
@@ -21550,7 +21977,7 @@ async function readHistory(checkout, opts = {}) {
21550
21977
  return { found: false, via: "fetch", origin, fetch: { ok: true }, read: { at: at2 }, logs: [], note: `${origin} has no ${LIFECYCLE_BRANCH} branch, so no gate has a history yet.` };
21551
21978
  }
21552
21979
  if (f.ok) {
21553
- const repo2 = ["--git-dir", cache6];
21980
+ const repo2 = ["--git-dir", cache7];
21554
21981
  const commit2 = await tipOf(git3, repo2, CACHE_REF);
21555
21982
  const logs2 = commit2 ? await ledgerLogs(git3, repo2, CACHE_REF) : void 0;
21556
21983
  if (commit2 && logs2) return { found: true, via: "fetch", origin, fetch: { ok: true }, commit: commit2, read: { at: at2 }, logs: logs2, note: `the gate ledgers' history on ${LIFECYCLE_BRANCH}, as fetched from ${origin} at ${at2}.` };
@@ -21977,13 +22404,13 @@ var RUNS_INDEX_KEY = "runs/index.json";
21977
22404
  var runKey = (id) => `runs/${id}.json`;
21978
22405
  var RUNS_READ_TTL_MS = 2e3;
21979
22406
  var RUN_STATUSES = ["queued", "running", "waiting", "success", "failure", "cancelled", "skipped"];
21980
- var isRecord11 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
22407
+ var isRecord12 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
21981
22408
  var str7 = (v) => typeof v === "string";
21982
22409
  var int = (v) => typeof v === "number" && Number.isInteger(v);
21983
22410
  var timeOrNull = (v) => v === null || v === void 0 || str7(v);
21984
22411
  var status = (v) => str7(v) && RUN_STATUSES.includes(v);
21985
22412
  function jobProblem(j, withSteps, at2) {
21986
- if (!isRecord11(j)) return `${at2} is not an object`;
22413
+ if (!isRecord12(j)) return `${at2} is not an object`;
21987
22414
  if (!int(j.id)) return `${at2}.id is not an integer`;
21988
22415
  if (!str7(j.name)) return `${at2}.name is not a string`;
21989
22416
  if (!Array.isArray(j.needs) || !j.needs.every(str7)) return `${at2}.needs is not a list of job names`;
@@ -21993,7 +22420,7 @@ function jobProblem(j, withSteps, at2) {
21993
22420
  if (!Array.isArray(j.steps)) return `${at2}.steps is not a list`;
21994
22421
  for (const [i, s] of j.steps.entries()) {
21995
22422
  const sat = `${at2}.steps[${i}]`;
21996
- if (!isRecord11(s)) return `${sat} is not an object`;
22423
+ if (!isRecord12(s)) return `${sat} is not an object`;
21997
22424
  if (!str7(s.name)) return `${sat}.name is not a string`;
21998
22425
  if (!str7(s.status)) return `${sat}.status is not a string`;
21999
22426
  if (!Array.isArray(s.log) || !s.log.every(str7)) return `${sat}.log is not a list of lines`;
@@ -22003,7 +22430,7 @@ function jobProblem(j, withSteps, at2) {
22003
22430
  return void 0;
22004
22431
  }
22005
22432
  function runProblem(r, withSteps, at2) {
22006
- if (!isRecord11(r)) return `${at2} is not an object`;
22433
+ if (!isRecord12(r)) return `${at2} is not an object`;
22007
22434
  if (!int(r.id)) return `${at2}.id is not an integer`;
22008
22435
  if (!str7(r.title)) return `${at2}.title is not a string`;
22009
22436
  if (!status(r.status)) return `${at2}.status is not one of ${RUN_STATUSES.join(", ")}`;
@@ -22017,7 +22444,7 @@ function runProblem(r, withSteps, at2) {
22017
22444
  return void 0;
22018
22445
  }
22019
22446
  function runsIndexProblem(doc) {
22020
- if (!isRecord11(doc)) return "it is not an object";
22447
+ if (!isRecord12(doc)) return "it is not an object";
22021
22448
  if (doc.schema !== "demo.runs/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.runs/v1`;
22022
22449
  if (!Array.isArray(doc.runs)) return "runs is not a list";
22023
22450
  for (const [i, r] of doc.runs.entries()) {
@@ -22027,7 +22454,7 @@ function runsIndexProblem(doc) {
22027
22454
  return void 0;
22028
22455
  }
22029
22456
  function runProblemOf(doc, id) {
22030
- if (!isRecord11(doc)) return "it is not an object";
22457
+ if (!isRecord12(doc)) return "it is not an object";
22031
22458
  if (doc.schema !== "demo.run/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.run/v1`;
22032
22459
  if (doc.id !== id) return `its id is ${JSON.stringify(doc.id)}, not ${id}`;
22033
22460
  return runProblem(doc, true, "the run");
@@ -22062,14 +22489,14 @@ function runIdOf(raw) {
22062
22489
  return /^[1-9][0-9]{0,15}$/.test(raw) ? Number(raw) : null;
22063
22490
  }
22064
22491
  function terragucciRunsRoutes(app, source2, opts = {}) {
22065
- const cache6 = /* @__PURE__ */ new Map();
22492
+ const cache7 = /* @__PURE__ */ new Map();
22066
22493
  const shared2 = (key3, read) => {
22067
22494
  const at2 = Date.now();
22068
- const hit = cache6.get(key3);
22495
+ const hit = cache7.get(key3);
22069
22496
  if (hit && at2 - hit.at < RUNS_READ_TTL_MS) return hit.read;
22070
- for (const [k, v] of cache6) if (at2 - v.at >= RUNS_READ_TTL_MS) cache6.delete(k);
22497
+ for (const [k, v] of cache7) if (at2 - v.at >= RUNS_READ_TTL_MS) cache7.delete(k);
22071
22498
  const p = read();
22072
- cache6.set(key3, { at: at2, read: p });
22499
+ cache7.set(key3, { at: at2, read: p });
22073
22500
  return p;
22074
22501
  };
22075
22502
  const answer = (a) => {
@@ -22500,18 +22927,18 @@ async function eventsKey(src, pull, commit, file) {
22500
22927
  }
22501
22928
  }
22502
22929
  function chantPrRoute(app, dir, deps = {}) {
22503
- const cache6 = /* @__PURE__ */ new Map();
22930
+ const cache7 = /* @__PURE__ */ new Map();
22504
22931
  app.get("/api/chant/pr", async (c) => {
22505
22932
  const q = new URL(c.req.url).searchParams;
22506
22933
  const pin = q.get("pin");
22507
22934
  const d = dir();
22508
22935
  const key3 = `${d}|${pin ?? ""}`;
22509
22936
  const t2 = Date.now();
22510
- const hit = cache6.get(key3);
22937
+ const hit = cache7.get(key3);
22511
22938
  const r = hit && t2 - hit.at < 2e3 && q.get("fresh") !== "1" ? hit.read : readChantPr(d, pin, deps);
22512
22939
  if (r !== hit?.read) {
22513
- cache6.set(key3, { at: t2, read: r });
22514
- r.catch(() => cache6.delete(key3));
22940
+ cache7.set(key3, { at: t2, read: r });
22941
+ r.catch(() => cache7.delete(key3));
22515
22942
  }
22516
22943
  return c.json(await r, 200, { "cache-control": "no-store" });
22517
22944
  });
@@ -22542,7 +22969,7 @@ function chantPrFacets(dir, ir, engine) {
22542
22969
  }
22543
22970
 
22544
22971
  // src/chant-demo.ts
22545
- import { Ajv2020 as Ajv20202 } from "ajv/dist/2020.js";
22972
+ import { Ajv2020 as Ajv20203 } from "ajv/dist/2020.js";
22546
22973
 
22547
22974
  // src/demo-schemas/demo-cycle.schema.json
22548
22975
  var demo_cycle_schema_default = {
@@ -23140,14 +23567,14 @@ var DEMO_READ_TTL_MS = 2e3;
23140
23567
  var DEMO_STEPS = ["pull-request", "planned", "merged", "applying", "waiting", "approved", "failed", "resumed", "applied", "reset", "stalled"];
23141
23568
  var DEMO_ABOUT_FIELDS = ["changes", "watch", "shows"];
23142
23569
  function highlightOf(v) {
23143
- if (!isRecord12(v)) return void 0;
23570
+ if (!isRecord13(v)) return void 0;
23144
23571
  const title = text(v.title);
23145
23572
  const body = text(v.body);
23146
23573
  return title && body ? { title, body } : void 0;
23147
23574
  }
23148
23575
  var OUTSIDE_STATES = ["applying", "applied", "failed"];
23149
23576
  function outsideOf(v) {
23150
- if (!isRecord12(v)) return void 0;
23577
+ if (!isRecord13(v)) return void 0;
23151
23578
  const estate = text(v.estate);
23152
23579
  const state = v.state;
23153
23580
  if (!estate || !str8(state) || !OUTSIDE_STATES.includes(state)) return void 0;
@@ -23165,7 +23592,7 @@ function outsideOf(v) {
23165
23592
  };
23166
23593
  }
23167
23594
  function chapterOf(v) {
23168
- if (!isRecord12(v)) return void 0;
23595
+ if (!isRecord13(v)) return void 0;
23169
23596
  const n = v.n;
23170
23597
  const of = v.of;
23171
23598
  if (!int2(n) || !int2(of) || n < 1 || of < n || !str8(v.headline) || !v.headline.trim()) return void 0;
@@ -23174,12 +23601,12 @@ function chapterOf(v) {
23174
23601
  }
23175
23602
  var UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
23176
23603
  var UTC_MS = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/;
23177
- var isRecord12 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23604
+ var isRecord13 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23178
23605
  var str8 = (v) => typeof v === "string";
23179
23606
  var int2 = (v) => typeof v === "number" && Number.isInteger(v);
23180
23607
  var positive = (v) => int2(v) && v > 0 ? v : null;
23181
23608
  function demoProblem(doc) {
23182
- if (!isRecord12(doc)) return "it is not an object";
23609
+ if (!isRecord13(doc)) return "it is not an object";
23183
23610
  if (!int2(doc.cycle)) return "cycle is not an integer";
23184
23611
  if (!str8(doc.scenario) || !doc.scenario) return "scenario is not a string";
23185
23612
  if (!str8(doc.title)) return "title is not a string";
@@ -23187,7 +23614,7 @@ function demoProblem(doc) {
23187
23614
  if (!str8(doc.label)) return "label is not a string";
23188
23615
  if (!str8(doc.started_at) || !UTC.test(doc.started_at)) return "started_at is not a UTC time (YYYY-MM-DDTHH:MM:SSZ)";
23189
23616
  if (doc.next !== null) {
23190
- if (!isRecord12(doc.next)) return "next is neither an object nor null";
23617
+ if (!isRecord13(doc.next)) return "next is neither an object nor null";
23191
23618
  if (!str8(doc.next.action)) return "next.action is not a string";
23192
23619
  if (doc.next.at !== null && !(str8(doc.next.at) && UTC.test(doc.next.at))) return "next.at is neither a UTC time nor null";
23193
23620
  if (doc.next.from !== void 0 && !(str8(doc.next.from) && UTC.test(doc.next.from))) return "next.from is not a UTC time";
@@ -23195,7 +23622,7 @@ function demoProblem(doc) {
23195
23622
  if (doc.pull !== null && !int2(doc.pull)) return "pull is neither an integer nor null";
23196
23623
  if (doc.commit !== null && !str8(doc.commit)) return "commit is neither a string nor null";
23197
23624
  if (doc.about !== void 0 && doc.about !== null) {
23198
- if (!isRecord12(doc.about)) return "about is neither an object nor null";
23625
+ if (!isRecord13(doc.about)) return "about is neither an object nor null";
23199
23626
  for (const f of DEMO_ABOUT_FIELDS) if (!str8(doc.about[f]) || !doc.about[f].trim()) return `about.${f} is not a non-empty string`;
23200
23627
  }
23201
23628
  return void 0;
@@ -23352,7 +23779,7 @@ var cycleToolName = (v) => isVendorTool(v) || /^[a-z0-9][a-z0-9-]{0,40}$/.test(v
23352
23779
  var CYCLE_READ_TTL_MS = 1e4;
23353
23780
  var timeOrNull2 = (v) => v === null || v === void 0 || str8(v) && UTC.test(v);
23354
23781
  function cycleProblem(doc, tool) {
23355
- if (!isRecord12(doc)) return "it is not an object";
23782
+ if (!isRecord13(doc)) return "it is not an object";
23356
23783
  if (doc.schema !== void 0 && doc.schema !== "demo.cycle/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.cycle/v1`;
23357
23784
  if (doc.tool !== tool) return `tool is ${JSON.stringify(doc.tool)}, not ${tool}`;
23358
23785
  if (!str8(doc.repo) || !doc.repo) return "repo is not a string";
@@ -23403,14 +23830,14 @@ async function readCycle(source2, tool, now = /* @__PURE__ */ new Date()) {
23403
23830
  };
23404
23831
  }
23405
23832
  function terragucciCyclesRoute(app, source2, opts = {}) {
23406
- const cache6 = /* @__PURE__ */ new Map();
23833
+ const cache7 = /* @__PURE__ */ new Map();
23407
23834
  app.get("/api/terragucci/cycles/:tool", async (c) => {
23408
23835
  const tool = c.req.param("tool");
23409
23836
  if (!cycleToolName(tool)) return c.json({ error: `no tool "${tool.slice(0, 40)}" has a page; the tools are ${VENDOR_TOOLS.join(", ")}`, code: "terragucci-cycle" }, 404);
23410
23837
  const at2 = Date.now();
23411
- const hit = cache6.get(tool);
23838
+ const hit = cache7.get(tool);
23412
23839
  const read = hit && at2 - hit.at < CYCLE_READ_TTL_MS ? hit.read : readCycle(source2, tool, opts.now ? opts.now() : /* @__PURE__ */ new Date());
23413
- if (read !== hit?.read) cache6.set(tool, { at: at2, read });
23840
+ if (read !== hit?.read) cache7.set(tool, { at: at2, read });
23414
23841
  const a = await read;
23415
23842
  return c.json(a, "error" in a ? 502 : "absent" in a ? 404 : 200, { "cache-control": "no-store" });
23416
23843
  });
@@ -23470,7 +23897,7 @@ var STEP_READ_TTL_MS = 2e3;
23470
23897
  var CYCLE_READ_TTL_MS2 = 1e4;
23471
23898
  var RUN_READ_TTL_MS = 2e3;
23472
23899
  var REPORT_KEY = /^([0-9]+)\/([0-9a-f]{40,64})$/;
23473
- var isRecord13 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23900
+ var isRecord14 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23474
23901
  var str9 = (v) => typeof v === "string";
23475
23902
  var int3 = (v) => typeof v === "number" && Number.isInteger(v);
23476
23903
  var text2 = (v) => str9(v) && v.trim() ? v.trim() : null;
@@ -23506,7 +23933,7 @@ function readerSchema(kind) {
23506
23933
  function schemaProblem(doc, kind) {
23507
23934
  let v = validators[kind];
23508
23935
  if (!v) {
23509
- const ajv = new Ajv20202({ strict: false, allErrors: false });
23936
+ const ajv = new Ajv20203({ strict: false, allErrors: false });
23510
23937
  v = validators[kind] = ajv.compile(readerSchema(kind));
23511
23938
  }
23512
23939
  if (v(doc)) return void 0;
@@ -23518,9 +23945,9 @@ function keyParts(key3) {
23518
23945
  return { pr: Number(m[1]), commit: m[2] };
23519
23946
  }
23520
23947
  function stepOf(d) {
23521
- const next = isRecord13(d.next) ? d.next : null;
23522
- const about = isRecord13(d.about) && ["changes", "watch", "shows"].every((f) => text2(d.about[f])) ? d.about : null;
23523
- const r = isRecord13(d.reports) ? d.reports : null;
23948
+ const next = isRecord14(d.next) ? d.next : null;
23949
+ const about = isRecord14(d.about) && ["changes", "watch", "shows"].every((f) => text2(d.about[f])) ? d.about : null;
23950
+ const r = isRecord14(d.reports) ? d.reports : null;
23524
23951
  const chapter = chapterOf(d.chapter);
23525
23952
  const highlight = highlightOf(d.highlight);
23526
23953
  const demo = str9(d.demo) ? d.demo : "";
@@ -23595,7 +24022,7 @@ async function readRecord(source2, key3, kind, what, problem, of) {
23595
24022
  } catch {
23596
24023
  return { error: `${key3} in ${source2.location} is not JSON.` };
23597
24024
  }
23598
- if (!isRecord13(doc)) return { error: `${key3} in ${source2.location} is not a ${kind} record: it is not an object.` };
24025
+ if (!isRecord14(doc)) return { error: `${key3} in ${source2.location} is not a ${kind} record: it is not an object.` };
23599
24026
  const floor = contractRefusal2(doc, kind);
23600
24027
  if (floor) return { error: `behold refuses ${key3} in ${source2.location}: ${floor.problem}.`, remedy: floor.remedy };
23601
24028
  const p = schemaProblem(doc, kind) ?? problem(doc);
@@ -23623,7 +24050,7 @@ function demoRunOf(entry, repo, reportsAt, events, report) {
23623
24050
  const first = events[0];
23624
24051
  const settle = [...events].reverse().find((e) => e.type === "run-settle");
23625
24052
  const at2 = (e) => e && str9(e.at) ? e.at : null;
23626
- const origin = first && isRecord13(first.runOrigin) && str9(first.runOrigin.url) ? first.runOrigin.url : void 0;
24053
+ const origin = first && isRecord14(first.runOrigin) && str9(first.runOrigin.url) ? first.runOrigin.url : void 0;
23627
24054
  const steps = [];
23628
24055
  const part = (name, e) => {
23629
24056
  let s = steps.find((x) => x.name === name);
@@ -23885,7 +24312,7 @@ function chantDemoRoutes(app, demo) {
23885
24312
 
23886
24313
  // src/ci-run-index.ts
23887
24314
  init_chant_floors();
23888
- import { Ajv2020 as Ajv20203 } from "ajv/dist/2020.js";
24315
+ import { Ajv2020 as Ajv20204 } from "ajv/dist/2020.js";
23889
24316
 
23890
24317
  // src/ci-run-index-schema/ci-run-index.schema.json
23891
24318
  var ci_run_index_schema_default = {
@@ -23959,7 +24386,7 @@ function heldBy(e) {
23959
24386
  if (e.job === "apply" && e.exitCode === 3 && !(e.failure && OTHER_REFUSALS.has(e.failure.code))) return "exit 3";
23960
24387
  return null;
23961
24388
  }
23962
- var isRecord14 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24389
+ var isRecord15 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23963
24390
  var str10 = (v) => typeof v === "string";
23964
24391
  function readerSchema2(which) {
23965
24392
  const schema = structuredClone(ci_run_index_schema_default);
@@ -23976,7 +24403,7 @@ var validators2 = {};
23976
24403
  function schemaProblem2(doc, which) {
23977
24404
  let v = validators2[which];
23978
24405
  if (!v) {
23979
- const ajv = new Ajv20203({ strict: false, allErrors: false });
24406
+ const ajv = new Ajv20204({ strict: false, allErrors: false });
23980
24407
  v = validators2[which] = ajv.compile(readerSchema2(which));
23981
24408
  }
23982
24409
  if (v(doc)) return void 0;
@@ -24064,7 +24491,7 @@ async function readCiRunIndex(source2, url, now = /* @__PURE__ */ new Date()) {
24064
24491
  const entries = [];
24065
24492
  const skipped = [];
24066
24493
  doc.runs.forEach((r, i) => {
24067
- const q = schemaProblem2(r, "run") ?? (isRecord14(r) && str10(r.key) && !KEY.test(r.key) ? `/key ${JSON.stringify(r.key)} is not <pr>/<commit>[/<member>]` : void 0);
24494
+ const q = schemaProblem2(r, "run") ?? (isRecord15(r) && str10(r.key) && !KEY.test(r.key) ? `/key ${JSON.stringify(r.key)} is not <pr>/<commit>[/<member>]` : void 0);
24068
24495
  if (q) skipped.push(`runs[${i}]: ${q.replace(/^\/?/, "")}`);
24069
24496
  else entries.push(r);
24070
24497
  });
@@ -24149,7 +24576,7 @@ var ID = /^local-[a-z0-9-]{1,40}$/;
24149
24576
  function localRunArgs(a) {
24150
24577
  return ["ci", "run", a.job, "--local", "--events-json", "--env", a.env, "--base", a.base, "--commit", a.commit, "--pr", String(a.pr), "--forge", a.forge];
24151
24578
  }
24152
- var isRecord15 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24579
+ var isRecord16 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24153
24580
  var str11 = (v) => typeof v === "string" && v.length > 0;
24154
24581
  function noteStdout(rec7, line) {
24155
24582
  const r = readRunLine(line);
@@ -24203,13 +24630,13 @@ function localRunOf(rec7) {
24203
24630
  let status2 = settle ? RUN_STATUS2[String(settle.status)] ?? "failure" : ended ? "lost" : rec7.events.length ? "running" : "queued";
24204
24631
  if (!settle && ended && rec7.exitCode !== 0 && !rec7.events.length) status2 = "failure";
24205
24632
  for (const s of steps) if (s.status === "running" && status2 !== "running") s.status = status2 === "lost" ? "cancelled" : status2;
24206
- const failure = settle && isRecord15(settle.failure) && str11(settle.failure.code) ? settle.failure.code : null;
24633
+ const failure = settle && isRecord16(settle.failure) && str11(settle.failure.code) ? settle.failure.code : null;
24207
24634
  const tail = [...loose];
24208
24635
  if (settle && str11(settle.error)) tail.push(`run ${String(settle.status)}: ${settle.error}`);
24209
24636
  if (ended && !settle) tail.push(rec7.events.length ? `chant exited ${rec7.exitCode} without settling the run: the stream was lost, and the run's last settled step is where it stopped.` : `chant exited ${rec7.exitCode} before the run started.`);
24210
24637
  if (tail.length || ended) steps.push({ name: "chant", status: ended ? status2 === "lost" ? "cancelled" : status2 : "running", started_at: null, ended_at: rec7.endedAt, log: tail });
24211
24638
  if (rec7.refused) steps.push({ name: "refused lines", status: "failure", started_at: null, ended_at: null, log: [`${rec7.refused} line${rec7.refused === 1 ? "" : "s"} on chant's stdout failed run-event/v1's schema and are not shown${rec7.reason ? `: ${rec7.reason}` : ""}.`] });
24212
- const origin = start && isRecord15(start.runOrigin) && str11(start.runOrigin.forge) ? start.runOrigin.forge : null;
24639
+ const origin = start && isRecord16(start.runOrigin) && str11(start.runOrigin.forge) ? start.runOrigin.forge : null;
24213
24640
  const job = `pr-${rec7.ask.job}`;
24214
24641
  const startedAt = at2(start) ?? rec7.startedAt;
24215
24642
  const endedAt = settle ? at2(settle) : rec7.endedAt;
@@ -24310,7 +24737,7 @@ function localRunRoutes(app, opts) {
24310
24737
  let body;
24311
24738
  try {
24312
24739
  const parsed = await c.req.json();
24313
- body = isRecord15(parsed) ? parsed : {};
24740
+ body = isRecord16(parsed) ? parsed : {};
24314
24741
  } catch {
24315
24742
  return c.json({ error: "the body is JSON: {job, commit, pr, env?, base?, member?, forge?}", code: "local-run" }, 400);
24316
24743
  }
@@ -25338,11 +25765,11 @@ function runLabel(run4) {
25338
25765
  function tookLabel(ms) {
25339
25766
  return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
25340
25767
  }
25341
- function paintPlayhead(ir, join61, gate) {
25342
- if (!join61.byNode.size && !join61.at) return ir;
25768
+ function paintPlayhead(ir, join62, gate) {
25769
+ if (!join62.byNode.size && !join62.at) return ir;
25343
25770
  const nodes = ir.nodes.map((node) => {
25344
- const run4 = join61.byNode.get(node.id);
25345
- const here = join61.at === node.id;
25771
+ const run4 = join62.byNode.get(node.id);
25772
+ const here = join62.at === node.id;
25346
25773
  if (!run4 && !here) return node;
25347
25774
  const isGate = node.attrs?._step === "gate";
25348
25775
  const attrs = { ...node.attrs };
@@ -25359,7 +25786,7 @@ function paintPlayhead(ir, join61, gate) {
25359
25786
  if (here) {
25360
25787
  attrs._playhead = true;
25361
25788
  attrs._status = isGate && gate ? "warn" : "accent";
25362
- attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join61.atReason ?? "here";
25789
+ attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join62.atReason ?? "here";
25363
25790
  if (isGate && gate?.description) attrs.gateDescription = gate.description;
25364
25791
  }
25365
25792
  return { ...node, attrs };
@@ -25384,11 +25811,11 @@ function pendingGateCard(op, gate, ir) {
25384
25811
  function settledCount(steps) {
25385
25812
  return steps.filter((s) => s.state !== "running").length;
25386
25813
  }
25387
- function playheadNote(state, join61) {
25814
+ function playheadNote(state, join62) {
25388
25815
  if (!state.op) {
25389
25816
  return "No run state: nothing has been run from this behold session, so every step paints as declared.";
25390
25817
  }
25391
- const settled = join61 ? join61.byNode.size : settledCount(state.steps);
25818
+ const settled = join62 ? join62.byNode.size : settledCount(state.steps);
25392
25819
  const bits = [];
25393
25820
  const from = state.source === "events" ? "chant's run events" : "chant's older progress stream (degraded)";
25394
25821
  const head = state.status === "idle" ? `Run state for ${state.op}: no per-step events; this behold session didn't start the run, so only the status read answers` : `Run: ${state.op} (${state.runtime ?? "local"}, from ${from}${state.following ? ", followed" : ""}): ${settled} step${settled === 1 ? "" : "s"} settled`;
@@ -25408,9 +25835,9 @@ function playheadNote(state, join61) {
25408
25835
  bits.push(`gate state unavailable: ${state.gateNote}`);
25409
25836
  }
25410
25837
  if (state.sourceNote) bits.push(state.sourceNote);
25411
- if (join61?.unplaced.length) {
25838
+ if (join62?.unplaced.length) {
25412
25839
  bits.push(
25413
- `${join61.unplaced.length} step${join61.unplaced.length === 1 ? "" : "s"} matched no declared step and ${join61.unplaced.length === 1 ? "is" : "are"} not painted`
25840
+ `${join62.unplaced.length} step${join62.unplaced.length === 1 ? "" : "s"} matched no declared step and ${join62.unplaced.length === 1 ? "is" : "are"} not painted`
25414
25841
  );
25415
25842
  }
25416
25843
  if (!bits.length) return `${head}.`;
@@ -26280,6 +26707,8 @@ var REFUSED_READS = [
26280
26707
  [/^\/api\/overlay$/, "it reads the live estate with behold's own credentials"],
26281
26708
  [/^\/api\/reconcile$/, "it plans against the live estate with behold's own credentials"],
26282
26709
  [/^\/api\/diff(\/|$)/, "it reads the live estate with behold's own credentials"],
26710
+ [/^\/api\/health$/, "it reads the live estate with behold's own credentials"],
26711
+ [/^\/api\/health$/, "it reads the live estate with behold's own credentials"],
26283
26712
  [/^\/api\/components\/compare$/, "it reads the live estate with behold's own credentials"],
26284
26713
  [/^\/api\/resources$/, "it runs chant against the project"],
26285
26714
  [/^\/api\/ci(\/|$)/, "it reads the pipeline and the forge run"],
@@ -26324,19 +26753,19 @@ import { join as join37 } from "node:path";
26324
26753
  import { platform } from "node:os";
26325
26754
  var DOCKER_DOWN_DETAIL = "docker is down";
26326
26755
  function probe(cmd, args) {
26327
- return new Promise((resolve38) => {
26756
+ return new Promise((resolve39) => {
26328
26757
  let out = "";
26329
26758
  let proc;
26330
26759
  try {
26331
26760
  proc = spawn7(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
26332
26761
  } catch {
26333
- resolve38({ code: 127, out: "" });
26762
+ resolve39({ code: 127, out: "" });
26334
26763
  return;
26335
26764
  }
26336
26765
  proc.stdout.on("data", (d) => out += d);
26337
26766
  proc.stderr.on("data", (d) => out += d);
26338
- proc.on("error", () => resolve38({ code: 127, out }));
26339
- proc.on("close", (code) => resolve38({ code: code ?? 1, out }));
26767
+ proc.on("error", () => resolve39({ code: 127, out }));
26768
+ proc.on("close", (code) => resolve39({ code: code ?? 1, out }));
26340
26769
  });
26341
26770
  }
26342
26771
  async function dockerAvailable(run4) {
@@ -27204,7 +27633,7 @@ init_choudoufu_member();
27204
27633
  import { mkdtempSync, rmSync as rmSync3 } from "node:fs";
27205
27634
  import { tmpdir as tmpdir3 } from "node:os";
27206
27635
  import { join as join39 } from "node:path";
27207
- var isRecord16 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27636
+ var isRecord17 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27208
27637
  var refuse7 = (error, remedy) => ({ ok: false, refusal: { error, code: "choudoufu-live-check", remedy } });
27209
27638
  var CREDS2 = "Give behold the ambient read-only AWS credentials the estate's `plan` needs (AWS_PROFILE, or AWS_ENDPOINT_URL for an emulator), then re-check live with plan.";
27210
27639
  function said3(run4, fallback) {
@@ -27221,7 +27650,7 @@ function parsePlanShow(run4, dir) {
27221
27650
  } catch {
27222
27651
  return refuse7(`choudoufu show printed something that is not JSON for ${dir}: ${said3(run4, "unparseable stdout")}`, CREDS2);
27223
27652
  }
27224
- if (!isRecord16(json2) || typeof json2.format_version !== "string") {
27653
+ if (!isRecord17(json2) || typeof json2.format_version !== "string") {
27225
27654
  return refuse7("That is not a plan document \u2014 no `format_version`.", CREDS2);
27226
27655
  }
27227
27656
  if (json2.resource_changes !== void 0 && json2.resource_changes !== null && !Array.isArray(json2.resource_changes)) {
@@ -27233,9 +27662,9 @@ var KNOWN_AFTER_APPLY = "(known after apply)";
27233
27662
  var SENSITIVE = "(sensitive)";
27234
27663
  var flagged = (tree, key3) => {
27235
27664
  if (tree === true) return true;
27236
- if (!isRecord16(tree)) return false;
27665
+ if (!isRecord17(tree)) return false;
27237
27666
  const v = tree[key3];
27238
- return v === true || isRecord16(v) && Object.values(v).some((x) => x === true) || Array.isArray(v) && v.some((x) => x === true);
27667
+ return v === true || isRecord17(v) && Object.values(v).some((x) => x === true) || Array.isArray(v) && v.some((x) => x === true);
27239
27668
  };
27240
27669
  function same(a, b) {
27241
27670
  if (a === b) return true;
@@ -27243,7 +27672,7 @@ function same(a, b) {
27243
27672
  if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
27244
27673
  return a.every((x, i) => same(x, b[i]));
27245
27674
  }
27246
- if (isRecord16(a) && isRecord16(b)) {
27675
+ if (isRecord17(a) && isRecord17(b)) {
27247
27676
  const ka = Object.keys(a);
27248
27677
  const kb = Object.keys(b);
27249
27678
  if (ka.length !== kb.length) return false;
@@ -27254,10 +27683,10 @@ function same(a, b) {
27254
27683
  function planDrift(doc) {
27255
27684
  const out = /* @__PURE__ */ new Map();
27256
27685
  for (const rc of doc.resource_changes ?? []) {
27257
- if (!rc || typeof rc.address !== "string" || !isRecord16(rc.change)) continue;
27686
+ if (!rc || typeof rc.address !== "string" || !isRecord17(rc.change)) continue;
27258
27687
  const { actions, before, after: after2 } = rc.change;
27259
27688
  if (!Array.isArray(actions) || actions.every((a) => a === "no-op")) continue;
27260
- if (!isRecord16(before) || !isRecord16(after2)) continue;
27689
+ if (!isRecord17(before) || !isRecord17(after2)) continue;
27261
27690
  const changes = [];
27262
27691
  for (const key3 of [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after2)])].sort()) {
27263
27692
  const unknownAfter = flagged(rc.change.after_unknown, key3);
@@ -27312,13 +27741,13 @@ init_choudoufu_member();
27312
27741
  init_choudoufu_live();
27313
27742
  import { existsSync as existsSync25, readFileSync as readFileSync30 } from "node:fs";
27314
27743
  import { join as join40, relative as relative8 } from "node:path";
27315
- var isRecord17 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27744
+ var isRecord18 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27316
27745
  var refuse8 = (error, remedy) => ({ ok: false, refusal: { error, code: "choudoufu-live-check", remedy } });
27317
27746
  var HOW_TO_GET_ONE2 = "A split plan is split.json: `{from, estates[], moves[{address, from, to}]}`. The live-mv workbench's plan phase writes one as carve.json, which reads the same; or write it by hand.";
27318
27747
  function parseSplitPlan(value) {
27319
- if (!isRecord17(value)) return refuse8("That file is not a move plan \u2014 its top level is not a JSON object.", HOW_TO_GET_ONE2);
27748
+ if (!isRecord18(value)) return refuse8("That file is not a move plan \u2014 its top level is not a JSON object.", HOW_TO_GET_ONE2);
27320
27749
  if (!Array.isArray(value.moves)) return refuse8("That JSON is not a move plan \u2014 it has no `moves` array.", HOW_TO_GET_ONE2);
27321
- const bad2 = value.moves.findIndex((m) => !isRecord17(m) || typeof m.address !== "string" || typeof m.from !== "string" || typeof m.to !== "string");
27750
+ const bad2 = value.moves.findIndex((m) => !isRecord18(m) || typeof m.address !== "string" || typeof m.from !== "string" || typeof m.to !== "string");
27322
27751
  if (bad2 >= 0) return refuse8(`moves[${bad2}] is not a move (needs string \`address\`, \`from\` and \`to\`).`, HOW_TO_GET_ONE2);
27323
27752
  const moves = value.moves;
27324
27753
  return {
@@ -27363,7 +27792,7 @@ function parseLiveMv(run4, what) {
27363
27792
  } catch {
27364
27793
  return refuse8(`choudoufu live-mv printed something that is not JSON for ${what}.`, "Run the line by hand to see choudoufu's own words.");
27365
27794
  }
27366
- if (!isRecord17(json2) || !isRecord17(json2.from) || !isRecord17(json2.to) || typeof json2.dry_run !== "boolean") {
27795
+ if (!isRecord18(json2) || !isRecord18(json2.from) || !isRecord18(json2.to) || typeof json2.dry_run !== "boolean") {
27367
27796
  return refuse8(`That is not a live-mv document (${what}).`, "Upgrade choudoufu to 0.16.0 or newer.");
27368
27797
  }
27369
27798
  return { ok: true, doc: json2 };
@@ -27518,7 +27947,7 @@ async function readPolicyOverride(dir, g, read = gitLifecycleReader) {
27518
27947
  }
27519
27948
 
27520
27949
  // src/workspace-gates.ts
27521
- var isRecord18 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27950
+ var isRecord19 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27522
27951
  var str15 = (v) => typeof v === "string" && v ? v : null;
27523
27952
  function gateKey(member, op, gate) {
27524
27953
  return `${member}/${op}/${gate}`;
@@ -27529,16 +27958,16 @@ function approveArgs(g) {
27529
27958
  function gatesFromStatus(doc, root) {
27530
27959
  const contract = contractRefusal(doc, "status");
27531
27960
  if (contract) return { ok: false, refusal: contract };
27532
- if (isRecord18(doc.error)) {
27961
+ if (isRecord19(doc.error)) {
27533
27962
  const code = String(doc.error.code ?? "unknown");
27534
27963
  return { ok: false, refusal: { error: `chant could not read the workspace's status: ${code}: ${String(doc.error.message ?? "")}`, code, remedy: "`chant workspace check` names the problem and where it is." } };
27535
27964
  }
27536
27965
  const gates = [];
27537
27966
  for (const m of Array.isArray(doc.members) ? doc.members : []) {
27538
- if (!isRecord18(m) || typeof m.name !== "string") continue;
27967
+ if (!isRecord19(m) || typeof m.name !== "string") continue;
27539
27968
  const dir = typeof m.dir === "string" ? m.dir === "." ? resolve21(root) : resolve21(root, m.dir) : resolve21(root);
27540
27969
  for (const g of Array.isArray(m.gates) ? m.gates : []) {
27541
- if (!isRecord18(g)) continue;
27970
+ if (!isRecord19(g)) continue;
27542
27971
  const op = str15(g.component);
27543
27972
  const gate = str15(g.name);
27544
27973
  if (!op || !gate) continue;
@@ -27546,7 +27975,7 @@ function gatesFromStatus(doc, root) {
27546
27975
  if (g.state !== void 0 && g.state !== "pending" && !keepApproved) continue;
27547
27976
  const env = str15(g.env);
27548
27977
  const planDigest = str15(g.planDigest);
27549
- const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord18).map((a) => ({
27978
+ const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord19).map((a) => ({
27550
27979
  principal: String(a.principal ?? "unknown"),
27551
27980
  at: str15(a.at),
27552
27981
  channel: str15(a.channel)
@@ -27563,16 +27992,16 @@ function gatesFromStatus(doc, root) {
27563
27992
  needed: typeof g.needed === "number" ? g.needed : 1,
27564
27993
  recordedAt: str15(g.recordedAt),
27565
27994
  expiresAt: str15(g.expiresAt),
27566
- signed: isRecord18(g.signed),
27995
+ signed: isRecord19(g.signed),
27567
27996
  // status's line already carries --sign for a signed gate; only the
27568
27997
  // line built here needs it added.
27569
27998
  state: keepApproved ? "approved" : "pending",
27570
- approve: str15(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord18(g.signed) ? ["--sign"] : []].join(" "),
27999
+ approve: str15(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord19(g.signed) ? ["--sign"] : []].join(" "),
27571
28000
  ...str15(g.gitSha) ? { gitSha: str15(g.gitSha) } : {},
27572
28001
  ...str15(g.runId) ? { runId: str15(g.runId) } : {},
27573
28002
  ...str15(g.changeSet) ? { changeSet: str15(g.changeSet) } : {},
27574
28003
  ...str15(g.releaseDigest) ? { releaseDigest: str15(g.releaseDigest) } : {},
27575
- ...isRecord18(g.answer) && str15(g.answer.id) ? { answer: { point: String(g.answer.point ?? ""), id: str15(g.answer.id), path: String(g.answer.path ?? "") } } : {}
28004
+ ...isRecord19(g.answer) && str15(g.answer.id) ? { answer: { point: String(g.answer.point ?? ""), id: str15(g.answer.id), path: String(g.answer.path ?? "") } } : {}
27576
28005
  });
27577
28006
  }
27578
28007
  }
@@ -27612,7 +28041,7 @@ function localApprover(env = process.env) {
27612
28041
  // src/decision-points.ts
27613
28042
  init_chant_floors();
27614
28043
  var POINTS_READ_NAME = "decision points";
27615
- var isRecord19 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28044
+ var isRecord20 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27616
28045
  var str16 = (v) => typeof v === "string" && v ? v : null;
27617
28046
  var arr = (v) => Array.isArray(v) ? v : [];
27618
28047
  var num2 = (v) => typeof v === "number" ? v : null;
@@ -27629,24 +28058,24 @@ function answerCommand(id) {
27629
28058
  return `chant workspace points answer ${id} --answer <value> --by <name>`;
27630
28059
  }
27631
28060
  function openPointsFrom(doc, at2 = /* @__PURE__ */ new Date()) {
27632
- if (isRecord19(doc.error)) {
28061
+ if (isRecord20(doc.error)) {
27633
28062
  const code = String(doc.error.code ?? "unknown");
27634
28063
  return { ok: false, refusal: { error: `chant could not read the workspace's decision points: ${code}: ${String(doc.error.message ?? "")}`, code, remedy: "`chant workspace check` names the problem and where it is." } };
27635
28064
  }
27636
28065
  const declared2 = /* @__PURE__ */ new Map();
27637
- for (const p of arr(doc.points)) if (isRecord19(p) && typeof p.name === "string") declared2.set(p.name, p);
28066
+ for (const p of arr(doc.points)) if (isRecord20(p) && typeof p.name === "string") declared2.set(p.name, p);
27638
28067
  const points = [];
27639
28068
  for (const q of arr(doc.questions)) {
27640
- if (!isRecord19(q) || q.open !== true) continue;
28069
+ if (!isRecord20(q) || q.open !== true) continue;
27641
28070
  const id = str16(q.id);
27642
28071
  const name = str16(q.point);
27643
28072
  if (!id || !name) continue;
27644
28073
  const p = declared2.get(name);
27645
- const asked = isRecord19(q.asked) ? q.asked : null;
27646
- const quorum = p && isRecord19(p.quorum) ? p.quorum : isRecord19(q.decider) && q.decider.kind === "quorum" ? q.decider : null;
27647
- const m = isRecord19(q.model) ? q.model : null;
28074
+ const asked = isRecord20(q.asked) ? q.asked : null;
28075
+ const quorum = p && isRecord20(p.quorum) ? p.quorum : isRecord20(q.decider) && q.decider.kind === "quorum" ? q.decider : null;
28076
+ const m = isRecord20(q.model) ? q.model : null;
27648
28077
  const subject = str16(q.subject);
27649
- const by = isRecord19(q.askedBy) ? str16(q.askedBy.steward) : null;
28078
+ const by = isRecord20(q.askedBy) ? str16(q.askedBy.steward) : null;
27650
28079
  points.push({
27651
28080
  id,
27652
28081
  point: name,
@@ -27667,7 +28096,7 @@ function openPointsFrom(doc, at2 = /* @__PURE__ */ new Date()) {
27667
28096
  });
27668
28097
  }
27669
28098
  points.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
27670
- const unread = arr(doc.sources).filter(isRecord19).filter((s) => isRecord19(s.reason)).map((s) => ({ kind: String(s.kind ?? ""), code: String(s.reason.code ?? ""), message: String(s.reason.message ?? "") }));
28099
+ const unread = arr(doc.sources).filter(isRecord20).filter((s) => isRecord20(s.reason)).map((s) => ({ kind: String(s.kind ?? ""), code: String(s.reason.code ?? ""), message: String(s.reason.message ?? "") }));
27671
28100
  return { ok: true, points: { points, unread, read: { at: at2.toISOString() } } };
27672
28101
  }
27673
28102
  async function readOpenPoints(ws, opts = {}) {
@@ -27829,7 +28258,7 @@ function resolveApproverOptions(flags, dir, env = process.env) {
27829
28258
  // src/workspace-why.ts
27830
28259
  init_chant_floors();
27831
28260
  var WHY_COMMITS_SHOWN = 8;
27832
- var isRecord20 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28261
+ var isRecord21 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27833
28262
  var str17 = (v) => typeof v === "string" && v ? v : null;
27834
28263
  var num3 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
27835
28264
  var strings3 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
@@ -27854,12 +28283,12 @@ function hudReviewUrl(hud, record) {
27854
28283
  return `${hud.replace(/\/+$/, "")}/decisions#${encodeURIComponent(record)}`;
27855
28284
  }
27856
28285
  function whyFromIntent(doc, hud = null) {
27857
- if (isRecord20(doc.error)) {
28286
+ if (isRecord21(doc.error)) {
27858
28287
  const code = String(doc.error.code ?? "unknown");
27859
28288
  return refuse9(`chant couldn't read that region: ${code}: ${String(doc.error.message ?? "")}`, code, code === "intent-region-invalid" ? "chant reads a node's why from the file that declares it; a card behold added (a live-only or ops card) has none." : "Run `chant workspace graph --intent <region>` in the workspace root.");
27860
28289
  }
27861
28290
  const nodes = /* @__PURE__ */ new Map();
27862
- for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (isRecord20(n) && typeof n.id === "string") nodes.set(n.id, n);
28291
+ for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (isRecord21(n) && typeof n.id === "string") nodes.set(n.id, n);
27863
28292
  const regionId = String(doc.region ?? "");
27864
28293
  const regionNode = nodes.get(regionId);
27865
28294
  const base = {
@@ -27869,12 +28298,12 @@ function whyFromIntent(doc, hud = null) {
27869
28298
  chant: String(doc.chant ?? "")
27870
28299
  };
27871
28300
  const why = doc.why;
27872
- if (!isRecord20(why)) {
28301
+ if (!isRecord21(why)) {
27873
28302
  return { ok: true, why: { ...base, answered: false, explained: false, decisions: [], runs: [], commits: [], commitsTotal: 0, uncommittedLines: 0, gaps: [], trace: null } };
27874
28303
  }
27875
28304
  const decisions = [];
27876
28305
  for (const d of Array.isArray(why.decisions) ? why.decisions : []) {
27877
- if (!isRecord20(d) || typeof d.decision !== "string") continue;
28306
+ if (!isRecord21(d) || typeof d.decision !== "string") continue;
27878
28307
  const n = nodes.get(d.decision) ?? {};
27879
28308
  const id = str17(n.record) ?? after(d.decision, "record:").replace(/^[^/]*\//, "");
27880
28309
  const state = str17(n.state);
@@ -27893,28 +28322,28 @@ function whyFromIntent(doc, hud = null) {
27893
28322
  }
27894
28323
  const commitOf = (id) => {
27895
28324
  const n = nodes.get(id) ?? {};
27896
- const joins = isRecord20(n.joins) ? n.joins : {};
28325
+ const joins = isRecord21(n.joins) ? n.joins : {};
27897
28326
  return {
27898
28327
  sha: str17(n.sha) ?? after(id, "commit:"),
27899
28328
  subject: str17(n.subject),
27900
28329
  date: str17(n.date),
27901
- author: isRecord20(n.author) ? str17(n.author.name) : null,
28330
+ author: isRecord21(n.author) ? str17(n.author.name) : null,
27902
28331
  pullRequest: typeof n.pullRequest === "number" ? n.pullRequest : null,
27903
28332
  run: str17(joins.run)
27904
28333
  };
27905
28334
  };
27906
28335
  const runs2 = [];
27907
28336
  for (const r of Array.isArray(why.runs) ? why.runs : []) {
27908
- if (!isRecord20(r) || typeof r.run !== "string") continue;
28337
+ if (!isRecord21(r) || typeof r.run !== "string") continue;
27909
28338
  const n = nodes.get(r.run) ?? {};
27910
- const unit = isRecord20(r.unit) ? str17(r.unit.id) : null;
28339
+ const unit = isRecord21(r.unit) ? str17(r.unit.id) : null;
27911
28340
  runs2.push({
27912
28341
  id: str17(n.run) ?? after(r.run, "run:"),
27913
28342
  lines: num3(r.lines),
27914
28343
  commits: strings3(r.commits).map((c) => commitOf(c).sha),
27915
28344
  unit,
27916
28345
  by: str17(n.by),
27917
- harness: isRecord20(n.harness) ? str17(n.harness.name) : null,
28346
+ harness: isRecord21(n.harness) ? str17(n.harness.name) : null,
27918
28347
  model: str17(n.model),
27919
28348
  outcome: str17(n.outcome),
27920
28349
  startedAt: str17(n.startedAt),
@@ -27922,7 +28351,7 @@ function whyFromIntent(doc, hud = null) {
27922
28351
  decisions: strings3(r.decisions).map((d) => str17(nodes.get(d)?.record) ?? after(d, "record:"))
27923
28352
  });
27924
28353
  }
27925
- const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord20);
28354
+ const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord21);
27926
28355
  let uncommittedLines = 0;
27927
28356
  const ids = [];
27928
28357
  for (const span of blame) {
@@ -27949,17 +28378,17 @@ function whyFromIntent(doc, hud = null) {
27949
28378
  commits: commits.slice(0, WHY_COMMITS_SHOWN),
27950
28379
  commitsTotal: commits.length,
27951
28380
  uncommittedLines,
27952
- gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord20).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") })),
28381
+ gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord21).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") })),
27953
28382
  trace: traceFromIntent(doc.trace, nodes)
27954
28383
  }
27955
28384
  };
27956
28385
  }
27957
- var records = (v) => Array.isArray(v) ? v.filter(isRecord20) : [];
28386
+ var records = (v) => Array.isArray(v) ? v.filter(isRecord21) : [];
27958
28387
  function traceFromIntent(raw, nodes) {
27959
- if (!isRecord20(raw)) return null;
28388
+ if (!isRecord21(raw)) return null;
27960
28389
  const work = (w) => ({ ...w, title: typeof w.node === "string" ? str17(nodes.get(w.node)?.title) : null });
27961
28390
  const commits = records(raw.commits).map((c) => {
27962
- const judged = isRecord20(c.work) ? c.work : null;
28391
+ const judged = isRecord21(c.work) ? c.work : null;
27963
28392
  return {
27964
28393
  ...c,
27965
28394
  subject: typeof c.commit === "string" ? str17(nodes.get(c.commit)?.subject) : null,
@@ -28677,6 +29106,8 @@ function renderLanes(frames, summaries) {
28677
29106
 
28678
29107
  // src/emulator.ts
28679
29108
  init_chant();
29109
+ import { existsSync as existsSync28, readFileSync as readFileSync32 } from "node:fs";
29110
+ import { join as join43, resolve as resolve24 } from "node:path";
28680
29111
  function parseEmulators(stdout) {
28681
29112
  const lines2 = stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
28682
29113
  for (let i = lines2.length - 1; i >= 0; i--) {
@@ -28709,26 +29140,49 @@ async function emulatorUp(projectDir) {
28709
29140
  async function emulatorDown(projectDir) {
28710
29141
  await runChantRaw(["emulator", "down"], projectDir);
28711
29142
  }
29143
+ function emulatorDirs(dir, workspace) {
29144
+ if (workspace) {
29145
+ const dirs = workspace.members.filter((m) => m.kind === "chant").map((m) => m.abs);
29146
+ return dirs.length ? dirs : [dir];
29147
+ }
29148
+ const file = join43(dir, "chant.workspace.json");
29149
+ if (!existsSync28(file)) return [dir];
29150
+ try {
29151
+ const doc = JSON.parse(readFileSync32(file, "utf8"));
29152
+ const dirs = (doc.members ?? []).filter((m) => (m.kind ?? "chant") === "chant" && typeof m.dir === "string").map((m) => resolve24(dir, m.dir));
29153
+ return dirs.length ? dirs : [dir];
29154
+ } catch {
29155
+ return [dir];
29156
+ }
29157
+ }
29158
+ async function emulatorsUp(dirs) {
29159
+ const seen = /* @__PURE__ */ new Map();
29160
+ for (const d of dirs) for (const e of await emulatorUp(d)) if (!seen.has(e.name)) seen.set(e.name, e);
29161
+ return [...seen.values()];
29162
+ }
29163
+ async function emulatorsDown(dirs) {
29164
+ for (const d of dirs) await emulatorDown(d).catch(() => void 0);
29165
+ }
28712
29166
 
28713
29167
  // src/terragucci-view.ts
28714
29168
  import { execFileSync as execFileSync3 } from "node:child_process";
28715
- import { dirname as dirname15, join as join48, relative as relative10, sep as sep8 } from "node:path";
29169
+ import { dirname as dirname15, join as join49, relative as relative10, sep as sep8 } from "node:path";
28716
29170
  init_terraform_member();
28717
29171
 
28718
29172
  // src/terragucci-reports.ts
28719
- import { readFileSync as readFileSync32, statSync as statSync11 } from "node:fs";
29173
+ import { readFileSync as readFileSync33, statSync as statSync11 } from "node:fs";
28720
29174
  import { createRequire as createRequire4 } from "node:module";
28721
- import { dirname as dirname11, join as join43, resolve as resolve24 } from "node:path";
29175
+ import { dirname as dirname11, join as join44, resolve as resolve25 } from "node:path";
28722
29176
  import { fileURLToPath as fileURLToPath7 } from "node:url";
28723
- import { Ajv2020 as Ajv20204 } from "ajv/dist/2020.js";
29177
+ import { Ajv2020 as Ajv20205 } from "ajv/dist/2020.js";
28724
29178
 
28725
29179
  // src/terragucci-cone.ts
28726
- var isRecord21 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
29180
+ var isRecord22 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
28727
29181
  var str18 = (v) => typeof v === "string" && v.length > 0;
28728
29182
  var count = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : void 0;
28729
29183
  function readCone(v) {
28730
- if (!isRecord21(v) || !str18(v.base)) return void 0;
28731
- const fb = isRecord21(v.fallback) ? v.fallback : null;
29184
+ if (!isRecord22(v) || !str18(v.base)) return void 0;
29185
+ const fb = isRecord22(v.fallback) ? v.fallback : null;
28732
29186
  if (fb) return { base: v.base, fallback: { kind: str18(fb.kind) ? fb.kind : "unknown", reason: str18(fb.reason) ? fb.reason : "" } };
28733
29187
  const blocks = count(v.blocks);
28734
29188
  const of = count(v.of);
@@ -28736,11 +29190,11 @@ function readCone(v) {
28736
29190
  return { base: v.base, ...blocks !== void 0 && of !== void 0 ? { blocks, of } : {}, ...targets !== void 0 ? { targets } : {} };
28737
29191
  }
28738
29192
  function plannedInstances(plan) {
28739
- if (!isRecord21(plan) || !Array.isArray(plan.resource_changes)) return [];
29193
+ if (!isRecord22(plan) || !Array.isArray(plan.resource_changes)) return [];
28740
29194
  const out = [];
28741
29195
  for (const rc of plan.resource_changes) {
28742
- if (!isRecord21(rc) || !str18(rc.address) || rc.mode === "data") continue;
28743
- const acts = isRecord21(rc.change) && Array.isArray(rc.change.actions) ? rc.change.actions.filter(str18) : [];
29196
+ if (!isRecord22(rc) || !str18(rc.address) || rc.mode === "data") continue;
29197
+ const acts = isRecord22(rc.change) && Array.isArray(rc.change.actions) ? rc.change.actions.filter(str18) : [];
28744
29198
  out.push({ address: rc.address, changed: !acts.every((a) => a === "no-op" || a === "read") });
28745
29199
  }
28746
29200
  return out;
@@ -28772,7 +29226,7 @@ function coneView(doc, { roots = [], planned = {}, facts = {} } = {}) {
28772
29226
  const all = out.map((r) => r.root);
28773
29227
  const binaryOf = (p) => {
28774
29228
  const own = doc.roots.find((r) => r.path === p);
28775
- const b = own && isRecord21(own.binary) && str18(own.binary.name) ? own.binary.name : void 0;
29229
+ const b = own && isRecord22(own.binary) && str18(own.binary.name) ? own.binary.name : void 0;
28776
29230
  return b ?? facts[p]?.binary;
28777
29231
  };
28778
29232
  const live2 = all.length > 0 && all.every((p) => binaryOf(p) === "choudoufu" && facts[p]?.state !== true);
@@ -28783,7 +29237,7 @@ async function readConePlans(source2, runPath, doc) {
28783
29237
  for (const r of doc.roots) {
28784
29238
  const c = readCone(r.cone);
28785
29239
  if (!c || c.fallback) continue;
28786
- const key3 = isRecord21(r.plan) && str18(r.plan.json) ? r.plan.json : null;
29240
+ const key3 = isRecord22(r.plan) && str18(r.plan.json) ? r.plan.json : null;
28787
29241
  if (!key3 || key3.split("/").some((s) => s === ".." || s === ".")) continue;
28788
29242
  let text3;
28789
29243
  try {
@@ -28832,13 +29286,13 @@ function attributeValues(a) {
28832
29286
  }
28833
29287
  var OUTCOMES = ["applied", "unchanged", "failed"];
28834
29288
  function waveRootNames(w) {
28835
- return (w && Array.isArray(w.roots) ? w.roots : []).flatMap((r) => str19(r) ? [r] : isRecord22(r) && str19(r.root ?? r.path) ? [String(r.root ?? r.path)] : []);
29289
+ return (w && Array.isArray(w.roots) ? w.roots : []).flatMap((r) => str19(r) ? [r] : isRecord23(r) && str19(r.root ?? r.path) ? [String(r.root ?? r.path)] : []);
28836
29290
  }
28837
29291
  function waveOutcomes(w) {
28838
29292
  const rows = [...w && Array.isArray(w.roots) ? w.roots : [], ...w && Array.isArray(w.outcomes) ? w.outcomes : []];
28839
29293
  const out = /* @__PURE__ */ new Map();
28840
29294
  for (const r of rows) {
28841
- if (!isRecord22(r)) continue;
29295
+ if (!isRecord23(r)) continue;
28842
29296
  const root = r.root ?? r.path;
28843
29297
  if (!str19(root) || !root || !str19(r.outcome) || !OUTCOMES.includes(r.outcome) || out.has(root)) continue;
28844
29298
  out.set(root, { root, outcome: r.outcome, ...r.outcome === "failed" && str19(r.error) && r.error ? { error: r.error } : {} });
@@ -28847,34 +29301,34 @@ function waveOutcomes(w) {
28847
29301
  }
28848
29302
  var SCHEMA_FILES = { report: "report.schema.json", index: "report-index.schema.json", estate: "estate.schema.json" };
28849
29303
  var SCHEMA_IDS = { report: REPORT_SCHEMA, index: INDEX_SCHEMA, estate: ESTATE_SCHEMA };
28850
- var isRecord22 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29304
+ var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28851
29305
  var str19 = (v) => typeof v === "string";
28852
29306
  function structural(name, doc) {
28853
- if (!isRecord22(doc)) return "it is not a JSON object";
29307
+ if (!isRecord23(doc)) return "it is not a JSON object";
28854
29308
  if (doc.schema !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(doc.schema)}, not ${SCHEMA_IDS[name]}`;
28855
29309
  if (name === "index") {
28856
29310
  if (!Array.isArray(doc.reports)) return "it has no reports array";
28857
29311
  for (const [i, r] of doc.reports.entries()) {
28858
- if (!isRecord22(r) || !str19(r.project) || !str19(r.commit) || !str19(r.stage) || !str19(r.finished) || !str19(r.path)) return `row ${i} lacks project, commit, stage, finished or path`;
29312
+ if (!isRecord23(r) || !str19(r.project) || !str19(r.commit) || !str19(r.stage) || !str19(r.finished) || !str19(r.path)) return `row ${i} lacks project, commit, stage, finished or path`;
28859
29313
  }
28860
29314
  } else if (name === "report") {
28861
29315
  const run4 = doc.run;
28862
- if (!isRecord22(run4) || !str19(run4.project) || !str19(run4.commit) || !str19(run4.stage) || !str19(run4.finished)) return "its run lacks project, commit, stage or finished";
29316
+ if (!isRecord23(run4) || !str19(run4.project) || !str19(run4.commit) || !str19(run4.stage) || !str19(run4.finished)) return "its run lacks project, commit, stage or finished";
28863
29317
  if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
28864
29318
  for (const [i, r] of doc.roots.entries()) {
28865
- if (!isRecord22(r) || !str19(r.path) || r.status !== "planned" && r.status !== "failed" || !Array.isArray(r.changes)) return `root ${i} lacks path, status or changes`;
28866
- for (const c of r.changes) if (!isRecord22(c) || !str19(c.address) || !str19(c.action)) return `a change in root ${String(r.path)} lacks address or action`;
29319
+ if (!isRecord23(r) || !str19(r.path) || r.status !== "planned" && r.status !== "failed" || !Array.isArray(r.changes)) return `root ${i} lacks path, status or changes`;
29320
+ for (const c of r.changes) if (!isRecord23(c) || !str19(c.address) || !str19(c.action)) return `a change in root ${String(r.path)} lacks address or action`;
28867
29321
  }
28868
29322
  } else {
28869
- if (!str19(doc.generated) || !isRecord22(doc.totals) || !Array.isArray(doc.projects)) return "it lacks generated, totals or projects";
28870
- for (const p of doc.projects) if (!isRecord22(p) || !str19(p.project) || !Array.isArray(p.waiting)) return "a project lacks project or waiting";
29323
+ if (!str19(doc.generated) || !isRecord23(doc.totals) || !Array.isArray(doc.projects)) return "it lacks generated, totals or projects";
29324
+ for (const p of doc.projects) if (!isRecord23(p) || !str19(p.project) || !Array.isArray(p.waiting)) return "a project lacks project or waiting";
28871
29325
  }
28872
29326
  return void 0;
28873
29327
  }
28874
29328
  var compiledSchemas = /* @__PURE__ */ new Map();
28875
29329
  function schemaStamp(dist) {
28876
29330
  try {
28877
- const files = [join43(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join43(dist, f))];
29331
+ const files = [join44(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join44(dist, f))];
28878
29332
  return [dist, ...files.map((f) => {
28879
29333
  const st = statSync11(f);
28880
29334
  return `${st.mtimeMs}:${st.size}`;
@@ -28884,15 +29338,15 @@ function schemaStamp(dist) {
28884
29338
  }
28885
29339
  }
28886
29340
  function compileSchemas(dist) {
28887
- const version = JSON.parse(readFileSync32(join43(dist, "..", "package.json"), "utf8")).version ?? "";
28888
- const ajv = new Ajv20204({ strict: false, allErrors: false });
29341
+ const version = JSON.parse(readFileSync33(join44(dist, "..", "package.json"), "utf8")).version ?? "";
29342
+ const ajv = new Ajv20205({ strict: false, allErrors: false });
28889
29343
  const compiled4 = Object.fromEntries(
28890
- Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync32(join43(dist, SCHEMA_FILES[n]), "utf8")))])
29344
+ Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync33(join44(dist, SCHEMA_FILES[n]), "utf8")))])
28891
29345
  );
28892
29346
  return {
28893
29347
  validation: { by: "schema", terragucci: version },
28894
29348
  check(name, doc) {
28895
- const id = isRecord22(doc) ? doc.schema : void 0;
29349
+ const id = isRecord23(doc) ? doc.schema : void 0;
28896
29350
  if (id !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(id)}, not ${SCHEMA_IDS[name]}`;
28897
29351
  if (compiled4[name](doc)) return void 0;
28898
29352
  const e = compiled4[name].errors?.[0];
@@ -28904,7 +29358,7 @@ function terragucciValidator(dirs = []) {
28904
29358
  for (const from of [...dirs, dirname11(fileURLToPath7(import.meta.url))]) {
28905
29359
  let entry;
28906
29360
  try {
28907
- entry = createRequire4(join43(resolve24(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
29361
+ entry = createRequire4(join44(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
28908
29362
  } catch {
28909
29363
  continue;
28910
29364
  }
@@ -28927,7 +29381,7 @@ function terragucciValidator(dirs = []) {
28927
29381
  }
28928
29382
  function waveBlocked(w) {
28929
29383
  const rows = w && Array.isArray(w.blocked) ? w.blocked : [];
28930
- return rows.flatMap((b) => isRecord22(b) && str19(b.root) && b.root && str19(b.blocked_by) && b.blocked_by ? [{ root: b.root, by: b.blocked_by }] : []);
29384
+ return rows.flatMap((b) => isRecord23(b) && str19(b.root) && b.root && str19(b.blocked_by) && b.blocked_by ? [{ root: b.root, by: b.blocked_by }] : []);
28931
29385
  }
28932
29386
  var RESULT_COMMITS = 4;
28933
29387
  function waveResult(w, finished) {
@@ -29018,7 +29472,7 @@ async function readTerragucci(source2, opts = {}) {
29018
29472
  }
29019
29473
  const project = pickProject(index.reports, opts, source2);
29020
29474
  const rows = index.reports.filter((r) => r.project === project).sort(newestFirst);
29021
- const cache6 = /* @__PURE__ */ new Map();
29475
+ const cache7 = /* @__PURE__ */ new Map();
29022
29476
  const facts = {};
29023
29477
  const seenRoots = /* @__PURE__ */ new Set();
29024
29478
  const note = (doc) => {
@@ -29031,12 +29485,12 @@ async function readTerragucci(source2, opts = {}) {
29031
29485
  };
29032
29486
  const report = (row) => {
29033
29487
  const key3 = under(row.path, "report.json");
29034
- if (!cache6.has(key3)) {
29488
+ if (!cache7.has(key3)) {
29035
29489
  const p = readDoc2(source2, key3, "report", v);
29036
- cache6.set(key3, p);
29490
+ cache7.set(key3, p);
29037
29491
  void p.then(note, () => void 0);
29038
29492
  }
29039
- return cache6.get(key3);
29493
+ return cache7.get(key3);
29040
29494
  };
29041
29495
  const wanted = opts.roots ? new Set(opts.roots) : void 0;
29042
29496
  const roots = {};
@@ -29140,7 +29594,7 @@ async function readTerragucci(source2, opts = {}) {
29140
29594
  if (commit && Object.keys(found).length) blocked = { commit, roots: found };
29141
29595
  if (commit && Object.keys(own).length) outcomes2 = { commit, roots: own };
29142
29596
  }
29143
- const results = {};
29597
+ const results2 = {};
29144
29598
  {
29145
29599
  const applies = rows.filter((r) => r.stage === "tf-apply" && r.wave !== void 0);
29146
29600
  for (const commit of [...new Set(applies.map((r) => r.commit))].slice(0, RESULT_COMMITS)) {
@@ -29153,11 +29607,11 @@ async function readTerragucci(source2, opts = {}) {
29153
29607
  const res = waveResult(doc?.waves.find((w) => w.number === r.wave) ?? doc?.waves[0], doc?.run.finished ?? r.finished);
29154
29608
  if (res) out.push({ ...res, wave: r.wave });
29155
29609
  }
29156
- if (out.length) results[commit] = out.sort((a, b) => a.wave - b.wave);
29610
+ if (out.length) results2[commit] = out.sort((a, b) => a.wave - b.wave);
29157
29611
  }
29158
29612
  }
29159
29613
  if (pullRequest && prRow && prDoc) {
29160
- await Promise.all([...cache6.values()].map((p) => p.catch(() => void 0)));
29614
+ await Promise.all([...cache7.values()].map((p) => p.catch(() => void 0)));
29161
29615
  const planned = prDoc.roots.some((r) => r.cone !== void 0) ? await readConePlans(source2, prRow.path, prDoc) : {};
29162
29616
  const cone = coneView(prDoc, { roots: [.../* @__PURE__ */ new Set([...opts.roots ?? [], ...seenRoots])], planned, facts });
29163
29617
  if (cone) pullRequest.cone = cone;
@@ -29168,7 +29622,7 @@ async function readTerragucci(source2, opts = {}) {
29168
29622
  project,
29169
29623
  validation: v.validation,
29170
29624
  read: (opts.now ?? /* @__PURE__ */ new Date()).toISOString(),
29171
- reports: cache6.size,
29625
+ reports: cache7.size,
29172
29626
  roots,
29173
29627
  waiting,
29174
29628
  ...pullRequest ? { pull_request: pullRequest } : {},
@@ -29186,7 +29640,7 @@ async function readTerragucci(source2, opts = {}) {
29186
29640
  } : {},
29187
29641
  ...blocked ? { blocked } : {},
29188
29642
  ...outcomes2 ? { outcomes: outcomes2 } : {},
29189
- ...Object.keys(results).length ? { results } : {}
29643
+ ...Object.keys(results2).length ? { results: results2 } : {}
29190
29644
  };
29191
29645
  }
29192
29646
  function pullRequestPlan(doc, report) {
@@ -29367,11 +29821,11 @@ function joinTerragucci(read, nodes, roots) {
29367
29821
  }
29368
29822
 
29369
29823
  // src/terragucci-timeline.ts
29370
- import { readFileSync as readFileSync33, statSync as statSync12 } from "node:fs";
29824
+ import { readFileSync as readFileSync34, statSync as statSync12 } from "node:fs";
29371
29825
  import { createRequire as createRequire5 } from "node:module";
29372
- import { dirname as dirname12, join as join44, resolve as resolve25 } from "node:path";
29826
+ import { dirname as dirname12, join as join45, resolve as resolve26 } from "node:path";
29373
29827
  import { fileURLToPath as fileURLToPath8 } from "node:url";
29374
- import { Ajv2020 as Ajv20205 } from "ajv/dist/2020.js";
29828
+ import { Ajv2020 as Ajv20206 } from "ajv/dist/2020.js";
29375
29829
  var AUDIT_SCHEMA = "terragucci.audit/v1";
29376
29830
  var AUDIT_KEY = "audit.jsonl";
29377
29831
  var AUDIT_SCHEMA_FILE = "audit.schema.json";
@@ -29379,25 +29833,25 @@ var WHAT_IS_ROOT = /* @__PURE__ */ new Set(["override-requested", "override", "o
29379
29833
  var TIMELINE_LIMIT = 200;
29380
29834
  var TIMELINE_MAX = 1e3;
29381
29835
  var TIMELINE_TTL_MS = 3e4;
29382
- var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29836
+ var isRecord24 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29383
29837
  var str20 = (v) => typeof v === "string";
29384
29838
  function structuralAudit(doc) {
29385
- if (!isRecord23(doc)) return "it is not a JSON object";
29839
+ if (!isRecord24(doc)) return "it is not a JSON object";
29386
29840
  if (doc.schema !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${AUDIT_SCHEMA}`;
29387
29841
  for (const f of ["id", "kind", "project", "at", "what", "result"]) if (!str20(doc[f])) return `its ${f} is not a string`;
29388
29842
  if (Number.isNaN(Date.parse(doc.at))) return `its at, ${JSON.stringify(doc.at)}, is not a time`;
29389
29843
  if (doc.who !== null && !str20(doc.who)) return "its who is neither a string nor null";
29390
29844
  if (doc.digest !== null && !str20(doc.digest)) return "its digest is neither a string nor null";
29391
- if (!isRecord23(doc.evidence) || !str20(doc.evidence.source)) return "its evidence has no source";
29392
- if (doc.detail !== void 0 && !isRecord23(doc.detail)) return "its detail is not an object";
29845
+ if (!isRecord24(doc.evidence) || !str20(doc.evidence.source)) return "its evidence has no source";
29846
+ if (doc.detail !== void 0 && !isRecord24(doc.detail)) return "its detail is not an object";
29393
29847
  return void 0;
29394
29848
  }
29395
29849
  function compileAuditSchema(schema, version) {
29396
- const v = new Ajv20205({ strict: false, allErrors: false }).compile(schema);
29850
+ const v = new Ajv20206({ strict: false, allErrors: false }).compile(schema);
29397
29851
  return {
29398
29852
  validation: { by: "schema", terragucci: version },
29399
29853
  check(doc) {
29400
- const id = isRecord23(doc) ? doc.schema : void 0;
29854
+ const id = isRecord24(doc) ? doc.schema : void 0;
29401
29855
  if (id !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${AUDIT_SCHEMA}`;
29402
29856
  if (v(doc)) return void 0;
29403
29857
  const e = v.errors?.[0];
@@ -29410,12 +29864,12 @@ function auditValidator(dirs = []) {
29410
29864
  for (const from of [...dirs, dirname12(fileURLToPath8(import.meta.url))]) {
29411
29865
  let dist;
29412
29866
  try {
29413
- dist = dirname12(createRequire5(join44(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
29867
+ dist = dirname12(createRequire5(join45(resolve26(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
29414
29868
  } catch {
29415
29869
  continue;
29416
29870
  }
29417
- const pkg = join44(dist, "..", "package.json");
29418
- const file = join44(dist, AUDIT_SCHEMA_FILE);
29871
+ const pkg = join45(dist, "..", "package.json");
29872
+ const file = join45(dist, AUDIT_SCHEMA_FILE);
29419
29873
  let stamp;
29420
29874
  try {
29421
29875
  stamp = [dist, ...[pkg, file].map((f) => {
@@ -29429,8 +29883,8 @@ function auditValidator(dirs = []) {
29429
29883
  if (hit) return hit;
29430
29884
  let v;
29431
29885
  try {
29432
- const version = JSON.parse(readFileSync33(pkg, "utf8")).version ?? "";
29433
- v = compileAuditSchema(JSON.parse(readFileSync33(file, "utf8")), version);
29886
+ const version = JSON.parse(readFileSync34(pkg, "utf8")).version ?? "";
29887
+ v = compileAuditSchema(JSON.parse(readFileSync34(file, "utf8")), version);
29434
29888
  } catch {
29435
29889
  continue;
29436
29890
  }
@@ -29472,8 +29926,8 @@ function ownRoots(e) {
29472
29926
  if (Array.isArray(listed)) {
29473
29927
  for (const r of listed) {
29474
29928
  if (str20(r)) roots.add(r);
29475
- else if (isRecord23(r) && str20(r.root)) roots.add(r.root);
29476
- else if (isRecord23(r) && str20(r.path)) roots.add(r.path);
29929
+ else if (isRecord24(r) && str20(r.root)) roots.add(r.root);
29930
+ else if (isRecord24(r) && str20(r.path)) roots.add(r.path);
29477
29931
  }
29478
29932
  }
29479
29933
  if (WHAT_IS_ROOT.has(e.kind)) roots.add(e.what);
@@ -29628,7 +30082,7 @@ function terragucciTimelineRoute(app, source2, opts = {}) {
29628
30082
  // src/terragucci-poll.ts
29629
30083
  import { createHash as createHash10 } from "node:crypto";
29630
30084
  import { stat as stat2 } from "node:fs/promises";
29631
- import { join as join45, resolve as resolve26 } from "node:path";
30085
+ import { join as join46, resolve as resolve27 } from "node:path";
29632
30086
  import { streamSSE } from "hono/streaming";
29633
30087
  var TERRAGUCCI_POLL_SECS = 30;
29634
30088
  var INDEX_KEY = "index.json";
@@ -29679,7 +30133,7 @@ function indexProbe(spec2, opts = {}) {
29679
30133
  return verdict2(prev, etag);
29680
30134
  };
29681
30135
  }
29682
- const file = join45(resolve26(opts.cwd ?? process.cwd(), spec2), name);
30136
+ const file = join46(resolve27(opts.cwd ?? process.cwd(), spec2), name);
29683
30137
  return async (prev) => {
29684
30138
  try {
29685
30139
  const s = await stat2(file);
@@ -29834,29 +30288,29 @@ function terragucciLaneRoutes(app, o, base, forget) {
29834
30288
  }
29835
30289
 
29836
30290
  // src/terragucci-progress.ts
29837
- import { readFileSync as readFileSync34, statSync as statSync13 } from "node:fs";
30291
+ import { readFileSync as readFileSync35, statSync as statSync13 } from "node:fs";
29838
30292
  import { createRequire as createRequire6 } from "node:module";
29839
- import { dirname as dirname13, join as join46, resolve as resolve27 } from "node:path";
30293
+ import { dirname as dirname13, join as join47, resolve as resolve28 } from "node:path";
29840
30294
  import { fileURLToPath as fileURLToPath9 } from "node:url";
29841
- import { Ajv2020 as Ajv20206 } from "ajv/dist/2020.js";
30295
+ import { Ajv2020 as Ajv20207 } from "ajv/dist/2020.js";
29842
30296
  var RUN_SCHEMA = "terragucci.run/v1";
29843
30297
  var RUN_SCHEMA_FILE = "run.schema.json";
29844
30298
  var PROGRESS_TTL_MS = 3e4;
29845
30299
  var PROGRESS_STATUSES = ["done", "in-flight", "waiting", "not-applied"];
29846
- var isRecord24 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
30300
+ var isRecord25 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29847
30301
  var str21 = (v) => typeof v === "string";
29848
30302
  function structuralRun(doc) {
29849
- if (!isRecord24(doc)) return "it is not a JSON object";
30303
+ if (!isRecord25(doc)) return "it is not a JSON object";
29850
30304
  if (doc.schema !== RUN_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA}`;
29851
30305
  for (const f of ["project", "commit", "updated"]) if (!str21(doc[f])) return `its ${f} is not a string`;
29852
30306
  if (!Array.isArray(doc.waves)) return "it has no waves array";
29853
30307
  for (const [i, w] of doc.waves.entries()) {
29854
- if (!isRecord24(w) || typeof w.number !== "number" || !str21(w.state) || !str21(w.gate) || !Array.isArray(w.roots)) return `wave ${i} lacks number, state, gate or roots`;
30308
+ if (!isRecord25(w) || typeof w.number !== "number" || !str21(w.state) || !str21(w.gate) || !Array.isArray(w.roots)) return `wave ${i} lacks number, state, gate or roots`;
29855
30309
  if (w.progress === void 0) continue;
29856
30310
  const p = w.progress;
29857
- if (!isRecord24(p) || !str21(p.read) || !Array.isArray(p.resources)) return `wave ${String(w.number)}'s progress lacks read or resources`;
30311
+ if (!isRecord25(p) || !str21(p.read) || !Array.isArray(p.resources)) return `wave ${String(w.number)}'s progress lacks read or resources`;
29858
30312
  for (const r of p.resources) {
29859
- if (!isRecord24(r) || !str21(r.root) || !str21(r.address) || !str21(r.action)) return `a resource of wave ${String(w.number)}'s progress lacks root, address or action`;
30313
+ if (!isRecord25(r) || !str21(r.root) || !str21(r.address) || !str21(r.action)) return `a resource of wave ${String(w.number)}'s progress lacks root, address or action`;
29860
30314
  if (!PROGRESS_STATUSES.includes(r.status)) return `a resource of wave ${String(w.number)}'s progress has status ${JSON.stringify(r.status)}`;
29861
30315
  if (r.done_at !== void 0 && !str21(r.done_at)) return `a resource of wave ${String(w.number)}'s progress has a done_at that is not a string`;
29862
30316
  }
@@ -29864,11 +30318,11 @@ function structuralRun(doc) {
29864
30318
  return void 0;
29865
30319
  }
29866
30320
  function compileRunSchema(schema, version) {
29867
- const v = new Ajv20206({ strict: false, allErrors: false }).compile(schema);
30321
+ const v = new Ajv20207({ strict: false, allErrors: false }).compile(schema);
29868
30322
  return {
29869
30323
  validation: { by: "schema", terragucci: version },
29870
30324
  check(doc) {
29871
- const id = isRecord24(doc) ? doc.schema : void 0;
30325
+ const id = isRecord25(doc) ? doc.schema : void 0;
29872
30326
  if (id !== RUN_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA}`;
29873
30327
  if (v(doc)) return void 0;
29874
30328
  const e = v.errors?.[0];
@@ -29881,12 +30335,12 @@ function runValidator(dirs = []) {
29881
30335
  for (const from of [...dirs, dirname13(fileURLToPath9(import.meta.url))]) {
29882
30336
  let dist;
29883
30337
  try {
29884
- dist = dirname13(createRequire6(join46(resolve27(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
30338
+ dist = dirname13(createRequire6(join47(resolve28(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
29885
30339
  } catch {
29886
30340
  continue;
29887
30341
  }
29888
- const pkg = join46(dist, "..", "package.json");
29889
- const file = join46(dist, RUN_SCHEMA_FILE);
30342
+ const pkg = join47(dist, "..", "package.json");
30343
+ const file = join47(dist, RUN_SCHEMA_FILE);
29890
30344
  let stamp;
29891
30345
  try {
29892
30346
  stamp = [dist, ...[pkg, file].map((f) => {
@@ -29900,8 +30354,8 @@ function runValidator(dirs = []) {
29900
30354
  if (hit) return hit;
29901
30355
  let v;
29902
30356
  try {
29903
- const version = JSON.parse(readFileSync34(pkg, "utf8")).version ?? "";
29904
- v = compileRunSchema(JSON.parse(readFileSync34(file, "utf8")), version);
30357
+ const version = JSON.parse(readFileSync35(pkg, "utf8")).version ?? "";
30358
+ v = compileRunSchema(JSON.parse(readFileSync35(file, "utf8")), version);
29905
30359
  } catch {
29906
30360
  continue;
29907
30361
  }
@@ -30096,7 +30550,7 @@ var TerragucciProgress = class {
30096
30550
  /** One GET of run.json, checked and joined. */
30097
30551
  async readRun(project, commit, key3, v) {
30098
30552
  const src = this.o.source;
30099
- const validator4 = v ?? runValidator();
30553
+ const validator5 = v ?? runValidator();
30100
30554
  let text3;
30101
30555
  let unreadable;
30102
30556
  try {
@@ -30111,7 +30565,7 @@ var TerragucciProgress = class {
30111
30565
  const html = key3.replace(/run\.json$/, "run.html");
30112
30566
  if (text3 === void 0) {
30113
30567
  return {
30114
- ...this.base(project, validator4.validation),
30568
+ ...this.base(project, validator5.validation),
30115
30569
  run: { commit, key: key3, present: false },
30116
30570
  ...unreadable ? { unreadable: true } : {},
30117
30571
  absent: unreadable ?? `${src.location} has no ${key3}: terragucci writes the run view when reports.bucket is set, and a wave's progress per resource only for a choudoufu wave (terragucci 0.4.7 and newer). This says nothing about whether the apply moved.`,
@@ -30129,11 +30583,11 @@ var TerragucciProgress = class {
30129
30583
  } catch {
30130
30584
  refuse12(`${key3} in ${src.location} is not JSON.`, "Check that terragucci wrote it.");
30131
30585
  }
30132
- const why = validator4.check(doc);
30586
+ const why = validator5.check(doc);
30133
30587
  if (why) {
30134
30588
  refuse12(
30135
30589
  `${key3} in ${src.location} is not a terragucci ${RUN_SCHEMA} document: ${why}.`,
30136
- validator4.validation.by === "schema" ? `It was checked against @intentius/terragucci ${validator4.validation.terragucci}'s ${RUN_SCHEMA_FILE}. Check that this terragucci wrote it, or upgrade behold.` : "Install @intentius/terragucci beside behold to check it against terragucci's own JSON Schema, and check that terragucci wrote it."
30590
+ validator5.validation.by === "schema" ? `It was checked against @intentius/terragucci ${validator5.validation.terragucci}'s ${RUN_SCHEMA_FILE}. Check that this terragucci wrote it, or upgrade behold.` : "Install @intentius/terragucci beside behold to check it against terragucci's own JSON Schema, and check that terragucci wrote it."
30137
30591
  );
30138
30592
  }
30139
30593
  const run4 = doc;
@@ -30144,7 +30598,7 @@ var TerragucciProgress = class {
30144
30598
  throw new ProgressGraphError(`behold could not read the checkout's roots to place the progress on: ${e instanceof Error ? e.message : String(e)}`);
30145
30599
  }
30146
30600
  return {
30147
- ...this.base(project, validator4.validation),
30601
+ ...this.base(project, validator5.validation),
30148
30602
  run: { commit, key: key3, present: true, updated: run4.updated, html },
30149
30603
  ...joinProgress(run4, ctx.nodes, ctx.roots)
30150
30604
  };
@@ -30195,21 +30649,21 @@ function terragucciProgressRoute(app, progress) {
30195
30649
  }
30196
30650
 
30197
30651
  // src/terragucci-tour.ts
30198
- import { readFileSync as readFileSync35, readdirSync as readdirSync17, existsSync as existsSync28 } from "node:fs";
30199
- import { dirname as dirname14, join as join47 } from "node:path";
30652
+ import { readFileSync as readFileSync36, readdirSync as readdirSync17, existsSync as existsSync29 } from "node:fs";
30653
+ import { dirname as dirname14, join as join48 } from "node:path";
30200
30654
  import { fileURLToPath as fileURLToPath10 } from "node:url";
30201
- import { Ajv2020 as Ajv20207 } from "ajv/dist/2020.js";
30655
+ import { Ajv2020 as Ajv20208 } from "ajv/dist/2020.js";
30202
30656
  var TOUR_SCHEMA_ID = "behold.tour/v1";
30203
- var isRecord25 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30657
+ var isRecord26 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30204
30658
  var str22 = (v) => typeof v === "string" && v.length > 0;
30205
30659
  var num4 = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
30206
- var webRoot = join47(dirname14(fileURLToPath10(import.meta.url)), "..", "web");
30207
- var TOURS_DIR = join47(webRoot, "tours");
30208
- var TOUR_SCHEMA_FILE = join47(TOURS_DIR, "behold.tour.v1.schema.json");
30209
- var validator3 = null;
30660
+ var webRoot = join48(dirname14(fileURLToPath10(import.meta.url)), "..", "web");
30661
+ var TOURS_DIR = join48(webRoot, "tours");
30662
+ var TOUR_SCHEMA_FILE = join48(TOURS_DIR, "behold.tour.v1.schema.json");
30663
+ var validator4 = null;
30210
30664
  function tourProblem(doc) {
30211
- if (!validator3) validator3 = new Ajv20207({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync35(TOUR_SCHEMA_FILE, "utf8")));
30212
- if (validator3(doc)) {
30665
+ if (!validator4) validator4 = new Ajv20208({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync36(TOUR_SCHEMA_FILE, "utf8")));
30666
+ if (validator4(doc)) {
30213
30667
  const t2 = doc;
30214
30668
  const runs2 = new Set(Object.keys(t2.runs ?? {}));
30215
30669
  const facts = new Set(Object.keys(t2.facts ?? {}));
@@ -30229,11 +30683,11 @@ function tourProblem(doc) {
30229
30683
  }
30230
30684
  return void 0;
30231
30685
  }
30232
- const e = validator3.errors?.[0];
30686
+ const e = validator4.errors?.[0];
30233
30687
  return e ? `${e.instancePath || "the file"} ${e.message ?? "is not behold.tour/v1"}` : "it is not behold.tour/v1";
30234
30688
  }
30235
30689
  function toursIn(dir, from, problems) {
30236
- if (!existsSync28(dir)) return [];
30690
+ if (!existsSync29(dir)) return [];
30237
30691
  const out = [];
30238
30692
  let names = [];
30239
30693
  try {
@@ -30244,25 +30698,25 @@ function toursIn(dir, from, problems) {
30244
30698
  for (const f of names) {
30245
30699
  let doc;
30246
30700
  try {
30247
- doc = JSON.parse(readFileSync35(join47(dir, f), "utf8"));
30701
+ doc = JSON.parse(readFileSync36(join48(dir, f), "utf8"));
30248
30702
  } catch {
30249
- problems.push(`${join47(dir, f)} is not JSON`);
30703
+ problems.push(`${join48(dir, f)} is not JSON`);
30250
30704
  continue;
30251
30705
  }
30252
30706
  const p = tourProblem(doc);
30253
- if (p) problems.push(`${join47(dir, f)} is not a ${TOUR_SCHEMA_ID} tour: ${p}`);
30254
- else out.push({ tour: doc, from: from(join47(dir, f)) });
30707
+ if (p) problems.push(`${join48(dir, f)} is not a ${TOUR_SCHEMA_ID} tour: ${p}`);
30708
+ else out.push({ tour: doc, from: from(join48(dir, f)) });
30255
30709
  }
30256
30710
  return out;
30257
30711
  }
30258
30712
  function findTour(demo, dirs, problems, shipped = TOURS_DIR) {
30259
30713
  if (!demo) return null;
30260
- const all = [...dirs.flatMap((d) => toursIn(join47(d, ".behold", "tours"), (f) => f, problems)), ...toursIn(shipped, () => "behold", problems)];
30714
+ const all = [...dirs.flatMap((d) => toursIn(join48(d, ".behold", "tours"), (f) => f, problems)), ...toursIn(shipped, () => "behold", problems)];
30261
30715
  const fits = (t2) => !!t2.match && Object.entries(t2.match).every(([k, v]) => demo[k] === v);
30262
30716
  return all.find((t2) => fits(t2.tour)) ?? null;
30263
30717
  }
30264
30718
  function tourRow(v) {
30265
- if (!isRecord25(v) || !str22(v.project) || !str22(v.commit) || !str22(v.stage) || !str22(v.finished) || !str22(v.path)) return void 0;
30719
+ if (!isRecord26(v) || !str22(v.project) || !str22(v.commit) || !str22(v.stage) || !str22(v.finished) || !str22(v.path)) return void 0;
30266
30720
  return {
30267
30721
  project: v.project,
30268
30722
  commit: v.commit,
@@ -30301,14 +30755,14 @@ async function readDoc3(source2, k, problems) {
30301
30755
  var keyOf = (...p) => p.join("/").split("/").filter((s) => s && s !== ".").join("/");
30302
30756
  var rootPath = (p) => p.replace(/^\.\/+/, "").replace(/\/+$/, "") || ".";
30303
30757
  function planCounts(report, roots = null) {
30304
- if (!isRecord25(report) || !Array.isArray(report.roots)) return null;
30758
+ if (!isRecord26(report) || !Array.isArray(report.roots)) return null;
30305
30759
  let planned = 0;
30306
30760
  let changed = 0;
30307
30761
  let recreated = 0;
30308
30762
  let deleted = 0;
30309
30763
  let any = false;
30310
30764
  for (const r of report.roots) {
30311
- if (!isRecord25(r) || !isRecord25(r.counts)) continue;
30765
+ if (!isRecord26(r) || !isRecord26(r.counts)) continue;
30312
30766
  if (roots && !roots.includes(rootPath(String(r.path ?? ".")))) continue;
30313
30767
  any = true;
30314
30768
  for (const [a, n] of Object.entries(r.counts)) {
@@ -30322,24 +30776,24 @@ function planCounts(report, roots = null) {
30322
30776
  return any ? { planned, changed, recreated, deleted } : null;
30323
30777
  }
30324
30778
  function waveRoots(report, n) {
30325
- if (n === void 0 || !isRecord25(report) || !Array.isArray(report.waves)) return null;
30326
- const w = report.waves.find((x) => isRecord25(x) && x.number === n);
30327
- return isRecord25(w) && Array.isArray(w.roots) ? w.roots.filter(str22).map(rootPath) : null;
30779
+ if (n === void 0 || !isRecord26(report) || !Array.isArray(report.waves)) return null;
30780
+ const w = report.waves.find((x) => isRecord26(x) && x.number === n);
30781
+ return isRecord26(w) && Array.isArray(w.roots) ? w.roots.filter(str22).map(rootPath) : null;
30328
30782
  }
30329
30783
  function planAddresses(plan) {
30330
- if (!isRecord25(plan) || !Array.isArray(plan.resource_changes)) return [];
30784
+ if (!isRecord26(plan) || !Array.isArray(plan.resource_changes)) return [];
30331
30785
  const out = [];
30332
30786
  for (const rc of plan.resource_changes) {
30333
- if (!isRecord25(rc) || !str22(rc.address) || rc.mode === "data") continue;
30334
- const acts = isRecord25(rc.change) && Array.isArray(rc.change.actions) ? rc.change.actions.filter(str22) : [];
30787
+ if (!isRecord26(rc) || !str22(rc.address) || rc.mode === "data") continue;
30788
+ const acts = isRecord26(rc.change) && Array.isArray(rc.change.actions) ? rc.change.actions.filter(str22) : [];
30335
30789
  out.push({ address: rc.address, changed: !acts.every((a) => a === "no-op" || a === "read") });
30336
30790
  }
30337
30791
  return out;
30338
30792
  }
30339
30793
  function plannedOutput(plan, name) {
30340
- if (!isRecord25(plan) || !isRecord25(plan.output_changes)) return void 0;
30794
+ if (!isRecord26(plan) || !isRecord26(plan.output_changes)) return void 0;
30341
30795
  const o = plan.output_changes[name];
30342
- if (!isRecord25(o) || o.after_unknown === true || o.after_sensitive === true) return void 0;
30796
+ if (!isRecord26(o) || o.after_unknown === true || o.after_sensitive === true) return void 0;
30343
30797
  const v = o.after;
30344
30798
  return typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? v : void 0;
30345
30799
  }
@@ -30387,7 +30841,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30387
30841
  } catch {
30388
30842
  problems.push(`${project}/index.json is not JSON`);
30389
30843
  }
30390
- const list4 = (isRecord25(doc) && Array.isArray(doc.reports) ? doc.reports : []).map(tourRow).filter((r) => !!r && (Number.isNaN(from) || Date.parse(r.finished) >= from)).sort((a, b) => Date.parse(a.finished) - Date.parse(b.finished));
30844
+ const list4 = (isRecord26(doc) && Array.isArray(doc.reports) ? doc.reports : []).map(tourRow).filter((r) => !!r && (Number.isNaN(from) || Date.parse(r.finished) >= from)).sort((a, b) => Date.parse(a.finished) - Date.parse(b.finished));
30391
30845
  rows.set(project, list4);
30392
30846
  return list4;
30393
30847
  };
@@ -30396,7 +30850,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30396
30850
  let row;
30397
30851
  if (spec2.migration) {
30398
30852
  const m = ctx.migrations.find((x) => x.name === spec2.migration);
30399
- const commit = m && isRecord25(m.record) && str22(m.record.commit) ? m.record.commit : null;
30853
+ const commit = m && isRecord26(m.record) && str22(m.record.commit) ? m.record.commit : null;
30400
30854
  if (m && commit) row = (await rowsOf(m.home)).find((r) => r.commit === commit && r.stage === "tf-apply");
30401
30855
  } else if (spec2.repo && spec2.stage) {
30402
30856
  const project = projectOf(spec2.repo);
@@ -30412,12 +30866,12 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30412
30866
  }
30413
30867
  const reportOf = async (f) => f.report ??= await readDoc3(source2, keyOf(f.row.project, f.row.path, "report.json"), problems);
30414
30868
  const planOf = async (f, root) => {
30415
- const p = isRecord25(root.plan) && str22(root.plan.json) ? root.plan.json : null;
30869
+ const p = isRecord26(root.plan) && str22(root.plan.json) ? root.plan.json : null;
30416
30870
  return p ? readDoc3(source2, keyOf(f.row.project, f.row.path, p), problems) : void 0;
30417
30871
  };
30418
30872
  const rootsOf = async (f) => {
30419
30873
  const rep = await reportOf(f);
30420
- return isRecord25(rep) && Array.isArray(rep.roots) ? rep.roots.filter(isRecord25) : [];
30874
+ return isRecord26(rep) && Array.isArray(rep.roots) ? rep.roots.filter(isRecord26) : [];
30421
30875
  };
30422
30876
  const recordEstates = /* @__PURE__ */ new Map();
30423
30877
  const note = (project, root, estate) => {
@@ -30427,13 +30881,13 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30427
30881
  recordEstates.get(k).add(estate);
30428
30882
  };
30429
30883
  for (const m of ctx.migrations) {
30430
- const rec7 = isRecord25(m.record) ? m.record : null;
30884
+ const rec7 = isRecord26(m.record) ? m.record : null;
30431
30885
  if (!rec7) continue;
30432
- for (const r of Array.isArray(rec7.retags) ? rec7.retags.filter(isRecord25) : []) {
30886
+ for (const r of Array.isArray(rec7.retags) ? rec7.retags.filter(isRecord26) : []) {
30433
30887
  note(m.home, r.to, r.to_estate);
30434
30888
  note(m.home, r.from, r.from_estate);
30435
30889
  }
30436
- for (const r of Array.isArray(rec7.stamps) ? rec7.stamps.filter(isRecord25) : []) note(m.home, r.root, r.estate);
30890
+ for (const r of Array.isArray(rec7.stamps) ? rec7.stamps.filter(isRecord26) : []) note(m.home, r.root, r.estate);
30437
30891
  }
30438
30892
  const estatesOf = (project, root) => {
30439
30893
  const rp = rootPath(root);
@@ -30443,7 +30897,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30443
30897
  const facts = {};
30444
30898
  const recordOf = (name) => {
30445
30899
  const m = ctx.migrations.find((x) => x.name === name);
30446
- return m && isRecord25(m.record) ? m.record : null;
30900
+ return m && isRecord26(m.record) ? m.record : null;
30447
30901
  };
30448
30902
  for (const [name, f] of Object.entries(t2.facts ?? {})) {
30449
30903
  let v;
@@ -30466,10 +30920,10 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30466
30920
  } else if ("migration" in f) {
30467
30921
  const rec7 = recordOf(f.migration);
30468
30922
  if (!rec7) continue;
30469
- const p = isRecord25(rec7.progress) ? rec7.progress : null;
30923
+ const p = isRecord26(rec7.progress) ? rec7.progress : null;
30470
30924
  if (f.value === "version_id") {
30471
- const root = Array.isArray(rec7.roots) ? rec7.roots.find((x) => isRecord25(x) && isRecord25(x.source) && str22(x.source.version_id)) : void 0;
30472
- if (isRecord25(root) && isRecord25(root.source)) v = root.source.version_id;
30925
+ const root = Array.isArray(rec7.roots) ? rec7.roots.find((x) => isRecord26(x) && isRecord26(x.source) && str22(x.source.version_id)) : void 0;
30926
+ if (isRecord26(root) && isRecord26(root.source)) v = root.source.version_id;
30473
30927
  } else if (f.value === "approved_by") v = str22(rec7.approved_by) ? rec7.approved_by : void 0;
30474
30928
  else if (f.value === "moved_resources" || f.value === "stamped_resources" || f.value === "refused_resources") {
30475
30929
  const m = ctx.migrations.find((x) => x.name === f.migration);
@@ -30481,7 +30935,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30481
30935
  } else if ("sum" in f) {
30482
30936
  if (f.sum.every((x) => typeof facts[x] === "number")) v = f.sum.reduce((s, x) => s + facts[x], 0);
30483
30937
  } else if ("approvals" in f) {
30484
- const migs = ctx.migrations.filter((m) => isRecord25(m.record) && str22(m.record.approved_by)).length;
30938
+ const migs = ctx.migrations.filter((m) => isRecord26(m.record) && str22(m.record.approved_by)).length;
30485
30939
  let waves = 0;
30486
30940
  for (const list4 of rows.values()) waves += list4.filter((r) => r.stage === "tf-apply" && r.approval === "approved").length;
30487
30941
  if (ctx.migrations.length || rows.size) v = migs + waves;
@@ -30533,7 +30987,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30533
30987
  const threads = [];
30534
30988
  let value;
30535
30989
  for (const root of roots) {
30536
- const reads2 = Array.isArray(root.reads) ? root.reads.filter(isRecord25) : [];
30990
+ const reads2 = Array.isArray(root.reads) ? root.reads.filter(isRecord26) : [];
30537
30991
  for (const rd of reads2) {
30538
30992
  if (!str22(rd.upstream)) continue;
30539
30993
  threads.push({ from: estatesOf(r.row.project, rd.upstream), to: estatesOf(r.row.project, String(root.path ?? ".")) });
@@ -30548,8 +31002,8 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30548
31002
  }
30549
31003
  if (s.state) {
30550
31004
  const rec7 = recordOf(s.state);
30551
- const root = rec7 && Array.isArray(rec7.roots) ? rec7.roots.find((x) => isRecord25(x) && isRecord25(x.source) && str22(x.source.version_id)) : void 0;
30552
- if (!isRecord25(root) || !isRecord25(root.source)) return null;
31005
+ const root = rec7 && Array.isArray(rec7.roots) ? rec7.roots.find((x) => isRecord26(x) && isRecord26(x.source) && str22(x.source.version_id)) : void 0;
31006
+ if (!isRecord26(root) || !isRecord26(root.source)) return null;
30553
31007
  const m = ctx.migrations.find((x) => x.name === s.state);
30554
31008
  return {
30555
31009
  ...base,
@@ -30565,7 +31019,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30565
31019
  if (s.checks) {
30566
31020
  const r = found.get(s.checks);
30567
31021
  if (!r) return null;
30568
- const checks = (await rootsOf(r)).filter((x) => isRecord25(x.counts)).map((x) => {
31022
+ const checks = (await rootsOf(r)).filter((x) => isRecord26(x.counts)).map((x) => {
30569
31023
  const rp = rootPath(String(x.path ?? "."));
30570
31024
  const counts = x.counts;
30571
31025
  return { root: rp, estates: estatesOf(r.row.project, rp), noChange: Object.entries(counts).every(([a, n]) => a === "no-op" || !n), counts };
@@ -30600,14 +31054,14 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30600
31054
  const ats = m.lines.map((l) => Date.parse(l.at)).filter((x) => !Number.isNaN(x));
30601
31055
  if (!ats.length) continue;
30602
31056
  events.push({ kind: "line", migration: m.name, line: "first", at: Math.min(...ats) });
30603
- const rec7 = isRecord25(m.record) ? m.record : null;
31057
+ const rec7 = isRecord26(m.record) ? m.record : null;
30604
31058
  const done = !m.running && !!rec7 && (str22(rec7.finished) || str22(rec7.status) && FINAL.has(rec7.status));
30605
31059
  if (done) events.push({ kind: "line", migration: m.name, line: "last", at: Math.max(...ats) });
30606
31060
  }
30607
- const runs2 = isRecord25(runsIndex) && Array.isArray(runsIndex.runs) ? runsIndex.runs.filter(isRecord25) : [];
31061
+ const runs2 = isRecord26(runsIndex) && Array.isArray(runsIndex.runs) ? runsIndex.runs.filter(isRecord26) : [];
30608
31062
  for (const run4 of runs2) {
30609
31063
  if (run4.cycle !== ctx.demo.cycle || !str22(run4.repo) || !(run4.repo === repo || run4.repo.startsWith(`${repo}-`))) continue;
30610
- for (const j of Array.isArray(run4.jobs) ? run4.jobs.filter(isRecord25) : []) {
31064
+ for (const j of Array.isArray(run4.jobs) ? run4.jobs.filter(isRecord26) : []) {
30611
31065
  const w = str22(j.name) ? /^apply-wave-(\d+)$/.exec(j.name) : null;
30612
31066
  if (!w) continue;
30613
31067
  const wave = Number(w[1]);
@@ -30628,7 +31082,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30628
31082
  }
30629
31083
  const migrationRuns = {};
30630
31084
  for (const m of ctx.migrations) {
30631
- const rec7 = isRecord25(m.record) ? m.record : null;
31085
+ const rec7 = isRecord26(m.record) ? m.record : null;
30632
31086
  const tool = rec7 && rec7.change === "adopt" ? "live-import" : "live-mv";
30633
31087
  const commit = rec7 && str22(rec7.commit) ? rec7.commit : null;
30634
31088
  const row = commit ? (await rowsOf(m.home)).find((r) => r.commit === commit && r.stage === "tf-apply") : void 0;
@@ -30657,13 +31111,13 @@ var CARVE_TOUR_TTL_MS = 3e3;
30657
31111
  var MAX_ROSTERS = 64;
30658
31112
  var MAX_MIGRATIONS = 8;
30659
31113
  var CARVE_OUTCOMES = ["moved", "stamped", "refused", "skipped"];
30660
- var isRecord26 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
31114
+ var isRecord27 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30661
31115
  var str23 = (v) => typeof v === "string" && v.length > 0;
30662
31116
  var count2 = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : null;
30663
31117
  var trim3 = (s) => s.replace(/^\/+|\/+$/g, "");
30664
31118
  var key = (...p) => p.map(trim3).filter(Boolean).join("/");
30665
31119
  function rosterResource(v) {
30666
- if (!isRecord26(v) || !str23(v.address)) return void 0;
31120
+ if (!isRecord27(v) || !str23(v.address)) return void 0;
30667
31121
  return {
30668
31122
  address: v.address,
30669
31123
  type: str23(v.type) ? v.type : /(?:^|\.)((?:aws|google|azurerm|kubernetes)_[a-z0-9_]+)\./.exec(v.address)?.[1] ?? "",
@@ -30673,7 +31127,7 @@ function rosterResource(v) {
30673
31127
  };
30674
31128
  }
30675
31129
  function progressLine(v) {
30676
- if (!isRecord26(v) || !str23(v.at) || !str23(v.address)) return void 0;
31130
+ if (!isRecord27(v) || !str23(v.at) || !str23(v.address)) return void 0;
30677
31131
  if (!CARVE_OUTCOMES.includes(v.outcome)) return void 0;
30678
31132
  const to = str23(v.estate_to) ? v.estate_to : str23(v.estate_from) ? v.estate_from : "";
30679
31133
  if (!to) return void 0;
@@ -30707,7 +31161,7 @@ function readProgress(text3, from = null) {
30707
31161
  if (line && !Number.isNaN(since) && Date.parse(line.at) < since) return;
30708
31162
  if (line) {
30709
31163
  lines2.push(line);
30710
- counts = countsIn(isRecord26(doc) ? doc.counts : void 0) ?? counts;
31164
+ counts = countsIn(isRecord27(doc) ? doc.counts : void 0) ?? counts;
30711
31165
  } else bad2++;
30712
31166
  });
30713
31167
  return { lines: lines2, bad: bad2, counts };
@@ -30718,11 +31172,11 @@ function countLines(lines2) {
30718
31172
  return c;
30719
31173
  }
30720
31174
  function countsIn(c) {
30721
- if (!isRecord26(c)) return null;
31175
+ if (!isRecord27(c)) return null;
30722
31176
  return { moved: count2(c.moved) ?? 0, stamped: count2(c.stamped) ?? 0, refused: count2(c.refused) ?? 0, skipped: count2(c.skipped) ?? 0, left: count2(c.left) };
30723
31177
  }
30724
31178
  function recordCounts(doc) {
30725
- return isRecord26(doc) ? countsIn(doc.progress) : null;
31179
+ return isRecord27(doc) ? countsIn(doc.progress) : null;
30726
31180
  }
30727
31181
  function demoMigration(next) {
30728
31182
  const m = typeof next === "string" ? /^\s*([A-Za-z0-9._~@+-]{1,128}):\s+\d+\s+of\s+\d+\s+(?:moved|stamped)\b/.exec(next) : null;
@@ -30731,11 +31185,11 @@ function demoMigration(next) {
30731
31185
  var ESTATES_SCHEMA = "terragucci.estates/v1";
30732
31186
  var ESTATES_KEY = "estates.json";
30733
31187
  function estateEntries(doc) {
30734
- const list4 = isRecord26(doc) && Array.isArray(doc.estates) ? doc.estates : [];
31188
+ const list4 = isRecord27(doc) && Array.isArray(doc.estates) ? doc.estates : [];
30735
31189
  const out = [];
30736
31190
  const seen = /* @__PURE__ */ new Set();
30737
31191
  for (const e of list4) {
30738
- if (!isRecord26(e) || !str23(e.estate) || seen.has(e.estate) || !str23(e.roster)) continue;
31192
+ if (!isRecord27(e) || !str23(e.estate) || seen.has(e.estate) || !str23(e.roster)) continue;
30739
31193
  const roster = trim3(e.roster);
30740
31194
  if (roster.split("/").some((p) => p === ".." || p === "." || p === "")) continue;
30741
31195
  seen.add(e.estate);
@@ -30744,8 +31198,8 @@ function estateEntries(doc) {
30744
31198
  return out;
30745
31199
  }
30746
31200
  var projectsOf = (doc) => {
30747
- const rows = isRecord26(doc) && Array.isArray(doc.reports) ? doc.reports : [];
30748
- return [...new Set(rows.filter(isRecord26).map((r) => r.project).filter(str23))].sort();
31201
+ const rows = isRecord27(doc) && Array.isArray(doc.reports) ? doc.reports : [];
31202
+ return [...new Set(rows.filter(isRecord27).map((r) => r.project).filter(str23))].sort();
30749
31203
  };
30750
31204
  var FINISHED = /* @__PURE__ */ new Set(["applied", "refused", "failed", "proof-failed", "done", "finished"]);
30751
31205
  async function readText2(source2, k, problems) {
@@ -30780,7 +31234,7 @@ function recordTargets(doc) {
30780
31234
  const walk = (v, depth) => {
30781
31235
  if (depth > 6 || out.size >= 256) return;
30782
31236
  if (Array.isArray(v)) for (const x of v) walk(x, depth + 1);
30783
- else if (isRecord26(v))
31237
+ else if (isRecord27(v))
30784
31238
  for (const [k, x] of Object.entries(v)) {
30785
31239
  if ((k === "estate_to" || k === "to_estate") && str23(x)) out.add(x);
30786
31240
  else walk(x, depth + 1);
@@ -30851,7 +31305,7 @@ function inCycle(startedAt, lines2, finished, modified) {
30851
31305
  return lines2.some((l) => after2(l.at)) || after2(finished) || after2(modified);
30852
31306
  }
30853
31307
  function adoptedInto(record, lines2) {
30854
- const stamps = isRecord26(record) && Array.isArray(record.stamps) ? record.stamps.filter(isRecord26) : [];
31308
+ const stamps = isRecord27(record) && Array.isArray(record.stamps) ? record.stamps.filter(isRecord27) : [];
30855
31309
  const pairs = new Set(stamps.filter((x) => str23(x.estate)).map((x) => `${x.estate}\0${str23(x.root) ? x.root : ""}`));
30856
31310
  if (pairs.size === 1) {
30857
31311
  const [estate, root] = [...pairs][0].split("\0");
@@ -30860,7 +31314,7 @@ function adoptedInto(record, lines2) {
30860
31314
  if (pairs.size > 1) return null;
30861
31315
  const into = new Set(lines2.filter((l) => l.outcome === "stamped").map((l) => l.estate_to));
30862
31316
  if (into.size !== 1) return null;
30863
- const roots = isRecord26(record) && Array.isArray(record.roots) ? record.roots.filter(isRecord26).map((r) => r.root).filter(str23) : [];
31317
+ const roots = isRecord27(record) && Array.isArray(record.roots) ? record.roots.filter(isRecord27).map((r) => r.root).filter(str23) : [];
30864
31318
  return { estate: [...into][0], root: roots.length === 1 ? roots[0] : null };
30865
31319
  }
30866
31320
  function replaceAdopted(entries, adoptions) {
@@ -30886,7 +31340,7 @@ async function readCarve2(source2, opts) {
30886
31340
  const base = { source: source2.location, read: now.toISOString() };
30887
31341
  const problems = [];
30888
31342
  const estatesDoc = parse(await readText2(source2, ESTATES_KEY, problems), ESTATES_KEY, problems);
30889
- const isEstates = isRecord26(estatesDoc) && estatesDoc.schema === ESTATES_SCHEMA;
31343
+ const isEstates = isRecord27(estatesDoc) && estatesDoc.schema === ESTATES_SCHEMA;
30890
31344
  if (estatesDoc !== void 0 && !isEstates) problems.push(`${ESTATES_KEY} is not a ${ESTATES_SCHEMA} document`);
30891
31345
  const all = isEstates ? estateEntries(estatesDoc) : [];
30892
31346
  const demoAnswer = await readDemo(source2, now);
@@ -30945,8 +31399,8 @@ async function readCarve2(source2, opts) {
30945
31399
  }
30946
31400
  }
30947
31401
  const { lines: lines2, bad: bad2, counts: lineCounts } = text3 !== void 0 ? readProgress(text3, startedAt) : { lines: [], bad: 0, counts: null };
30948
- const status2 = isRecord26(record) && str23(record.status) ? record.status : null;
30949
- const finished = isRecord26(record) && str23(record.finished) ? record.finished : null;
31402
+ const status2 = isRecord27(record) && str23(record.status) ? record.status : null;
31403
+ const finished = isRecord27(record) && str23(record.finished) ? record.finished : null;
30950
31404
  if (f.listed && !inCycle(startedAt, lines2, finished, f.listed.modified)) continue;
30951
31405
  if (home !== null) opts.places?.set(m.name, home);
30952
31406
  if (home !== null && f.listed) opts.remembered?.add(m.name);
@@ -30962,7 +31416,7 @@ async function readCarve2(source2, opts) {
30962
31416
  if (into) adoptions.push({ ...into, project: home, migration: m.name });
30963
31417
  }
30964
31418
  const running = !done && (lines2.length > 0 || named === m.name);
30965
- migrations.push({ name: m.name, progress, lines: lines2, counts, status: status2, finished, running, change: isRecord26(record) && str23(record.change) ? record.change : null });
31419
+ migrations.push({ name: m.name, progress, lines: lines2, counts, status: status2, finished, running, change: isRecord27(record) && str23(record.change) ? record.change : null });
30966
31420
  if (home !== null) followed.push({ name: m.name, home, record, lines: lines2, running });
30967
31421
  }
30968
31422
  const carved = carvedEntries(all, { repo: ofRepo, homes: [...homes], targets });
@@ -30978,7 +31432,7 @@ async function readCarve2(source2, opts) {
30978
31432
  for (const e of entries.slice(0, MAX_ROSTERS)) {
30979
31433
  const doc = parse(await readText2(source2, e.roster, problems), e.roster, problems);
30980
31434
  if (doc === void 0) continue;
30981
- if (!isRecord26(doc) || !Array.isArray(doc.resources)) {
31435
+ if (!isRecord27(doc) || !Array.isArray(doc.resources)) {
30982
31436
  problems.push(`${e.roster} is not a roster: it has no resources list`);
30983
31437
  continue;
30984
31438
  }
@@ -31060,7 +31514,7 @@ function terragucciCarveRoute(app, source2, opts) {
31060
31514
 
31061
31515
  // src/terragucci-view.ts
31062
31516
  init_member_kind();
31063
- import { readFileSync as readFileSync36 } from "node:fs";
31517
+ import { readFileSync as readFileSync37 } from "node:fs";
31064
31518
  var TERRAGUCCI_READ_TTL_MS = 3e4;
31065
31519
  function repoBase(dirs) {
31066
31520
  for (const d of dirs) {
@@ -31098,7 +31552,7 @@ function checkoutRoots(dirs, base = repoBase(dirs)) {
31098
31552
  for (const m of estateMembers(dirs)) {
31099
31553
  if (m.kind !== "terraform") continue;
31100
31554
  for (const r of checkoutRootDirs(m.dir)) {
31101
- const path = relative10(base, join48(m.dir, r.dir)).split(sep8).join("/") || ".";
31555
+ const path = relative10(base, join49(m.dir, r.dir)).split(sep8).join("/") || ".";
31102
31556
  out.push({ member: m.name, name: r.name, path });
31103
31557
  }
31104
31558
  }
@@ -31111,7 +31565,7 @@ function servedChoudoufu(dirs) {
31111
31565
  if (!cfg) continue;
31112
31566
  if (toolOfBinary(configKeys(cfg).binary) === "choudoufu") return true;
31113
31567
  try {
31114
- if (/\bbinary\s*:\s*["']?[^\s"',}]*choudoufu\b/.test(readFileSync36(cfg, "utf8"))) return true;
31568
+ if (/\bbinary\s*:\s*["']?[^\s"',}]*choudoufu\b/.test(readFileSync37(cfg, "utf8"))) return true;
31115
31569
  } catch {
31116
31570
  }
31117
31571
  }
@@ -31666,8 +32120,8 @@ function tracesRoute(app, opts) {
31666
32120
 
31667
32121
  // src/view-repos.ts
31668
32122
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
31669
- import { existsSync as existsSync29, readdirSync as readdirSync18, readFileSync as readFileSync37 } from "node:fs";
31670
- import { join as join49, resolve as resolve28 } from "node:path";
32123
+ import { existsSync as existsSync30, readdirSync as readdirSync18, readFileSync as readFileSync38 } from "node:fs";
32124
+ import { join as join50, resolve as resolve29 } from "node:path";
31671
32125
  var NAME2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
31672
32126
  function repoName(value) {
31673
32127
  const v = value.trim().replace(/\.git$/, "");
@@ -31681,7 +32135,7 @@ function listCheckouts(parent) {
31681
32135
  } catch {
31682
32136
  return [];
31683
32137
  }
31684
- return names.map((name) => ({ name, dir: resolve28(parent, name) })).filter((c) => existsSync29(join49(c.dir, ".git")));
32138
+ return names.map((name) => ({ name, dir: resolve29(parent, name) })).filter((c) => existsSync30(join50(c.dir, ".git")));
31685
32139
  }
31686
32140
  var scope = new AsyncLocalStorage2();
31687
32141
  var requestRepo = () => scope.getStore();
@@ -31730,7 +32184,7 @@ var SHA2 = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
31730
32184
  function checkoutCommit(dir) {
31731
32185
  const read = (f) => {
31732
32186
  try {
31733
- return readFileSync37(join49(dir, ".git", f), "utf8");
32187
+ return readFileSync38(join50(dir, ".git", f), "utf8");
31734
32188
  } catch {
31735
32189
  return void 0;
31736
32190
  }
@@ -31760,11 +32214,11 @@ function viewRepoFacts(repos, servedDir) {
31760
32214
  }
31761
32215
 
31762
32216
  // src/lifecycle-releases.ts
31763
- import { existsSync as existsSync30, readFileSync as readFileSync38 } from "node:fs";
31764
- import { join as join50 } from "node:path";
32217
+ import { existsSync as existsSync31, readFileSync as readFileSync39 } from "node:fs";
32218
+ import { join as join51 } from "node:path";
31765
32219
 
31766
32220
  // node_modules/@intentius/chant/src/lifecycle/legacy-digest.ts
31767
- import { resolve as resolve29 } from "node:path";
32221
+ import { resolve as resolve30 } from "node:path";
31768
32222
  var LEGACY_DIGEST = /^sha256:([0-9a-f]{8})\1{7}$/;
31769
32223
  var LEGACY_DIGEST_FLAG = "legacy-digest";
31770
32224
  var LEGACY_DIGEST_ACCEPTED_THROUGH = "0.89.x";
@@ -31785,7 +32239,7 @@ function flagLegacyDigest(record, values) {
31785
32239
  }
31786
32240
  var warnedProjects = /* @__PURE__ */ new Set();
31787
32241
  function warnOnLegacyDigests(values, where, cwd) {
31788
- const project = resolve29(cwd ?? process.cwd());
32242
+ const project = resolve30(cwd ?? process.cwd());
31789
32243
  if (warnedProjects.has(project)) return false;
31790
32244
  if (!hasLegacyContentDigest(values)) return false;
31791
32245
  warnedProjects.add(project);
@@ -31874,10 +32328,10 @@ function memberNote(l) {
31874
32328
  // src/lifecycle-releases.ts
31875
32329
  var WAVES_SPEC_FILE = "yodel-waves.json";
31876
32330
  function waveOrder(checkout) {
31877
- const p = join50(checkout, WAVES_SPEC_FILE);
31878
- if (!existsSync30(p)) return void 0;
32331
+ const p = join51(checkout, WAVES_SPEC_FILE);
32332
+ if (!existsSync31(p)) return void 0;
31879
32333
  try {
31880
- const doc = JSON.parse(readFileSync38(p, "utf8"));
32334
+ const doc = JSON.parse(readFileSync39(p, "utf8"));
31881
32335
  const names = (doc.waves ?? []).map((w) => w?.name).filter((n) => typeof n === "string" && n.length > 0);
31882
32336
  return names.length ? [...new Set(names)] : void 0;
31883
32337
  } catch {
@@ -31885,7 +32339,7 @@ function waveOrder(checkout) {
31885
32339
  }
31886
32340
  }
31887
32341
  function hasReleaseLedgerHint(checkout) {
31888
- return existsSync30(join50(checkout, "yodel.config.ts")) || existsSync30(join50(checkout, WAVES_SPEC_FILE));
32342
+ return existsSync31(join51(checkout, "yodel.config.ts")) || existsSync31(join51(checkout, WAVES_SPEC_FILE));
31889
32343
  }
31890
32344
  function orderEnvironments(envs, waves) {
31891
32345
  const seen = new Set(envs);
@@ -31925,17 +32379,17 @@ function releaseCells(ledgers, order, sources) {
31925
32379
  }
31926
32380
  return { components, cells };
31927
32381
  }
31928
- async function copyCheckoutRef(git3, checkout, cache6) {
31929
- assertScratch(cache6.split(/[\\/]/).pop());
31930
- if (!existsSync30(join50(cache6, "HEAD"))) {
31931
- const init = await git3(["init", "--bare", "-q", cache6]);
32382
+ async function copyCheckoutRef(git3, checkout, cache7) {
32383
+ assertScratch(cache7.split(/[\\/]/).pop());
32384
+ if (!existsSync31(join51(cache7, "HEAD"))) {
32385
+ const init = await git3(["init", "--bare", "-q", cache7]);
31932
32386
  if (init.code !== 0) return false;
31933
32387
  }
31934
- const f = await git3(["--git-dir", cache6, "fetch", "-q", "--no-tags", checkout, `+${CHECKOUT_REF}:refs/heads/${LIFECYCLE_BRANCH}`]);
32388
+ const f = await git3(["--git-dir", cache7, "fetch", "-q", "--no-tags", checkout, `+${CHECKOUT_REF}:refs/heads/${LIFECYCLE_BRANCH}`]);
31935
32389
  return f.code === 0;
31936
32390
  }
31937
- async function readCache(git3, cache6, prefix = "") {
31938
- const at2 = { cwd: cache6, ledgerPrefix: prefix };
32391
+ async function readCache(git3, cache7, prefix = "") {
32392
+ const at2 = { cwd: cache7, ledgerPrefix: prefix };
31939
32393
  const envs = await listReleaseEnvironments(at2);
31940
32394
  const ledgers = /* @__PURE__ */ new Map();
31941
32395
  const malformed = {};
@@ -31945,7 +32399,7 @@ async function readCache(git3, cache6, prefix = "") {
31945
32399
  ledgers.set(env, r.records);
31946
32400
  if (r.malformed) malformed[env] = r.malformed;
31947
32401
  const path = `${prefix}${env}/releases.jsonl`;
31948
- const log = await git3(["--git-dir", cache6, "log", "-1", "--format=%H%x00%cI", `refs/heads/${LIFECYCLE_BRANCH}`, "--", path]);
32402
+ const log = await git3(["--git-dir", cache7, "log", "-1", "--format=%H%x00%cI", `refs/heads/${LIFECYCLE_BRANCH}`, "--", path]);
31949
32403
  const [commit, committed] = log.code === 0 && log.stdout.trim() ? log.stdout.trim().split("\0") : [];
31950
32404
  sources.set(env, { branch: LIFECYCLE_BRANCH, path, ...commit ? { commit } : {}, ...committed ? { committed } : {} });
31951
32405
  }
@@ -31960,8 +32414,8 @@ async function readReleases(checkout, opts = {}) {
31960
32414
  const also = memberNote(ledger);
31961
32415
  const base = { branch: LIFECYCLE_BRANCH, read: { at: now.toISOString() }, order: waves ? "waves" : "name", ...member };
31962
32416
  const empty = { environments: [], components: [], cells: [], malformed: {} };
31963
- const answer = async (cache6, via, fetch2, origin2, note) => {
31964
- const { ledgers, malformed, sources } = await readCache(git3, cache6, ledger.prefix);
32417
+ const answer = async (cache7, via, fetch2, origin2, note) => {
32418
+ const { ledgers, malformed, sources } = await readCache(git3, cache7, ledger.prefix);
31965
32419
  const environments = orderEnvironments([...ledgers.keys()], waves);
31966
32420
  const { components, cells } = releaseCells(ledgers, environments, sources);
31967
32421
  return { ...base, found: true, via, ...origin2 ? { origin: origin2 } : {}, fetch: fetch2, environments, components, cells, malformed, note: also ? `${note} ${also}` : note };
@@ -31975,17 +32429,17 @@ async function readReleases(checkout, opts = {}) {
31975
32429
  } else {
31976
32430
  const from = fetchable(url, checkout);
31977
32431
  origin = redact(from);
31978
- const cache6 = cacheDir(from, opts.cacheRoot);
32432
+ const cache7 = cacheDir(from, opts.cacheRoot);
31979
32433
  let f;
31980
32434
  try {
31981
- f = await fetchIntoCache(git3, from, cache6);
32435
+ f = await fetchIntoCache(git3, from, cache7);
31982
32436
  } catch (e) {
31983
32437
  f = { ok: false, error: e instanceof Error ? e.message : String(e) };
31984
32438
  }
31985
32439
  if (f.ok && !f.found) return { ...base, found: false, via: "fetch", origin, fetch: { ok: true }, ...empty, note: `${origin} has no ${LIFECYCLE_BRANCH} branch: no environment has recorded a release yet.` };
31986
32440
  if (f.ok) {
31987
32441
  try {
31988
- return await answer(cache6, "fetch", { ok: true }, origin, `release ledger on ${LIFECYCLE_BRANCH} as fetched from ${origin} at ${base.read.at}.`);
32442
+ return await answer(cache7, "fetch", { ok: true }, origin, `release ledger on ${LIFECYCLE_BRANCH} as fetched from ${origin} at ${base.read.at}.`);
31989
32443
  } catch (e) {
31990
32444
  fetchError = `fetched ${LIFECYCLE_BRANCH}, but chant's release-ledger reader failed on it: ${e instanceof Error ? e.message : String(e)}`;
31991
32445
  }
@@ -32032,7 +32486,7 @@ function releasesRoutes(app, base, opts = {}) {
32032
32486
  // src/trunk-lane.ts
32033
32487
  init_chant_floors();
32034
32488
  var LANE_READS = ["trunk commits", "release list", "promotion order"];
32035
- var isRecord27 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32489
+ var isRecord28 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32036
32490
  var str24 = (v) => typeof v === "string" && v ? v : null;
32037
32491
  var arr2 = (v) => Array.isArray(v) ? v : [];
32038
32492
  var webUrl = (v) => typeof v === "string" && /^https?:\/\//.test(v) ? v : null;
@@ -32044,30 +32498,30 @@ function laneFloorRefusal(version) {
32044
32498
  return void 0;
32045
32499
  }
32046
32500
  function errorRefusal(doc, shown) {
32047
- if (!isRecord27(doc.error)) return void 0;
32501
+ if (!isRecord28(doc.error)) return void 0;
32048
32502
  const code = String(doc.error.code ?? "unknown");
32049
32503
  const remedy = code === "ci-green-undeclared" ? "Declare ci.green in chant.workspace.json; chant ci tick then tags the trunk's commits green or revoked." : `Run \`${shown}\` to see what chant says.`;
32050
32504
  return { error: `${shown}: ${String(doc.error.message ?? code)}`, code, remedy };
32051
32505
  }
32052
- var run2 = (r) => isRecord27(r) && typeof r.name === "string" ? { name: r.name, url: webUrl(r.url), conclusion: str24(r.conclusion) } : null;
32506
+ var run2 = (r) => isRecord28(r) && typeof r.name === "string" ? { name: r.name, url: webUrl(r.url), conclusion: str24(r.conclusion) } : null;
32053
32507
  function commitsFromCiList(doc) {
32054
32508
  const out = [];
32055
32509
  for (const c of arr2(doc.commits)) {
32056
- if (!isRecord27(c) || typeof c.sha !== "string") continue;
32510
+ if (!isRecord28(c) || typeof c.sha !== "string") continue;
32057
32511
  const state = c.state === "green" || c.state === "revoked" ? c.state : "undecided";
32058
- const phases = arr2(c.phases).filter(isRecord27).map((p) => ({
32512
+ const phases = arr2(c.phases).filter(isRecord28).map((p) => ({
32059
32513
  phase: String(p.phase ?? ""),
32060
32514
  result: ["pass", "fail", "pending"].includes(String(p.result)) ? p.result : "unrecorded",
32061
32515
  runs: arr2(p.runs).map(run2).filter((r) => r !== null)
32062
32516
  }));
32063
- const rv = isRecord27(c.revoked) ? { phase: str24(c.revoked.phase), run: run2(c.revoked.run) } : null;
32064
- const w = isRecord27(c.work) && ["linked", "unlinked", "wrong", "merge"].includes(String(c.work.state)) ? c.work : null;
32517
+ const rv = isRecord28(c.revoked) ? { phase: str24(c.revoked.phase), run: run2(c.revoked.run) } : null;
32518
+ const w = isRecord28(c.work) && ["linked", "unlinked", "wrong", "merge"].includes(String(c.work.state)) ? c.work : null;
32065
32519
  const work = w ? {
32066
32520
  state: w.state,
32067
32521
  ids: arr2(w.ids).filter((x) => typeof x === "string"),
32068
- problems: arr2(w.problems).filter(isRecord27).map((p) => ({ trailer: String(p.trailer ?? ""), message: String(p.message ?? "") }))
32522
+ problems: arr2(w.problems).filter(isRecord28).map((p) => ({ trailer: String(p.trailer ?? ""), message: String(p.message ?? "") }))
32069
32523
  } : null;
32070
- const ignored = arr2(c.ignored).filter(isRecord27).map((t2) => ({ tag: String(t2.tag ?? ""), status: String(t2.status ?? ""), reason: String(t2.reason ?? "") }));
32524
+ const ignored = arr2(c.ignored).filter(isRecord28).map((t2) => ({ tag: String(t2.tag ?? ""), status: String(t2.status ?? ""), reason: String(t2.reason ?? "") }));
32071
32525
  out.push({ sha: c.sha, committed: String(c.committed ?? ""), state, phases, revoked: rv, work, ignored, where: [], cuts: [] });
32072
32526
  }
32073
32527
  return out;
@@ -32075,9 +32529,9 @@ function commitsFromCiList(doc) {
32075
32529
  function promotionOrder(status2) {
32076
32530
  const out = [];
32077
32531
  for (const m of arr2(status2.members)) {
32078
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32532
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32079
32533
  for (const step of arr2(m.promotionOrder)) {
32080
- if (!isRecord27(step) || typeof step.name !== "string") continue;
32534
+ if (!isRecord28(step) || typeof step.name !== "string") continue;
32081
32535
  let at2 = out.find((e) => e.env === step.name);
32082
32536
  if (!at2) out.push(at2 = { env: step.name, canary: false, members: [] });
32083
32537
  if (step.canary === true) at2.canary = true;
@@ -32087,20 +32541,20 @@ function promotionOrder(status2) {
32087
32541
  return out;
32088
32542
  }
32089
32543
  function releaseMembers(status2) {
32090
- return arr2(status2.members).filter(isRecord27).filter((m) => typeof m.name === "string" && arr2(m.promotionOrder).length > 0).map((m) => ({ name: m.name, dir: typeof m.dir === "string" ? m.dir : "." }));
32544
+ return arr2(status2.members).filter(isRecord28).filter((m) => typeof m.name === "string" && arr2(m.promotionOrder).length > 0).map((m) => ({ name: m.name, dir: typeof m.dir === "string" ? m.dir : "." }));
32091
32545
  }
32092
32546
  function revocation(v) {
32093
- if (!isRecord27(v) || typeof v.tag !== "string") return null;
32547
+ if (!isRecord28(v) || typeof v.tag !== "string") return null;
32094
32548
  return { tag: v.tag, tagged: str24(v.tagged), phase: str24(v.phase), run: run2(v.run), signer: str24(v.signer) };
32095
32549
  }
32096
32550
  function deployRecords(status2, env, full) {
32097
32551
  const out = [];
32098
32552
  for (const m of arr2(status2.members)) {
32099
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32553
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32100
32554
  for (const e of arr2(m.environments)) {
32101
- if (!isRecord27(e) || e.env !== env) continue;
32555
+ if (!isRecord28(e) || e.env !== env) continue;
32102
32556
  for (const r of arr2(e.releases)) {
32103
- if (!isRecord27(r) || typeof r.component !== "string") continue;
32557
+ if (!isRecord28(r) || typeof r.component !== "string") continue;
32104
32558
  out.push({
32105
32559
  member: m.name,
32106
32560
  component: r.component,
@@ -32111,7 +32565,7 @@ function deployRecords(status2, env, full) {
32111
32565
  approver: str24(r.approver),
32112
32566
  runId: String(r.runId ?? ""),
32113
32567
  release: full && str24(r.releaseDigest) ? { releaseDigest: r.releaseDigest, label: str24(r.releaseLabel) } : null,
32114
- rollback: full && isRecord27(r.revoked) ? str24(r.revoked.rollback) : null
32568
+ rollback: full && isRecord28(r.revoked) ? str24(r.revoked.rollback) : null
32115
32569
  });
32116
32570
  }
32117
32571
  }
@@ -32121,10 +32575,10 @@ function deployRecords(status2, env, full) {
32121
32575
  function releasesIn(doc, member, env) {
32122
32576
  const out = [];
32123
32577
  for (const r of arr2(doc.releases)) {
32124
- if (!isRecord27(r) || typeof r.releaseDigest !== "string" || typeof r.commit !== "string") continue;
32125
- const here = arr2(r.environments).find((e) => isRecord27(e) && e.env === env);
32126
- if (!isRecord27(here)) continue;
32127
- const cuts = arr2(r.cuts).filter(isRecord27);
32578
+ if (!isRecord28(r) || typeof r.releaseDigest !== "string" || typeof r.commit !== "string") continue;
32579
+ const here = arr2(r.environments).find((e) => isRecord28(e) && e.env === env);
32580
+ if (!isRecord28(here)) continue;
32581
+ const cuts = arr2(r.cuts).filter(isRecord28);
32128
32582
  const last = cuts.at(-1);
32129
32583
  out.push({
32130
32584
  member,
@@ -32141,9 +32595,9 @@ function releasesIn(doc, member, env) {
32141
32595
  function supersededGates(status2, env) {
32142
32596
  const out = [];
32143
32597
  for (const m of arr2(status2.members)) {
32144
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32598
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32145
32599
  for (const g of arr2(m.gates)) {
32146
- if (!isRecord27(g) || g.state !== "superseded" || g.env !== env) continue;
32600
+ if (!isRecord28(g) || g.state !== "superseded" || g.env !== env) continue;
32147
32601
  const op = str24(g.component);
32148
32602
  const gate = str24(g.name);
32149
32603
  const releaseDigest = str24(g.releaseDigest);
@@ -32158,11 +32612,11 @@ var releaseOf = (digest, label) => str24(digest) ? { releaseDigest: digest, labe
32158
32612
  function mixedIn(status2, env) {
32159
32613
  const out = [];
32160
32614
  for (const m of arr2(status2.members)) {
32161
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32615
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32162
32616
  for (const e of arr2(m.environments)) {
32163
- if (!isRecord27(e) || e.env !== env || !isRecord27(e.mixed)) continue;
32164
- const components = arr2(e.mixed.components).filter(isRecord27).filter((c) => typeof c.component === "string").map((c) => {
32165
- const a = isRecord27(c.attempt) ? c.attempt : null;
32617
+ if (!isRecord28(e) || e.env !== env || !isRecord28(e.mixed)) continue;
32618
+ const components = arr2(e.mixed.components).filter(isRecord28).filter((c) => typeof c.component === "string").map((c) => {
32619
+ const a = isRecord28(c.attempt) ? c.attempt : null;
32166
32620
  return {
32167
32621
  component: c.component,
32168
32622
  release: releaseOf(c.releaseDigest, c.releaseLabel),
@@ -32182,23 +32636,23 @@ function mixedIn(status2, env) {
32182
32636
  }
32183
32637
  return out;
32184
32638
  }
32185
- var artifactKey = (v) => arr2(v).filter(isRecord27).map((a) => JSON.stringify([String(a.component ?? ""), String(a.kind ?? ""), String(a.path ?? ""), String(a.digest ?? "")])).sort();
32639
+ var artifactKey = (v) => arr2(v).filter(isRecord28).map((a) => JSON.stringify([String(a.component ?? ""), String(a.kind ?? ""), String(a.path ?? ""), String(a.digest ?? "")])).sort();
32186
32640
  function releaseColumn(docs2, commits, environments, full) {
32187
32641
  const at2 = new Map(commits.map((c, i) => [c.sha, i]));
32188
32642
  const place = (commit) => at2.get(commit) ?? Number.POSITIVE_INFINITY;
32189
32643
  const rows = [];
32190
32644
  for (const { member, doc } of docs2) {
32191
- const items = arr2(doc.releases).map((r, i) => ({ r, i })).filter((x) => isRecord27(x.r) && typeof x.r.releaseDigest === "string" && typeof x.r.commit === "string").sort((a, b) => place(a.r.commit) - place(b.r.commit) || a.i - b.i);
32645
+ const items = arr2(doc.releases).map((r, i) => ({ r, i })).filter((x) => isRecord28(x.r) && typeof x.r.releaseDigest === "string" && typeof x.r.commit === "string").sort((a, b) => place(a.r.commit) - place(b.r.commit) || a.i - b.i);
32192
32646
  const order = environments.filter((e) => e.members.includes(member)).map((e) => e.env);
32193
32647
  items.forEach(({ r, i }, k) => {
32194
32648
  const releaseDigest = r.releaseDigest;
32195
32649
  const commit = r.commit;
32196
32650
  const before = items[k + 1]?.r;
32197
32651
  const artifacts = artifactKey(r.artifactDigests);
32198
- const cuts = arr2(r.cuts).filter(isRecord27);
32652
+ const cuts = arr2(r.cuts).filter(isRecord28);
32199
32653
  const last = cuts.at(-1);
32200
- const check = last && isRecord27(last.signatureCheck) ? last.signatureCheck : null;
32201
- const ran = arr2(r.environments).filter(isRecord27);
32654
+ const check = last && isRecord28(last.signatureCheck) ? last.signatureCheck : null;
32655
+ const ran = arr2(r.environments).filter(isRecord28);
32202
32656
  const runs2 = [
32203
32657
  ...environments.map((e) => e.env),
32204
32658
  ...ran.map((e) => String(e.env ?? "")).filter((env) => !environments.some((e) => e.env === env))
@@ -32350,7 +32804,7 @@ init_chant_floors();
32350
32804
  var OVERLAY_READS = ["promotion order", "change set"];
32351
32805
  var BUCKET_OF = { create: "create", update: "change", replace: "change", delete: "delete", forget: "delete" };
32352
32806
  var STRENGTH = { create: 1, change: 2, delete: 3 };
32353
- var isRecord28 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32807
+ var isRecord29 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32354
32808
  var str25 = (v) => typeof v === "string" && v ? v : null;
32355
32809
  var arr3 = (v) => Array.isArray(v) ? v : [];
32356
32810
  function overlayFloorRefusal(version) {
@@ -32373,13 +32827,13 @@ function attributeOf(a) {
32373
32827
  }
32374
32828
  function showRefusal(doc, digest, member) {
32375
32829
  const shown = `chant change-set show ${digest} --member ${member}`;
32376
- if (isRecord28(doc.error)) {
32830
+ if (isRecord29(doc.error)) {
32377
32831
  return { error: `${shown}: ${String(doc.error.message ?? doc.error.code)}`, code: String(doc.error.code ?? "change-set-show"), remedy: `Run \`${shown}\` in the workspace root to see what chant says.` };
32378
32832
  }
32379
- if (isRecord28(doc.reason)) {
32833
+ if (isRecord29(doc.reason)) {
32380
32834
  return { error: `${shown}: ${String(doc.reason.message ?? doc.reason.code)}`, code: String(doc.reason.code ?? "change-set-show"), remedy: "The stored file is not the change set its digest names, so behold draws nothing from it." };
32381
32835
  }
32382
- if (!isRecord28(doc.changeSet)) {
32836
+ if (!isRecord29(doc.changeSet)) {
32383
32837
  return { error: `chant has no change set stored under ${digest} for ${member}.`, code: "no-change-set", remedy: "A pull-request or release gate stores the change set it binds; fetch chant/lifecycle if it was stored elsewhere." };
32384
32838
  }
32385
32839
  if (doc.changeSet.digest !== digest) {
@@ -32388,11 +32842,11 @@ function showRefusal(doc, digest, member) {
32388
32842
  return void 0;
32389
32843
  }
32390
32844
  function overlayFrom(gate, doc, at2) {
32391
- const cs = isRecord28(doc.changeSet) ? doc.changeSet : {};
32845
+ const cs = isRecord29(doc.changeSet) ? doc.changeSet : {};
32392
32846
  const entries = [];
32393
32847
  let unchanged = 0;
32394
32848
  for (const e of arr3(cs.entries)) {
32395
- if (!isRecord28(e) || typeof e.address !== "string") continue;
32849
+ if (!isRecord29(e) || typeof e.address !== "string") continue;
32396
32850
  const action = String(e.action ?? "");
32397
32851
  const bucket = BUCKET_OF[action];
32398
32852
  if (!bucket) {
@@ -32408,7 +32862,7 @@ function overlayFrom(gate, doc, at2) {
32408
32862
  node: str25(e.node),
32409
32863
  disruption: str25(e.disruption),
32410
32864
  deposed: str25(e.deposed),
32411
- attributes: arr3(e.attributes).filter(isRecord28).map(attributeOf)
32865
+ attributes: arr3(e.attributes).filter(isRecord29).map(attributeOf)
32412
32866
  });
32413
32867
  }
32414
32868
  const nodes = {};
@@ -32420,13 +32874,13 @@ function overlayFrom(gate, doc, at2) {
32420
32874
  if (STRENGTH[e.bucket] > STRENGTH[n.bucket]) n.bucket = e.bucket;
32421
32875
  n.actions[e.action] = (n.actions[e.action] ?? 0) + 1;
32422
32876
  }
32423
- const gaps = arr3(cs.members).filter(isRecord28).map((m) => ({
32877
+ const gaps = arr3(cs.members).filter(isRecord29).map((m) => ({
32424
32878
  member: String(m.member ?? ""),
32425
32879
  status: String(m.status ?? ""),
32426
32880
  error: str25(m.error),
32427
- holes: arr3(m.holes).filter(isRecord28).map((h) => ({ address: String(h.address ?? ""), reason: String(h.reason ?? "") }))
32881
+ holes: arr3(m.holes).filter(isRecord29).map((h) => ({ address: String(h.address ?? ""), reason: String(h.reason ?? "") }))
32428
32882
  })).filter((m) => m.status !== "planned" || m.holes.length > 0);
32429
- const graph = isRecord28(cs.graph) ? { member: str25(cs.graph.member), at: str25(cs.graph.at) } : null;
32883
+ const graph = isRecord29(cs.graph) ? { member: str25(cs.graph.member), at: str25(cs.graph.at) } : null;
32430
32884
  const planned = str25(cs.releaseDigest) && str25(cs.environment) ? { releaseDigest: str25(cs.releaseDigest), environment: str25(cs.environment) } : null;
32431
32885
  return {
32432
32886
  gate: {
@@ -32485,7 +32939,7 @@ async function readChangeSetOverlay(ws, opts) {
32485
32939
  // src/feature-flags.ts
32486
32940
  init_chant_floors();
32487
32941
  var FLAG_READS = ["feature flags", "promotion order", "change set"];
32488
- var isRecord29 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32942
+ var isRecord30 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32489
32943
  var str26 = (v) => typeof v === "string" && v ? v : null;
32490
32944
  var arr4 = (v) => Array.isArray(v) ? v : [];
32491
32945
  var isValue = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean";
@@ -32511,7 +32965,7 @@ function turnOnLines(flag2, env) {
32511
32965
  ];
32512
32966
  }
32513
32967
  function flagsFromStatus(status2) {
32514
- const members = arr4(status2.members).filter(isRecord29);
32968
+ const members = arr4(status2.members).filter(isRecord30);
32515
32969
  if (!members.some((m) => "featureFlags" in m)) return null;
32516
32970
  const flags = [];
32517
32971
  const unreadable = [];
@@ -32523,12 +32977,12 @@ function flagsFromStatus(status2) {
32523
32977
  continue;
32524
32978
  }
32525
32979
  for (const f of arr4(m.featureFlags)) {
32526
- if (!isRecord29(f) || !str26(f.id)) continue;
32980
+ if (!isRecord30(f) || !str26(f.id)) continue;
32527
32981
  const values = {};
32528
- if (isRecord29(f.values)) {
32982
+ if (isRecord30(f.values)) {
32529
32983
  for (const [env, v] of Object.entries(f.values)) if (isValue(v)) values[env] = v;
32530
32984
  }
32531
- const work = isRecord29(f.work) && str26(f.work.id) ? { id: str26(f.work.id), state: str26(f.work.state) } : null;
32985
+ const work = isRecord30(f.work) && str26(f.work.id) ? { id: str26(f.work.id), state: str26(f.work.state) } : null;
32532
32986
  flags.push({
32533
32987
  key: `${member}/${f.id}`,
32534
32988
  member,
@@ -32536,7 +32990,7 @@ function flagsFromStatus(status2) {
32536
32990
  param: String(f.param ?? ""),
32537
32991
  owner: String(f.owner ?? ""),
32538
32992
  work,
32539
- implements: arr4(f.implements).filter(isRecord29).map((d) => ({ id: String(d.id ?? ""), state: str26(d.state), confirmed: d.confirmed === true })),
32993
+ implements: arr4(f.implements).filter(isRecord30).map((d) => ({ id: String(d.id ?? ""), state: str26(d.state), confirmed: d.confirmed === true })),
32540
32994
  stale: f.stale === true,
32541
32995
  kind: String(f.kind ?? ""),
32542
32996
  path: String(f.path ?? ""),
@@ -32547,20 +33001,20 @@ function flagsFromStatus(status2) {
32547
33001
  return { flags, unreadable };
32548
33002
  }
32549
33003
  function paramMoves(doc, param) {
32550
- const cs = isRecord29(doc.changeSet) ? doc.changeSet : null;
33004
+ const cs = isRecord30(doc.changeSet) ? doc.changeSet : null;
32551
33005
  if (!cs) return null;
32552
33006
  const path = `param:${param}`;
32553
33007
  let found = null;
32554
33008
  for (const e of arr4(cs.entries)) {
32555
- if (!isRecord29(e)) continue;
32556
- const a = arr4(e.attributes).find((x) => isRecord29(x) && x.path === path);
33009
+ if (!isRecord30(e)) continue;
33010
+ const a = arr4(e.attributes).find((x) => isRecord30(x) && x.path === path);
32557
33011
  if (!a) continue;
32558
33012
  found ??= { before: a.before, after: a.after, entries: [] };
32559
33013
  found.entries.push({ address: String(e.address ?? ""), node: str26(e.node) });
32560
33014
  }
32561
33015
  return found;
32562
33016
  }
32563
- var isRefusal3 = (v) => isRecord29(v) && typeof v.error === "string" && typeof v.code === "string" && typeof v.remedy === "string";
33017
+ var isRefusal3 = (v) => isRecord30(v) && typeof v.error === "string" && typeof v.code === "string" && typeof v.remedy === "string";
32564
33018
  var shownKey = (env, gate) => `${env}\0${gate}`;
32565
33019
  function flagsFrom(input) {
32566
33020
  const listed = flagsFromStatus(input.status);
@@ -32651,7 +33105,7 @@ async function readFeatureFlags(ws, opts) {
32651
33105
  // src/collision-marks.ts
32652
33106
  init_chant_floors();
32653
33107
  var COLLISION_READ = "work overlap";
32654
- var isRecord30 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33108
+ var isRecord31 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32655
33109
  var str27 = (v) => typeof v === "string" && v ? v : null;
32656
33110
  var arr5 = (v) => Array.isArray(v) ? v : [];
32657
33111
  var strs = (v) => arr5(v).filter((x) => typeof x === "string");
@@ -32664,7 +33118,7 @@ function overlapRefusal(status2) {
32664
33118
  if (!("overlap" in status2)) {
32665
33119
  return { error: "chant's workspace status carries no overlap.", code: "no-overlap", remedy: `Collision marks need chant ${floorFor(COLLISION_READ).floor} or newer in the project.` };
32666
33120
  }
32667
- if (status2.overlap === null || !isRecord30(status2.overlap)) {
33121
+ if (status2.overlap === null || !isRecord31(status2.overlap)) {
32668
33122
  return {
32669
33123
  error: "chant reported no overlap: the workspace declares no work kind, or chant could not read the work records or the history.",
32670
33124
  code: "overlap-unavailable",
@@ -32678,7 +33132,7 @@ function collisionsFrom(status2, at2) {
32678
33132
  const overlap = status2.overlap;
32679
33133
  const details = /* @__PURE__ */ new Map();
32680
33134
  for (const i of arr5(overlap.items)) {
32681
- if (!isRecord30(i) || !str27(i.item)) continue;
33135
+ if (!isRecord31(i) || !str27(i.item)) continue;
32682
33136
  details.set(String(i.item), { path: String(i.path ?? ""), state: str27(i.state), commits: strs(i.commits) });
32683
33137
  }
32684
33138
  const nodes = /* @__PURE__ */ new Map();
@@ -32686,7 +33140,7 @@ function collisionsFrom(status2, at2) {
32686
33140
  const files = [];
32687
33141
  const withs = /* @__PURE__ */ new Map();
32688
33142
  for (const p of arr5(overlap.pairs)) {
32689
- if (!isRecord30(p)) continue;
33143
+ if (!isRecord31(p)) continue;
32690
33144
  const pair = strs(p.items).sort(byString);
32691
33145
  if (pair.length !== 2) continue;
32692
33146
  const [a, b] = pair;
@@ -32694,7 +33148,7 @@ function collisionsFrom(status2, at2) {
32694
33148
  const shared2 = strs(p.files);
32695
33149
  if (shared2.length) files.push({ items: [a, b], files: shared2 });
32696
33150
  for (const e of arr5(p.addresses)) {
32697
- if (!isRecord30(e)) continue;
33151
+ if (!isRecord31(e)) continue;
32698
33152
  const entry = { changeSet: String(e.changeSet ?? ""), member: String(e.member ?? ""), address: String(e.address ?? ""), source: String(e.source ?? ""), items: pair };
32699
33153
  const node = str27(e.node);
32700
33154
  if (!node) {
@@ -32735,8 +33189,8 @@ async function readCollisions(ws, opts) {
32735
33189
  }
32736
33190
 
32737
33191
  // src/sql-yodeler-lane.ts
32738
- import { existsSync as existsSync31, readdirSync as readdirSync19, readFileSync as readFileSync39 } from "node:fs";
32739
- import { join as join51 } from "node:path";
33192
+ import { existsSync as existsSync32, readdirSync as readdirSync19, readFileSync as readFileSync40 } from "node:fs";
33193
+ import { join as join52 } from "node:path";
32740
33194
  var YODEL_APPLY_OP = "yodel-apply";
32741
33195
  var YODEL_HEAD_PLANS_DIR = headPlansPath(YODEL_APPLY_OP, "").dir;
32742
33196
  function parseYodelWaves(text3, path = WAVES_SPEC_FILE) {
@@ -32768,17 +33222,17 @@ function parseYodelWaves(text3, path = WAVES_SPEC_FILE) {
32768
33222
  return { path, waves };
32769
33223
  }
32770
33224
  function readYodelWaves(checkout) {
32771
- const p = join51(checkout, WAVES_SPEC_FILE);
32772
- if (!existsSync31(p)) return void 0;
33225
+ const p = join52(checkout, WAVES_SPEC_FILE);
33226
+ if (!existsSync32(p)) return void 0;
32773
33227
  try {
32774
- return parseYodelWaves(readFileSync39(p, "utf8"));
33228
+ return parseYodelWaves(readFileSync40(p, "utf8"));
32775
33229
  } catch (e) {
32776
33230
  return { path: WAVES_SPEC_FILE, waves: [], error: e instanceof Error ? e.message : String(e) };
32777
33231
  }
32778
33232
  }
32779
33233
  function migrateOpEnvironments(checkout) {
32780
- const dir = join51(checkout, "ops");
32781
- if (!existsSync31(dir)) return [];
33234
+ const dir = join52(checkout, "ops");
33235
+ if (!existsSync32(dir)) return [];
32782
33236
  try {
32783
33237
  return readdirSync19(dir).map((f) => /^migrate-(.+)\.op\.ts$/.exec(f)?.[1]).filter((e) => !!e).sort();
32784
33238
  } catch {
@@ -32898,18 +33352,75 @@ function sqlYodelerLaneRoute(app, checkout, opts = {}) {
32898
33352
  });
32899
33353
  }
32900
33354
 
33355
+ // src/health-overlay.ts
33356
+ init_chant_floors();
33357
+ var HEALTH_READ_NAME = "runtime health";
33358
+ var HEALTH_TTL_MS = 3e4;
33359
+ async function readHealthOverlay(members, env, deps) {
33360
+ const floor = floorFor(HEALTH_READ_NAME);
33361
+ const reads2 = await Promise.all(
33362
+ members.map(async (m) => {
33363
+ const chant = deps.chantVersion(m.dir) ?? null;
33364
+ const base = { member: m.name ?? null, chant };
33365
+ if (!floorMet(floor, chant ?? void 0)) return { m, read: { ...base, refusal: floorRefusal(floor, chant ?? void 0) } };
33366
+ try {
33367
+ const doc = await deps.reader(m.dir).readHealth(env);
33368
+ return { m, doc, read: { ...base, observedAt: doc.observedAt, ...doc.summary ? { summary: doc.summary } : {} } };
33369
+ } catch (e) {
33370
+ if (!(e instanceof WorkspaceReadError)) return { m, read: { ...base, refusal: { error: `The health read stopped: ${e.message}.`, code: "lifecycle-health", remedy: "BEHOLD_READ_TIMEOUT_MS raises the read deadline; /api/doctor shows what else is reading." } } };
33371
+ if (e.refusal.code === "health-none") return { m, read: { ...base, none: true } };
33372
+ return { m, read: { ...base, refusal: e.refusal } };
33373
+ }
33374
+ })
33375
+ );
33376
+ const nodes = {};
33377
+ for (const r of reads2) if (r.doc) Object.assign(nodes, nodeHealthOf(r.doc, r.m.name));
33378
+ const rotation = {};
33379
+ await Promise.all(
33380
+ reads2.filter((r) => r.doc).map(async (r) => {
33381
+ const graph = await deps.graph(r.m.dir).catch(() => void 0);
33382
+ if (graph) Object.assign(rotation, rotationOf(graph, nodes, r.m.name));
33383
+ })
33384
+ );
33385
+ const answer = {
33386
+ env,
33387
+ nodes,
33388
+ rotation,
33389
+ members: reads2.map((r) => r.read),
33390
+ counts: healthCounts(nodes, rotation),
33391
+ readAt: (deps.now?.() ?? /* @__PURE__ */ new Date()).toISOString()
33392
+ };
33393
+ const tooOld = reads2.filter((r) => r.read.refusal?.code === "chant-too-old");
33394
+ if (reads2.length > 0 && tooOld.length === reads2.length) {
33395
+ answer.refusal = tooOld[0].read.refusal;
33396
+ answer.degraded = floor.degraded;
33397
+ }
33398
+ return answer;
33399
+ }
33400
+ var cache6 = /* @__PURE__ */ new Map();
33401
+ function cachedHealth(key3, now = Date.now()) {
33402
+ const hit = cache6.get(key3);
33403
+ return hit && now - hit.at < HEALTH_TTL_MS ? hit.answer : void 0;
33404
+ }
33405
+ function rememberHealth(key3, answer, now = Date.now()) {
33406
+ cache6.set(key3, { at: now, answer });
33407
+ }
33408
+ function invalidateHealth() {
33409
+ cache6.clear();
33410
+ }
33411
+
32901
33412
  // src/terragucci-estate.ts
32902
33413
  init_yaml();
32903
- import { existsSync as existsSync32, readFileSync as readFileSync40, statSync as statSync14 } from "node:fs";
33414
+ import { existsSync as existsSync33, readFileSync as readFileSync41, statSync as statSync14 } from "node:fs";
32904
33415
  import { createRequire as createRequire7 } from "node:module";
32905
- import { dirname as dirname16, extname as extname2, join as join52, resolve as resolve30 } from "node:path";
33416
+ import { dirname as dirname16, extname as extname2, join as join53, resolve as resolve31 } from "node:path";
32906
33417
  import { fileURLToPath as fileURLToPath11 } from "node:url";
32907
- import { Ajv2020 as Ajv20208 } from "ajv/dist/2020.js";
33418
+ import { Ajv2020 as Ajv20209 } from "ajv/dist/2020.js";
32908
33419
  var RUN_SCHEMA2 = "terragucci.run/v1";
32909
33420
  function configProjects(file) {
32910
33421
  let text3;
32911
33422
  try {
32912
- text3 = readFileSync40(file, "utf8");
33423
+ text3 = readFileSync41(file, "utf8");
32913
33424
  } catch {
32914
33425
  return void 0;
32915
33426
  }
@@ -32937,21 +33448,21 @@ function controlRepo(dirs, roots = () => checkoutRoots(dirs).length) {
32937
33448
  }
32938
33449
  return n === 0 ? { config, projects } : void 0;
32939
33450
  }
32940
- var isRecord31 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33451
+ var isRecord32 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32941
33452
  var str28 = (v) => typeof v === "string";
32942
33453
  var int4 = (v) => typeof v === "number" && Number.isInteger(v);
32943
33454
  function structuralRun2(doc) {
32944
- if (!isRecord31(doc)) return "it is not a JSON object";
33455
+ if (!isRecord32(doc)) return "it is not a JSON object";
32945
33456
  if (doc.schema !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA2}`;
32946
33457
  if (!str28(doc.project) || !str28(doc.commit) || !str28(doc.updated)) return "it lacks project, commit or updated";
32947
33458
  if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
32948
33459
  for (const [i, r] of doc.roots.entries()) {
32949
- if (!isRecord31(r) || !str28(r.root) || !int4(r.wave) || !Array.isArray(r.reads) || !r.reads.every(str28)) return `root ${i} lacks root, wave or reads`;
32950
- if (r.state !== void 0 && !(isRecord31(r.state) && str28(r.state.key))) return `root ${String(r.root)}'s state has no key`;
32951
- if (r.external !== void 0 && !(Array.isArray(r.external) && r.external.every((x) => isRecord31(x) && str28(x.data) && str28(x.key)))) return `root ${String(r.root)}'s external reads lack data or key`;
33460
+ if (!isRecord32(r) || !str28(r.root) || !int4(r.wave) || !Array.isArray(r.reads) || !r.reads.every(str28)) return `root ${i} lacks root, wave or reads`;
33461
+ if (r.state !== void 0 && !(isRecord32(r.state) && str28(r.state.key))) return `root ${String(r.root)}'s state has no key`;
33462
+ if (r.external !== void 0 && !(Array.isArray(r.external) && r.external.every((x) => isRecord32(x) && str28(x.data) && str28(x.key)))) return `root ${String(r.root)}'s external reads lack data or key`;
32952
33463
  }
32953
33464
  for (const [i, w] of doc.waves.entries()) {
32954
- if (!isRecord31(w) || !int4(w.number) || !Array.isArray(w.roots) || !Array.isArray(w.reads) || !str28(w.state) || !str28(w.gate)) return `wave ${i} lacks number, roots, reads, state or gate`;
33465
+ if (!isRecord32(w) || !int4(w.number) || !Array.isArray(w.roots) || !Array.isArray(w.reads) || !str28(w.state) || !str28(w.gate)) return `wave ${i} lacks number, roots, reads, state or gate`;
32955
33466
  }
32956
33467
  return void 0;
32957
33468
  }
@@ -32960,16 +33471,16 @@ function runViewValidator(dirs = []) {
32960
33471
  for (const from of [...dirs, dirname16(fileURLToPath11(import.meta.url))]) {
32961
33472
  let entry;
32962
33473
  try {
32963
- entry = createRequire7(join52(resolve30(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
33474
+ entry = createRequire7(join53(resolve31(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
32964
33475
  } catch {
32965
33476
  continue;
32966
33477
  }
32967
33478
  const dist = dirname16(entry);
32968
- const schema = join52(dist, "run.schema.json");
33479
+ const schema = join53(dist, "run.schema.json");
32969
33480
  let stamp;
32970
33481
  try {
32971
33482
  const st = statSync14(schema);
32972
- const pkg = statSync14(join52(dist, "..", "package.json"));
33483
+ const pkg = statSync14(join53(dist, "..", "package.json"));
32973
33484
  stamp = `${schema}\0${st.mtimeMs}:${st.size}\0${pkg.mtimeMs}`;
32974
33485
  } catch {
32975
33486
  continue;
@@ -32978,12 +33489,12 @@ function runViewValidator(dirs = []) {
32978
33489
  if (hit) return hit;
32979
33490
  let v;
32980
33491
  try {
32981
- const version = JSON.parse(readFileSync40(join52(dist, "..", "package.json"), "utf8")).version ?? "";
32982
- const validate2 = new Ajv20208({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync40(schema, "utf8")));
33492
+ const version = JSON.parse(readFileSync41(join53(dist, "..", "package.json"), "utf8")).version ?? "";
33493
+ const validate2 = new Ajv20209({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync41(schema, "utf8")));
32983
33494
  v = {
32984
33495
  validation: { by: "schema", terragucci: version },
32985
33496
  check(doc) {
32986
- const id = isRecord31(doc) ? doc.schema : void 0;
33497
+ const id = isRecord32(doc) ? doc.schema : void 0;
32987
33498
  if (id !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA2}`;
32988
33499
  if (validate2(doc)) return void 0;
32989
33500
  const e = validate2.errors?.[0];
@@ -33034,8 +33545,8 @@ function controlEdges(views) {
33034
33545
  function siblingCheckout(project, base, projectOf = checkoutProject) {
33035
33546
  const name = project.split("/").filter(Boolean).pop();
33036
33547
  if (!name) return void 0;
33037
- const dir = join52(dirname16(resolve30(base)), name);
33038
- if (dir === resolve30(base) || !existsSync32(join52(dir, ".git"))) return void 0;
33548
+ const dir = join53(dirname16(resolve31(base)), name);
33549
+ if (dir === resolve31(base) || !existsSync33(join53(dir, ".git"))) return void 0;
33039
33550
  return projectOf(dir) === project ? dir : void 0;
33040
33551
  }
33041
33552
  var shellWord = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
@@ -33242,11 +33753,11 @@ function controlRepoInfo(dirs) {
33242
33753
  }
33243
33754
 
33244
33755
  // src/yodel-report.ts
33245
- import { readdirSync as readdirSync20, readFileSync as readFileSync41, statSync as statSync15 } from "node:fs";
33756
+ import { readdirSync as readdirSync20, readFileSync as readFileSync42, statSync as statSync15 } from "node:fs";
33246
33757
  import { createRequire as createRequire8 } from "node:module";
33247
- import { basename as basename6, dirname as dirname17, join as join53, resolve as resolve31 } from "node:path";
33758
+ import { basename as basename6, dirname as dirname17, join as join54, resolve as resolve32 } from "node:path";
33248
33759
  import { fileURLToPath as fileURLToPath12 } from "node:url";
33249
- import { Ajv2020 as Ajv20209 } from "ajv/dist/2020.js";
33760
+ import { Ajv2020 as Ajv202010 } from "ajv/dist/2020.js";
33250
33761
 
33251
33762
  // src/sql-yodeler-schemas/common.schema.json
33252
33763
  var common_schema_default = {
@@ -33655,7 +34166,7 @@ var refuse14 = (error, remedy) => {
33655
34166
  throw new YodelReadError({ error, code: "yodel-report", remedy });
33656
34167
  };
33657
34168
  function compile(schemas, validation) {
33658
- const ajv = new Ajv20209({ strict: false, allErrors: false });
34169
+ const ajv = new Ajv202010({ strict: false, allErrors: false });
33659
34170
  ajv.addSchema(schemas.common);
33660
34171
  const compiled4 = { report: ajv.compile(schemas.report), drift: ajv.compile(schemas.drift) };
33661
34172
  return {
@@ -33673,13 +34184,13 @@ var installed = /* @__PURE__ */ new Map();
33673
34184
  function packageRoot(from) {
33674
34185
  let entry;
33675
34186
  try {
33676
- entry = createRequire8(join53(resolve31(from), "noop.js")).resolve("@intentius/sql-yodeler");
34187
+ entry = createRequire8(join54(resolve32(from), "noop.js")).resolve("@intentius/sql-yodeler");
33677
34188
  } catch {
33678
34189
  return void 0;
33679
34190
  }
33680
34191
  for (let d = dirname17(entry); d !== dirname17(d); d = dirname17(d)) {
33681
34192
  try {
33682
- const pkg = JSON.parse(readFileSync41(join53(d, "package.json"), "utf8"));
34193
+ const pkg = JSON.parse(readFileSync42(join54(d, "package.json"), "utf8"));
33683
34194
  if (pkg.name === "@intentius/sql-yodeler") return d;
33684
34195
  } catch {
33685
34196
  }
@@ -33691,11 +34202,11 @@ function yodelValidator(dirs = []) {
33691
34202
  const root = packageRoot(from);
33692
34203
  if (!root) continue;
33693
34204
  try {
33694
- const version = JSON.parse(readFileSync41(join53(root, "package.json"), "utf8")).version ?? "";
34205
+ const version = JSON.parse(readFileSync42(join54(root, "package.json"), "utf8")).version ?? "";
33695
34206
  const key3 = `${root}\0${version}`;
33696
34207
  let v = installed.get(key3);
33697
34208
  if (!v) {
33698
- const load2 = (n) => JSON.parse(readFileSync41(join53(root, "schemas", `${n}.schema.json`), "utf8"));
34209
+ const load2 = (n) => JSON.parse(readFileSync42(join54(root, "schemas", `${n}.schema.json`), "utf8"));
33699
34210
  v = compile({ common: load2("common"), report: load2("report"), drift: load2("drift") }, { by: "schema", from: "package", sqlYodeler: version });
33700
34211
  installed.set(key3, v);
33701
34212
  }
@@ -33706,9 +34217,9 @@ function yodelValidator(dirs = []) {
33706
34217
  pinned ??= compile({ common: common_schema_default, report: report_schema_default, drift: drift_schema_default }, { by: "schema", from: "pinned", commit: PINNED_COMMIT.slice(0, 7) });
33707
34218
  return pinned;
33708
34219
  }
33709
- var isRecord32 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
33710
- var looksLikeReport = (d) => isRecord32(d) && "generatedAt" in d && "environments" in d;
33711
- var looksLikeDrift = (d) => isRecord32(d) && "environment" in d && ("drifted" in d || "changed" in d);
34220
+ var isRecord33 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
34221
+ var looksLikeReport = (d) => isRecord33(d) && "generatedAt" in d && "environments" in d;
34222
+ var looksLikeDrift = (d) => isRecord33(d) && "environment" in d && ("drifted" in d || "changed" in d);
33712
34223
  function filesOf(source2) {
33713
34224
  let st;
33714
34225
  try {
@@ -33717,11 +34228,11 @@ function filesOf(source2) {
33717
34228
  return refuse14(`--yodel-report ${source2}: no such file or directory`, "Point --yodel-report at the file `yodel report --json` wrote, or the directory holding it.");
33718
34229
  }
33719
34230
  const dir = st.isDirectory() ? source2 : dirname17(source2);
33720
- const files = readdirSync20(dir).filter((f) => f.endsWith(".json")).sort().map((f) => join53(dir, f));
33721
- return st.isDirectory() ? { dir, files } : { dir, files, named: resolve31(source2) };
34231
+ const files = readdirSync20(dir).filter((f) => f.endsWith(".json")).sort().map((f) => join54(dir, f));
34232
+ return st.isDirectory() ? { dir, files } : { dir, files, named: resolve32(source2) };
33722
34233
  }
33723
- function readYodelReport(source2, validator4) {
33724
- const { files, named } = filesOf(resolve31(source2));
34234
+ function readYodelReport(source2, validator5) {
34235
+ const { files, named } = filesOf(resolve32(source2));
33725
34236
  let report;
33726
34237
  const drifts = [];
33727
34238
  const ignored = [];
@@ -33729,7 +34240,7 @@ function readYodelReport(source2, validator4) {
33729
34240
  for (const file of files) {
33730
34241
  let doc;
33731
34242
  try {
33732
- doc = JSON.parse(readFileSync41(file, "utf8"));
34243
+ doc = JSON.parse(readFileSync42(file, "utf8"));
33733
34244
  } catch (e) {
33734
34245
  if (file === named) refuse14(`${basename6(file)} is not JSON: ${e instanceof Error ? e.message : String(e)}`, remedy);
33735
34246
  ignored.push(basename6(file));
@@ -33740,7 +34251,7 @@ function readYodelReport(source2, validator4) {
33740
34251
  ignored.push(basename6(file));
33741
34252
  continue;
33742
34253
  }
33743
- const why = validator4.check(kind, doc);
34254
+ const why = validator5.check(kind, doc);
33744
34255
  if (why) refuse14(`${basename6(file)} is not a SQL Yodeler ${kind} document: ${why}`, remedy);
33745
34256
  if (kind === "report") {
33746
34257
  if (report) refuse14(`${source2} holds two reports, ${basename6(report.file)} and ${basename6(file)}`, "Name the one to read: --yodel-report <file>.");
@@ -33794,7 +34305,7 @@ function readYodelReport(source2, validator4) {
33794
34305
  }
33795
34306
  return {
33796
34307
  source: source2,
33797
- validation: validator4.validation,
34308
+ validation: validator5.validation,
33798
34309
  report: report ? { file: basename6(report.file), project: report.doc.project, dialect: report.doc.dialect, generatedAt: report.doc.generatedAt, migrations: report.doc.migrations.length } : null,
33799
34310
  environments,
33800
34311
  drift,
@@ -33816,24 +34327,24 @@ function yodelReportRoute(app, source2, dirs) {
33816
34327
 
33817
34328
  // src/demo-pins.ts
33818
34329
  init_terraform_member();
33819
- import { existsSync as existsSync33, lstatSync as lstatSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync42, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
33820
- import { dirname as dirname18, join as join54, resolve as resolve32 } from "node:path";
33821
- var isRecord33 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
34330
+ import { existsSync as existsSync34, lstatSync as lstatSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync43, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
34331
+ import { dirname as dirname18, join as join55, resolve as resolve33 } from "node:path";
34332
+ var isRecord34 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33822
34333
  function linkDemoPins(work, probes = {}) {
33823
- const file = join54(work, "chant.workspace.json");
33824
- if (!existsSync33(file)) return { ok: true, linked: [] };
34334
+ const file = join55(work, "chant.workspace.json");
34335
+ if (!existsSync34(file)) return { ok: true, linked: [] };
33825
34336
  let decl;
33826
34337
  try {
33827
- decl = JSON.parse(readFileSync42(file, "utf8"));
34338
+ decl = JSON.parse(readFileSync43(file, "utf8"));
33828
34339
  } catch {
33829
34340
  return { ok: true, linked: [] };
33830
34341
  }
33831
- if (!isRecord33(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
34342
+ if (!isRecord34(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
33832
34343
  const find = probes.resolve ?? ((pkg) => resolvedPackage(pkg));
33833
34344
  const linked = [];
33834
34345
  let rewrite = false;
33835
34346
  for (const pin of decl.pins) {
33836
- if (!isRecord33(pin) || typeof pin.package !== "string") continue;
34347
+ if (!isRecord34(pin) || typeof pin.package !== "string") continue;
33837
34348
  const pkg = pin.package;
33838
34349
  if (pkg === TERRAFORM_LEXICON_PKG) {
33839
34350
  const refusal2 = (probes.reader ?? terraformReaderState)().refusal;
@@ -33847,7 +34358,7 @@ function linkDemoPins(work, probes = {}) {
33847
34358
  remedy: `Install ${pkg} beside behold, then load the demo again.`
33848
34359
  };
33849
34360
  }
33850
- const link = join54(work, "node_modules", ...pkg.split("/"));
34361
+ const link = join55(work, "node_modules", ...pkg.split("/"));
33851
34362
  if (!present(link)) {
33852
34363
  mkdirSync7(dirname18(link), { recursive: true });
33853
34364
  symlinkSync2(found.dir, link, "junction");
@@ -33875,26 +34386,26 @@ function present(path) {
33875
34386
  }
33876
34387
  function linksTo(link, target) {
33877
34388
  try {
33878
- return lstatSync2(link).isSymbolicLink() && resolve32(dirname18(link), readlinkSync2(link)) === resolve32(target);
34389
+ return lstatSync2(link).isSymbolicLink() && resolve33(dirname18(link), readlinkSync2(link)) === resolve33(target);
33879
34390
  } catch {
33880
34391
  return false;
33881
34392
  }
33882
34393
  }
33883
34394
 
33884
34395
  // src/demos.ts
33885
- import { readFileSync as readFileSync43, existsSync as existsSync34, cpSync, mkdirSync as mkdirSync8 } from "node:fs";
33886
- import { dirname as dirname19, isAbsolute as isAbsolute7, join as join55, relative as relative11, resolve as resolve33, sep as sep9 } from "node:path";
34396
+ import { readFileSync as readFileSync44, existsSync as existsSync35, cpSync, mkdirSync as mkdirSync8 } from "node:fs";
34397
+ import { dirname as dirname19, isAbsolute as isAbsolute7, join as join56, relative as relative11, resolve as resolve34, sep as sep9 } from "node:path";
33887
34398
  import { spawn as spawn9, spawnSync as spawnSync3 } from "node:child_process";
33888
34399
  function readCatalog(file, catalog) {
33889
34400
  let raw;
33890
34401
  try {
33891
- raw = JSON.parse(readFileSync43(file, "utf8"));
34402
+ raw = JSON.parse(readFileSync44(file, "utf8"));
33892
34403
  } catch {
33893
34404
  return [];
33894
34405
  }
33895
34406
  const list4 = raw?.demos;
33896
34407
  if (!Array.isArray(list4)) return [];
33897
- const catalogDir = dirname19(resolve33(file));
34408
+ const catalogDir = dirname19(resolve34(file));
33898
34409
  return list4.filter((e) => validEntry(e)).map((e) => ({ ...e, catalog, catalogDir }));
33899
34410
  }
33900
34411
  function validEntry(e) {
@@ -33929,10 +34440,10 @@ function validEntry(e) {
33929
34440
  return true;
33930
34441
  }
33931
34442
  function loadDemoRegistry(pkgRoot3) {
33932
- const merged = readCatalog(join55(pkgRoot3, "demos.json"), "demos");
34443
+ const merged = readCatalog(join56(pkgRoot3, "demos.json"), "demos");
33933
34444
  const seen = new Set(merged.map((e) => e.name));
33934
34445
  const named = process.env.BEHOLD_WORKBENCH;
33935
- for (const e of [...readCatalog(join55(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve33(named), "workbench") : []]) {
34446
+ for (const e of [...readCatalog(join56(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve34(named), "workbench") : []]) {
33936
34447
  if (seen.has(e.name)) {
33937
34448
  process.stderr.write(`behold: workbench entry "${e.name}" collides with a demo already in the catalog \u2014 dropped
33938
34449
  `);
@@ -33945,17 +34456,17 @@ function loadDemoRegistry(pkgRoot3) {
33945
34456
  }
33946
34457
  function demoLocalPath(entry) {
33947
34458
  if (entry.source !== "local" || !entry.path) return void 0;
33948
- return isAbsolute7(entry.path) ? entry.path : resolve33(entry.catalogDir ?? process.cwd(), entry.path);
34459
+ return isAbsolute7(entry.path) ? entry.path : resolve34(entry.catalogDir ?? process.cwd(), entry.path);
33949
34460
  }
33950
34461
  function missingRequirements(entry) {
33951
34462
  const bins = entry.source === "git" && !entry.requires.includes("git") ? [...entry.requires, "git"] : entry.requires;
33952
34463
  const finder = process.platform === "win32" ? "where" : "which";
33953
34464
  const missing = bins.filter((bin) => {
33954
- if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync34(process.env.CHOUDOUFU_BIN)) return false;
34465
+ if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync35(process.env.CHOUDOUFU_BIN)) return false;
33955
34466
  return spawnSync3(finder, [bin], { stdio: "ignore" }).status !== 0;
33956
34467
  });
33957
34468
  const local = demoLocalPath(entry);
33958
- if (local && !existsSync34(local)) missing.push(`${entry.path} (not checked out)`);
34469
+ if (local && !existsSync35(local)) missing.push(`${entry.path} (not checked out)`);
33959
34470
  return missing;
33960
34471
  }
33961
34472
  function fetchesFromNetwork(entry) {
@@ -33964,9 +34475,9 @@ function fetchesFromNetwork(entry) {
33964
34475
  function demoTargetDir(entry, cwd = process.cwd()) {
33965
34476
  const inPlace = entry.inPlace ? demoLocalPath(entry) : void 0;
33966
34477
  if (inPlace) return inPlace;
33967
- const legacy = resolve33(cwd, "behold-demo");
33968
- if (entry.name === "writes" && existsSync34(legacy)) return legacy;
33969
- return resolve33(cwd, "behold-demos", entry.name);
34478
+ const legacy = resolve34(cwd, "behold-demo");
34479
+ if (entry.name === "writes" && existsSync35(legacy)) return legacy;
34480
+ return resolve34(cwd, "behold-demos", entry.name);
33970
34481
  }
33971
34482
  async function loadDemo(entry, opts) {
33972
34483
  const { pkgRoot: pkgRoot3, target } = opts;
@@ -33975,12 +34486,12 @@ async function loadDemo(entry, opts) {
33975
34486
  const inPlace = entry.source === "local" && entry.inPlace;
33976
34487
  const work = inPlace ? local : target;
33977
34488
  if (inPlace) {
33978
- if (!existsSync34(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
34489
+ if (!existsSync35(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
33979
34490
  say(`serving ${work} where it is \u2014 nothing copied`);
33980
- } else if (!existsSync34(target)) {
34491
+ } else if (!existsSync35(target)) {
33981
34492
  if (entry.source === "bundled" || entry.source === "local" && local) {
33982
- const from = entry.source === "bundled" ? join55(pkgRoot3, entry.dir) : local;
33983
- if (!existsSync34(from)) return { ok: false, error: entry.source === "bundled" ? `this install has no bundled ${entry.dir}` : `${entry.path} is not checked out (looked in ${from})` };
34493
+ const from = entry.source === "bundled" ? join56(pkgRoot3, entry.dir) : local;
34494
+ if (!existsSync35(from)) return { ok: false, error: entry.source === "bundled" ? `this install has no bundled ${entry.dir}` : `${entry.path} is not checked out (looked in ${from})` };
33984
34495
  say(`copying to ${target} (it's yours \u2014 edit it)`);
33985
34496
  try {
33986
34497
  cpSync(from, target, {
@@ -34011,7 +34522,7 @@ async function loadDemo(entry, opts) {
34011
34522
  if (!pins.ok) return { ok: false, error: `${pins.error} ${pins.remedy}` };
34012
34523
  for (const p of pins.linked) say(`linked ${p.pkg} ${p.version} into the copy${p.was ? ` (the declaration pinned ${p.was}; now ${p.version})` : ""}`);
34013
34524
  }
34014
- if (!inPlace && existsSync34(join55(work, "package.json")) && !existsSync34(join55(work, "node_modules"))) {
34525
+ if (!inPlace && existsSync35(join56(work, "package.json")) && !existsSync35(join56(work, "node_modules"))) {
34015
34526
  say("npm install\u2026");
34016
34527
  if (await runStep("npm", ["install"], { cwd: work, shell: process.platform === "win32" }) !== 0) {
34017
34528
  return { ok: false, error: `npm install failed in ${work}` };
@@ -34028,7 +34539,7 @@ async function loadDemo(entry, opts) {
34028
34539
  return { ok: false, error: `setup failed (${entry.setup})` };
34029
34540
  }
34030
34541
  }
34031
- return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join55(work, d)) : [work] };
34542
+ return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join56(work, d)) : [work] };
34032
34543
  }
34033
34544
  function runStep(cmd, args, opts = {}) {
34034
34545
  return new Promise((res) => {
@@ -34039,8 +34550,8 @@ function runStep(cmd, args, opts = {}) {
34039
34550
  }
34040
34551
 
34041
34552
  // src/server.ts
34042
- var pkgRoot = join56(dirname20(fileURLToPath13(import.meta.url)), "..");
34043
- var webRoot2 = join56(pkgRoot, "web");
34553
+ var pkgRoot = join57(dirname20(fileURLToPath13(import.meta.url)), "..");
34554
+ var webRoot2 = join57(pkgRoot, "web");
34044
34555
  var execFileP = async (cmd, args) => (await promisify3(execFile6)(cmd, args, { encoding: "utf8", timeout: 1e4 })).stdout;
34045
34556
  function optsFromQuery(url, tierEnvVar, projectDir) {
34046
34557
  const q = url.searchParams;
@@ -34091,7 +34602,7 @@ function tierFailure(tier, message2) {
34091
34602
  function beholdVersion() {
34092
34603
  try {
34093
34604
  const here = dirname20(fileURLToPath13(import.meta.url));
34094
- return JSON.parse(readFileSync44(join56(here, "..", "package.json"), "utf8")).version ?? "unknown";
34605
+ return JSON.parse(readFileSync45(join57(here, "..", "package.json"), "utf8")).version ?? "unknown";
34095
34606
  } catch {
34096
34607
  return "unknown";
34097
34608
  }
@@ -34127,6 +34638,7 @@ function deployTargets(lexicons = [], k8sTarget) {
34127
34638
  async function captureFrame(projectDir, env, frames, broadcaster) {
34128
34639
  try {
34129
34640
  invalidateOverlay();
34641
+ invalidateHealth();
34130
34642
  const ir = await graphIr(projectDir, env ? { live: true, overlay: true, env } : {});
34131
34643
  const captured = frames.capture(ir) !== null;
34132
34644
  if (captured) broadcaster.emit("frames");
@@ -34139,11 +34651,11 @@ async function captureFrame(projectDir, env, frames, broadcaster) {
34139
34651
  }
34140
34652
  function terralithRoutes(app, demo) {
34141
34653
  app.get("/api/terralith", (c) => c.json(readTerralith(demo.root)));
34142
- app.get("/terralith", serveStatic({ path: join56(relative12(process.cwd(), webRoot2) || ".", "terralith.html") }));
34654
+ app.get("/terralith", serveStatic({ path: join57(relative12(process.cwd(), webRoot2) || ".", "terralith.html") }));
34143
34655
  app.get("/", (c) => c.redirect("/terralith"));
34144
34656
  }
34145
34657
  function carveRoutes(app, reportPath, demo) {
34146
- const load2 = () => readCarveReport(reportPath, (p) => readFileSync44(p, "utf8"));
34658
+ const load2 = () => readCarveReport(reportPath, (p) => readFileSync45(p, "utf8"));
34147
34659
  const carveDirs = [dirname20(reportPath), ...demo ? [demo.out] : []];
34148
34660
  const carveStates = () => readCarveStates(carveDirs, nodeCarveIo, 0);
34149
34661
  const emittedNodes = async (states) => {
@@ -34581,9 +35093,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34581
35093
  return c.json({ started: true, name, ran: label });
34582
35094
  });
34583
35095
  app.post("/api/local/reset", (c) => {
34584
- const down = join56(cfg.projectDir, "scripts/local/local-down.sh");
34585
- const up = join56(cfg.projectDir, "scripts/local/local-up.sh");
34586
- if (!existsSync35(down) || !existsSync35(up)) {
35096
+ const down = join57(cfg.projectDir, "scripts/local/local-down.sh");
35097
+ const up = join57(cfg.projectDir, "scripts/local/local-up.sh");
35098
+ if (!existsSync36(down) || !existsSync36(up)) {
34587
35099
  return c.json({ error: "no local-down.sh / local-up.sh in scripts/local \u2014 reset is only for local emulator projects" }, 400);
34588
35100
  }
34589
35101
  if (!runner.bringUp("reset local emulator", "bash", ["-c", "bash scripts/local/local-down.sh && bash scripts/local/local-up.sh"], cfg.projectDir)) {
@@ -34607,7 +35119,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34607
35119
  const dirs = [];
34608
35120
  const declared2 = [];
34609
35121
  for (const f of discoverOpIrs(estateDirs())) {
34610
- const parsed = readOpIr(f.path, (p) => readFileSync44(p, "utf8"));
35122
+ const parsed = readOpIr(f.path, (p) => readFileSync45(p, "utf8"));
34611
35123
  if (!parsed.ok) continue;
34612
35124
  const mine = declaredConvergeOps([parsed.ir]);
34613
35125
  if (!mine.length) continue;
@@ -34856,9 +35368,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34856
35368
  recent: recent2.map(({ dir, ...rest }) => ({ dir: relative12(cfg.projectDir, dir) || ".", ...rest }))
34857
35369
  }
34858
35370
  };
34859
- const cache6 = memberIrCacheStats();
34860
- if (readsOnly) return c.json({ reads: reads2, cache: cache6 });
34861
- return c.json({ ...await diagnose(cfg.projectDir), reads: reads2, cache: cache6 });
35371
+ const cache7 = memberIrCacheStats();
35372
+ if (readsOnly) return c.json({ reads: reads2, cache: cache7 });
35373
+ return c.json({ ...await diagnose(cfg.projectDir), reads: reads2, cache: cache7 });
34862
35374
  });
34863
35375
  app.get("/api/project", async (c) => {
34864
35376
  const { environments: declaredEnvs, lexicons, stacks, k8sProfiles } = await detectProject(cfg.projectDir);
@@ -34997,9 +35509,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34997
35509
  app.post("/api/project/open", async (c) => {
34998
35510
  if (cfg.previewMode) return c.json({ error: "switching projects is locked in preview mode" }, 403);
34999
35511
  const body = await c.req.json().catch(() => ({}));
35000
- const dir = typeof body.dir === "string" && body.dir.trim() ? resolve34(body.dir.trim()) : "";
35001
- if (!dir || !existsSync35(dir)) return c.json({ error: `no such directory: ${dir || "(no dir given)"}` }, 400);
35002
- if (!existsSync35(join56(dir, "chant.config.ts"))) {
35512
+ const dir = typeof body.dir === "string" && body.dir.trim() ? resolve35(body.dir.trim()) : "";
35513
+ if (!dir || !existsSync36(dir)) return c.json({ error: `no such directory: ${dir || "(no dir given)"}` }, 400);
35514
+ if (!existsSync36(join57(dir, "chant.config.ts"))) {
35003
35515
  return c.json({ error: `${dir} doesn't look like a chant project \u2014 no chant.config.ts` }, 400);
35004
35516
  }
35005
35517
  switchServedProject([dir]);
@@ -35022,7 +35534,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35022
35534
  };
35023
35535
  app.post("/api/project/reveal", async (c) => {
35024
35536
  const body = await c.req.json().catch(() => ({}));
35025
- const dir = typeof body.dir === "string" && body.dir.trim() ? resolve34(body.dir.trim()) : cfg.projectDir;
35537
+ const dir = typeof body.dir === "string" && body.dir.trim() ? resolve35(body.dir.trim()) : cfg.projectDir;
35026
35538
  const known = /* @__PURE__ */ new Set([cfg.projectDir, ...cfg.projectDirs ?? [], ...listRecents().map((r) => r.dir)]);
35027
35539
  if (!known.has(dir)) return c.json({ error: "not a served or recent project directory" }, 400);
35028
35540
  const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
@@ -35050,7 +35562,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35050
35562
  fetches: fetchesFromNetwork(e),
35051
35563
  ...e.repo ? { repo: e.repo } : {},
35052
35564
  target,
35053
- loaded: existsSync35(target),
35565
+ loaded: existsSync36(target),
35054
35566
  satisfiable: missing.length === 0,
35055
35567
  // #254: the carve walkthrough runs fine here — it just isn't a project
35056
35568
  // to switch INTO. Carve mode claims `/api/graph` and `/api/project` at
@@ -35101,8 +35613,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35101
35613
  return c.json({ error: `${entry.name} loaded to ${target} but ${dirs[0]} is neither a chant project nor a choudoufu estate` }, 500);
35102
35614
  }
35103
35615
  if (entry.serve.local) {
35104
- if (cfg.emulators?.length) await emulatorDown(cfg.projectDir).catch(() => {
35105
- });
35616
+ if (cfg.emulators?.length) await emulatorsDown(emulatorDirs(cfg.workspace?.root ?? cfg.projectDir, cfg.workspace));
35106
35617
  cfg.local = true;
35107
35618
  cfg.emulators = await bootLocalEmulators(dirs[0], `behold demo ${entry.name} --local`);
35108
35619
  }
@@ -35218,6 +35729,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35218
35729
  },
35219
35730
  { method: "GET", path: "/api/layout", desc: "hand-layout sidecar (.behold/layout.json): ?lens=<key> \u2192 {lens, deltas, writable}; no lens \u2192 every lens" },
35220
35731
  { method: "POST", path: "/api/layout", desc: "store one lens's deltas: JSON body {lens, deltas: {<node id>: {dx,dy,dw,dh}}} (the only file behold writes in your project)" },
35732
+ { method: "GET", path: "/api/health", desc: "runtime health for ?env= from chant lifecycle health (chant 0.124.33+): {env, nodes: {<id>: {state: healthy|unhealthy|unknown|unobserved|absent, detail, observedAt, checkedAt?, reason?}}, rotation: {<record id>: {check, inRotation: true|false|null, line}}, members, counts}; cached 30 s, ?fresh=1 reads again (#825)" },
35221
35733
  { method: "GET", path: "/api/diff", desc: "per-node live diff for ?env= \u2014 {env, nodes: {<id>: {observed, diff, health, fieldDrift}}}" },
35222
35734
  { method: "GET", path: "/api/reconcile", desc: "pending-change summary for ?env=" },
35223
35735
  { method: "GET", path: "/api/resources", desc: "component \u2192 declared resources" },
@@ -35364,7 +35876,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35364
35876
  }
35365
35877
  const parsedOps = [];
35366
35878
  for (const f of files) {
35367
- const parsed = readOpIr(f.path, (p) => readFileSync44(p, "utf8"));
35879
+ const parsed = readOpIr(f.path, (p) => readFileSync45(p, "utf8"));
35368
35880
  if (!parsed.ok) return c.json(parsed.refusal, 422);
35369
35881
  parsedOps.push(parsed.ir);
35370
35882
  }
@@ -35377,8 +35889,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35377
35889
  }
35378
35890
  const runState = runner.runState;
35379
35891
  const ranOp = runState.op ? parsedOps.find((o) => o.name === runState.op) : void 0;
35380
- const join61 = ranOp ? joinRun(ranOp, runState.steps, runState.gate, { guessNext: runState.source !== "events" }) : null;
35381
- const opsIr = join61 ? paintPlayhead(declaredIr, join61, runState.gate) : declaredIr;
35892
+ const join62 = ranOp ? joinRun(ranOp, runState.steps, runState.gate, { guessNext: runState.source !== "events" }) : null;
35893
+ const opsIr = join62 ? paintPlayhead(declaredIr, join62, runState.gate) : declaredIr;
35382
35894
  const { svg: svg2 } = renderGraph(opsIr, { boxes: "byStack" });
35383
35895
  const operator = runner.noteDeclaredConvergeOps(declaredConvergeOps(parsedOps));
35384
35896
  return c.json({
@@ -35391,7 +35903,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35391
35903
  target: null,
35392
35904
  mode: "ops",
35393
35905
  ops: parsedOps.length,
35394
- note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join61)} ${operatorNote(operator)}`,
35906
+ note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join62)} ${operatorNote(operator)}`,
35395
35907
  // The operator strip's own model: the ConvergeOps this project
35396
35908
  // declares, plus whatever the last status read said. `declared`
35397
35909
  // without a `strip` is the honest starting state — a loop exists and
@@ -35504,7 +36016,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35504
36016
  srcCompositeEdgesAttached = 0;
35505
36017
  }
35506
36018
  }
35507
- if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync35(join56(cfg.projectDir, "chant.config.ts"))) {
36019
+ if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync36(join57(cfg.projectDir, "chant.config.ts"))) {
35508
36020
  return c.json(noProjectError(cfg.projectDir), 404);
35509
36021
  }
35510
36022
  const radial = new URL(c.req.url).searchParams.get("radial") === "1";
@@ -35938,6 +36450,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35938
36450
  if (url.searchParams.get("notify") === "1") {
35939
36451
  invalidateMember();
35940
36452
  invalidateOverlay();
36453
+ invalidateHealth();
35941
36454
  broadcaster.emit("changed", "");
35942
36455
  return c.json({ notified: true });
35943
36456
  }
@@ -35971,6 +36484,24 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35971
36484
  captured: result.captured
35972
36485
  });
35973
36486
  });
36487
+ app.get("/api/health", async (c) => {
36488
+ const url = new URL(c.req.url);
36489
+ const env = optsFromQuery(url).env ?? cfg.env;
36490
+ if (!env) return c.json({ error: "health needs an environment: pick one, or start with --env", code: "env" }, 400);
36491
+ if (!isEnvName(env)) return c.json({ error: `${JSON.stringify(env)} isn't an env name`, code: "env" }, 400);
36492
+ const ws = servedWorkspace();
36493
+ const members = ws ? ws.members.filter((m) => m.kind === "chant" && !m.reason).map((m) => ({ name: m.name, dir: m.abs })) : cfg.projectDirs ? estateMembers(cfg.projectDirs).filter((m) => m.kind === "chant").map((m) => ({ name: m.name, dir: m.dir })) : (memberKindOf(cfg.projectDir) ?? "chant") === "chant" ? [{ dir: cfg.projectDir }] : [];
36494
+ const key3 = `${ws?.root ?? cfg.projectDir}\0${env}`;
36495
+ const hit = url.searchParams.get("fresh") === "1" ? void 0 : cachedHealth(key3);
36496
+ if (hit) return c.json({ ...hit, cached: true });
36497
+ const answer = await readHealthOverlay(members, env, {
36498
+ chantVersion: (dir) => resolveChant(dir).version,
36499
+ reader: (dir) => rootReader(dir),
36500
+ graph: (dir) => memberIr(dir, { detail: 2 })
36501
+ });
36502
+ rememberHealth(key3, answer);
36503
+ return c.json(answer);
36504
+ });
35974
36505
  app.get("/api/diff", async (c) => {
35975
36506
  const env = optsFromQuery(new URL(c.req.url)).env ?? cfg.env;
35976
36507
  if (!env) return c.json({ error: "diff needs an environment \u2014 pick one, or start with --env" }, 400);
@@ -36021,9 +36552,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
36021
36552
  });
36022
36553
  const choudoufuPlanPath = (plan) => {
36023
36554
  if (!plan) return { error: "no plan named", code: "choudoufu_no_plan", remedy: "pass ?plan=<path to a split.json inside a served choudoufu member> \u2014 GET /api/project lists the ones found" };
36024
- const abs = resolve34(cfg.projectDir, plan);
36555
+ const abs = resolve35(cfg.projectDir, plan);
36025
36556
  const members = (cfg.projectDirs ?? [cfg.projectDir]).filter((d) => memberKindOf(d) === "choudoufu");
36026
- const inside = members.some((d) => abs.startsWith(resolve34(d) + sep10));
36557
+ const inside = members.some((d) => abs.startsWith(resolve35(d) + sep10));
36027
36558
  if (!inside) return { error: `${plan} is not inside a served choudoufu member`, code: "choudoufu_plan_outside", remedy: "a plan lives in the estate it moves; point ?plan= at a split.json under one of the served members" };
36028
36559
  return { path: abs };
36029
36560
  };
@@ -36162,13 +36693,13 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
36162
36693
  if (!c.req.path.startsWith("/api/") && c.res.ok && !c.res.headers.has("cache-control")) c.res.headers.set("cache-control", "no-cache");
36163
36694
  });
36164
36695
  app.use("/*", serveStatic({ root: rel }));
36165
- app.get("/", serveStatic({ path: join56(rel, "index.html") }));
36696
+ app.get("/", serveStatic({ path: join57(rel, "index.html") }));
36166
36697
  if (cfg.terragucci || cfg.chantDemo) vendorFallback(app);
36167
36698
  return app;
36168
36699
  }
36169
- async function bootLocalEmulators(dir, who) {
36700
+ async function bootLocalEmulators(dir, who, workspace) {
36170
36701
  try {
36171
- const emulators = await emulatorUp(dir);
36702
+ const emulators = await emulatorsUp(emulatorDirs(dir, workspace));
36172
36703
  if (emulators.length === 0) {
36173
36704
  process.stderr.write(`${who}: no configured lexicon has a local emulator \u2014 serving without one.
36174
36705
  `);
@@ -36190,9 +36721,9 @@ async function bootLocalEmulators(dir, who) {
36190
36721
  }
36191
36722
  }
36192
36723
  async function startServer(cfg) {
36193
- if (cfg.local) cfg.emulators = await bootLocalEmulators(cfg.projectDir, "behold serve --local");
36724
+ if (cfg.local) cfg.emulators = await bootLocalEmulators(cfg.workspace?.root ?? cfg.projectDir, "behold serve --local", cfg.workspace);
36194
36725
  for (const dir of cfg.projectDirs ?? [cfg.projectDir]) {
36195
- if (existsSync35(join56(dir, "chant.config.ts"))) addRecent(dir);
36726
+ if (existsSync36(join57(dir, "chant.config.ts"))) addRecent(dir);
36196
36727
  }
36197
36728
  const broadcaster = new Broadcaster();
36198
36729
  const frames = new FrameBuffer();
@@ -36304,10 +36835,7 @@ async function startServer(cfg) {
36304
36835
  stopPoll();
36305
36836
  const downs = [];
36306
36837
  if (cfg.local && cfg.emulators && cfg.emulators.length) {
36307
- downs.push(
36308
- emulatorDown(cfg.projectDir).catch((err) => process.stderr.write(`emulator down: ${err instanceof Error ? err.message : String(err)}
36309
- `))
36310
- );
36838
+ downs.push(emulatorsDown(emulatorDirs(cfg.workspace?.root ?? cfg.projectDir, cfg.workspace)));
36311
36839
  }
36312
36840
  if (cfg.carveDemo?.live) downs.push(teardownScratchFloci().catch(() => void 0));
36313
36841
  void Promise.all(downs).finally(() => process.exit(0));
@@ -36377,8 +36905,8 @@ init_chant();
36377
36905
 
36378
36906
  // src/workspace-convert.ts
36379
36907
  init_chant();
36380
- import { existsSync as existsSync36, mkdirSync as mkdirSync9, readFileSync as readFileSync45, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
36381
- import { basename as basename8, dirname as dirname21, join as join57, relative as relative13, resolve as resolve35, sep as sep11 } from "node:path";
36908
+ import { existsSync as existsSync37, mkdirSync as mkdirSync9, readFileSync as readFileSync46, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
36909
+ import { basename as basename8, dirname as dirname21, join as join58, relative as relative13, resolve as resolve36, sep as sep11 } from "node:path";
36382
36910
  import { shortStackNames as shortStackNames2 } from "@intentius/pinhole";
36383
36911
  init_project();
36384
36912
  init_terraform_member();
@@ -36395,11 +36923,11 @@ function unique(name, taken) {
36395
36923
  }
36396
36924
  var posix5 = (p) => p.split(sep11).join("/");
36397
36925
  function installedVersion(pkg, dir) {
36398
- for (let at2 = resolve35(dir); ; at2 = dirname21(at2)) {
36399
- const manifest = join57(at2, "node_modules", ...pkg.split("/"), "package.json");
36400
- if (existsSync36(manifest)) {
36926
+ for (let at2 = resolve36(dir); ; at2 = dirname21(at2)) {
36927
+ const manifest = join58(at2, "node_modules", ...pkg.split("/"), "package.json");
36928
+ if (existsSync37(manifest)) {
36401
36929
  try {
36402
- const v = JSON.parse(readFileSync45(manifest, "utf8")).version;
36930
+ const v = JSON.parse(readFileSync46(manifest, "utf8")).version;
36403
36931
  return typeof v === "string" ? v : void 0;
36404
36932
  } catch {
36405
36933
  return void 0;
@@ -36409,14 +36937,14 @@ function installedVersion(pkg, dir) {
36409
36937
  }
36410
36938
  }
36411
36939
  function planConversion(rootArg) {
36412
- const root = resolve35(rootArg);
36413
- const existing = DECLARATION_FILES.find((f) => existsSync36(join57(root, f)));
36940
+ const root = resolve36(rootArg);
36941
+ const existing = DECLARATION_FILES.find((f) => existsSync37(join58(root, f)));
36414
36942
  if (existing) return { ok: false, error: `${root} already has ${existing}; there is nothing to convert.` };
36415
36943
  const shape = detectProjectShape(root);
36416
36944
  if (shape.kind !== "estate" || !shape.members?.length || shape.membersFrom === "itself") {
36417
36945
  return { ok: false, error: `${root} is not an estate root with a member list, so there is no member list to convert.` };
36418
36946
  }
36419
- const abs = shape.members.map((m) => resolve35(root, m.dir));
36947
+ const abs = shape.members.map((m) => resolve36(root, m.dir));
36420
36948
  const shorts = shortStackNames2(abs);
36421
36949
  const taken = /* @__PURE__ */ new Set();
36422
36950
  const members = [];
@@ -36431,10 +36959,10 @@ function planConversion(rootArg) {
36431
36959
  const scan = discoverTerraformRoots(abs[i]);
36432
36960
  for (const r of scan.roots) {
36433
36961
  const name2 = unique(declarationName(r.name), taken);
36434
- members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join57(dir, r.dir)), kind: "terraform" });
36962
+ members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join58(dir, r.dir)), kind: "terraform" });
36435
36963
  moves.push({ from: `${short}/${r.name}/`, to: `${name2}/${name2}/` });
36436
36964
  }
36437
- for (const s of scan.skipped) notes.push(`${posix5(join57(dir, s.dir))} is not declared: ${s.why}.`);
36965
+ for (const s of scan.skipped) notes.push(`${posix5(join58(dir, s.dir))} is not declared: ${s.why}.`);
36438
36966
  if (scan.roots.length > 1) notes.push(`${dir} held ${scan.roots.length} Terraform roots; each is its own member now, since a chant terraform member is one root.`);
36439
36967
  return;
36440
36968
  }
@@ -36462,7 +36990,7 @@ function planConversion(rootArg) {
36462
36990
  };
36463
36991
  const firstLayout = layoutPath(abs[0]);
36464
36992
  moves.sort((a, b) => b.from.length - a.from.length);
36465
- return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...existsSync36(firstLayout) ? { layoutFrom: firstLayout } : {}, notes } };
36993
+ return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...existsSync37(firstLayout) ? { layoutFrom: firstLayout } : {}, notes } };
36466
36994
  }
36467
36995
  function moveLayoutIds(file, moves) {
36468
36996
  const lenses = {};
@@ -36477,18 +37005,18 @@ function moveLayoutIds(file, moves) {
36477
37005
  return { version: 1, lenses };
36478
37006
  }
36479
37007
  function applyConversion(plan) {
36480
- const declarationFile = join57(plan.root, DECLARATION_FILES[0]);
36481
- if (existsSync36(declarationFile)) throw new Error(`${declarationFile} appeared while converting; nothing was written`);
37008
+ const declarationFile = join58(plan.root, DECLARATION_FILES[0]);
37009
+ if (existsSync37(declarationFile)) throw new Error(`${declarationFile} appeared while converting; nothing was written`);
36482
37010
  writeFileSync7(declarationFile, `${JSON.stringify(plan.declaration, null, 2)}
36483
37011
  `);
36484
37012
  let layout;
36485
37013
  const target = layoutPath(plan.root);
36486
37014
  if (!plan.layoutFrom) layout = { skipped: "no saved layout to move" };
36487
- else if (resolve35(plan.layoutFrom) === resolve35(target)) layout = { skipped: "the saved layout is already in the root" };
36488
- else if (existsSync36(target)) layout = { skipped: `${target} already exists; the layout in ${plan.layoutFrom} was left alone` };
37015
+ else if (resolve36(plan.layoutFrom) === resolve36(target)) layout = { skipped: "the saved layout is already in the root" };
37016
+ else if (existsSync37(target)) layout = { skipped: `${target} already exists; the layout in ${plan.layoutFrom} was left alone` };
36489
37017
  else {
36490
37018
  const moved = moveLayoutIds(readLayoutFile(dirname21(dirname21(plan.layoutFrom))), plan.moves);
36491
- mkdirSync9(join57(plan.root, LAYOUT_DIR), { recursive: true });
37019
+ mkdirSync9(join58(plan.root, LAYOUT_DIR), { recursive: true });
36492
37020
  const tmp = `${target}.tmp`;
36493
37021
  writeFileSync7(tmp, `${JSON.stringify(moved, null, 2)}
36494
37022
  `);
@@ -36499,9 +37027,9 @@ function applyConversion(plan) {
36499
37027
  }
36500
37028
 
36501
37029
  // src/export.ts
36502
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, copyFileSync, cpSync as cpSync2, readFileSync as readFileSync46, readdirSync as readdirSync21, existsSync as existsSync37, realpathSync as realpathSync2 } from "node:fs";
37030
+ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, copyFileSync, cpSync as cpSync2, readFileSync as readFileSync47, readdirSync as readdirSync21, existsSync as existsSync38, realpathSync as realpathSync2 } from "node:fs";
36503
37031
  import { homedir as homedir4 } from "node:os";
36504
- import { join as join58, dirname as dirname22, basename as basename9, relative as relative14, resolve as resolve36, sep as sep12 } from "node:path";
37032
+ import { join as join59, dirname as dirname22, basename as basename9, relative as relative14, resolve as resolve37, sep as sep12 } from "node:path";
36505
37033
  import { createHash as createHash11 } from "node:crypto";
36506
37034
  import { fileURLToPath as fileURLToPath14 } from "node:url";
36507
37035
  var LENS_PARAMS = ["collapse", "components", "detail", "env", "logical", "ops", "radial", "stacks", "tier"];
@@ -36528,6 +37056,7 @@ function captureKeys(axes) {
36528
37056
  if (axes.terragucci || axes.sqlYodeler) add("/api/lifecycle/history", {});
36529
37057
  if (axes.yodelReport) add("/api/yodel-report", {});
36530
37058
  if (axes.sqlYodeler) add("/api/sql-yodeler/lifecycle", {});
37059
+ for (const env of axes.environments) add("/api/health", { env });
36531
37060
  const tiers = axes.tiers && axes.tiers.length ? axes.tiers : [""];
36532
37061
  const envs = ["", ...axes.environments];
36533
37062
  for (const env of envs) {
@@ -36558,34 +37087,66 @@ function captureKeys(axes) {
36558
37087
  return [...keys];
36559
37088
  }
36560
37089
  function webDir() {
36561
- return join58(dirname22(fileURLToPath14(import.meta.url)), "..", "web");
37090
+ return join59(dirname22(fileURLToPath14(import.meta.url)), "..", "web");
36562
37091
  }
36563
37092
  function pkgRoot2() {
36564
- return join58(dirname22(fileURLToPath14(import.meta.url)), "..");
37093
+ return join59(dirname22(fileURLToPath14(import.meta.url)), "..");
36565
37094
  }
36566
37095
  var NOTICE_FILES = ["LICENSE", "THIRD_PARTY.md"];
36567
37096
  function copyNotices(outDir, root = pkgRoot2()) {
36568
37097
  const copied = [];
36569
37098
  for (const f of NOTICE_FILES) {
36570
- if (!existsSync37(join58(root, f))) continue;
36571
- copyFileSync(join58(root, f), join58(outDir, f));
37099
+ if (!existsSync38(join59(root, f))) continue;
37100
+ copyFileSync(join59(root, f), join59(outDir, f));
36572
37101
  copied.push(f);
36573
37102
  }
36574
- const lic = join58(root, "licenses");
36575
- if (existsSync37(lic)) {
36576
- mkdirSync10(join58(outDir, "licenses"), { recursive: true });
37103
+ const lic = join59(root, "licenses");
37104
+ if (existsSync38(lic)) {
37105
+ mkdirSync10(join59(outDir, "licenses"), { recursive: true });
36577
37106
  for (const f of readdirSync21(lic)) {
36578
- copyFileSync(join58(lic, f), join58(outDir, "licenses", f));
37107
+ copyFileSync(join59(lic, f), join59(outDir, "licenses", f));
36579
37108
  copied.push(`licenses/${f}`);
36580
37109
  }
36581
37110
  }
36582
37111
  return copied;
36583
37112
  }
36584
37113
  function workerName(project, override) {
36585
- const raw = override ?? `behold-${basename9(project)}`;
37114
+ const raw = override ?? `behold-${project}`;
36586
37115
  const name = raw.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63);
36587
37116
  return name || "behold-export";
36588
37117
  }
37118
+ function bundleIdentity(cfg) {
37119
+ if (cfg.workspace) return { projectDir: basename9(cfg.workspace.root), worker: cfg.workspace.name, workspace: cfg.workspace.name };
37120
+ return { projectDir: basename9(cfg.projectDir), worker: basename9(cfg.projectDir) };
37121
+ }
37122
+ var OPENING_ZOOMS = ["components", "logical", "composites", "resources", "attributes"];
37123
+ var ExportRefusal = class extends Error {
37124
+ };
37125
+ function settleOpening(want, axes) {
37126
+ const opening = {};
37127
+ if (want.env !== void 0) {
37128
+ if (!axes.environments.includes(want.env)) {
37129
+ const has = axes.environments.length ? `it captures ${axes.environments.join(", ")}` : "it captures no environment, only the source graph";
37130
+ return { error: `--open-env ${want.env} isn't an environment this export captures: ${has}` };
37131
+ }
37132
+ opening.env = want.env;
37133
+ }
37134
+ if (want.zoom !== void 0) {
37135
+ const zooms = [...OPENING_ZOOMS, ...axes.ops ? ["ops"] : []];
37136
+ if (!zooms.includes(want.zoom)) return { error: `--open-zoom ${want.zoom} isn't a zoom this export captures: it takes ${zooms.join(", ")}` };
37137
+ opening.zoom = want.zoom;
37138
+ }
37139
+ return { opening };
37140
+ }
37141
+ var NOTE_MAX = 200;
37142
+ function settleNote(note) {
37143
+ if (note === void 0) return {};
37144
+ const text3 = note.trim();
37145
+ if (!text3) return { error: "--note needs the line the page shows at its foot" };
37146
+ if (/[\r\n]/.test(text3)) return { error: "--note takes one line" };
37147
+ if (text3.length > NOTE_MAX) return { error: `--note takes at most ${NOTE_MAX} characters, not ${text3.length}` };
37148
+ return { note: text3 };
37149
+ }
36589
37150
  var VIEWS_REPORTS_BASE = "../../";
36590
37151
  async function runExport(cfg, outDir, opts = {}) {
36591
37152
  const app = createApp({ ...cfg, layoutWrites: false });
@@ -36599,8 +37160,13 @@ async function runExport(cfg, outDir, opts = {}) {
36599
37160
  ...proj.yodelReport ? { yodelReport: true } : {},
36600
37161
  ...proj.sqlYodeler ? { sqlYodeler: true } : {}
36601
37162
  };
37163
+ const settled = settleOpening(opts.open ?? {}, axes);
37164
+ if ("error" in settled) throw new ExportRefusal(settled.error);
37165
+ const opening = settled.opening;
37166
+ const settledNote = settleNote(opts.note);
37167
+ if ("error" in settledNote) throw new ExportRefusal(settledNote.error);
36602
37168
  const scrub = exportScrubber(cfg);
36603
- const snapDir = join58(outDir, "snapshots");
37169
+ const snapDir = join59(outDir, "snapshots");
36604
37170
  mkdirSync10(snapDir, { recursive: true });
36605
37171
  const keyToFile = {};
36606
37172
  let ok = 0;
@@ -36609,7 +37175,7 @@ async function runExport(cfg, outDir, opts = {}) {
36609
37175
  const res = await app.request(`${key3}${key3.includes("?") ? "&" : "?"}layout=1`);
36610
37176
  const body = scrub(shapeSnapshot(key3, await res.text(), opts));
36611
37177
  const file = slug3(key3, body);
36612
- writeFileSync8(join58(snapDir, file), body);
37178
+ writeFileSync8(join59(snapDir, file), body);
36613
37179
  keyToFile[key3] = `snapshots/${file}`;
36614
37180
  if (res.ok) ok++;
36615
37181
  else failed++;
@@ -36624,36 +37190,40 @@ async function runExport(cfg, outDir, opts = {}) {
36624
37190
  ${refusal2.remedy}` : ""}`);
36625
37191
  }
36626
37192
  }
37193
+ const identity = bundleIdentity(cfg);
36627
37194
  const manifest = {
36628
37195
  static: true,
36629
37196
  capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
36630
- projectDir: basename9(cfg.projectDir),
37197
+ projectDir: identity.projectDir,
37198
+ ...identity.workspace ? { workspace: identity.workspace } : {},
37199
+ ...Object.keys(opening).length ? { opening } : {},
37200
+ ...settledNote.note ? { note: settledNote.note } : {},
36631
37201
  axes,
36632
37202
  keyToFile
36633
37203
  };
36634
- writeFileSync8(join58(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
36635
- const html = readFileSync46(join58(webDir(), "index.html"), "utf8").replace(
37204
+ writeFileSync8(join59(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
37205
+ const html = readFileSync47(join59(webDir(), "index.html"), "utf8").replace(
36636
37206
  /<\/head>/i,
36637
37207
  ` <script>window.__BEHOLD_STATIC__ = true;</script>
36638
37208
  </head>`
36639
37209
  );
36640
- writeFileSync8(join58(outDir, "index.html"), html);
37210
+ writeFileSync8(join59(outDir, "index.html"), html);
36641
37211
  for (const f of readdirSync21(webDir())) {
36642
37212
  if (f === "index.html" || f.endsWith(".test.js")) continue;
36643
- cpSync2(join58(webDir(), f), join58(outDir, f), { recursive: true });
37213
+ cpSync2(join59(webDir(), f), join59(outDir, f), { recursive: true });
36644
37214
  }
36645
- writeFileSync8(join58(outDir, "README.md"), BUNDLE_README);
37215
+ writeFileSync8(join59(outDir, "README.md"), BUNDLE_README);
36646
37216
  copyNotices(outDir);
36647
- const name = workerName(cfg.projectDir, opts.name);
37217
+ const name = workerName(identity.worker, opts.name);
36648
37218
  writeFileSync8(
36649
- join58(outDir, "wrangler.jsonc"),
37219
+ join59(outDir, "wrangler.jsonc"),
36650
37220
  JSON.stringify(
36651
37221
  { $schema: "node_modules/wrangler/config-schema.json", name, compatibility_date: "2025-06-01", assets: { directory: "." } },
36652
37222
  null,
36653
37223
  2
36654
37224
  ) + "\n"
36655
37225
  );
36656
- writeFileSync8(join58(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
37226
+ writeFileSync8(join59(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
36657
37227
  process.stdout.write(
36658
37228
  `behold export \u2192 ${outDir}
36659
37229
  ${ok} snapshots${failed ? ` (${failed} endpoint error(s) captured as-is)` : ""}
@@ -36662,11 +37232,11 @@ async function runExport(cfg, outDir, opts = {}) {
36662
37232
  `
36663
37233
  );
36664
37234
  }
36665
- var isRecord34 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
37235
+ var isRecord35 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
36666
37236
  function dropSource(v) {
36667
37237
  if (Array.isArray(v)) return v.forEach(dropSource);
36668
- if (!isRecord34(v)) return;
36669
- if (isRecord34(v.attrs)) delete v.attrs.source;
37238
+ if (!isRecord35(v)) return;
37239
+ if (isRecord35(v.attrs)) delete v.attrs.source;
36670
37240
  for (const x of Object.values(v)) dropSource(x);
36671
37241
  }
36672
37242
  function shapeSnapshot(key3, body, opts = {}) {
@@ -36676,7 +37246,7 @@ function shapeSnapshot(key3, body, opts = {}) {
36676
37246
  } catch {
36677
37247
  return body;
36678
37248
  }
36679
- if (!isRecord34(doc)) return body;
37249
+ if (!isRecord35(doc)) return body;
36680
37250
  if (key3 === "/api/project") {
36681
37251
  delete doc.recents;
36682
37252
  delete doc.approver;
@@ -36688,11 +37258,11 @@ function shapeSnapshot(key3, body, opts = {}) {
36688
37258
  function exportScrubber(cfg, home = homedir4()) {
36689
37259
  const dirs = [cfg.projectDir, ...cfg.projectDirs ?? [], ...cfg.workspace ? [cfg.workspace.root] : []];
36690
37260
  const tg = cfg.terragucci?.source;
36691
- if (tg && !/^[a-z0-9]+:\/\//i.test(tg)) dirs.push(resolve36(tg));
36692
- if (cfg.yodelReport) dirs.push(resolve36(cfg.yodelReport));
37261
+ if (tg && !/^[a-z0-9]+:\/\//i.test(tg)) dirs.push(resolve37(tg));
37262
+ if (cfg.yodelReport) dirs.push(resolve37(cfg.yodelReport));
36693
37263
  const pairs = /* @__PURE__ */ new Map();
36694
37264
  for (const d of dirs) {
36695
- for (const p of [resolve36(d), safeRealpath(d)]) if (p && p !== "/") pairs.set(p, basename9(p));
37265
+ for (const p of [resolve37(d), safeRealpath(d)]) if (p && p !== "/") pairs.set(p, basename9(p));
36696
37266
  }
36697
37267
  const ordered = [...pairs].sort((a, b) => b[0].length - a[0].length);
36698
37268
  return (text3) => {
@@ -36746,11 +37316,11 @@ function manifestFiles(text3) {
36746
37316
  } catch {
36747
37317
  return [];
36748
37318
  }
36749
- const map = isRecord34(doc) && isRecord34(doc.keyToFile) ? doc.keyToFile : {};
37319
+ const map = isRecord35(doc) && isRecord35(doc.keyToFile) ? doc.keyToFile : {};
36750
37320
  return Object.values(map).filter((f) => typeof f === "string" && /^snapshots\/[A-Za-z0-9=_.-]+$/.test(f) && !f.includes(".."));
36751
37321
  }
36752
37322
  function bundleFiles(outDir) {
36753
- return readdirSync21(outDir, { recursive: true, withFileTypes: true }).filter((d) => d.isFile()).map((d) => relative14(outDir, join58(d.parentPath, d.name)).split(sep12).join("/")).sort();
37323
+ return readdirSync21(outDir, { recursive: true, withFileTypes: true }).filter((d) => d.isFile()).map((d) => relative14(outDir, join59(d.parentPath, d.name)).split(sep12).join("/")).sort();
36754
37324
  }
36755
37325
  async function publishBundle(outDir, target, client) {
36756
37326
  const files = bundleFiles(outDir);
@@ -36766,7 +37336,7 @@ async function publishBundle(outDir, target, client) {
36766
37336
  }
36767
37337
  const last = ["manifest.json", "index.html"];
36768
37338
  const order = [...files.filter((f) => !last.includes(f)), ...last.filter((f) => files.includes(f))];
36769
- for (const f of order) await client.put(at2(f), readFileSync46(join58(outDir, f)), contentType(f), CONTENT_ADDRESSED.test(f) ? IMMUTABLE : NO_CACHE);
37339
+ for (const f of order) await client.put(at2(f), readFileSync47(join59(outDir, f)), contentType(f), CONTENT_ADDRESSED.test(f) ? IMMUTABLE : NO_CACHE);
36770
37340
  const wrote = new Set(files);
36771
37341
  const removed = [];
36772
37342
  for (const f of previous) {
@@ -36818,8 +37388,8 @@ It's just files \u2014 GitHub Pages, S3, nginx, or Cloudflare Pages
36818
37388
 
36819
37389
  // src/publish-snapshots.ts
36820
37390
  import { execFileSync as execFileSync4 } from "node:child_process";
36821
- import { readFileSync as readFileSync47 } from "node:fs";
36822
- import { join as join59 } from "node:path";
37391
+ import { readFileSync as readFileSync48 } from "node:fs";
37392
+ import { join as join60 } from "node:path";
36823
37393
  var DEFAULT_KEEP = 30;
36824
37394
  var SNAPSHOT_REPORTS_BASE = "../../../";
36825
37395
  var COMMIT2 = /^[0-9a-f]{7,64}$/;
@@ -36844,12 +37414,12 @@ function resolveCommit2(dir, given) {
36844
37414
  return { sha };
36845
37415
  }
36846
37416
  }
36847
- var isRecord35 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
37417
+ var isRecord36 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
36848
37418
  function parseHistory(text3) {
36849
37419
  const doc = JSON.parse(text3);
36850
37420
  if (!Array.isArray(doc)) throw new Error("history.json is not an array");
36851
37421
  const str29 = (v) => typeof v === "string" ? v : "";
36852
- return doc.filter((e) => isRecord35(e) && typeof e.commit === "string" && COMMIT2.test(e.commit)).map((e) => ({ commit: e.commit, at: str29(e.at), project: str29(e.project), generated: str29(e.generated) }));
37422
+ return doc.filter((e) => isRecord36(e) && typeof e.commit === "string" && COMMIT2.test(e.commit)).map((e) => ({ commit: e.commit, at: str29(e.at), project: str29(e.project), generated: str29(e.generated) }));
36853
37423
  }
36854
37424
  function nextHistory(old, entry, keep) {
36855
37425
  const all = [entry, ...old.filter((e) => e.commit !== entry.commit)];
@@ -36861,9 +37431,9 @@ var BUNDLE_PATH = /^[A-Za-z0-9=_.@+-]+(\/[A-Za-z0-9=_.@+-]+)*$/;
36861
37431
  var insideBundle = (f) => typeof f === "string" && BUNDLE_PATH.test(f) && !f.split("/").some((p) => p === "." || p === "..");
36862
37432
  function commitFiles(manifestText) {
36863
37433
  const doc = JSON.parse(manifestText);
36864
- if (!isRecord35(doc)) return ["manifest.json"];
37434
+ if (!isRecord36(doc)) return ["manifest.json"];
36865
37435
  const listed = Array.isArray(doc.files) ? doc.files.filter(insideBundle) : [];
36866
- const snaps = isRecord35(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
37436
+ const snaps = isRecord36(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
36867
37437
  const rest = [.../* @__PURE__ */ new Set([...listed, ...snaps])].filter((f) => f !== "index.html" && f !== "manifest.json").sort();
36868
37438
  return ["index.html", ...rest, "manifest.json"];
36869
37439
  }
@@ -36907,7 +37477,7 @@ async function publishSnapshot(outDir, target, commit, client, opts = {}) {
36907
37477
  const keep = opts.keep ?? DEFAULT_KEEP;
36908
37478
  if (!Number.isInteger(keep) || keep < 1) throw new Error(`--keep takes a whole number of at least 1, not ${keep}`);
36909
37479
  const at2 = (f) => `${target.prefix}/${f}`;
36910
- const local = JSON.parse(readFileSync47(join59(outDir, "manifest.json"), "utf8"));
37480
+ const local = JSON.parse(readFileSync48(join60(outDir, "manifest.json"), "utf8"));
36911
37481
  const generated = local.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString();
36912
37482
  const entry = { commit: sha, at: commit.at ?? generated, project: opts.project ?? local.projectDir ?? "", generated };
36913
37483
  const bundle = await publishBundle(outDir, { bucket: target.bucket, prefix: at2(sha) }, client);
@@ -36972,7 +37542,7 @@ Usage:
36972
37542
  behold preview [project-dir] [--port <n>] [--emulator]
36973
37543
  behold export [project-dir] [--out <dir>] [--env <name>] [--name <worker>] [--emulator]
36974
37544
  [--terragucci <src> [--terragucci-project <p>] [--reports-base <rel>]] [--no-source]
36975
- [--yodel-report <file|dir>]
37545
+ [--yodel-report <file|dir>] [--open-env <env>] [--open-zoom <zoom>] [--note <text>]
36976
37546
  [--publish s3://<bucket>/<prefix>/views/<name> [--commit <sha>] [--keep <n>]]
36977
37547
  behold serve <project-dir\u2026> [--port <n>] [--host <addr>] [--allow-host <name,\u2026>] [--hud <url>] [--env <name>] [--poll <secs>] [--local]
36978
37548
  [--public] [--terragucci <src> [--terragucci-project <p>] [--terragucci-poll <secs>] [--terragucci-runs <src>]]
@@ -37222,7 +37792,16 @@ Options:
37222
37792
  bundle at <prefix>/views/behold/; ../../../ with
37223
37793
  --publish, whose bundle sits one commit deeper).
37224
37794
  --name <worker> export only: Cloudflare Worker name in the generated
37225
- wrangler.jsonc.
37795
+ wrangler.jsonc (default behold-<directory>, or
37796
+ behold-<workspace name> for a declared workspace).
37797
+ --open-env <env> export only: the environment the bundle opens on, one
37798
+ it captures (a declared one). Default: the source graph.
37799
+ --open-zoom <zoom> export only: the zoom the bundle opens on: components,
37800
+ logical, composites, resources or attributes, or ops
37801
+ when the estate has emitted Ops.
37802
+ --note <text> export only: one line the page shows at its foot, such
37803
+ as how to run the estate yourself; a span in backticks
37804
+ is drawn as code. At most 200 characters.
37226
37805
  -h, --help This text.
37227
37806
  -v, --version Print the behold version.
37228
37807
  `;
@@ -37425,7 +38004,7 @@ ${USAGE}`);
37425
38004
  process.stderr.write("behold serve: --repos serves one checkout per request, beside one <project-dir>\n");
37426
38005
  process.exit(2);
37427
38006
  }
37428
- const dirs = projectDirs.map((d) => resolve37(d));
38007
+ const dirs = projectDirs.map((d) => resolve38(d));
37429
38008
  for (const [flag2, v] of Object.entries({ "--as": approverFlags2.as, "--signing-key": approverFlags2.signingKey, "--identity-header": approverFlags2.header, "--identity-forge": approverFlags2.headerForge })) {
37430
38009
  if (v !== void 0 && (!v || v.startsWith("--"))) {
37431
38010
  process.stderr.write(`behold serve: ${flag2} needs a value
@@ -37450,7 +38029,7 @@ ${USAGE}`);
37450
38029
  ` : `behold: the runs pane reads chant's run index at ${target.ciReportUrlDeclared}, the declaration's ci.reportUrl
37451
38030
  `);
37452
38031
  }
37453
- const viewRepos = reposParent !== void 0 ? await serveRepos(resolve37(reposParent), target) : void 0;
38032
+ const viewRepos = reposParent !== void 0 ? await serveRepos(resolve38(reposParent), target) : void 0;
37454
38033
  await startServer({
37455
38034
  ...target,
37456
38035
  ...viewRepos ? { viewRepos } : {},
@@ -37466,7 +38045,7 @@ ${USAGE}`);
37466
38045
  ...Object.keys(approver).length ? { approver } : {},
37467
38046
  ...prometheus ? { prometheus } : {},
37468
38047
  ...tempo ? { tempo } : {},
37469
- ...yodelReport ? { yodelReport: resolve37(yodelReport) } : {},
38048
+ ...yodelReport ? { yodelReport: resolve38(yodelReport) } : {},
37470
38049
  ...chantReportUrl ? { chantReportUrl } : {},
37471
38050
  ...chantDemo ? { chantDemo } : {},
37472
38051
  ...ciReportUrl ? { ciReportUrl } : {},
@@ -37476,7 +38055,7 @@ ${USAGE}`);
37476
38055
  async function serveRepos(parent, primary) {
37477
38056
  const repos = /* @__PURE__ */ new Map();
37478
38057
  for (const c of listCheckouts(parent)) {
37479
- if (resolve37(c.dir) === resolve37(primary.projectDir) && !primary.workspace) {
38058
+ if (resolve38(c.dir) === resolve38(primary.projectDir) && !primary.workspace) {
37480
38059
  repos.set(c.name, { projectDir: primary.projectDir, ...primary.projectDirs ? { projectDirs: primary.projectDirs } : {} });
37481
38060
  continue;
37482
38061
  }
@@ -37547,7 +38126,7 @@ function warnIfNotChantProject(dir) {
37547
38126
  if (shape.kind === "estate") {
37548
38127
  process.stderr.write(
37549
38128
  `behold: warning \u2014 ${dir} is an estate root, not a chant project itself.
37550
- Serve its members composed: behold serve ${shape.members.map((m) => join60(dir, m.dir)).join(" ")}
38129
+ Serve its members composed: behold serve ${shape.members.map((m) => join61(dir, m.dir)).join(" ")}
37551
38130
  `
37552
38131
  );
37553
38132
  return;
@@ -37582,8 +38161,8 @@ async function runCarve(rest) {
37582
38161
  );
37583
38162
  process.exit(2);
37584
38163
  }
37585
- const reportPath = resolve37(fileArg);
37586
- const parsed = readCarveReport(reportPath, (p) => readFileSync48(p, "utf8"));
38164
+ const reportPath = resolve38(fileArg);
38165
+ const parsed = readCarveReport(reportPath, (p) => readFileSync49(p, "utf8"));
37587
38166
  if (!parsed.ok) {
37588
38167
  process.stderr.write(`behold carve: ${parsed.refusal.error}
37589
38168
  ${parsed.refusal.remedy}
@@ -37612,8 +38191,8 @@ async function runDoctor(rest) {
37612
38191
  }
37613
38192
  }
37614
38193
  const dir = dirArg ?? ".";
37615
- if (!existsSync38(resolve37(dir))) {
37616
- process.stderr.write(`behold doctor: no such directory: ${resolve37(dir)}
38194
+ if (!existsSync39(resolve38(dir))) {
38195
+ process.stderr.write(`behold doctor: no such directory: ${resolve38(dir)}
37617
38196
  `);
37618
38197
  process.exit(2);
37619
38198
  }
@@ -37649,7 +38228,7 @@ ${check.stdout || check.stderr}
37649
38228
  if (check.code !== 0) process.exitCode = 1;
37650
38229
  }
37651
38230
  async function runDemo(rest) {
37652
- const pkgRoot3 = join60(dirname23(fileURLToPath15(import.meta.url)), "..");
38231
+ const pkgRoot3 = join61(dirname23(fileURLToPath15(import.meta.url)), "..");
37653
38232
  const registry2 = loadDemoRegistry(pkgRoot3);
37654
38233
  let port = 4600;
37655
38234
  let live2 = false;
@@ -37712,7 +38291,7 @@ async function runDemo(rest) {
37712
38291
  `);
37713
38292
  process.exit(2);
37714
38293
  }
37715
- const target = dirArg ? resolve37(dirArg) : demoTargetDir(entry);
38294
+ const target = dirArg ? resolve38(dirArg) : demoTargetDir(entry);
37716
38295
  const loaded = await loadDemo(entry, { pkgRoot: pkgRoot3, target, log: (line) => process.stdout.write(line + "\n") });
37717
38296
  if (!loaded.ok) {
37718
38297
  process.stderr.write(`behold demo ${entry.name}: ${loaded.error}
@@ -37754,7 +38333,7 @@ async function serveTerralithDemo(target, port) {
37754
38333
  await startServer({ projectDir: target, terralithDemo: { root: target, endpoint }, port });
37755
38334
  }
37756
38335
  async function serveCarveDemo(target, carve, port, live2 = false) {
37757
- const at2 = (rel) => resolve37(target, rel);
38336
+ const at2 = (rel) => resolve38(target, rel);
37758
38337
  const project = at2(carve.project);
37759
38338
  const from = at2(carve.from);
37760
38339
  const state = carve.state ? at2(carve.state) : void 0;
@@ -37794,7 +38373,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37794
38373
  };
37795
38374
  process.stdout.write("behold demo carve --live \u2192 the tfstate is real now; the advisor reads what terraform wrote.\n");
37796
38375
  }
37797
- if (existsSync38(join60(project, "package.json")) && !existsSync38(join60(project, "node_modules"))) {
38376
+ if (existsSync39(join61(project, "package.json")) && !existsSync39(join61(project, "node_modules"))) {
37798
38377
  process.stdout.write(`behold demo carve \u2192 npm install in ${carve.project}/ (the chant this walkthrough shells)\u2026
37799
38378
  `);
37800
38379
  const code = await spawnStep("npm", ["install"], project);
@@ -37805,7 +38384,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37805
38384
  }
37806
38385
  }
37807
38386
  let degraded;
37808
- if (!existsSync38(join60(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
38387
+ if (!existsSync39(join61(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
37809
38388
  process.stdout.write(`behold demo carve \u2192 npm install ${HCL_PARSER_PKG} (chant's HCL parser, ~2MB, once)\u2026
37810
38389
  `);
37811
38390
  const code = await spawnStep("npm", ["install", "--no-save", "--no-package-lock", HCL_PARSER_PKG], target);
@@ -37822,7 +38401,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37822
38401
  );
37823
38402
  if (code !== 0) degraded = `chant carve advise exited ${code}`;
37824
38403
  }
37825
- const serving = !degraded && existsSync38(report) ? report : committed;
38404
+ const serving = !degraded && existsSync39(report) ? report : committed;
37826
38405
  if (degraded) {
37827
38406
  process.stderr.write(
37828
38407
  `behold demo carve: ${degraded}
@@ -37830,7 +38409,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37830
38409
  `
37831
38410
  );
37832
38411
  }
37833
- if (!existsSync38(serving)) {
38412
+ if (!existsSync39(serving)) {
37834
38413
  process.stderr.write(`behold demo carve: no carve report at ${serving}
37835
38414
  `);
37836
38415
  process.exit(2);
@@ -37875,8 +38454,8 @@ async function runPreview(rest) {
37875
38454
  process.stderr.write("behold preview: --port must be a number\n");
37876
38455
  process.exit(2);
37877
38456
  }
37878
- const projectDir = resolve37(dirArg ?? process.cwd());
37879
- if (!existsSync38(projectDir)) {
38457
+ const projectDir = resolve38(dirArg ?? process.cwd());
38458
+ if (!existsSync39(projectDir)) {
37880
38459
  process.stderr.write(`behold preview: project not found at ${projectDir}
37881
38460
  `);
37882
38461
  process.exit(2);
@@ -37896,7 +38475,7 @@ async function runPreview(rest) {
37896
38475
  await startServer({ projectDir, port, env: "local", previewMode: true });
37897
38476
  }
37898
38477
  async function runExportCmd(rest) {
37899
- let outDir = resolve37("behold-export");
38478
+ let outDir = resolve38("behold-export");
37900
38479
  let env;
37901
38480
  let name;
37902
38481
  let dirArg;
@@ -37910,9 +38489,15 @@ async function runExportCmd(rest) {
37910
38489
  let noSource = false;
37911
38490
  let yodelReport;
37912
38491
  let chantReportUrl;
38492
+ let openEnv;
38493
+ let openZoom;
38494
+ let note;
37913
38495
  for (let i = 0; i < rest.length; i++) {
37914
38496
  const a = rest[i];
37915
- if (a === "--out") outDir = resolve37(rest[++i]);
38497
+ if (a === "--out") outDir = resolve38(rest[++i]);
38498
+ else if (a === "--note") note = rest[++i] ?? "";
38499
+ else if (a === "--open-env") openEnv = rest[++i] ?? "";
38500
+ else if (a === "--open-zoom") openZoom = rest[++i] ?? "";
37916
38501
  else if (a === "--yodel-report") yodelReport = rest[++i];
37917
38502
  else if (a === "--env") env = rest[++i];
37918
38503
  else if (a === "--name") name = rest[++i];
@@ -37931,6 +38516,21 @@ async function runExportCmd(rest) {
37931
38516
  process.stderr.write("behold export: --yodel-report needs the file `yodel report --json` wrote, or the directory holding it\n");
37932
38517
  process.exit(2);
37933
38518
  }
38519
+ if (openEnv !== void 0 && !openEnv) {
38520
+ process.stderr.write("behold export: --open-env needs an environment the export captures\n");
38521
+ process.exit(2);
38522
+ }
38523
+ if (openZoom !== void 0 && ![...OPENING_ZOOMS, "ops"].includes(openZoom)) {
38524
+ process.stderr.write(`behold export: --open-zoom ${openZoom || "(nothing)"} isn't a zoom an export opens on: it takes ${[...OPENING_ZOOMS, "ops"].join(", ")}
38525
+ `);
38526
+ process.exit(2);
38527
+ }
38528
+ const settledNote = settleNote(note);
38529
+ if ("error" in settledNote) {
38530
+ process.stderr.write(`behold export: ${settledNote.error}
38531
+ `);
38532
+ process.exit(2);
38533
+ }
37934
38534
  if ((terragucciProject || reportsBase !== void 0) && !terragucci) {
37935
38535
  process.stderr.write("behold export: --terragucci-project and --reports-base need --terragucci\n");
37936
38536
  process.exit(2);
@@ -37957,7 +38557,7 @@ async function runExportCmd(rest) {
37957
38557
  );
37958
38558
  process.exit(2);
37959
38559
  }
37960
- const projectDir = resolve37(dirArg ?? process.cwd());
38560
+ const projectDir = resolve38(dirArg ?? process.cwd());
37961
38561
  const commit = destination ? resolveCommit2(projectDir, commitArg) : void 0;
37962
38562
  if (commit && "error" in commit) {
37963
38563
  process.stderr.write(`behold export: ${commit.error}
@@ -37968,27 +38568,35 @@ async function runExportCmd(rest) {
37968
38568
  injectEmulatorEnv(env);
37969
38569
  env ??= "local";
37970
38570
  }
37971
- if (!existsSync38(projectDir)) {
38571
+ if (!existsSync39(projectDir)) {
37972
38572
  process.stderr.write(`behold export: project not found at ${projectDir}
37973
38573
  `);
37974
38574
  process.exit(2);
37975
38575
  }
37976
38576
  const target = await serveTarget([projectDir], "export");
38577
+ const open = { ...openEnv !== void 0 ? { env: openEnv } : {}, ...openZoom !== void 0 ? { zoom: openZoom } : {} };
37977
38578
  await runExport(
37978
38579
  {
37979
38580
  ...target,
37980
38581
  port: 0,
37981
38582
  ...env ? { env } : {},
37982
38583
  ...terragucci ? { terragucci: { source: terragucci, ...terragucciProject ? { project: terragucciProject } : {} } } : {},
37983
- ...yodelReport ? { yodelReport: resolve37(yodelReport) } : {}
38584
+ ...yodelReport ? { yodelReport: resolve38(yodelReport) } : {}
37984
38585
  },
37985
38586
  outDir,
37986
38587
  {
37987
38588
  ...name ? { name } : {},
37988
38589
  ...noSource ? { noSource } : {},
37989
- ...reportsBase !== void 0 ? { reportsBase } : destination ? { reportsBase: SNAPSHOT_REPORTS_BASE } : {}
38590
+ ...reportsBase !== void 0 ? { reportsBase } : destination ? { reportsBase: SNAPSHOT_REPORTS_BASE } : {},
38591
+ ...Object.keys(open).length ? { open } : {},
38592
+ ...settledNote.note ? { note: settledNote.note } : {}
37990
38593
  }
37991
- );
38594
+ ).catch((e) => {
38595
+ if (!(e instanceof ExportRefusal)) throw e;
38596
+ process.stderr.write(`behold export: ${e.message}
38597
+ `);
38598
+ process.exit(2);
38599
+ });
37992
38600
  if (destination && !("error" in destination) && commit && !("error" in commit)) {
37993
38601
  const done = await publishSnapshot(outDir, destination, commit, new S3Object(s3FromEnv(destination.bucket)), { keep });
37994
38602
  process.stdout.write(