@intentius/behold 0.29.50 → 0.29.52

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",
@@ -17253,6 +17640,7 @@ var AZURE_HEADLINE_KINDS = /* @__PURE__ */ new Set([
17253
17640
  var AZURE_FABRIC_KINDS = /* @__PURE__ */ new Set([
17254
17641
  "Microsoft.Network/virtualNetworks",
17255
17642
  "Microsoft.Network/virtualNetworks_subnets",
17643
+ "Microsoft.Network/virtualNetworks/subnets",
17256
17644
  "Microsoft.Network/networkSecurityGroups",
17257
17645
  "Microsoft.Network/routeTables",
17258
17646
  "Microsoft.Network/networkInterfaces",
@@ -17264,7 +17652,7 @@ var AZURE_FABRIC_KINDS = /* @__PURE__ */ new Set([
17264
17652
  "Microsoft.KeyVault/vaults"
17265
17653
  ]);
17266
17654
  var VNET_KIND = "Microsoft.Network/virtualNetworks";
17267
- var SUBNET_KIND = "Microsoft.Network/virtualNetworks_subnets";
17655
+ var SUBNET_KINDS = /* @__PURE__ */ new Set(["Microsoft.Network/virtualNetworks_subnets", "Microsoft.Network/virtualNetworks/subnets"]);
17268
17656
  var NSG_KIND = "Microsoft.Network/networkSecurityGroups";
17269
17657
  var RESOURCE_ID_RE = /resourceId\(\s*([^)]*)\)/g;
17270
17658
  var QUOTED_RE = /'([^']*)'/g;
@@ -17302,6 +17690,28 @@ function subnetShortName(node) {
17302
17690
  const name = resourceName(node);
17303
17691
  return name?.includes("/") ? name.split("/").slice(1).join("/") : name;
17304
17692
  }
17693
+ var CONCAT_SUBNET_RE = /resourceId\(\s*'Microsoft\.Network\/virtualNetworks'\s*,\s*'([^']+)'\s*\)\s*,\s*'\/subnets\/([^']+)'/gi;
17694
+ function subnetRefs(value, out = /* @__PURE__ */ new Set()) {
17695
+ if (typeof value === "string") {
17696
+ for (const call of value.matchAll(RESOURCE_ID_RE)) {
17697
+ const args = [...call[1].matchAll(QUOTED_RE)].map((m) => m[1]);
17698
+ if (args.length === 3 && /^Microsoft\.Network\/virtualNetworks[/_]subnets$/i.test(args[0])) out.add(`${args[1]}/${args[2]}`);
17699
+ }
17700
+ for (const m of value.matchAll(CONCAT_SUBNET_RE)) out.add(`${m[1]}/${m[2]}`);
17701
+ } else if (value && typeof value === "object") {
17702
+ for (const v of Object.values(value)) subnetRefs(v, out);
17703
+ }
17704
+ return out;
17705
+ }
17706
+ function inlineSubnets(vnet) {
17707
+ const list4 = vnet.attrs?.subnets;
17708
+ if (!Array.isArray(list4)) return [];
17709
+ return list4.flatMap((s) => {
17710
+ const name = s?.name;
17711
+ const prefix = s?.properties?.addressPrefix;
17712
+ return typeof name === "string" ? [[name, typeof prefix === "string" ? prefix : void 0]] : [];
17713
+ });
17714
+ }
17305
17715
  function vnetCidr(node) {
17306
17716
  const space = node.attrs?.addressSpace;
17307
17717
  const prefixes = space?.addressPrefixes;
@@ -17310,7 +17720,7 @@ function vnetCidr(node) {
17310
17720
  function projectAzureLogical(ir, env) {
17311
17721
  const azure = ir.nodes.filter((n) => n.lexicon === "azure");
17312
17722
  if (azure.length === 0) return { ir: { nodes: [], edges: [], groups: {} }, byContainer: {} };
17313
- const componentOf = componentNamer(azure);
17723
+ const componentOf = componentNamer(azure, ir.groups);
17314
17724
  const byId = new Map(azure.map((n) => [n.id, n]));
17315
17725
  const byName = /* @__PURE__ */ new Map();
17316
17726
  for (const n of azure) {
@@ -17318,7 +17728,7 @@ function projectAzureLogical(ir, env) {
17318
17728
  if (name && !byName.has(name)) byName.set(name, n);
17319
17729
  }
17320
17730
  const vnets = azure.filter((n) => n.kind === VNET_KIND);
17321
- const subnets = azure.filter((n) => n.kind === SUBNET_KIND);
17731
+ const subnets = azure.filter((n) => SUBNET_KINDS.has(n.kind));
17322
17732
  const vnetByName = new Map(vnets.map((v) => [resourceName(v) ?? v.id, v]));
17323
17733
  const refOut = /* @__PURE__ */ new Map();
17324
17734
  for (const n of azure) {
@@ -17375,8 +17785,38 @@ function projectAzureLogical(ir, env) {
17375
17785
  const v = parentVnet ? vnetByName.get(parentVnet) : void 0;
17376
17786
  child(v ? vnetTitle(v) : RG_TITLE, subnetTitle(s));
17377
17787
  }
17788
+ const inlineBox = /* @__PURE__ */ new Map();
17789
+ for (const v of vnets) {
17790
+ for (const [name, prefix] of inlineSubnets(v)) {
17791
+ const key3 = `${resourceName(v) ?? v.id}/${name}`;
17792
+ if (subnets.some((s) => resourceName(s) === key3)) continue;
17793
+ const title = `subnet ${prefix ?? name}`;
17794
+ inlineBox.set(key3, title);
17795
+ child(vnetTitle(v), title);
17796
+ }
17797
+ }
17798
+ const inlinePlace = (start) => {
17799
+ const seen = /* @__PURE__ */ new Set();
17800
+ let frontier = [start];
17801
+ for (let depth = 0; depth < 6 && frontier.length; depth++) {
17802
+ const next = [];
17803
+ for (const id of frontier) {
17804
+ if (seen.has(id)) continue;
17805
+ seen.add(id);
17806
+ for (const key3 of subnetRefs(byId.get(id)?.attrs)) if (inlineBox.has(key3)) return inlineBox.get(key3);
17807
+ for (const r of refOut.get(id) ?? []) if (!seen.has(r)) next.push(r);
17808
+ }
17809
+ frontier = next;
17810
+ }
17811
+ return void 0;
17812
+ };
17378
17813
  const placeOf = /* @__PURE__ */ new Map();
17379
17814
  for (const n of headline) {
17815
+ const inline = inlinePlace(n.id);
17816
+ if (inline) {
17817
+ placeOf.set(n.id, inline);
17818
+ continue;
17819
+ }
17380
17820
  const subnetId = nearest(n.id, subnetIds);
17381
17821
  if (subnetId) {
17382
17822
  placeOf.set(n.id, subnetTitle(byId.get(subnetId)));
@@ -17447,7 +17887,11 @@ var GCP_HEADLINE_KINDS = /* @__PURE__ */ new Set([
17447
17887
  "GCP::Sql::Instance",
17448
17888
  "GCP::Storage::Bucket",
17449
17889
  "GCP::Compute::Instance",
17450
- "GCP::Dns::ManagedZone"
17890
+ "GCP::Dns::ManagedZone",
17891
+ // A load balancer's front end, the card the AWS lens draws for an ALB
17892
+ // (behold#824); its proxy, URL map, backend service and NEG are contracted
17893
+ // through, so the card joins the service they route to.
17894
+ "GCP::Compute::ForwardingRule"
17451
17895
  ]);
17452
17896
  var GCP_FABRIC_KINDS = /* @__PURE__ */ new Set([
17453
17897
  // networking — declared, not emulated
@@ -17487,7 +17931,7 @@ function collectRefs(v, out) {
17487
17931
  function projectGcpLogical(ir, env) {
17488
17932
  const gcp = ir.nodes.filter((n) => n.lexicon === "gcp");
17489
17933
  if (gcp.length === 0) return { ir: { nodes: [], edges: [], groups: {} }, byContainer: {} };
17490
- const componentOf = componentNamer(gcp);
17934
+ const componentOf = componentNamer(gcp, ir.groups);
17491
17935
  const byId = new Map(gcp.map((n) => [n.id, n]));
17492
17936
  const project = declaredProject(gcp) ?? env;
17493
17937
  const PROJECT_TITLE = project ? `project ${project}` : "project";
@@ -17529,10 +17973,25 @@ function projectGcpLogical(ir, env) {
17529
17973
  }
17530
17974
  for (const [component, members] of byComponent) {
17531
17975
  const places = new Set(members.map((m) => placeOf.get(m.id)));
17532
- const parent = places.size === 1 ? [...places][0] : PROJECT_TITLE;
17533
- if (parent === GLOBAL) child(PROJECT_TITLE, GLOBAL);
17534
- child(parent, component);
17535
- for (const m of members) child(component, m.id);
17976
+ const regional = [...places].filter((p) => p !== "location global");
17977
+ if (places.size > 1 && regional.length > 1) {
17978
+ child(PROJECT_TITLE, component);
17979
+ for (const m of members) child(component, m.id);
17980
+ continue;
17981
+ }
17982
+ if (places.size === 1) {
17983
+ const parent = [...places][0];
17984
+ if (parent === GLOBAL) child(PROJECT_TITLE, GLOBAL);
17985
+ child(parent, component);
17986
+ for (const m of members) child(component, m.id);
17987
+ continue;
17988
+ }
17989
+ for (const place of places) {
17990
+ if (place === GLOBAL) child(PROJECT_TITLE, GLOBAL);
17991
+ const part = `${component} \xB7 ${place.replace(/^location /, "")}`;
17992
+ child(place, part);
17993
+ for (const m of members) if (placeOf.get(m.id) === place) child(part, m.id);
17994
+ }
17536
17995
  }
17537
17996
  const kept = new Set(headline.map((n) => n.id));
17538
17997
  const adj = /* @__PURE__ */ new Map();
@@ -17930,6 +18389,9 @@ var NO_CONTRACT_KINDS = /* @__PURE__ */ new Set([
17930
18389
  "AWS::Logs::LogGroup",
17931
18390
  "AWS::SecretsManager::Secret",
17932
18391
  "AWS::SSM::Parameter",
18392
+ // every record in a zone references it, so records in one zone are not
18393
+ // thereby connected (three latency records for one name, say)
18394
+ "AWS::Route53::HostedZone",
17933
18395
  // containment fabric
17934
18396
  "AWS::EC2::VPC",
17935
18397
  "AWS::EC2::Subnet",
@@ -17952,8 +18414,13 @@ function dirSegments(node) {
17952
18414
  const parts = (node.sourceLoc?.file ?? "").split("/");
17953
18415
  return parts.slice(0, -1).filter((s) => s.length > 0);
17954
18416
  }
17955
- function componentNamer(nodes) {
17956
- const all = nodes.map(dirSegments).filter((d) => d.length > 0);
18417
+ function componentNamer(nodes, groups) {
18418
+ const memberOf = memberNamer(groups);
18419
+ const segments = (node) => {
18420
+ const member = memberOf(node);
18421
+ return member ? [member, ...dirSegments(node)] : dirSegments(node);
18422
+ };
18423
+ const all = nodes.map(segments).filter((d) => d.length > 0);
17957
18424
  let shared2 = 0;
17958
18425
  if (all.length > 0) {
17959
18426
  const first = all[0];
@@ -17963,10 +18430,28 @@ function componentNamer(nodes) {
17963
18430
  }
17964
18431
  }
17965
18432
  }
17966
- return (node) => {
17967
- const dirs = dirSegments(node);
18433
+ const component = (node) => {
18434
+ const dirs = segments(node);
17968
18435
  return dirs[shared2] ?? dirs[dirs.length - 1] ?? "other";
17969
18436
  };
18437
+ const seen = /* @__PURE__ */ new Map();
18438
+ for (const n of nodes) {
18439
+ const m = memberOf(n);
18440
+ if (m) (seen.get(m) ?? seen.set(m, /* @__PURE__ */ new Set()).get(m)).add(component(n));
18441
+ }
18442
+ return (node) => {
18443
+ const m = memberOf(node);
18444
+ return m && seen.get(m)?.size === 1 ? m : component(node);
18445
+ };
18446
+ }
18447
+ function memberNamer(groups) {
18448
+ const byStack = groups?.byStack;
18449
+ if (!byStack) return () => void 0;
18450
+ const member = /* @__PURE__ */ new Map();
18451
+ for (const [stack, ids] of Object.entries(byStack)) {
18452
+ for (const id of ids) if (id.startsWith(`${stack}/`)) member.set(id, stack);
18453
+ }
18454
+ return (node) => member.get(node.id);
17970
18455
  }
17971
18456
  function collectRefs3(v, out) {
17972
18457
  if (!v || typeof v !== "object") return;
@@ -18097,14 +18582,37 @@ function retainCrossLensEdges(ir, projections, nodes, edges, byContainer) {
18097
18582
  }
18098
18583
  return false;
18099
18584
  };
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;
18585
+ const retain = (e) => {
18586
+ if (e.from === e.to || !cards.has(e.from) || !cards.has(e.to)) return;
18587
+ if (perLens.some((ids) => ids.has(e.from) && ids.has(e.to))) return;
18103
18588
  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;
18589
+ if (drawn.has(key3)) return;
18590
+ if (nests(e.from, e.to) || nests(e.to, e.from)) return;
18106
18591
  drawn.add(key3);
18107
18592
  edges.push(e);
18593
+ };
18594
+ for (const e of ir.edges) retain(e);
18595
+ const kindOf2 = new Map(ir.nodes.map((n) => [n.id, n.kind]));
18596
+ const out = /* @__PURE__ */ new Map();
18597
+ for (const e of ir.edges) (out.get(e.from) ?? out.set(e.from, []).get(e.from)).push(e);
18598
+ for (const start of cards) {
18599
+ const lens = perLens.filter((ids) => ids.has(start));
18600
+ const seen = /* @__PURE__ */ new Set([start]);
18601
+ let frontier = [...out.get(start) ?? []];
18602
+ for (let depth = 0; depth < 4 && frontier.length; depth++) {
18603
+ const next = [];
18604
+ for (const e of frontier) {
18605
+ if (seen.has(e.to)) continue;
18606
+ seen.add(e.to);
18607
+ if (cards.has(e.to)) {
18608
+ if (depth > 0 && !lens.some((ids) => ids.has(e.to))) retain({ from: start, to: e.to, kind: "ref", ...e.viaAttr ? { viaAttr: e.viaAttr } : {} });
18609
+ continue;
18610
+ }
18611
+ if (NO_CONTRACT_KINDS.has(kindOf2.get(e.to) ?? "")) continue;
18612
+ next.push(...out.get(e.to) ?? []);
18613
+ }
18614
+ frontier = next;
18615
+ }
18108
18616
  }
18109
18617
  }
18110
18618
  function placeHelmReleases(nodes, byContainer, boxes) {
@@ -18147,7 +18655,7 @@ function nestReleaseBoxes(byContainer) {
18147
18655
  }
18148
18656
  function projectLogical(ir) {
18149
18657
  const aws = ir.nodes.filter((n) => n.lexicon === "aws" && !isExample(n));
18150
- const componentOf = componentNamer(aws);
18658
+ const componentOf = componentNamer(aws, ir.groups);
18151
18659
  const byId = new Map(aws.map((n) => [n.id, n]));
18152
18660
  const refOut = enrichedRefs(ir, aws, byId);
18153
18661
  const vpcIds = new Set(aws.filter((n) => n.kind === "AWS::EC2::VPC").map((n) => n.id));
@@ -18574,7 +19082,7 @@ import { basename as basename4, join as join30 } from "node:path";
18574
19082
  import { fileURLToPath as fileURLToPath6 } from "node:url";
18575
19083
 
18576
19084
  // src/run-events.ts
18577
- import { Ajv2020 } from "ajv/dist/2020.js";
19085
+ import { Ajv2020 as Ajv20202 } from "ajv/dist/2020.js";
18578
19086
 
18579
19087
  // src/run-event-schema/run-event.schema.json
18580
19088
  var run_event_schema_default = {
@@ -18876,15 +19384,15 @@ var run_event_schema_default = {
18876
19384
  // src/run-events.ts
18877
19385
  var RUN_EVENT_SCHEMA_ID = run_event_schema_default.$id;
18878
19386
  var RUN_EVENT_CONTRACT = 1;
18879
- var isRecord10 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
18880
- var validator;
19387
+ var isRecord11 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
19388
+ var validator2;
18881
19389
  function validate(v) {
18882
- if (!validator) {
18883
- const ajv = new Ajv2020({ strict: false, allErrors: false });
18884
- validator = ajv.compile(run_event_schema_default);
19390
+ if (!validator2) {
19391
+ const ajv = new Ajv20202({ strict: false, allErrors: false });
19392
+ validator2 = ajv.compile(run_event_schema_default);
18885
19393
  }
18886
- if (validator(v)) return null;
18887
- const e = validator.errors?.[0];
19394
+ if (validator2(v)) return null;
19395
+ const e = validator2.errors?.[0];
18888
19396
  return e ? `${e.instancePath || "the event"} ${e.message ?? "does not match"}` : "does not match the schema";
18889
19397
  }
18890
19398
  function readRunLine(line) {
@@ -18896,7 +19404,7 @@ function readRunLine(line) {
18896
19404
  } catch {
18897
19405
  return null;
18898
19406
  }
18899
- if (!isRecord10(parsed)) return null;
19407
+ if (!isRecord11(parsed)) return null;
18900
19408
  if (parsed.$schema === RUN_EVENT_SCHEMA_ID || "contract" in parsed && "runId" in parsed && "seq" in parsed) {
18901
19409
  if (parsed.contract !== RUN_EVENT_CONTRACT) {
18902
19410
  return { kind: "refused", reason: `a run event with contract ${JSON.stringify(parsed.contract)}; behold reads contract ${RUN_EVENT_CONTRACT}` };
@@ -18956,7 +19464,7 @@ function legacyRunLine(v) {
18956
19464
  const one = legacyStepRecord(v);
18957
19465
  if (one) return [one];
18958
19466
  if (typeof v.op === "string" && Array.isArray(v.records)) {
18959
- const all = v.records.filter(isRecord10).map(legacyStepRecord).filter((r) => r !== null);
19467
+ const all = v.records.filter(isRecord11).map(legacyStepRecord).filter((r) => r !== null);
18960
19468
  return all.length ? all : null;
18961
19469
  }
18962
19470
  return null;
@@ -20247,7 +20755,7 @@ var NodeRuntimeAdapter = class {
20247
20755
  return (0, import_picomatch.default)(pattern)(filePath);
20248
20756
  }
20249
20757
  async spawn(cmd, opts) {
20250
- return new Promise((resolve38) => {
20758
+ return new Promise((resolve39) => {
20251
20759
  const child = execFile2(
20252
20760
  cmd[0],
20253
20761
  cmd.slice(1),
@@ -20257,7 +20765,7 @@ var NodeRuntimeAdapter = class {
20257
20765
  ...opts?.env ? { env: { ...process.env, ...opts.env } } : {}
20258
20766
  },
20259
20767
  (err, stdout, stderr) => {
20260
- resolve38({
20768
+ resolve39({
20261
20769
  stdout: stdout ?? "",
20262
20770
  stderr: stderr ?? "",
20263
20771
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -21315,22 +21823,22 @@ function fetchable(url, checkout) {
21315
21823
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(url) || /^[^/]+@[^:/]+:/.test(url) || isAbsolute4(url)) return url;
21316
21824
  return resolve17(checkout, url);
21317
21825
  }
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()}` };
21826
+ async function fetchIntoCache(git3, origin, cache7) {
21827
+ assertScratch(basename3(cache7));
21828
+ return serially(cache7, async () => {
21829
+ if (!existsSync18(join28(cache7, "HEAD"))) {
21830
+ if (existsSync18(cache7) && readdirSync13(cache7).length > 0) return { ok: false, error: `${cache7} exists and is not behold's lifecycle cache; behold leaves it alone` };
21831
+ mkdirSync4(cache7, { recursive: true });
21832
+ const init = await git3(["init", "--bare", "-q", cache7]);
21833
+ if (init.code !== 0) return { ok: false, error: `could not make the cache ${cache7}: ${init.stderr.trim()}` };
21326
21834
  }
21327
- const f = await git3(["--git-dir", cache6, "fetch", "-q", "--no-tags", origin, `+refs/heads/${LIFECYCLE_BRANCH}:${CACHE_REF}`]);
21835
+ const f = await git3(["--git-dir", cache7, "fetch", "-q", "--no-tags", origin, `+refs/heads/${LIFECYCLE_BRANCH}:${CACHE_REF}`]);
21328
21836
  if (f.code !== 0) {
21329
21837
  if (/couldn't find remote ref|could not find remote ref/i.test(f.stderr)) return { ok: true, found: false };
21330
21838
  return { ok: false, error: redact(f.stderr.trim() || `git fetch exited ${f.code}`) };
21331
21839
  }
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() : "";
21840
+ const b = await git3(["--git-dir", cache7, "fetch", "-q", "--no-tags", "--depth=1", origin, `+HEAD:${CACHE_BASE_REF}`]);
21841
+ const sha = b.code === 0 ? (await git3(["--git-dir", cache7, "rev-parse", "--verify", "-q", `${CACHE_BASE_REF}^{commit}`])).stdout.trim() : "";
21334
21842
  return { ok: true, found: true, ...sha ? { base: sha } : {} };
21335
21843
  });
21336
21844
  }
@@ -21421,10 +21929,10 @@ async function readLifecycle(checkout, opts = {}) {
21421
21929
  } else {
21422
21930
  const from = fetchable(url, checkout);
21423
21931
  origin = redact(from);
21424
- const cache6 = cacheDir(from, opts.cacheRoot);
21932
+ const cache7 = cacheDir(from, opts.cacheRoot);
21425
21933
  let f;
21426
21934
  try {
21427
- f = await fetchIntoCache(git3, from, cache6);
21935
+ f = await fetchIntoCache(git3, from, cache7);
21428
21936
  } catch (e) {
21429
21937
  f = { ok: false, error: e instanceof Error ? e.message : String(e) };
21430
21938
  }
@@ -21432,7 +21940,7 @@ async function readLifecycle(checkout, opts = {}) {
21432
21940
  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
21941
  }
21434
21942
  if (f.ok) {
21435
- const lane2 = await readAt(git3, ["--git-dir", cache6], cache6, CACHE_REF, f.base, now, spec2, checkout);
21943
+ const lane2 = await readAt(git3, ["--git-dir", cache7], cache7, CACHE_REF, f.base, now, spec2, checkout);
21436
21944
  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
21945
  fetchError = `fetched ${LIFECYCLE_BRANCH}, but behold's cache could not read it`;
21438
21946
  } else {
@@ -21539,10 +22047,10 @@ async function readHistory(checkout, opts = {}) {
21539
22047
  } else {
21540
22048
  const from = fetchable(url, checkout);
21541
22049
  origin = redact(from);
21542
- const cache6 = cacheDir(from, opts.cacheRoot);
22050
+ const cache7 = cacheDir(from, opts.cacheRoot);
21543
22051
  let f;
21544
22052
  try {
21545
- f = await fetchIntoCache(git3, from, cache6);
22053
+ f = await fetchIntoCache(git3, from, cache7);
21546
22054
  } catch (e) {
21547
22055
  f = { ok: false, error: e instanceof Error ? e.message : String(e) };
21548
22056
  }
@@ -21550,7 +22058,7 @@ async function readHistory(checkout, opts = {}) {
21550
22058
  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
22059
  }
21552
22060
  if (f.ok) {
21553
- const repo2 = ["--git-dir", cache6];
22061
+ const repo2 = ["--git-dir", cache7];
21554
22062
  const commit2 = await tipOf(git3, repo2, CACHE_REF);
21555
22063
  const logs2 = commit2 ? await ledgerLogs(git3, repo2, CACHE_REF) : void 0;
21556
22064
  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 +22485,13 @@ var RUNS_INDEX_KEY = "runs/index.json";
21977
22485
  var runKey = (id) => `runs/${id}.json`;
21978
22486
  var RUNS_READ_TTL_MS = 2e3;
21979
22487
  var RUN_STATUSES = ["queued", "running", "waiting", "success", "failure", "cancelled", "skipped"];
21980
- var isRecord11 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
22488
+ var isRecord12 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
21981
22489
  var str7 = (v) => typeof v === "string";
21982
22490
  var int = (v) => typeof v === "number" && Number.isInteger(v);
21983
22491
  var timeOrNull = (v) => v === null || v === void 0 || str7(v);
21984
22492
  var status = (v) => str7(v) && RUN_STATUSES.includes(v);
21985
22493
  function jobProblem(j, withSteps, at2) {
21986
- if (!isRecord11(j)) return `${at2} is not an object`;
22494
+ if (!isRecord12(j)) return `${at2} is not an object`;
21987
22495
  if (!int(j.id)) return `${at2}.id is not an integer`;
21988
22496
  if (!str7(j.name)) return `${at2}.name is not a string`;
21989
22497
  if (!Array.isArray(j.needs) || !j.needs.every(str7)) return `${at2}.needs is not a list of job names`;
@@ -21993,7 +22501,7 @@ function jobProblem(j, withSteps, at2) {
21993
22501
  if (!Array.isArray(j.steps)) return `${at2}.steps is not a list`;
21994
22502
  for (const [i, s] of j.steps.entries()) {
21995
22503
  const sat = `${at2}.steps[${i}]`;
21996
- if (!isRecord11(s)) return `${sat} is not an object`;
22504
+ if (!isRecord12(s)) return `${sat} is not an object`;
21997
22505
  if (!str7(s.name)) return `${sat}.name is not a string`;
21998
22506
  if (!str7(s.status)) return `${sat}.status is not a string`;
21999
22507
  if (!Array.isArray(s.log) || !s.log.every(str7)) return `${sat}.log is not a list of lines`;
@@ -22003,7 +22511,7 @@ function jobProblem(j, withSteps, at2) {
22003
22511
  return void 0;
22004
22512
  }
22005
22513
  function runProblem(r, withSteps, at2) {
22006
- if (!isRecord11(r)) return `${at2} is not an object`;
22514
+ if (!isRecord12(r)) return `${at2} is not an object`;
22007
22515
  if (!int(r.id)) return `${at2}.id is not an integer`;
22008
22516
  if (!str7(r.title)) return `${at2}.title is not a string`;
22009
22517
  if (!status(r.status)) return `${at2}.status is not one of ${RUN_STATUSES.join(", ")}`;
@@ -22017,7 +22525,7 @@ function runProblem(r, withSteps, at2) {
22017
22525
  return void 0;
22018
22526
  }
22019
22527
  function runsIndexProblem(doc) {
22020
- if (!isRecord11(doc)) return "it is not an object";
22528
+ if (!isRecord12(doc)) return "it is not an object";
22021
22529
  if (doc.schema !== "demo.runs/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.runs/v1`;
22022
22530
  if (!Array.isArray(doc.runs)) return "runs is not a list";
22023
22531
  for (const [i, r] of doc.runs.entries()) {
@@ -22027,7 +22535,7 @@ function runsIndexProblem(doc) {
22027
22535
  return void 0;
22028
22536
  }
22029
22537
  function runProblemOf(doc, id) {
22030
- if (!isRecord11(doc)) return "it is not an object";
22538
+ if (!isRecord12(doc)) return "it is not an object";
22031
22539
  if (doc.schema !== "demo.run/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.run/v1`;
22032
22540
  if (doc.id !== id) return `its id is ${JSON.stringify(doc.id)}, not ${id}`;
22033
22541
  return runProblem(doc, true, "the run");
@@ -22062,14 +22570,14 @@ function runIdOf(raw) {
22062
22570
  return /^[1-9][0-9]{0,15}$/.test(raw) ? Number(raw) : null;
22063
22571
  }
22064
22572
  function terragucciRunsRoutes(app, source2, opts = {}) {
22065
- const cache6 = /* @__PURE__ */ new Map();
22573
+ const cache7 = /* @__PURE__ */ new Map();
22066
22574
  const shared2 = (key3, read) => {
22067
22575
  const at2 = Date.now();
22068
- const hit = cache6.get(key3);
22576
+ const hit = cache7.get(key3);
22069
22577
  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);
22578
+ for (const [k, v] of cache7) if (at2 - v.at >= RUNS_READ_TTL_MS) cache7.delete(k);
22071
22579
  const p = read();
22072
- cache6.set(key3, { at: at2, read: p });
22580
+ cache7.set(key3, { at: at2, read: p });
22073
22581
  return p;
22074
22582
  };
22075
22583
  const answer = (a) => {
@@ -22500,18 +23008,18 @@ async function eventsKey(src, pull, commit, file) {
22500
23008
  }
22501
23009
  }
22502
23010
  function chantPrRoute(app, dir, deps = {}) {
22503
- const cache6 = /* @__PURE__ */ new Map();
23011
+ const cache7 = /* @__PURE__ */ new Map();
22504
23012
  app.get("/api/chant/pr", async (c) => {
22505
23013
  const q = new URL(c.req.url).searchParams;
22506
23014
  const pin = q.get("pin");
22507
23015
  const d = dir();
22508
23016
  const key3 = `${d}|${pin ?? ""}`;
22509
23017
  const t2 = Date.now();
22510
- const hit = cache6.get(key3);
23018
+ const hit = cache7.get(key3);
22511
23019
  const r = hit && t2 - hit.at < 2e3 && q.get("fresh") !== "1" ? hit.read : readChantPr(d, pin, deps);
22512
23020
  if (r !== hit?.read) {
22513
- cache6.set(key3, { at: t2, read: r });
22514
- r.catch(() => cache6.delete(key3));
23021
+ cache7.set(key3, { at: t2, read: r });
23022
+ r.catch(() => cache7.delete(key3));
22515
23023
  }
22516
23024
  return c.json(await r, 200, { "cache-control": "no-store" });
22517
23025
  });
@@ -22542,7 +23050,7 @@ function chantPrFacets(dir, ir, engine) {
22542
23050
  }
22543
23051
 
22544
23052
  // src/chant-demo.ts
22545
- import { Ajv2020 as Ajv20202 } from "ajv/dist/2020.js";
23053
+ import { Ajv2020 as Ajv20203 } from "ajv/dist/2020.js";
22546
23054
 
22547
23055
  // src/demo-schemas/demo-cycle.schema.json
22548
23056
  var demo_cycle_schema_default = {
@@ -23140,14 +23648,14 @@ var DEMO_READ_TTL_MS = 2e3;
23140
23648
  var DEMO_STEPS = ["pull-request", "planned", "merged", "applying", "waiting", "approved", "failed", "resumed", "applied", "reset", "stalled"];
23141
23649
  var DEMO_ABOUT_FIELDS = ["changes", "watch", "shows"];
23142
23650
  function highlightOf(v) {
23143
- if (!isRecord12(v)) return void 0;
23651
+ if (!isRecord13(v)) return void 0;
23144
23652
  const title = text(v.title);
23145
23653
  const body = text(v.body);
23146
23654
  return title && body ? { title, body } : void 0;
23147
23655
  }
23148
23656
  var OUTSIDE_STATES = ["applying", "applied", "failed"];
23149
23657
  function outsideOf(v) {
23150
- if (!isRecord12(v)) return void 0;
23658
+ if (!isRecord13(v)) return void 0;
23151
23659
  const estate = text(v.estate);
23152
23660
  const state = v.state;
23153
23661
  if (!estate || !str8(state) || !OUTSIDE_STATES.includes(state)) return void 0;
@@ -23165,7 +23673,7 @@ function outsideOf(v) {
23165
23673
  };
23166
23674
  }
23167
23675
  function chapterOf(v) {
23168
- if (!isRecord12(v)) return void 0;
23676
+ if (!isRecord13(v)) return void 0;
23169
23677
  const n = v.n;
23170
23678
  const of = v.of;
23171
23679
  if (!int2(n) || !int2(of) || n < 1 || of < n || !str8(v.headline) || !v.headline.trim()) return void 0;
@@ -23174,12 +23682,12 @@ function chapterOf(v) {
23174
23682
  }
23175
23683
  var UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
23176
23684
  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);
23685
+ var isRecord13 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23178
23686
  var str8 = (v) => typeof v === "string";
23179
23687
  var int2 = (v) => typeof v === "number" && Number.isInteger(v);
23180
23688
  var positive = (v) => int2(v) && v > 0 ? v : null;
23181
23689
  function demoProblem(doc) {
23182
- if (!isRecord12(doc)) return "it is not an object";
23690
+ if (!isRecord13(doc)) return "it is not an object";
23183
23691
  if (!int2(doc.cycle)) return "cycle is not an integer";
23184
23692
  if (!str8(doc.scenario) || !doc.scenario) return "scenario is not a string";
23185
23693
  if (!str8(doc.title)) return "title is not a string";
@@ -23187,7 +23695,7 @@ function demoProblem(doc) {
23187
23695
  if (!str8(doc.label)) return "label is not a string";
23188
23696
  if (!str8(doc.started_at) || !UTC.test(doc.started_at)) return "started_at is not a UTC time (YYYY-MM-DDTHH:MM:SSZ)";
23189
23697
  if (doc.next !== null) {
23190
- if (!isRecord12(doc.next)) return "next is neither an object nor null";
23698
+ if (!isRecord13(doc.next)) return "next is neither an object nor null";
23191
23699
  if (!str8(doc.next.action)) return "next.action is not a string";
23192
23700
  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
23701
  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 +23703,7 @@ function demoProblem(doc) {
23195
23703
  if (doc.pull !== null && !int2(doc.pull)) return "pull is neither an integer nor null";
23196
23704
  if (doc.commit !== null && !str8(doc.commit)) return "commit is neither a string nor null";
23197
23705
  if (doc.about !== void 0 && doc.about !== null) {
23198
- if (!isRecord12(doc.about)) return "about is neither an object nor null";
23706
+ if (!isRecord13(doc.about)) return "about is neither an object nor null";
23199
23707
  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
23708
  }
23201
23709
  return void 0;
@@ -23352,7 +23860,7 @@ var cycleToolName = (v) => isVendorTool(v) || /^[a-z0-9][a-z0-9-]{0,40}$/.test(v
23352
23860
  var CYCLE_READ_TTL_MS = 1e4;
23353
23861
  var timeOrNull2 = (v) => v === null || v === void 0 || str8(v) && UTC.test(v);
23354
23862
  function cycleProblem(doc, tool) {
23355
- if (!isRecord12(doc)) return "it is not an object";
23863
+ if (!isRecord13(doc)) return "it is not an object";
23356
23864
  if (doc.schema !== void 0 && doc.schema !== "demo.cycle/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.cycle/v1`;
23357
23865
  if (doc.tool !== tool) return `tool is ${JSON.stringify(doc.tool)}, not ${tool}`;
23358
23866
  if (!str8(doc.repo) || !doc.repo) return "repo is not a string";
@@ -23403,14 +23911,14 @@ async function readCycle(source2, tool, now = /* @__PURE__ */ new Date()) {
23403
23911
  };
23404
23912
  }
23405
23913
  function terragucciCyclesRoute(app, source2, opts = {}) {
23406
- const cache6 = /* @__PURE__ */ new Map();
23914
+ const cache7 = /* @__PURE__ */ new Map();
23407
23915
  app.get("/api/terragucci/cycles/:tool", async (c) => {
23408
23916
  const tool = c.req.param("tool");
23409
23917
  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
23918
  const at2 = Date.now();
23411
- const hit = cache6.get(tool);
23919
+ const hit = cache7.get(tool);
23412
23920
  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 });
23921
+ if (read !== hit?.read) cache7.set(tool, { at: at2, read });
23414
23922
  const a = await read;
23415
23923
  return c.json(a, "error" in a ? 502 : "absent" in a ? 404 : 200, { "cache-control": "no-store" });
23416
23924
  });
@@ -23470,7 +23978,7 @@ var STEP_READ_TTL_MS = 2e3;
23470
23978
  var CYCLE_READ_TTL_MS2 = 1e4;
23471
23979
  var RUN_READ_TTL_MS = 2e3;
23472
23980
  var REPORT_KEY = /^([0-9]+)\/([0-9a-f]{40,64})$/;
23473
- var isRecord13 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23981
+ var isRecord14 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23474
23982
  var str9 = (v) => typeof v === "string";
23475
23983
  var int3 = (v) => typeof v === "number" && Number.isInteger(v);
23476
23984
  var text2 = (v) => str9(v) && v.trim() ? v.trim() : null;
@@ -23506,7 +24014,7 @@ function readerSchema(kind) {
23506
24014
  function schemaProblem(doc, kind) {
23507
24015
  let v = validators[kind];
23508
24016
  if (!v) {
23509
- const ajv = new Ajv20202({ strict: false, allErrors: false });
24017
+ const ajv = new Ajv20203({ strict: false, allErrors: false });
23510
24018
  v = validators[kind] = ajv.compile(readerSchema(kind));
23511
24019
  }
23512
24020
  if (v(doc)) return void 0;
@@ -23518,9 +24026,9 @@ function keyParts(key3) {
23518
24026
  return { pr: Number(m[1]), commit: m[2] };
23519
24027
  }
23520
24028
  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;
24029
+ const next = isRecord14(d.next) ? d.next : null;
24030
+ const about = isRecord14(d.about) && ["changes", "watch", "shows"].every((f) => text2(d.about[f])) ? d.about : null;
24031
+ const r = isRecord14(d.reports) ? d.reports : null;
23524
24032
  const chapter = chapterOf(d.chapter);
23525
24033
  const highlight = highlightOf(d.highlight);
23526
24034
  const demo = str9(d.demo) ? d.demo : "";
@@ -23595,7 +24103,7 @@ async function readRecord(source2, key3, kind, what, problem, of) {
23595
24103
  } catch {
23596
24104
  return { error: `${key3} in ${source2.location} is not JSON.` };
23597
24105
  }
23598
- if (!isRecord13(doc)) return { error: `${key3} in ${source2.location} is not a ${kind} record: it is not an object.` };
24106
+ if (!isRecord14(doc)) return { error: `${key3} in ${source2.location} is not a ${kind} record: it is not an object.` };
23599
24107
  const floor = contractRefusal2(doc, kind);
23600
24108
  if (floor) return { error: `behold refuses ${key3} in ${source2.location}: ${floor.problem}.`, remedy: floor.remedy };
23601
24109
  const p = schemaProblem(doc, kind) ?? problem(doc);
@@ -23623,7 +24131,7 @@ function demoRunOf(entry, repo, reportsAt, events, report) {
23623
24131
  const first = events[0];
23624
24132
  const settle = [...events].reverse().find((e) => e.type === "run-settle");
23625
24133
  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;
24134
+ const origin = first && isRecord14(first.runOrigin) && str9(first.runOrigin.url) ? first.runOrigin.url : void 0;
23627
24135
  const steps = [];
23628
24136
  const part = (name, e) => {
23629
24137
  let s = steps.find((x) => x.name === name);
@@ -23885,7 +24393,7 @@ function chantDemoRoutes(app, demo) {
23885
24393
 
23886
24394
  // src/ci-run-index.ts
23887
24395
  init_chant_floors();
23888
- import { Ajv2020 as Ajv20203 } from "ajv/dist/2020.js";
24396
+ import { Ajv2020 as Ajv20204 } from "ajv/dist/2020.js";
23889
24397
 
23890
24398
  // src/ci-run-index-schema/ci-run-index.schema.json
23891
24399
  var ci_run_index_schema_default = {
@@ -23959,7 +24467,7 @@ function heldBy(e) {
23959
24467
  if (e.job === "apply" && e.exitCode === 3 && !(e.failure && OTHER_REFUSALS.has(e.failure.code))) return "exit 3";
23960
24468
  return null;
23961
24469
  }
23962
- var isRecord14 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24470
+ var isRecord15 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23963
24471
  var str10 = (v) => typeof v === "string";
23964
24472
  function readerSchema2(which) {
23965
24473
  const schema = structuredClone(ci_run_index_schema_default);
@@ -23976,7 +24484,7 @@ var validators2 = {};
23976
24484
  function schemaProblem2(doc, which) {
23977
24485
  let v = validators2[which];
23978
24486
  if (!v) {
23979
- const ajv = new Ajv20203({ strict: false, allErrors: false });
24487
+ const ajv = new Ajv20204({ strict: false, allErrors: false });
23980
24488
  v = validators2[which] = ajv.compile(readerSchema2(which));
23981
24489
  }
23982
24490
  if (v(doc)) return void 0;
@@ -24064,7 +24572,7 @@ async function readCiRunIndex(source2, url, now = /* @__PURE__ */ new Date()) {
24064
24572
  const entries = [];
24065
24573
  const skipped = [];
24066
24574
  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);
24575
+ 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
24576
  if (q) skipped.push(`runs[${i}]: ${q.replace(/^\/?/, "")}`);
24069
24577
  else entries.push(r);
24070
24578
  });
@@ -24149,7 +24657,7 @@ var ID = /^local-[a-z0-9-]{1,40}$/;
24149
24657
  function localRunArgs(a) {
24150
24658
  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
24659
  }
24152
- var isRecord15 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24660
+ var isRecord16 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
24153
24661
  var str11 = (v) => typeof v === "string" && v.length > 0;
24154
24662
  function noteStdout(rec7, line) {
24155
24663
  const r = readRunLine(line);
@@ -24203,13 +24711,13 @@ function localRunOf(rec7) {
24203
24711
  let status2 = settle ? RUN_STATUS2[String(settle.status)] ?? "failure" : ended ? "lost" : rec7.events.length ? "running" : "queued";
24204
24712
  if (!settle && ended && rec7.exitCode !== 0 && !rec7.events.length) status2 = "failure";
24205
24713
  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;
24714
+ const failure = settle && isRecord16(settle.failure) && str11(settle.failure.code) ? settle.failure.code : null;
24207
24715
  const tail = [...loose];
24208
24716
  if (settle && str11(settle.error)) tail.push(`run ${String(settle.status)}: ${settle.error}`);
24209
24717
  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
24718
  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
24719
  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;
24720
+ const origin = start && isRecord16(start.runOrigin) && str11(start.runOrigin.forge) ? start.runOrigin.forge : null;
24213
24721
  const job = `pr-${rec7.ask.job}`;
24214
24722
  const startedAt = at2(start) ?? rec7.startedAt;
24215
24723
  const endedAt = settle ? at2(settle) : rec7.endedAt;
@@ -24310,7 +24818,7 @@ function localRunRoutes(app, opts) {
24310
24818
  let body;
24311
24819
  try {
24312
24820
  const parsed = await c.req.json();
24313
- body = isRecord15(parsed) ? parsed : {};
24821
+ body = isRecord16(parsed) ? parsed : {};
24314
24822
  } catch {
24315
24823
  return c.json({ error: "the body is JSON: {job, commit, pr, env?, base?, member?, forge?}", code: "local-run" }, 400);
24316
24824
  }
@@ -25338,11 +25846,11 @@ function runLabel(run4) {
25338
25846
  function tookLabel(ms) {
25339
25847
  return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
25340
25848
  }
25341
- function paintPlayhead(ir, join61, gate) {
25342
- if (!join61.byNode.size && !join61.at) return ir;
25849
+ function paintPlayhead(ir, join62, gate) {
25850
+ if (!join62.byNode.size && !join62.at) return ir;
25343
25851
  const nodes = ir.nodes.map((node) => {
25344
- const run4 = join61.byNode.get(node.id);
25345
- const here = join61.at === node.id;
25852
+ const run4 = join62.byNode.get(node.id);
25853
+ const here = join62.at === node.id;
25346
25854
  if (!run4 && !here) return node;
25347
25855
  const isGate = node.attrs?._step === "gate";
25348
25856
  const attrs = { ...node.attrs };
@@ -25359,7 +25867,7 @@ function paintPlayhead(ir, join61, gate) {
25359
25867
  if (here) {
25360
25868
  attrs._playhead = true;
25361
25869
  attrs._status = isGate && gate ? "warn" : "accent";
25362
- attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join61.atReason ?? "here";
25870
+ attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join62.atReason ?? "here";
25363
25871
  if (isGate && gate?.description) attrs.gateDescription = gate.description;
25364
25872
  }
25365
25873
  return { ...node, attrs };
@@ -25384,11 +25892,11 @@ function pendingGateCard(op, gate, ir) {
25384
25892
  function settledCount(steps) {
25385
25893
  return steps.filter((s) => s.state !== "running").length;
25386
25894
  }
25387
- function playheadNote(state, join61) {
25895
+ function playheadNote(state, join62) {
25388
25896
  if (!state.op) {
25389
25897
  return "No run state: nothing has been run from this behold session, so every step paints as declared.";
25390
25898
  }
25391
- const settled = join61 ? join61.byNode.size : settledCount(state.steps);
25899
+ const settled = join62 ? join62.byNode.size : settledCount(state.steps);
25392
25900
  const bits = [];
25393
25901
  const from = state.source === "events" ? "chant's run events" : "chant's older progress stream (degraded)";
25394
25902
  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 +25916,9 @@ function playheadNote(state, join61) {
25408
25916
  bits.push(`gate state unavailable: ${state.gateNote}`);
25409
25917
  }
25410
25918
  if (state.sourceNote) bits.push(state.sourceNote);
25411
- if (join61?.unplaced.length) {
25919
+ if (join62?.unplaced.length) {
25412
25920
  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`
25921
+ `${join62.unplaced.length} step${join62.unplaced.length === 1 ? "" : "s"} matched no declared step and ${join62.unplaced.length === 1 ? "is" : "are"} not painted`
25414
25922
  );
25415
25923
  }
25416
25924
  if (!bits.length) return `${head}.`;
@@ -26280,6 +26788,8 @@ var REFUSED_READS = [
26280
26788
  [/^\/api\/overlay$/, "it reads the live estate with behold's own credentials"],
26281
26789
  [/^\/api\/reconcile$/, "it plans against the live estate with behold's own credentials"],
26282
26790
  [/^\/api\/diff(\/|$)/, "it reads the live estate with behold's own credentials"],
26791
+ [/^\/api\/health$/, "it reads the live estate with behold's own credentials"],
26792
+ [/^\/api\/health$/, "it reads the live estate with behold's own credentials"],
26283
26793
  [/^\/api\/components\/compare$/, "it reads the live estate with behold's own credentials"],
26284
26794
  [/^\/api\/resources$/, "it runs chant against the project"],
26285
26795
  [/^\/api\/ci(\/|$)/, "it reads the pipeline and the forge run"],
@@ -26324,19 +26834,19 @@ import { join as join37 } from "node:path";
26324
26834
  import { platform } from "node:os";
26325
26835
  var DOCKER_DOWN_DETAIL = "docker is down";
26326
26836
  function probe(cmd, args) {
26327
- return new Promise((resolve38) => {
26837
+ return new Promise((resolve39) => {
26328
26838
  let out = "";
26329
26839
  let proc;
26330
26840
  try {
26331
26841
  proc = spawn7(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
26332
26842
  } catch {
26333
- resolve38({ code: 127, out: "" });
26843
+ resolve39({ code: 127, out: "" });
26334
26844
  return;
26335
26845
  }
26336
26846
  proc.stdout.on("data", (d) => out += d);
26337
26847
  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 }));
26848
+ proc.on("error", () => resolve39({ code: 127, out }));
26849
+ proc.on("close", (code) => resolve39({ code: code ?? 1, out }));
26340
26850
  });
26341
26851
  }
26342
26852
  async function dockerAvailable(run4) {
@@ -27204,7 +27714,7 @@ init_choudoufu_member();
27204
27714
  import { mkdtempSync, rmSync as rmSync3 } from "node:fs";
27205
27715
  import { tmpdir as tmpdir3 } from "node:os";
27206
27716
  import { join as join39 } from "node:path";
27207
- var isRecord16 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27717
+ var isRecord17 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27208
27718
  var refuse7 = (error, remedy) => ({ ok: false, refusal: { error, code: "choudoufu-live-check", remedy } });
27209
27719
  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
27720
  function said3(run4, fallback) {
@@ -27221,7 +27731,7 @@ function parsePlanShow(run4, dir) {
27221
27731
  } catch {
27222
27732
  return refuse7(`choudoufu show printed something that is not JSON for ${dir}: ${said3(run4, "unparseable stdout")}`, CREDS2);
27223
27733
  }
27224
- if (!isRecord16(json2) || typeof json2.format_version !== "string") {
27734
+ if (!isRecord17(json2) || typeof json2.format_version !== "string") {
27225
27735
  return refuse7("That is not a plan document \u2014 no `format_version`.", CREDS2);
27226
27736
  }
27227
27737
  if (json2.resource_changes !== void 0 && json2.resource_changes !== null && !Array.isArray(json2.resource_changes)) {
@@ -27233,9 +27743,9 @@ var KNOWN_AFTER_APPLY = "(known after apply)";
27233
27743
  var SENSITIVE = "(sensitive)";
27234
27744
  var flagged = (tree, key3) => {
27235
27745
  if (tree === true) return true;
27236
- if (!isRecord16(tree)) return false;
27746
+ if (!isRecord17(tree)) return false;
27237
27747
  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);
27748
+ return v === true || isRecord17(v) && Object.values(v).some((x) => x === true) || Array.isArray(v) && v.some((x) => x === true);
27239
27749
  };
27240
27750
  function same(a, b) {
27241
27751
  if (a === b) return true;
@@ -27243,7 +27753,7 @@ function same(a, b) {
27243
27753
  if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
27244
27754
  return a.every((x, i) => same(x, b[i]));
27245
27755
  }
27246
- if (isRecord16(a) && isRecord16(b)) {
27756
+ if (isRecord17(a) && isRecord17(b)) {
27247
27757
  const ka = Object.keys(a);
27248
27758
  const kb = Object.keys(b);
27249
27759
  if (ka.length !== kb.length) return false;
@@ -27254,10 +27764,10 @@ function same(a, b) {
27254
27764
  function planDrift(doc) {
27255
27765
  const out = /* @__PURE__ */ new Map();
27256
27766
  for (const rc of doc.resource_changes ?? []) {
27257
- if (!rc || typeof rc.address !== "string" || !isRecord16(rc.change)) continue;
27767
+ if (!rc || typeof rc.address !== "string" || !isRecord17(rc.change)) continue;
27258
27768
  const { actions, before, after: after2 } = rc.change;
27259
27769
  if (!Array.isArray(actions) || actions.every((a) => a === "no-op")) continue;
27260
- if (!isRecord16(before) || !isRecord16(after2)) continue;
27770
+ if (!isRecord17(before) || !isRecord17(after2)) continue;
27261
27771
  const changes = [];
27262
27772
  for (const key3 of [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after2)])].sort()) {
27263
27773
  const unknownAfter = flagged(rc.change.after_unknown, key3);
@@ -27312,13 +27822,13 @@ init_choudoufu_member();
27312
27822
  init_choudoufu_live();
27313
27823
  import { existsSync as existsSync25, readFileSync as readFileSync30 } from "node:fs";
27314
27824
  import { join as join40, relative as relative8 } from "node:path";
27315
- var isRecord17 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27825
+ var isRecord18 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27316
27826
  var refuse8 = (error, remedy) => ({ ok: false, refusal: { error, code: "choudoufu-live-check", remedy } });
27317
27827
  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
27828
  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);
27829
+ 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
27830
  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");
27831
+ const bad2 = value.moves.findIndex((m) => !isRecord18(m) || typeof m.address !== "string" || typeof m.from !== "string" || typeof m.to !== "string");
27322
27832
  if (bad2 >= 0) return refuse8(`moves[${bad2}] is not a move (needs string \`address\`, \`from\` and \`to\`).`, HOW_TO_GET_ONE2);
27323
27833
  const moves = value.moves;
27324
27834
  return {
@@ -27363,7 +27873,7 @@ function parseLiveMv(run4, what) {
27363
27873
  } catch {
27364
27874
  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
27875
  }
27366
- if (!isRecord17(json2) || !isRecord17(json2.from) || !isRecord17(json2.to) || typeof json2.dry_run !== "boolean") {
27876
+ if (!isRecord18(json2) || !isRecord18(json2.from) || !isRecord18(json2.to) || typeof json2.dry_run !== "boolean") {
27367
27877
  return refuse8(`That is not a live-mv document (${what}).`, "Upgrade choudoufu to 0.16.0 or newer.");
27368
27878
  }
27369
27879
  return { ok: true, doc: json2 };
@@ -27518,7 +28028,7 @@ async function readPolicyOverride(dir, g, read = gitLifecycleReader) {
27518
28028
  }
27519
28029
 
27520
28030
  // src/workspace-gates.ts
27521
- var isRecord18 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28031
+ var isRecord19 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27522
28032
  var str15 = (v) => typeof v === "string" && v ? v : null;
27523
28033
  function gateKey(member, op, gate) {
27524
28034
  return `${member}/${op}/${gate}`;
@@ -27529,16 +28039,16 @@ function approveArgs(g) {
27529
28039
  function gatesFromStatus(doc, root) {
27530
28040
  const contract = contractRefusal(doc, "status");
27531
28041
  if (contract) return { ok: false, refusal: contract };
27532
- if (isRecord18(doc.error)) {
28042
+ if (isRecord19(doc.error)) {
27533
28043
  const code = String(doc.error.code ?? "unknown");
27534
28044
  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
28045
  }
27536
28046
  const gates = [];
27537
28047
  for (const m of Array.isArray(doc.members) ? doc.members : []) {
27538
- if (!isRecord18(m) || typeof m.name !== "string") continue;
28048
+ if (!isRecord19(m) || typeof m.name !== "string") continue;
27539
28049
  const dir = typeof m.dir === "string" ? m.dir === "." ? resolve21(root) : resolve21(root, m.dir) : resolve21(root);
27540
28050
  for (const g of Array.isArray(m.gates) ? m.gates : []) {
27541
- if (!isRecord18(g)) continue;
28051
+ if (!isRecord19(g)) continue;
27542
28052
  const op = str15(g.component);
27543
28053
  const gate = str15(g.name);
27544
28054
  if (!op || !gate) continue;
@@ -27546,7 +28056,7 @@ function gatesFromStatus(doc, root) {
27546
28056
  if (g.state !== void 0 && g.state !== "pending" && !keepApproved) continue;
27547
28057
  const env = str15(g.env);
27548
28058
  const planDigest = str15(g.planDigest);
27549
- const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord18).map((a) => ({
28059
+ const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord19).map((a) => ({
27550
28060
  principal: String(a.principal ?? "unknown"),
27551
28061
  at: str15(a.at),
27552
28062
  channel: str15(a.channel)
@@ -27563,16 +28073,16 @@ function gatesFromStatus(doc, root) {
27563
28073
  needed: typeof g.needed === "number" ? g.needed : 1,
27564
28074
  recordedAt: str15(g.recordedAt),
27565
28075
  expiresAt: str15(g.expiresAt),
27566
- signed: isRecord18(g.signed),
28076
+ signed: isRecord19(g.signed),
27567
28077
  // status's line already carries --sign for a signed gate; only the
27568
28078
  // line built here needs it added.
27569
28079
  state: keepApproved ? "approved" : "pending",
27570
- approve: str15(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord18(g.signed) ? ["--sign"] : []].join(" "),
28080
+ approve: str15(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord19(g.signed) ? ["--sign"] : []].join(" "),
27571
28081
  ...str15(g.gitSha) ? { gitSha: str15(g.gitSha) } : {},
27572
28082
  ...str15(g.runId) ? { runId: str15(g.runId) } : {},
27573
28083
  ...str15(g.changeSet) ? { changeSet: str15(g.changeSet) } : {},
27574
28084
  ...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 ?? "") } } : {}
28085
+ ...isRecord19(g.answer) && str15(g.answer.id) ? { answer: { point: String(g.answer.point ?? ""), id: str15(g.answer.id), path: String(g.answer.path ?? "") } } : {}
27576
28086
  });
27577
28087
  }
27578
28088
  }
@@ -27612,7 +28122,7 @@ function localApprover(env = process.env) {
27612
28122
  // src/decision-points.ts
27613
28123
  init_chant_floors();
27614
28124
  var POINTS_READ_NAME = "decision points";
27615
- var isRecord19 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28125
+ var isRecord20 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27616
28126
  var str16 = (v) => typeof v === "string" && v ? v : null;
27617
28127
  var arr = (v) => Array.isArray(v) ? v : [];
27618
28128
  var num2 = (v) => typeof v === "number" ? v : null;
@@ -27629,24 +28139,24 @@ function answerCommand(id) {
27629
28139
  return `chant workspace points answer ${id} --answer <value> --by <name>`;
27630
28140
  }
27631
28141
  function openPointsFrom(doc, at2 = /* @__PURE__ */ new Date()) {
27632
- if (isRecord19(doc.error)) {
28142
+ if (isRecord20(doc.error)) {
27633
28143
  const code = String(doc.error.code ?? "unknown");
27634
28144
  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
28145
  }
27636
28146
  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);
28147
+ for (const p of arr(doc.points)) if (isRecord20(p) && typeof p.name === "string") declared2.set(p.name, p);
27638
28148
  const points = [];
27639
28149
  for (const q of arr(doc.questions)) {
27640
- if (!isRecord19(q) || q.open !== true) continue;
28150
+ if (!isRecord20(q) || q.open !== true) continue;
27641
28151
  const id = str16(q.id);
27642
28152
  const name = str16(q.point);
27643
28153
  if (!id || !name) continue;
27644
28154
  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;
28155
+ const asked = isRecord20(q.asked) ? q.asked : null;
28156
+ const quorum = p && isRecord20(p.quorum) ? p.quorum : isRecord20(q.decider) && q.decider.kind === "quorum" ? q.decider : null;
28157
+ const m = isRecord20(q.model) ? q.model : null;
27648
28158
  const subject = str16(q.subject);
27649
- const by = isRecord19(q.askedBy) ? str16(q.askedBy.steward) : null;
28159
+ const by = isRecord20(q.askedBy) ? str16(q.askedBy.steward) : null;
27650
28160
  points.push({
27651
28161
  id,
27652
28162
  point: name,
@@ -27667,7 +28177,7 @@ function openPointsFrom(doc, at2 = /* @__PURE__ */ new Date()) {
27667
28177
  });
27668
28178
  }
27669
28179
  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 ?? "") }));
28180
+ 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
28181
  return { ok: true, points: { points, unread, read: { at: at2.toISOString() } } };
27672
28182
  }
27673
28183
  async function readOpenPoints(ws, opts = {}) {
@@ -27829,7 +28339,7 @@ function resolveApproverOptions(flags, dir, env = process.env) {
27829
28339
  // src/workspace-why.ts
27830
28340
  init_chant_floors();
27831
28341
  var WHY_COMMITS_SHOWN = 8;
27832
- var isRecord20 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28342
+ var isRecord21 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27833
28343
  var str17 = (v) => typeof v === "string" && v ? v : null;
27834
28344
  var num3 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
27835
28345
  var strings3 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
@@ -27854,12 +28364,12 @@ function hudReviewUrl(hud, record) {
27854
28364
  return `${hud.replace(/\/+$/, "")}/decisions#${encodeURIComponent(record)}`;
27855
28365
  }
27856
28366
  function whyFromIntent(doc, hud = null) {
27857
- if (isRecord20(doc.error)) {
28367
+ if (isRecord21(doc.error)) {
27858
28368
  const code = String(doc.error.code ?? "unknown");
27859
28369
  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
28370
  }
27861
28371
  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);
28372
+ for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (isRecord21(n) && typeof n.id === "string") nodes.set(n.id, n);
27863
28373
  const regionId = String(doc.region ?? "");
27864
28374
  const regionNode = nodes.get(regionId);
27865
28375
  const base = {
@@ -27869,12 +28379,12 @@ function whyFromIntent(doc, hud = null) {
27869
28379
  chant: String(doc.chant ?? "")
27870
28380
  };
27871
28381
  const why = doc.why;
27872
- if (!isRecord20(why)) {
28382
+ if (!isRecord21(why)) {
27873
28383
  return { ok: true, why: { ...base, answered: false, explained: false, decisions: [], runs: [], commits: [], commitsTotal: 0, uncommittedLines: 0, gaps: [], trace: null } };
27874
28384
  }
27875
28385
  const decisions = [];
27876
28386
  for (const d of Array.isArray(why.decisions) ? why.decisions : []) {
27877
- if (!isRecord20(d) || typeof d.decision !== "string") continue;
28387
+ if (!isRecord21(d) || typeof d.decision !== "string") continue;
27878
28388
  const n = nodes.get(d.decision) ?? {};
27879
28389
  const id = str17(n.record) ?? after(d.decision, "record:").replace(/^[^/]*\//, "");
27880
28390
  const state = str17(n.state);
@@ -27893,28 +28403,28 @@ function whyFromIntent(doc, hud = null) {
27893
28403
  }
27894
28404
  const commitOf = (id) => {
27895
28405
  const n = nodes.get(id) ?? {};
27896
- const joins = isRecord20(n.joins) ? n.joins : {};
28406
+ const joins = isRecord21(n.joins) ? n.joins : {};
27897
28407
  return {
27898
28408
  sha: str17(n.sha) ?? after(id, "commit:"),
27899
28409
  subject: str17(n.subject),
27900
28410
  date: str17(n.date),
27901
- author: isRecord20(n.author) ? str17(n.author.name) : null,
28411
+ author: isRecord21(n.author) ? str17(n.author.name) : null,
27902
28412
  pullRequest: typeof n.pullRequest === "number" ? n.pullRequest : null,
27903
28413
  run: str17(joins.run)
27904
28414
  };
27905
28415
  };
27906
28416
  const runs2 = [];
27907
28417
  for (const r of Array.isArray(why.runs) ? why.runs : []) {
27908
- if (!isRecord20(r) || typeof r.run !== "string") continue;
28418
+ if (!isRecord21(r) || typeof r.run !== "string") continue;
27909
28419
  const n = nodes.get(r.run) ?? {};
27910
- const unit = isRecord20(r.unit) ? str17(r.unit.id) : null;
28420
+ const unit = isRecord21(r.unit) ? str17(r.unit.id) : null;
27911
28421
  runs2.push({
27912
28422
  id: str17(n.run) ?? after(r.run, "run:"),
27913
28423
  lines: num3(r.lines),
27914
28424
  commits: strings3(r.commits).map((c) => commitOf(c).sha),
27915
28425
  unit,
27916
28426
  by: str17(n.by),
27917
- harness: isRecord20(n.harness) ? str17(n.harness.name) : null,
28427
+ harness: isRecord21(n.harness) ? str17(n.harness.name) : null,
27918
28428
  model: str17(n.model),
27919
28429
  outcome: str17(n.outcome),
27920
28430
  startedAt: str17(n.startedAt),
@@ -27922,7 +28432,7 @@ function whyFromIntent(doc, hud = null) {
27922
28432
  decisions: strings3(r.decisions).map((d) => str17(nodes.get(d)?.record) ?? after(d, "record:"))
27923
28433
  });
27924
28434
  }
27925
- const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord20);
28435
+ const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord21);
27926
28436
  let uncommittedLines = 0;
27927
28437
  const ids = [];
27928
28438
  for (const span of blame) {
@@ -27949,17 +28459,17 @@ function whyFromIntent(doc, hud = null) {
27949
28459
  commits: commits.slice(0, WHY_COMMITS_SHOWN),
27950
28460
  commitsTotal: commits.length,
27951
28461
  uncommittedLines,
27952
- gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord20).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") })),
28462
+ gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord21).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") })),
27953
28463
  trace: traceFromIntent(doc.trace, nodes)
27954
28464
  }
27955
28465
  };
27956
28466
  }
27957
- var records = (v) => Array.isArray(v) ? v.filter(isRecord20) : [];
28467
+ var records = (v) => Array.isArray(v) ? v.filter(isRecord21) : [];
27958
28468
  function traceFromIntent(raw, nodes) {
27959
- if (!isRecord20(raw)) return null;
28469
+ if (!isRecord21(raw)) return null;
27960
28470
  const work = (w) => ({ ...w, title: typeof w.node === "string" ? str17(nodes.get(w.node)?.title) : null });
27961
28471
  const commits = records(raw.commits).map((c) => {
27962
- const judged = isRecord20(c.work) ? c.work : null;
28472
+ const judged = isRecord21(c.work) ? c.work : null;
27963
28473
  return {
27964
28474
  ...c,
27965
28475
  subject: typeof c.commit === "string" ? str17(nodes.get(c.commit)?.subject) : null,
@@ -28677,6 +29187,8 @@ function renderLanes(frames, summaries) {
28677
29187
 
28678
29188
  // src/emulator.ts
28679
29189
  init_chant();
29190
+ import { existsSync as existsSync28, readFileSync as readFileSync32 } from "node:fs";
29191
+ import { join as join43, resolve as resolve24 } from "node:path";
28680
29192
  function parseEmulators(stdout) {
28681
29193
  const lines2 = stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
28682
29194
  for (let i = lines2.length - 1; i >= 0; i--) {
@@ -28709,26 +29221,49 @@ async function emulatorUp(projectDir) {
28709
29221
  async function emulatorDown(projectDir) {
28710
29222
  await runChantRaw(["emulator", "down"], projectDir);
28711
29223
  }
29224
+ function emulatorDirs(dir, workspace) {
29225
+ if (workspace) {
29226
+ const dirs = workspace.members.filter((m) => m.kind === "chant").map((m) => m.abs);
29227
+ return dirs.length ? dirs : [dir];
29228
+ }
29229
+ const file = join43(dir, "chant.workspace.json");
29230
+ if (!existsSync28(file)) return [dir];
29231
+ try {
29232
+ const doc = JSON.parse(readFileSync32(file, "utf8"));
29233
+ const dirs = (doc.members ?? []).filter((m) => (m.kind ?? "chant") === "chant" && typeof m.dir === "string").map((m) => resolve24(dir, m.dir));
29234
+ return dirs.length ? dirs : [dir];
29235
+ } catch {
29236
+ return [dir];
29237
+ }
29238
+ }
29239
+ async function emulatorsUp(dirs) {
29240
+ const seen = /* @__PURE__ */ new Map();
29241
+ for (const d of dirs) for (const e of await emulatorUp(d)) if (!seen.has(e.name)) seen.set(e.name, e);
29242
+ return [...seen.values()];
29243
+ }
29244
+ async function emulatorsDown(dirs) {
29245
+ for (const d of dirs) await emulatorDown(d).catch(() => void 0);
29246
+ }
28712
29247
 
28713
29248
  // src/terragucci-view.ts
28714
29249
  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";
29250
+ import { dirname as dirname15, join as join49, relative as relative10, sep as sep8 } from "node:path";
28716
29251
  init_terraform_member();
28717
29252
 
28718
29253
  // src/terragucci-reports.ts
28719
- import { readFileSync as readFileSync32, statSync as statSync11 } from "node:fs";
29254
+ import { readFileSync as readFileSync33, statSync as statSync11 } from "node:fs";
28720
29255
  import { createRequire as createRequire4 } from "node:module";
28721
- import { dirname as dirname11, join as join43, resolve as resolve24 } from "node:path";
29256
+ import { dirname as dirname11, join as join44, resolve as resolve25 } from "node:path";
28722
29257
  import { fileURLToPath as fileURLToPath7 } from "node:url";
28723
- import { Ajv2020 as Ajv20204 } from "ajv/dist/2020.js";
29258
+ import { Ajv2020 as Ajv20205 } from "ajv/dist/2020.js";
28724
29259
 
28725
29260
  // src/terragucci-cone.ts
28726
- var isRecord21 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
29261
+ var isRecord22 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
28727
29262
  var str18 = (v) => typeof v === "string" && v.length > 0;
28728
29263
  var count = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : void 0;
28729
29264
  function readCone(v) {
28730
- if (!isRecord21(v) || !str18(v.base)) return void 0;
28731
- const fb = isRecord21(v.fallback) ? v.fallback : null;
29265
+ if (!isRecord22(v) || !str18(v.base)) return void 0;
29266
+ const fb = isRecord22(v.fallback) ? v.fallback : null;
28732
29267
  if (fb) return { base: v.base, fallback: { kind: str18(fb.kind) ? fb.kind : "unknown", reason: str18(fb.reason) ? fb.reason : "" } };
28733
29268
  const blocks = count(v.blocks);
28734
29269
  const of = count(v.of);
@@ -28736,11 +29271,11 @@ function readCone(v) {
28736
29271
  return { base: v.base, ...blocks !== void 0 && of !== void 0 ? { blocks, of } : {}, ...targets !== void 0 ? { targets } : {} };
28737
29272
  }
28738
29273
  function plannedInstances(plan) {
28739
- if (!isRecord21(plan) || !Array.isArray(plan.resource_changes)) return [];
29274
+ if (!isRecord22(plan) || !Array.isArray(plan.resource_changes)) return [];
28740
29275
  const out = [];
28741
29276
  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) : [];
29277
+ if (!isRecord22(rc) || !str18(rc.address) || rc.mode === "data") continue;
29278
+ const acts = isRecord22(rc.change) && Array.isArray(rc.change.actions) ? rc.change.actions.filter(str18) : [];
28744
29279
  out.push({ address: rc.address, changed: !acts.every((a) => a === "no-op" || a === "read") });
28745
29280
  }
28746
29281
  return out;
@@ -28772,7 +29307,7 @@ function coneView(doc, { roots = [], planned = {}, facts = {} } = {}) {
28772
29307
  const all = out.map((r) => r.root);
28773
29308
  const binaryOf = (p) => {
28774
29309
  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;
29310
+ const b = own && isRecord22(own.binary) && str18(own.binary.name) ? own.binary.name : void 0;
28776
29311
  return b ?? facts[p]?.binary;
28777
29312
  };
28778
29313
  const live2 = all.length > 0 && all.every((p) => binaryOf(p) === "choudoufu" && facts[p]?.state !== true);
@@ -28783,7 +29318,7 @@ async function readConePlans(source2, runPath, doc) {
28783
29318
  for (const r of doc.roots) {
28784
29319
  const c = readCone(r.cone);
28785
29320
  if (!c || c.fallback) continue;
28786
- const key3 = isRecord21(r.plan) && str18(r.plan.json) ? r.plan.json : null;
29321
+ const key3 = isRecord22(r.plan) && str18(r.plan.json) ? r.plan.json : null;
28787
29322
  if (!key3 || key3.split("/").some((s) => s === ".." || s === ".")) continue;
28788
29323
  let text3;
28789
29324
  try {
@@ -28832,13 +29367,13 @@ function attributeValues(a) {
28832
29367
  }
28833
29368
  var OUTCOMES = ["applied", "unchanged", "failed"];
28834
29369
  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)] : []);
29370
+ 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
29371
  }
28837
29372
  function waveOutcomes(w) {
28838
29373
  const rows = [...w && Array.isArray(w.roots) ? w.roots : [], ...w && Array.isArray(w.outcomes) ? w.outcomes : []];
28839
29374
  const out = /* @__PURE__ */ new Map();
28840
29375
  for (const r of rows) {
28841
- if (!isRecord22(r)) continue;
29376
+ if (!isRecord23(r)) continue;
28842
29377
  const root = r.root ?? r.path;
28843
29378
  if (!str19(root) || !root || !str19(r.outcome) || !OUTCOMES.includes(r.outcome) || out.has(root)) continue;
28844
29379
  out.set(root, { root, outcome: r.outcome, ...r.outcome === "failed" && str19(r.error) && r.error ? { error: r.error } : {} });
@@ -28847,34 +29382,34 @@ function waveOutcomes(w) {
28847
29382
  }
28848
29383
  var SCHEMA_FILES = { report: "report.schema.json", index: "report-index.schema.json", estate: "estate.schema.json" };
28849
29384
  var SCHEMA_IDS = { report: REPORT_SCHEMA, index: INDEX_SCHEMA, estate: ESTATE_SCHEMA };
28850
- var isRecord22 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29385
+ var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
28851
29386
  var str19 = (v) => typeof v === "string";
28852
29387
  function structural(name, doc) {
28853
- if (!isRecord22(doc)) return "it is not a JSON object";
29388
+ if (!isRecord23(doc)) return "it is not a JSON object";
28854
29389
  if (doc.schema !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(doc.schema)}, not ${SCHEMA_IDS[name]}`;
28855
29390
  if (name === "index") {
28856
29391
  if (!Array.isArray(doc.reports)) return "it has no reports array";
28857
29392
  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`;
29393
+ 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
29394
  }
28860
29395
  } else if (name === "report") {
28861
29396
  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";
29397
+ 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
29398
  if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
28864
29399
  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`;
29400
+ if (!isRecord23(r) || !str19(r.path) || r.status !== "planned" && r.status !== "failed" || !Array.isArray(r.changes)) return `root ${i} lacks path, status or changes`;
29401
+ 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
29402
  }
28868
29403
  } 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";
29404
+ if (!str19(doc.generated) || !isRecord23(doc.totals) || !Array.isArray(doc.projects)) return "it lacks generated, totals or projects";
29405
+ for (const p of doc.projects) if (!isRecord23(p) || !str19(p.project) || !Array.isArray(p.waiting)) return "a project lacks project or waiting";
28871
29406
  }
28872
29407
  return void 0;
28873
29408
  }
28874
29409
  var compiledSchemas = /* @__PURE__ */ new Map();
28875
29410
  function schemaStamp(dist) {
28876
29411
  try {
28877
- const files = [join43(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join43(dist, f))];
29412
+ const files = [join44(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join44(dist, f))];
28878
29413
  return [dist, ...files.map((f) => {
28879
29414
  const st = statSync11(f);
28880
29415
  return `${st.mtimeMs}:${st.size}`;
@@ -28884,15 +29419,15 @@ function schemaStamp(dist) {
28884
29419
  }
28885
29420
  }
28886
29421
  function compileSchemas(dist) {
28887
- const version = JSON.parse(readFileSync32(join43(dist, "..", "package.json"), "utf8")).version ?? "";
28888
- const ajv = new Ajv20204({ strict: false, allErrors: false });
29422
+ const version = JSON.parse(readFileSync33(join44(dist, "..", "package.json"), "utf8")).version ?? "";
29423
+ const ajv = new Ajv20205({ strict: false, allErrors: false });
28889
29424
  const compiled4 = Object.fromEntries(
28890
- Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync32(join43(dist, SCHEMA_FILES[n]), "utf8")))])
29425
+ Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync33(join44(dist, SCHEMA_FILES[n]), "utf8")))])
28891
29426
  );
28892
29427
  return {
28893
29428
  validation: { by: "schema", terragucci: version },
28894
29429
  check(name, doc) {
28895
- const id = isRecord22(doc) ? doc.schema : void 0;
29430
+ const id = isRecord23(doc) ? doc.schema : void 0;
28896
29431
  if (id !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(id)}, not ${SCHEMA_IDS[name]}`;
28897
29432
  if (compiled4[name](doc)) return void 0;
28898
29433
  const e = compiled4[name].errors?.[0];
@@ -28904,7 +29439,7 @@ function terragucciValidator(dirs = []) {
28904
29439
  for (const from of [...dirs, dirname11(fileURLToPath7(import.meta.url))]) {
28905
29440
  let entry;
28906
29441
  try {
28907
- entry = createRequire4(join43(resolve24(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
29442
+ entry = createRequire4(join44(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
28908
29443
  } catch {
28909
29444
  continue;
28910
29445
  }
@@ -28927,7 +29462,7 @@ function terragucciValidator(dirs = []) {
28927
29462
  }
28928
29463
  function waveBlocked(w) {
28929
29464
  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 }] : []);
29465
+ 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
29466
  }
28932
29467
  var RESULT_COMMITS = 4;
28933
29468
  function waveResult(w, finished) {
@@ -29018,7 +29553,7 @@ async function readTerragucci(source2, opts = {}) {
29018
29553
  }
29019
29554
  const project = pickProject(index.reports, opts, source2);
29020
29555
  const rows = index.reports.filter((r) => r.project === project).sort(newestFirst);
29021
- const cache6 = /* @__PURE__ */ new Map();
29556
+ const cache7 = /* @__PURE__ */ new Map();
29022
29557
  const facts = {};
29023
29558
  const seenRoots = /* @__PURE__ */ new Set();
29024
29559
  const note = (doc) => {
@@ -29031,12 +29566,12 @@ async function readTerragucci(source2, opts = {}) {
29031
29566
  };
29032
29567
  const report = (row) => {
29033
29568
  const key3 = under(row.path, "report.json");
29034
- if (!cache6.has(key3)) {
29569
+ if (!cache7.has(key3)) {
29035
29570
  const p = readDoc2(source2, key3, "report", v);
29036
- cache6.set(key3, p);
29571
+ cache7.set(key3, p);
29037
29572
  void p.then(note, () => void 0);
29038
29573
  }
29039
- return cache6.get(key3);
29574
+ return cache7.get(key3);
29040
29575
  };
29041
29576
  const wanted = opts.roots ? new Set(opts.roots) : void 0;
29042
29577
  const roots = {};
@@ -29140,7 +29675,7 @@ async function readTerragucci(source2, opts = {}) {
29140
29675
  if (commit && Object.keys(found).length) blocked = { commit, roots: found };
29141
29676
  if (commit && Object.keys(own).length) outcomes2 = { commit, roots: own };
29142
29677
  }
29143
- const results = {};
29678
+ const results2 = {};
29144
29679
  {
29145
29680
  const applies = rows.filter((r) => r.stage === "tf-apply" && r.wave !== void 0);
29146
29681
  for (const commit of [...new Set(applies.map((r) => r.commit))].slice(0, RESULT_COMMITS)) {
@@ -29153,11 +29688,11 @@ async function readTerragucci(source2, opts = {}) {
29153
29688
  const res = waveResult(doc?.waves.find((w) => w.number === r.wave) ?? doc?.waves[0], doc?.run.finished ?? r.finished);
29154
29689
  if (res) out.push({ ...res, wave: r.wave });
29155
29690
  }
29156
- if (out.length) results[commit] = out.sort((a, b) => a.wave - b.wave);
29691
+ if (out.length) results2[commit] = out.sort((a, b) => a.wave - b.wave);
29157
29692
  }
29158
29693
  }
29159
29694
  if (pullRequest && prRow && prDoc) {
29160
- await Promise.all([...cache6.values()].map((p) => p.catch(() => void 0)));
29695
+ await Promise.all([...cache7.values()].map((p) => p.catch(() => void 0)));
29161
29696
  const planned = prDoc.roots.some((r) => r.cone !== void 0) ? await readConePlans(source2, prRow.path, prDoc) : {};
29162
29697
  const cone = coneView(prDoc, { roots: [.../* @__PURE__ */ new Set([...opts.roots ?? [], ...seenRoots])], planned, facts });
29163
29698
  if (cone) pullRequest.cone = cone;
@@ -29168,7 +29703,7 @@ async function readTerragucci(source2, opts = {}) {
29168
29703
  project,
29169
29704
  validation: v.validation,
29170
29705
  read: (opts.now ?? /* @__PURE__ */ new Date()).toISOString(),
29171
- reports: cache6.size,
29706
+ reports: cache7.size,
29172
29707
  roots,
29173
29708
  waiting,
29174
29709
  ...pullRequest ? { pull_request: pullRequest } : {},
@@ -29186,7 +29721,7 @@ async function readTerragucci(source2, opts = {}) {
29186
29721
  } : {},
29187
29722
  ...blocked ? { blocked } : {},
29188
29723
  ...outcomes2 ? { outcomes: outcomes2 } : {},
29189
- ...Object.keys(results).length ? { results } : {}
29724
+ ...Object.keys(results2).length ? { results: results2 } : {}
29190
29725
  };
29191
29726
  }
29192
29727
  function pullRequestPlan(doc, report) {
@@ -29367,11 +29902,11 @@ function joinTerragucci(read, nodes, roots) {
29367
29902
  }
29368
29903
 
29369
29904
  // src/terragucci-timeline.ts
29370
- import { readFileSync as readFileSync33, statSync as statSync12 } from "node:fs";
29905
+ import { readFileSync as readFileSync34, statSync as statSync12 } from "node:fs";
29371
29906
  import { createRequire as createRequire5 } from "node:module";
29372
- import { dirname as dirname12, join as join44, resolve as resolve25 } from "node:path";
29907
+ import { dirname as dirname12, join as join45, resolve as resolve26 } from "node:path";
29373
29908
  import { fileURLToPath as fileURLToPath8 } from "node:url";
29374
- import { Ajv2020 as Ajv20205 } from "ajv/dist/2020.js";
29909
+ import { Ajv2020 as Ajv20206 } from "ajv/dist/2020.js";
29375
29910
  var AUDIT_SCHEMA = "terragucci.audit/v1";
29376
29911
  var AUDIT_KEY = "audit.jsonl";
29377
29912
  var AUDIT_SCHEMA_FILE = "audit.schema.json";
@@ -29379,25 +29914,25 @@ var WHAT_IS_ROOT = /* @__PURE__ */ new Set(["override-requested", "override", "o
29379
29914
  var TIMELINE_LIMIT = 200;
29380
29915
  var TIMELINE_MAX = 1e3;
29381
29916
  var TIMELINE_TTL_MS = 3e4;
29382
- var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29917
+ var isRecord24 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29383
29918
  var str20 = (v) => typeof v === "string";
29384
29919
  function structuralAudit(doc) {
29385
- if (!isRecord23(doc)) return "it is not a JSON object";
29920
+ if (!isRecord24(doc)) return "it is not a JSON object";
29386
29921
  if (doc.schema !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${AUDIT_SCHEMA}`;
29387
29922
  for (const f of ["id", "kind", "project", "at", "what", "result"]) if (!str20(doc[f])) return `its ${f} is not a string`;
29388
29923
  if (Number.isNaN(Date.parse(doc.at))) return `its at, ${JSON.stringify(doc.at)}, is not a time`;
29389
29924
  if (doc.who !== null && !str20(doc.who)) return "its who is neither a string nor null";
29390
29925
  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";
29926
+ if (!isRecord24(doc.evidence) || !str20(doc.evidence.source)) return "its evidence has no source";
29927
+ if (doc.detail !== void 0 && !isRecord24(doc.detail)) return "its detail is not an object";
29393
29928
  return void 0;
29394
29929
  }
29395
29930
  function compileAuditSchema(schema, version) {
29396
- const v = new Ajv20205({ strict: false, allErrors: false }).compile(schema);
29931
+ const v = new Ajv20206({ strict: false, allErrors: false }).compile(schema);
29397
29932
  return {
29398
29933
  validation: { by: "schema", terragucci: version },
29399
29934
  check(doc) {
29400
- const id = isRecord23(doc) ? doc.schema : void 0;
29935
+ const id = isRecord24(doc) ? doc.schema : void 0;
29401
29936
  if (id !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${AUDIT_SCHEMA}`;
29402
29937
  if (v(doc)) return void 0;
29403
29938
  const e = v.errors?.[0];
@@ -29410,12 +29945,12 @@ function auditValidator(dirs = []) {
29410
29945
  for (const from of [...dirs, dirname12(fileURLToPath8(import.meta.url))]) {
29411
29946
  let dist;
29412
29947
  try {
29413
- dist = dirname12(createRequire5(join44(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
29948
+ dist = dirname12(createRequire5(join45(resolve26(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
29414
29949
  } catch {
29415
29950
  continue;
29416
29951
  }
29417
- const pkg = join44(dist, "..", "package.json");
29418
- const file = join44(dist, AUDIT_SCHEMA_FILE);
29952
+ const pkg = join45(dist, "..", "package.json");
29953
+ const file = join45(dist, AUDIT_SCHEMA_FILE);
29419
29954
  let stamp;
29420
29955
  try {
29421
29956
  stamp = [dist, ...[pkg, file].map((f) => {
@@ -29429,8 +29964,8 @@ function auditValidator(dirs = []) {
29429
29964
  if (hit) return hit;
29430
29965
  let v;
29431
29966
  try {
29432
- const version = JSON.parse(readFileSync33(pkg, "utf8")).version ?? "";
29433
- v = compileAuditSchema(JSON.parse(readFileSync33(file, "utf8")), version);
29967
+ const version = JSON.parse(readFileSync34(pkg, "utf8")).version ?? "";
29968
+ v = compileAuditSchema(JSON.parse(readFileSync34(file, "utf8")), version);
29434
29969
  } catch {
29435
29970
  continue;
29436
29971
  }
@@ -29472,8 +30007,8 @@ function ownRoots(e) {
29472
30007
  if (Array.isArray(listed)) {
29473
30008
  for (const r of listed) {
29474
30009
  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);
30010
+ else if (isRecord24(r) && str20(r.root)) roots.add(r.root);
30011
+ else if (isRecord24(r) && str20(r.path)) roots.add(r.path);
29477
30012
  }
29478
30013
  }
29479
30014
  if (WHAT_IS_ROOT.has(e.kind)) roots.add(e.what);
@@ -29628,7 +30163,7 @@ function terragucciTimelineRoute(app, source2, opts = {}) {
29628
30163
  // src/terragucci-poll.ts
29629
30164
  import { createHash as createHash10 } from "node:crypto";
29630
30165
  import { stat as stat2 } from "node:fs/promises";
29631
- import { join as join45, resolve as resolve26 } from "node:path";
30166
+ import { join as join46, resolve as resolve27 } from "node:path";
29632
30167
  import { streamSSE } from "hono/streaming";
29633
30168
  var TERRAGUCCI_POLL_SECS = 30;
29634
30169
  var INDEX_KEY = "index.json";
@@ -29679,7 +30214,7 @@ function indexProbe(spec2, opts = {}) {
29679
30214
  return verdict2(prev, etag);
29680
30215
  };
29681
30216
  }
29682
- const file = join45(resolve26(opts.cwd ?? process.cwd(), spec2), name);
30217
+ const file = join46(resolve27(opts.cwd ?? process.cwd(), spec2), name);
29683
30218
  return async (prev) => {
29684
30219
  try {
29685
30220
  const s = await stat2(file);
@@ -29834,29 +30369,29 @@ function terragucciLaneRoutes(app, o, base, forget) {
29834
30369
  }
29835
30370
 
29836
30371
  // src/terragucci-progress.ts
29837
- import { readFileSync as readFileSync34, statSync as statSync13 } from "node:fs";
30372
+ import { readFileSync as readFileSync35, statSync as statSync13 } from "node:fs";
29838
30373
  import { createRequire as createRequire6 } from "node:module";
29839
- import { dirname as dirname13, join as join46, resolve as resolve27 } from "node:path";
30374
+ import { dirname as dirname13, join as join47, resolve as resolve28 } from "node:path";
29840
30375
  import { fileURLToPath as fileURLToPath9 } from "node:url";
29841
- import { Ajv2020 as Ajv20206 } from "ajv/dist/2020.js";
30376
+ import { Ajv2020 as Ajv20207 } from "ajv/dist/2020.js";
29842
30377
  var RUN_SCHEMA = "terragucci.run/v1";
29843
30378
  var RUN_SCHEMA_FILE = "run.schema.json";
29844
30379
  var PROGRESS_TTL_MS = 3e4;
29845
30380
  var PROGRESS_STATUSES = ["done", "in-flight", "waiting", "not-applied"];
29846
- var isRecord24 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
30381
+ var isRecord25 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
29847
30382
  var str21 = (v) => typeof v === "string";
29848
30383
  function structuralRun(doc) {
29849
- if (!isRecord24(doc)) return "it is not a JSON object";
30384
+ if (!isRecord25(doc)) return "it is not a JSON object";
29850
30385
  if (doc.schema !== RUN_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA}`;
29851
30386
  for (const f of ["project", "commit", "updated"]) if (!str21(doc[f])) return `its ${f} is not a string`;
29852
30387
  if (!Array.isArray(doc.waves)) return "it has no waves array";
29853
30388
  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`;
30389
+ 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
30390
  if (w.progress === void 0) continue;
29856
30391
  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`;
30392
+ if (!isRecord25(p) || !str21(p.read) || !Array.isArray(p.resources)) return `wave ${String(w.number)}'s progress lacks read or resources`;
29858
30393
  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`;
30394
+ 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
30395
  if (!PROGRESS_STATUSES.includes(r.status)) return `a resource of wave ${String(w.number)}'s progress has status ${JSON.stringify(r.status)}`;
29861
30396
  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
30397
  }
@@ -29864,11 +30399,11 @@ function structuralRun(doc) {
29864
30399
  return void 0;
29865
30400
  }
29866
30401
  function compileRunSchema(schema, version) {
29867
- const v = new Ajv20206({ strict: false, allErrors: false }).compile(schema);
30402
+ const v = new Ajv20207({ strict: false, allErrors: false }).compile(schema);
29868
30403
  return {
29869
30404
  validation: { by: "schema", terragucci: version },
29870
30405
  check(doc) {
29871
- const id = isRecord24(doc) ? doc.schema : void 0;
30406
+ const id = isRecord25(doc) ? doc.schema : void 0;
29872
30407
  if (id !== RUN_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA}`;
29873
30408
  if (v(doc)) return void 0;
29874
30409
  const e = v.errors?.[0];
@@ -29881,12 +30416,12 @@ function runValidator(dirs = []) {
29881
30416
  for (const from of [...dirs, dirname13(fileURLToPath9(import.meta.url))]) {
29882
30417
  let dist;
29883
30418
  try {
29884
- dist = dirname13(createRequire6(join46(resolve27(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
30419
+ dist = dirname13(createRequire6(join47(resolve28(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
29885
30420
  } catch {
29886
30421
  continue;
29887
30422
  }
29888
- const pkg = join46(dist, "..", "package.json");
29889
- const file = join46(dist, RUN_SCHEMA_FILE);
30423
+ const pkg = join47(dist, "..", "package.json");
30424
+ const file = join47(dist, RUN_SCHEMA_FILE);
29890
30425
  let stamp;
29891
30426
  try {
29892
30427
  stamp = [dist, ...[pkg, file].map((f) => {
@@ -29900,8 +30435,8 @@ function runValidator(dirs = []) {
29900
30435
  if (hit) return hit;
29901
30436
  let v;
29902
30437
  try {
29903
- const version = JSON.parse(readFileSync34(pkg, "utf8")).version ?? "";
29904
- v = compileRunSchema(JSON.parse(readFileSync34(file, "utf8")), version);
30438
+ const version = JSON.parse(readFileSync35(pkg, "utf8")).version ?? "";
30439
+ v = compileRunSchema(JSON.parse(readFileSync35(file, "utf8")), version);
29905
30440
  } catch {
29906
30441
  continue;
29907
30442
  }
@@ -30096,7 +30631,7 @@ var TerragucciProgress = class {
30096
30631
  /** One GET of run.json, checked and joined. */
30097
30632
  async readRun(project, commit, key3, v) {
30098
30633
  const src = this.o.source;
30099
- const validator4 = v ?? runValidator();
30634
+ const validator5 = v ?? runValidator();
30100
30635
  let text3;
30101
30636
  let unreadable;
30102
30637
  try {
@@ -30111,7 +30646,7 @@ var TerragucciProgress = class {
30111
30646
  const html = key3.replace(/run\.json$/, "run.html");
30112
30647
  if (text3 === void 0) {
30113
30648
  return {
30114
- ...this.base(project, validator4.validation),
30649
+ ...this.base(project, validator5.validation),
30115
30650
  run: { commit, key: key3, present: false },
30116
30651
  ...unreadable ? { unreadable: true } : {},
30117
30652
  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 +30664,11 @@ var TerragucciProgress = class {
30129
30664
  } catch {
30130
30665
  refuse12(`${key3} in ${src.location} is not JSON.`, "Check that terragucci wrote it.");
30131
30666
  }
30132
- const why = validator4.check(doc);
30667
+ const why = validator5.check(doc);
30133
30668
  if (why) {
30134
30669
  refuse12(
30135
30670
  `${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."
30671
+ 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
30672
  );
30138
30673
  }
30139
30674
  const run4 = doc;
@@ -30144,7 +30679,7 @@ var TerragucciProgress = class {
30144
30679
  throw new ProgressGraphError(`behold could not read the checkout's roots to place the progress on: ${e instanceof Error ? e.message : String(e)}`);
30145
30680
  }
30146
30681
  return {
30147
- ...this.base(project, validator4.validation),
30682
+ ...this.base(project, validator5.validation),
30148
30683
  run: { commit, key: key3, present: true, updated: run4.updated, html },
30149
30684
  ...joinProgress(run4, ctx.nodes, ctx.roots)
30150
30685
  };
@@ -30195,21 +30730,21 @@ function terragucciProgressRoute(app, progress) {
30195
30730
  }
30196
30731
 
30197
30732
  // 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";
30733
+ import { readFileSync as readFileSync36, readdirSync as readdirSync17, existsSync as existsSync29 } from "node:fs";
30734
+ import { dirname as dirname14, join as join48 } from "node:path";
30200
30735
  import { fileURLToPath as fileURLToPath10 } from "node:url";
30201
- import { Ajv2020 as Ajv20207 } from "ajv/dist/2020.js";
30736
+ import { Ajv2020 as Ajv20208 } from "ajv/dist/2020.js";
30202
30737
  var TOUR_SCHEMA_ID = "behold.tour/v1";
30203
- var isRecord25 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30738
+ var isRecord26 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30204
30739
  var str22 = (v) => typeof v === "string" && v.length > 0;
30205
30740
  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;
30741
+ var webRoot = join48(dirname14(fileURLToPath10(import.meta.url)), "..", "web");
30742
+ var TOURS_DIR = join48(webRoot, "tours");
30743
+ var TOUR_SCHEMA_FILE = join48(TOURS_DIR, "behold.tour.v1.schema.json");
30744
+ var validator4 = null;
30210
30745
  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)) {
30746
+ if (!validator4) validator4 = new Ajv20208({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync36(TOUR_SCHEMA_FILE, "utf8")));
30747
+ if (validator4(doc)) {
30213
30748
  const t2 = doc;
30214
30749
  const runs2 = new Set(Object.keys(t2.runs ?? {}));
30215
30750
  const facts = new Set(Object.keys(t2.facts ?? {}));
@@ -30229,11 +30764,11 @@ function tourProblem(doc) {
30229
30764
  }
30230
30765
  return void 0;
30231
30766
  }
30232
- const e = validator3.errors?.[0];
30767
+ const e = validator4.errors?.[0];
30233
30768
  return e ? `${e.instancePath || "the file"} ${e.message ?? "is not behold.tour/v1"}` : "it is not behold.tour/v1";
30234
30769
  }
30235
30770
  function toursIn(dir, from, problems) {
30236
- if (!existsSync28(dir)) return [];
30771
+ if (!existsSync29(dir)) return [];
30237
30772
  const out = [];
30238
30773
  let names = [];
30239
30774
  try {
@@ -30244,25 +30779,25 @@ function toursIn(dir, from, problems) {
30244
30779
  for (const f of names) {
30245
30780
  let doc;
30246
30781
  try {
30247
- doc = JSON.parse(readFileSync35(join47(dir, f), "utf8"));
30782
+ doc = JSON.parse(readFileSync36(join48(dir, f), "utf8"));
30248
30783
  } catch {
30249
- problems.push(`${join47(dir, f)} is not JSON`);
30784
+ problems.push(`${join48(dir, f)} is not JSON`);
30250
30785
  continue;
30251
30786
  }
30252
30787
  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)) });
30788
+ if (p) problems.push(`${join48(dir, f)} is not a ${TOUR_SCHEMA_ID} tour: ${p}`);
30789
+ else out.push({ tour: doc, from: from(join48(dir, f)) });
30255
30790
  }
30256
30791
  return out;
30257
30792
  }
30258
30793
  function findTour(demo, dirs, problems, shipped = TOURS_DIR) {
30259
30794
  if (!demo) return null;
30260
- const all = [...dirs.flatMap((d) => toursIn(join47(d, ".behold", "tours"), (f) => f, problems)), ...toursIn(shipped, () => "behold", problems)];
30795
+ const all = [...dirs.flatMap((d) => toursIn(join48(d, ".behold", "tours"), (f) => f, problems)), ...toursIn(shipped, () => "behold", problems)];
30261
30796
  const fits = (t2) => !!t2.match && Object.entries(t2.match).every(([k, v]) => demo[k] === v);
30262
30797
  return all.find((t2) => fits(t2.tour)) ?? null;
30263
30798
  }
30264
30799
  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;
30800
+ if (!isRecord26(v) || !str22(v.project) || !str22(v.commit) || !str22(v.stage) || !str22(v.finished) || !str22(v.path)) return void 0;
30266
30801
  return {
30267
30802
  project: v.project,
30268
30803
  commit: v.commit,
@@ -30301,14 +30836,14 @@ async function readDoc3(source2, k, problems) {
30301
30836
  var keyOf = (...p) => p.join("/").split("/").filter((s) => s && s !== ".").join("/");
30302
30837
  var rootPath = (p) => p.replace(/^\.\/+/, "").replace(/\/+$/, "") || ".";
30303
30838
  function planCounts(report, roots = null) {
30304
- if (!isRecord25(report) || !Array.isArray(report.roots)) return null;
30839
+ if (!isRecord26(report) || !Array.isArray(report.roots)) return null;
30305
30840
  let planned = 0;
30306
30841
  let changed = 0;
30307
30842
  let recreated = 0;
30308
30843
  let deleted = 0;
30309
30844
  let any = false;
30310
30845
  for (const r of report.roots) {
30311
- if (!isRecord25(r) || !isRecord25(r.counts)) continue;
30846
+ if (!isRecord26(r) || !isRecord26(r.counts)) continue;
30312
30847
  if (roots && !roots.includes(rootPath(String(r.path ?? ".")))) continue;
30313
30848
  any = true;
30314
30849
  for (const [a, n] of Object.entries(r.counts)) {
@@ -30322,24 +30857,24 @@ function planCounts(report, roots = null) {
30322
30857
  return any ? { planned, changed, recreated, deleted } : null;
30323
30858
  }
30324
30859
  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;
30860
+ if (n === void 0 || !isRecord26(report) || !Array.isArray(report.waves)) return null;
30861
+ const w = report.waves.find((x) => isRecord26(x) && x.number === n);
30862
+ return isRecord26(w) && Array.isArray(w.roots) ? w.roots.filter(str22).map(rootPath) : null;
30328
30863
  }
30329
30864
  function planAddresses(plan) {
30330
- if (!isRecord25(plan) || !Array.isArray(plan.resource_changes)) return [];
30865
+ if (!isRecord26(plan) || !Array.isArray(plan.resource_changes)) return [];
30331
30866
  const out = [];
30332
30867
  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) : [];
30868
+ if (!isRecord26(rc) || !str22(rc.address) || rc.mode === "data") continue;
30869
+ const acts = isRecord26(rc.change) && Array.isArray(rc.change.actions) ? rc.change.actions.filter(str22) : [];
30335
30870
  out.push({ address: rc.address, changed: !acts.every((a) => a === "no-op" || a === "read") });
30336
30871
  }
30337
30872
  return out;
30338
30873
  }
30339
30874
  function plannedOutput(plan, name) {
30340
- if (!isRecord25(plan) || !isRecord25(plan.output_changes)) return void 0;
30875
+ if (!isRecord26(plan) || !isRecord26(plan.output_changes)) return void 0;
30341
30876
  const o = plan.output_changes[name];
30342
- if (!isRecord25(o) || o.after_unknown === true || o.after_sensitive === true) return void 0;
30877
+ if (!isRecord26(o) || o.after_unknown === true || o.after_sensitive === true) return void 0;
30343
30878
  const v = o.after;
30344
30879
  return typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? v : void 0;
30345
30880
  }
@@ -30387,7 +30922,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30387
30922
  } catch {
30388
30923
  problems.push(`${project}/index.json is not JSON`);
30389
30924
  }
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));
30925
+ 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
30926
  rows.set(project, list4);
30392
30927
  return list4;
30393
30928
  };
@@ -30396,7 +30931,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30396
30931
  let row;
30397
30932
  if (spec2.migration) {
30398
30933
  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;
30934
+ const commit = m && isRecord26(m.record) && str22(m.record.commit) ? m.record.commit : null;
30400
30935
  if (m && commit) row = (await rowsOf(m.home)).find((r) => r.commit === commit && r.stage === "tf-apply");
30401
30936
  } else if (spec2.repo && spec2.stage) {
30402
30937
  const project = projectOf(spec2.repo);
@@ -30412,12 +30947,12 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30412
30947
  }
30413
30948
  const reportOf = async (f) => f.report ??= await readDoc3(source2, keyOf(f.row.project, f.row.path, "report.json"), problems);
30414
30949
  const planOf = async (f, root) => {
30415
- const p = isRecord25(root.plan) && str22(root.plan.json) ? root.plan.json : null;
30950
+ const p = isRecord26(root.plan) && str22(root.plan.json) ? root.plan.json : null;
30416
30951
  return p ? readDoc3(source2, keyOf(f.row.project, f.row.path, p), problems) : void 0;
30417
30952
  };
30418
30953
  const rootsOf = async (f) => {
30419
30954
  const rep = await reportOf(f);
30420
- return isRecord25(rep) && Array.isArray(rep.roots) ? rep.roots.filter(isRecord25) : [];
30955
+ return isRecord26(rep) && Array.isArray(rep.roots) ? rep.roots.filter(isRecord26) : [];
30421
30956
  };
30422
30957
  const recordEstates = /* @__PURE__ */ new Map();
30423
30958
  const note = (project, root, estate) => {
@@ -30427,13 +30962,13 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30427
30962
  recordEstates.get(k).add(estate);
30428
30963
  };
30429
30964
  for (const m of ctx.migrations) {
30430
- const rec7 = isRecord25(m.record) ? m.record : null;
30965
+ const rec7 = isRecord26(m.record) ? m.record : null;
30431
30966
  if (!rec7) continue;
30432
- for (const r of Array.isArray(rec7.retags) ? rec7.retags.filter(isRecord25) : []) {
30967
+ for (const r of Array.isArray(rec7.retags) ? rec7.retags.filter(isRecord26) : []) {
30433
30968
  note(m.home, r.to, r.to_estate);
30434
30969
  note(m.home, r.from, r.from_estate);
30435
30970
  }
30436
- for (const r of Array.isArray(rec7.stamps) ? rec7.stamps.filter(isRecord25) : []) note(m.home, r.root, r.estate);
30971
+ for (const r of Array.isArray(rec7.stamps) ? rec7.stamps.filter(isRecord26) : []) note(m.home, r.root, r.estate);
30437
30972
  }
30438
30973
  const estatesOf = (project, root) => {
30439
30974
  const rp = rootPath(root);
@@ -30443,7 +30978,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30443
30978
  const facts = {};
30444
30979
  const recordOf = (name) => {
30445
30980
  const m = ctx.migrations.find((x) => x.name === name);
30446
- return m && isRecord25(m.record) ? m.record : null;
30981
+ return m && isRecord26(m.record) ? m.record : null;
30447
30982
  };
30448
30983
  for (const [name, f] of Object.entries(t2.facts ?? {})) {
30449
30984
  let v;
@@ -30466,10 +31001,10 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30466
31001
  } else if ("migration" in f) {
30467
31002
  const rec7 = recordOf(f.migration);
30468
31003
  if (!rec7) continue;
30469
- const p = isRecord25(rec7.progress) ? rec7.progress : null;
31004
+ const p = isRecord26(rec7.progress) ? rec7.progress : null;
30470
31005
  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;
31006
+ const root = Array.isArray(rec7.roots) ? rec7.roots.find((x) => isRecord26(x) && isRecord26(x.source) && str22(x.source.version_id)) : void 0;
31007
+ if (isRecord26(root) && isRecord26(root.source)) v = root.source.version_id;
30473
31008
  } else if (f.value === "approved_by") v = str22(rec7.approved_by) ? rec7.approved_by : void 0;
30474
31009
  else if (f.value === "moved_resources" || f.value === "stamped_resources" || f.value === "refused_resources") {
30475
31010
  const m = ctx.migrations.find((x) => x.name === f.migration);
@@ -30481,7 +31016,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30481
31016
  } else if ("sum" in f) {
30482
31017
  if (f.sum.every((x) => typeof facts[x] === "number")) v = f.sum.reduce((s, x) => s + facts[x], 0);
30483
31018
  } else if ("approvals" in f) {
30484
- const migs = ctx.migrations.filter((m) => isRecord25(m.record) && str22(m.record.approved_by)).length;
31019
+ const migs = ctx.migrations.filter((m) => isRecord26(m.record) && str22(m.record.approved_by)).length;
30485
31020
  let waves = 0;
30486
31021
  for (const list4 of rows.values()) waves += list4.filter((r) => r.stage === "tf-apply" && r.approval === "approved").length;
30487
31022
  if (ctx.migrations.length || rows.size) v = migs + waves;
@@ -30533,7 +31068,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30533
31068
  const threads = [];
30534
31069
  let value;
30535
31070
  for (const root of roots) {
30536
- const reads2 = Array.isArray(root.reads) ? root.reads.filter(isRecord25) : [];
31071
+ const reads2 = Array.isArray(root.reads) ? root.reads.filter(isRecord26) : [];
30537
31072
  for (const rd of reads2) {
30538
31073
  if (!str22(rd.upstream)) continue;
30539
31074
  threads.push({ from: estatesOf(r.row.project, rd.upstream), to: estatesOf(r.row.project, String(root.path ?? ".")) });
@@ -30548,8 +31083,8 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30548
31083
  }
30549
31084
  if (s.state) {
30550
31085
  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;
31086
+ const root = rec7 && Array.isArray(rec7.roots) ? rec7.roots.find((x) => isRecord26(x) && isRecord26(x.source) && str22(x.source.version_id)) : void 0;
31087
+ if (!isRecord26(root) || !isRecord26(root.source)) return null;
30553
31088
  const m = ctx.migrations.find((x) => x.name === s.state);
30554
31089
  return {
30555
31090
  ...base,
@@ -30565,7 +31100,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30565
31100
  if (s.checks) {
30566
31101
  const r = found.get(s.checks);
30567
31102
  if (!r) return null;
30568
- const checks = (await rootsOf(r)).filter((x) => isRecord25(x.counts)).map((x) => {
31103
+ const checks = (await rootsOf(r)).filter((x) => isRecord26(x.counts)).map((x) => {
30569
31104
  const rp = rootPath(String(x.path ?? "."));
30570
31105
  const counts = x.counts;
30571
31106
  return { root: rp, estates: estatesOf(r.row.project, rp), noChange: Object.entries(counts).every(([a, n]) => a === "no-op" || !n), counts };
@@ -30600,14 +31135,14 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30600
31135
  const ats = m.lines.map((l) => Date.parse(l.at)).filter((x) => !Number.isNaN(x));
30601
31136
  if (!ats.length) continue;
30602
31137
  events.push({ kind: "line", migration: m.name, line: "first", at: Math.min(...ats) });
30603
- const rec7 = isRecord25(m.record) ? m.record : null;
31138
+ const rec7 = isRecord26(m.record) ? m.record : null;
30604
31139
  const done = !m.running && !!rec7 && (str22(rec7.finished) || str22(rec7.status) && FINAL.has(rec7.status));
30605
31140
  if (done) events.push({ kind: "line", migration: m.name, line: "last", at: Math.max(...ats) });
30606
31141
  }
30607
- const runs2 = isRecord25(runsIndex) && Array.isArray(runsIndex.runs) ? runsIndex.runs.filter(isRecord25) : [];
31142
+ const runs2 = isRecord26(runsIndex) && Array.isArray(runsIndex.runs) ? runsIndex.runs.filter(isRecord26) : [];
30608
31143
  for (const run4 of runs2) {
30609
31144
  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) : []) {
31145
+ for (const j of Array.isArray(run4.jobs) ? run4.jobs.filter(isRecord26) : []) {
30611
31146
  const w = str22(j.name) ? /^apply-wave-(\d+)$/.exec(j.name) : null;
30612
31147
  if (!w) continue;
30613
31148
  const wave = Number(w[1]);
@@ -30628,7 +31163,7 @@ async function resolveTour(source2, loaded, ctx, runsIndex) {
30628
31163
  }
30629
31164
  const migrationRuns = {};
30630
31165
  for (const m of ctx.migrations) {
30631
- const rec7 = isRecord25(m.record) ? m.record : null;
31166
+ const rec7 = isRecord26(m.record) ? m.record : null;
30632
31167
  const tool = rec7 && rec7.change === "adopt" ? "live-import" : "live-mv";
30633
31168
  const commit = rec7 && str22(rec7.commit) ? rec7.commit : null;
30634
31169
  const row = commit ? (await rowsOf(m.home)).find((r) => r.commit === commit && r.stage === "tf-apply") : void 0;
@@ -30657,13 +31192,13 @@ var CARVE_TOUR_TTL_MS = 3e3;
30657
31192
  var MAX_ROSTERS = 64;
30658
31193
  var MAX_MIGRATIONS = 8;
30659
31194
  var CARVE_OUTCOMES = ["moved", "stamped", "refused", "skipped"];
30660
- var isRecord26 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
31195
+ var isRecord27 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30661
31196
  var str23 = (v) => typeof v === "string" && v.length > 0;
30662
31197
  var count2 = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 ? v : null;
30663
31198
  var trim3 = (s) => s.replace(/^\/+|\/+$/g, "");
30664
31199
  var key = (...p) => p.map(trim3).filter(Boolean).join("/");
30665
31200
  function rosterResource(v) {
30666
- if (!isRecord26(v) || !str23(v.address)) return void 0;
31201
+ if (!isRecord27(v) || !str23(v.address)) return void 0;
30667
31202
  return {
30668
31203
  address: v.address,
30669
31204
  type: str23(v.type) ? v.type : /(?:^|\.)((?:aws|google|azurerm|kubernetes)_[a-z0-9_]+)\./.exec(v.address)?.[1] ?? "",
@@ -30673,7 +31208,7 @@ function rosterResource(v) {
30673
31208
  };
30674
31209
  }
30675
31210
  function progressLine(v) {
30676
- if (!isRecord26(v) || !str23(v.at) || !str23(v.address)) return void 0;
31211
+ if (!isRecord27(v) || !str23(v.at) || !str23(v.address)) return void 0;
30677
31212
  if (!CARVE_OUTCOMES.includes(v.outcome)) return void 0;
30678
31213
  const to = str23(v.estate_to) ? v.estate_to : str23(v.estate_from) ? v.estate_from : "";
30679
31214
  if (!to) return void 0;
@@ -30707,7 +31242,7 @@ function readProgress(text3, from = null) {
30707
31242
  if (line && !Number.isNaN(since) && Date.parse(line.at) < since) return;
30708
31243
  if (line) {
30709
31244
  lines2.push(line);
30710
- counts = countsIn(isRecord26(doc) ? doc.counts : void 0) ?? counts;
31245
+ counts = countsIn(isRecord27(doc) ? doc.counts : void 0) ?? counts;
30711
31246
  } else bad2++;
30712
31247
  });
30713
31248
  return { lines: lines2, bad: bad2, counts };
@@ -30718,11 +31253,11 @@ function countLines(lines2) {
30718
31253
  return c;
30719
31254
  }
30720
31255
  function countsIn(c) {
30721
- if (!isRecord26(c)) return null;
31256
+ if (!isRecord27(c)) return null;
30722
31257
  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
31258
  }
30724
31259
  function recordCounts(doc) {
30725
- return isRecord26(doc) ? countsIn(doc.progress) : null;
31260
+ return isRecord27(doc) ? countsIn(doc.progress) : null;
30726
31261
  }
30727
31262
  function demoMigration(next) {
30728
31263
  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 +31266,11 @@ function demoMigration(next) {
30731
31266
  var ESTATES_SCHEMA = "terragucci.estates/v1";
30732
31267
  var ESTATES_KEY = "estates.json";
30733
31268
  function estateEntries(doc) {
30734
- const list4 = isRecord26(doc) && Array.isArray(doc.estates) ? doc.estates : [];
31269
+ const list4 = isRecord27(doc) && Array.isArray(doc.estates) ? doc.estates : [];
30735
31270
  const out = [];
30736
31271
  const seen = /* @__PURE__ */ new Set();
30737
31272
  for (const e of list4) {
30738
- if (!isRecord26(e) || !str23(e.estate) || seen.has(e.estate) || !str23(e.roster)) continue;
31273
+ if (!isRecord27(e) || !str23(e.estate) || seen.has(e.estate) || !str23(e.roster)) continue;
30739
31274
  const roster = trim3(e.roster);
30740
31275
  if (roster.split("/").some((p) => p === ".." || p === "." || p === "")) continue;
30741
31276
  seen.add(e.estate);
@@ -30744,8 +31279,8 @@ function estateEntries(doc) {
30744
31279
  return out;
30745
31280
  }
30746
31281
  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();
31282
+ const rows = isRecord27(doc) && Array.isArray(doc.reports) ? doc.reports : [];
31283
+ return [...new Set(rows.filter(isRecord27).map((r) => r.project).filter(str23))].sort();
30749
31284
  };
30750
31285
  var FINISHED = /* @__PURE__ */ new Set(["applied", "refused", "failed", "proof-failed", "done", "finished"]);
30751
31286
  async function readText2(source2, k, problems) {
@@ -30780,7 +31315,7 @@ function recordTargets(doc) {
30780
31315
  const walk = (v, depth) => {
30781
31316
  if (depth > 6 || out.size >= 256) return;
30782
31317
  if (Array.isArray(v)) for (const x of v) walk(x, depth + 1);
30783
- else if (isRecord26(v))
31318
+ else if (isRecord27(v))
30784
31319
  for (const [k, x] of Object.entries(v)) {
30785
31320
  if ((k === "estate_to" || k === "to_estate") && str23(x)) out.add(x);
30786
31321
  else walk(x, depth + 1);
@@ -30851,7 +31386,7 @@ function inCycle(startedAt, lines2, finished, modified) {
30851
31386
  return lines2.some((l) => after2(l.at)) || after2(finished) || after2(modified);
30852
31387
  }
30853
31388
  function adoptedInto(record, lines2) {
30854
- const stamps = isRecord26(record) && Array.isArray(record.stamps) ? record.stamps.filter(isRecord26) : [];
31389
+ const stamps = isRecord27(record) && Array.isArray(record.stamps) ? record.stamps.filter(isRecord27) : [];
30855
31390
  const pairs = new Set(stamps.filter((x) => str23(x.estate)).map((x) => `${x.estate}\0${str23(x.root) ? x.root : ""}`));
30856
31391
  if (pairs.size === 1) {
30857
31392
  const [estate, root] = [...pairs][0].split("\0");
@@ -30860,7 +31395,7 @@ function adoptedInto(record, lines2) {
30860
31395
  if (pairs.size > 1) return null;
30861
31396
  const into = new Set(lines2.filter((l) => l.outcome === "stamped").map((l) => l.estate_to));
30862
31397
  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) : [];
31398
+ const roots = isRecord27(record) && Array.isArray(record.roots) ? record.roots.filter(isRecord27).map((r) => r.root).filter(str23) : [];
30864
31399
  return { estate: [...into][0], root: roots.length === 1 ? roots[0] : null };
30865
31400
  }
30866
31401
  function replaceAdopted(entries, adoptions) {
@@ -30886,7 +31421,7 @@ async function readCarve2(source2, opts) {
30886
31421
  const base = { source: source2.location, read: now.toISOString() };
30887
31422
  const problems = [];
30888
31423
  const estatesDoc = parse(await readText2(source2, ESTATES_KEY, problems), ESTATES_KEY, problems);
30889
- const isEstates = isRecord26(estatesDoc) && estatesDoc.schema === ESTATES_SCHEMA;
31424
+ const isEstates = isRecord27(estatesDoc) && estatesDoc.schema === ESTATES_SCHEMA;
30890
31425
  if (estatesDoc !== void 0 && !isEstates) problems.push(`${ESTATES_KEY} is not a ${ESTATES_SCHEMA} document`);
30891
31426
  const all = isEstates ? estateEntries(estatesDoc) : [];
30892
31427
  const demoAnswer = await readDemo(source2, now);
@@ -30945,8 +31480,8 @@ async function readCarve2(source2, opts) {
30945
31480
  }
30946
31481
  }
30947
31482
  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;
31483
+ const status2 = isRecord27(record) && str23(record.status) ? record.status : null;
31484
+ const finished = isRecord27(record) && str23(record.finished) ? record.finished : null;
30950
31485
  if (f.listed && !inCycle(startedAt, lines2, finished, f.listed.modified)) continue;
30951
31486
  if (home !== null) opts.places?.set(m.name, home);
30952
31487
  if (home !== null && f.listed) opts.remembered?.add(m.name);
@@ -30962,7 +31497,7 @@ async function readCarve2(source2, opts) {
30962
31497
  if (into) adoptions.push({ ...into, project: home, migration: m.name });
30963
31498
  }
30964
31499
  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 });
31500
+ migrations.push({ name: m.name, progress, lines: lines2, counts, status: status2, finished, running, change: isRecord27(record) && str23(record.change) ? record.change : null });
30966
31501
  if (home !== null) followed.push({ name: m.name, home, record, lines: lines2, running });
30967
31502
  }
30968
31503
  const carved = carvedEntries(all, { repo: ofRepo, homes: [...homes], targets });
@@ -30978,7 +31513,7 @@ async function readCarve2(source2, opts) {
30978
31513
  for (const e of entries.slice(0, MAX_ROSTERS)) {
30979
31514
  const doc = parse(await readText2(source2, e.roster, problems), e.roster, problems);
30980
31515
  if (doc === void 0) continue;
30981
- if (!isRecord26(doc) || !Array.isArray(doc.resources)) {
31516
+ if (!isRecord27(doc) || !Array.isArray(doc.resources)) {
30982
31517
  problems.push(`${e.roster} is not a roster: it has no resources list`);
30983
31518
  continue;
30984
31519
  }
@@ -31060,7 +31595,7 @@ function terragucciCarveRoute(app, source2, opts) {
31060
31595
 
31061
31596
  // src/terragucci-view.ts
31062
31597
  init_member_kind();
31063
- import { readFileSync as readFileSync36 } from "node:fs";
31598
+ import { readFileSync as readFileSync37 } from "node:fs";
31064
31599
  var TERRAGUCCI_READ_TTL_MS = 3e4;
31065
31600
  function repoBase(dirs) {
31066
31601
  for (const d of dirs) {
@@ -31098,7 +31633,7 @@ function checkoutRoots(dirs, base = repoBase(dirs)) {
31098
31633
  for (const m of estateMembers(dirs)) {
31099
31634
  if (m.kind !== "terraform") continue;
31100
31635
  for (const r of checkoutRootDirs(m.dir)) {
31101
- const path = relative10(base, join48(m.dir, r.dir)).split(sep8).join("/") || ".";
31636
+ const path = relative10(base, join49(m.dir, r.dir)).split(sep8).join("/") || ".";
31102
31637
  out.push({ member: m.name, name: r.name, path });
31103
31638
  }
31104
31639
  }
@@ -31111,7 +31646,7 @@ function servedChoudoufu(dirs) {
31111
31646
  if (!cfg) continue;
31112
31647
  if (toolOfBinary(configKeys(cfg).binary) === "choudoufu") return true;
31113
31648
  try {
31114
- if (/\bbinary\s*:\s*["']?[^\s"',}]*choudoufu\b/.test(readFileSync36(cfg, "utf8"))) return true;
31649
+ if (/\bbinary\s*:\s*["']?[^\s"',}]*choudoufu\b/.test(readFileSync37(cfg, "utf8"))) return true;
31115
31650
  } catch {
31116
31651
  }
31117
31652
  }
@@ -31666,8 +32201,8 @@ function tracesRoute(app, opts) {
31666
32201
 
31667
32202
  // src/view-repos.ts
31668
32203
  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";
32204
+ import { existsSync as existsSync30, readdirSync as readdirSync18, readFileSync as readFileSync38 } from "node:fs";
32205
+ import { join as join50, resolve as resolve29 } from "node:path";
31671
32206
  var NAME2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
31672
32207
  function repoName(value) {
31673
32208
  const v = value.trim().replace(/\.git$/, "");
@@ -31681,7 +32216,7 @@ function listCheckouts(parent) {
31681
32216
  } catch {
31682
32217
  return [];
31683
32218
  }
31684
- return names.map((name) => ({ name, dir: resolve28(parent, name) })).filter((c) => existsSync29(join49(c.dir, ".git")));
32219
+ return names.map((name) => ({ name, dir: resolve29(parent, name) })).filter((c) => existsSync30(join50(c.dir, ".git")));
31685
32220
  }
31686
32221
  var scope = new AsyncLocalStorage2();
31687
32222
  var requestRepo = () => scope.getStore();
@@ -31730,7 +32265,7 @@ var SHA2 = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
31730
32265
  function checkoutCommit(dir) {
31731
32266
  const read = (f) => {
31732
32267
  try {
31733
- return readFileSync37(join49(dir, ".git", f), "utf8");
32268
+ return readFileSync38(join50(dir, ".git", f), "utf8");
31734
32269
  } catch {
31735
32270
  return void 0;
31736
32271
  }
@@ -31760,11 +32295,11 @@ function viewRepoFacts(repos, servedDir) {
31760
32295
  }
31761
32296
 
31762
32297
  // src/lifecycle-releases.ts
31763
- import { existsSync as existsSync30, readFileSync as readFileSync38 } from "node:fs";
31764
- import { join as join50 } from "node:path";
32298
+ import { existsSync as existsSync31, readFileSync as readFileSync39 } from "node:fs";
32299
+ import { join as join51 } from "node:path";
31765
32300
 
31766
32301
  // node_modules/@intentius/chant/src/lifecycle/legacy-digest.ts
31767
- import { resolve as resolve29 } from "node:path";
32302
+ import { resolve as resolve30 } from "node:path";
31768
32303
  var LEGACY_DIGEST = /^sha256:([0-9a-f]{8})\1{7}$/;
31769
32304
  var LEGACY_DIGEST_FLAG = "legacy-digest";
31770
32305
  var LEGACY_DIGEST_ACCEPTED_THROUGH = "0.89.x";
@@ -31785,7 +32320,7 @@ function flagLegacyDigest(record, values) {
31785
32320
  }
31786
32321
  var warnedProjects = /* @__PURE__ */ new Set();
31787
32322
  function warnOnLegacyDigests(values, where, cwd) {
31788
- const project = resolve29(cwd ?? process.cwd());
32323
+ const project = resolve30(cwd ?? process.cwd());
31789
32324
  if (warnedProjects.has(project)) return false;
31790
32325
  if (!hasLegacyContentDigest(values)) return false;
31791
32326
  warnedProjects.add(project);
@@ -31874,10 +32409,10 @@ function memberNote(l) {
31874
32409
  // src/lifecycle-releases.ts
31875
32410
  var WAVES_SPEC_FILE = "yodel-waves.json";
31876
32411
  function waveOrder(checkout) {
31877
- const p = join50(checkout, WAVES_SPEC_FILE);
31878
- if (!existsSync30(p)) return void 0;
32412
+ const p = join51(checkout, WAVES_SPEC_FILE);
32413
+ if (!existsSync31(p)) return void 0;
31879
32414
  try {
31880
- const doc = JSON.parse(readFileSync38(p, "utf8"));
32415
+ const doc = JSON.parse(readFileSync39(p, "utf8"));
31881
32416
  const names = (doc.waves ?? []).map((w) => w?.name).filter((n) => typeof n === "string" && n.length > 0);
31882
32417
  return names.length ? [...new Set(names)] : void 0;
31883
32418
  } catch {
@@ -31885,7 +32420,7 @@ function waveOrder(checkout) {
31885
32420
  }
31886
32421
  }
31887
32422
  function hasReleaseLedgerHint(checkout) {
31888
- return existsSync30(join50(checkout, "yodel.config.ts")) || existsSync30(join50(checkout, WAVES_SPEC_FILE));
32423
+ return existsSync31(join51(checkout, "yodel.config.ts")) || existsSync31(join51(checkout, WAVES_SPEC_FILE));
31889
32424
  }
31890
32425
  function orderEnvironments(envs, waves) {
31891
32426
  const seen = new Set(envs);
@@ -31925,17 +32460,17 @@ function releaseCells(ledgers, order, sources) {
31925
32460
  }
31926
32461
  return { components, cells };
31927
32462
  }
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]);
32463
+ async function copyCheckoutRef(git3, checkout, cache7) {
32464
+ assertScratch(cache7.split(/[\\/]/).pop());
32465
+ if (!existsSync31(join51(cache7, "HEAD"))) {
32466
+ const init = await git3(["init", "--bare", "-q", cache7]);
31932
32467
  if (init.code !== 0) return false;
31933
32468
  }
31934
- const f = await git3(["--git-dir", cache6, "fetch", "-q", "--no-tags", checkout, `+${CHECKOUT_REF}:refs/heads/${LIFECYCLE_BRANCH}`]);
32469
+ const f = await git3(["--git-dir", cache7, "fetch", "-q", "--no-tags", checkout, `+${CHECKOUT_REF}:refs/heads/${LIFECYCLE_BRANCH}`]);
31935
32470
  return f.code === 0;
31936
32471
  }
31937
- async function readCache(git3, cache6, prefix = "") {
31938
- const at2 = { cwd: cache6, ledgerPrefix: prefix };
32472
+ async function readCache(git3, cache7, prefix = "") {
32473
+ const at2 = { cwd: cache7, ledgerPrefix: prefix };
31939
32474
  const envs = await listReleaseEnvironments(at2);
31940
32475
  const ledgers = /* @__PURE__ */ new Map();
31941
32476
  const malformed = {};
@@ -31945,7 +32480,7 @@ async function readCache(git3, cache6, prefix = "") {
31945
32480
  ledgers.set(env, r.records);
31946
32481
  if (r.malformed) malformed[env] = r.malformed;
31947
32482
  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]);
32483
+ const log = await git3(["--git-dir", cache7, "log", "-1", "--format=%H%x00%cI", `refs/heads/${LIFECYCLE_BRANCH}`, "--", path]);
31949
32484
  const [commit, committed] = log.code === 0 && log.stdout.trim() ? log.stdout.trim().split("\0") : [];
31950
32485
  sources.set(env, { branch: LIFECYCLE_BRANCH, path, ...commit ? { commit } : {}, ...committed ? { committed } : {} });
31951
32486
  }
@@ -31960,8 +32495,8 @@ async function readReleases(checkout, opts = {}) {
31960
32495
  const also = memberNote(ledger);
31961
32496
  const base = { branch: LIFECYCLE_BRANCH, read: { at: now.toISOString() }, order: waves ? "waves" : "name", ...member };
31962
32497
  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);
32498
+ const answer = async (cache7, via, fetch2, origin2, note) => {
32499
+ const { ledgers, malformed, sources } = await readCache(git3, cache7, ledger.prefix);
31965
32500
  const environments = orderEnvironments([...ledgers.keys()], waves);
31966
32501
  const { components, cells } = releaseCells(ledgers, environments, sources);
31967
32502
  return { ...base, found: true, via, ...origin2 ? { origin: origin2 } : {}, fetch: fetch2, environments, components, cells, malformed, note: also ? `${note} ${also}` : note };
@@ -31975,17 +32510,17 @@ async function readReleases(checkout, opts = {}) {
31975
32510
  } else {
31976
32511
  const from = fetchable(url, checkout);
31977
32512
  origin = redact(from);
31978
- const cache6 = cacheDir(from, opts.cacheRoot);
32513
+ const cache7 = cacheDir(from, opts.cacheRoot);
31979
32514
  let f;
31980
32515
  try {
31981
- f = await fetchIntoCache(git3, from, cache6);
32516
+ f = await fetchIntoCache(git3, from, cache7);
31982
32517
  } catch (e) {
31983
32518
  f = { ok: false, error: e instanceof Error ? e.message : String(e) };
31984
32519
  }
31985
32520
  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
32521
  if (f.ok) {
31987
32522
  try {
31988
- return await answer(cache6, "fetch", { ok: true }, origin, `release ledger on ${LIFECYCLE_BRANCH} as fetched from ${origin} at ${base.read.at}.`);
32523
+ return await answer(cache7, "fetch", { ok: true }, origin, `release ledger on ${LIFECYCLE_BRANCH} as fetched from ${origin} at ${base.read.at}.`);
31989
32524
  } catch (e) {
31990
32525
  fetchError = `fetched ${LIFECYCLE_BRANCH}, but chant's release-ledger reader failed on it: ${e instanceof Error ? e.message : String(e)}`;
31991
32526
  }
@@ -32032,7 +32567,7 @@ function releasesRoutes(app, base, opts = {}) {
32032
32567
  // src/trunk-lane.ts
32033
32568
  init_chant_floors();
32034
32569
  var LANE_READS = ["trunk commits", "release list", "promotion order"];
32035
- var isRecord27 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32570
+ var isRecord28 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32036
32571
  var str24 = (v) => typeof v === "string" && v ? v : null;
32037
32572
  var arr2 = (v) => Array.isArray(v) ? v : [];
32038
32573
  var webUrl = (v) => typeof v === "string" && /^https?:\/\//.test(v) ? v : null;
@@ -32044,30 +32579,30 @@ function laneFloorRefusal(version) {
32044
32579
  return void 0;
32045
32580
  }
32046
32581
  function errorRefusal(doc, shown) {
32047
- if (!isRecord27(doc.error)) return void 0;
32582
+ if (!isRecord28(doc.error)) return void 0;
32048
32583
  const code = String(doc.error.code ?? "unknown");
32049
32584
  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
32585
  return { error: `${shown}: ${String(doc.error.message ?? code)}`, code, remedy };
32051
32586
  }
32052
- var run2 = (r) => isRecord27(r) && typeof r.name === "string" ? { name: r.name, url: webUrl(r.url), conclusion: str24(r.conclusion) } : null;
32587
+ var run2 = (r) => isRecord28(r) && typeof r.name === "string" ? { name: r.name, url: webUrl(r.url), conclusion: str24(r.conclusion) } : null;
32053
32588
  function commitsFromCiList(doc) {
32054
32589
  const out = [];
32055
32590
  for (const c of arr2(doc.commits)) {
32056
- if (!isRecord27(c) || typeof c.sha !== "string") continue;
32591
+ if (!isRecord28(c) || typeof c.sha !== "string") continue;
32057
32592
  const state = c.state === "green" || c.state === "revoked" ? c.state : "undecided";
32058
- const phases = arr2(c.phases).filter(isRecord27).map((p) => ({
32593
+ const phases = arr2(c.phases).filter(isRecord28).map((p) => ({
32059
32594
  phase: String(p.phase ?? ""),
32060
32595
  result: ["pass", "fail", "pending"].includes(String(p.result)) ? p.result : "unrecorded",
32061
32596
  runs: arr2(p.runs).map(run2).filter((r) => r !== null)
32062
32597
  }));
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;
32598
+ const rv = isRecord28(c.revoked) ? { phase: str24(c.revoked.phase), run: run2(c.revoked.run) } : null;
32599
+ const w = isRecord28(c.work) && ["linked", "unlinked", "wrong", "merge"].includes(String(c.work.state)) ? c.work : null;
32065
32600
  const work = w ? {
32066
32601
  state: w.state,
32067
32602
  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 ?? "") }))
32603
+ problems: arr2(w.problems).filter(isRecord28).map((p) => ({ trailer: String(p.trailer ?? ""), message: String(p.message ?? "") }))
32069
32604
  } : null;
32070
- const ignored = arr2(c.ignored).filter(isRecord27).map((t2) => ({ tag: String(t2.tag ?? ""), status: String(t2.status ?? ""), reason: String(t2.reason ?? "") }));
32605
+ const ignored = arr2(c.ignored).filter(isRecord28).map((t2) => ({ tag: String(t2.tag ?? ""), status: String(t2.status ?? ""), reason: String(t2.reason ?? "") }));
32071
32606
  out.push({ sha: c.sha, committed: String(c.committed ?? ""), state, phases, revoked: rv, work, ignored, where: [], cuts: [] });
32072
32607
  }
32073
32608
  return out;
@@ -32075,9 +32610,9 @@ function commitsFromCiList(doc) {
32075
32610
  function promotionOrder(status2) {
32076
32611
  const out = [];
32077
32612
  for (const m of arr2(status2.members)) {
32078
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32613
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32079
32614
  for (const step of arr2(m.promotionOrder)) {
32080
- if (!isRecord27(step) || typeof step.name !== "string") continue;
32615
+ if (!isRecord28(step) || typeof step.name !== "string") continue;
32081
32616
  let at2 = out.find((e) => e.env === step.name);
32082
32617
  if (!at2) out.push(at2 = { env: step.name, canary: false, members: [] });
32083
32618
  if (step.canary === true) at2.canary = true;
@@ -32087,20 +32622,20 @@ function promotionOrder(status2) {
32087
32622
  return out;
32088
32623
  }
32089
32624
  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 : "." }));
32625
+ 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
32626
  }
32092
32627
  function revocation(v) {
32093
- if (!isRecord27(v) || typeof v.tag !== "string") return null;
32628
+ if (!isRecord28(v) || typeof v.tag !== "string") return null;
32094
32629
  return { tag: v.tag, tagged: str24(v.tagged), phase: str24(v.phase), run: run2(v.run), signer: str24(v.signer) };
32095
32630
  }
32096
32631
  function deployRecords(status2, env, full) {
32097
32632
  const out = [];
32098
32633
  for (const m of arr2(status2.members)) {
32099
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32634
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32100
32635
  for (const e of arr2(m.environments)) {
32101
- if (!isRecord27(e) || e.env !== env) continue;
32636
+ if (!isRecord28(e) || e.env !== env) continue;
32102
32637
  for (const r of arr2(e.releases)) {
32103
- if (!isRecord27(r) || typeof r.component !== "string") continue;
32638
+ if (!isRecord28(r) || typeof r.component !== "string") continue;
32104
32639
  out.push({
32105
32640
  member: m.name,
32106
32641
  component: r.component,
@@ -32111,7 +32646,7 @@ function deployRecords(status2, env, full) {
32111
32646
  approver: str24(r.approver),
32112
32647
  runId: String(r.runId ?? ""),
32113
32648
  release: full && str24(r.releaseDigest) ? { releaseDigest: r.releaseDigest, label: str24(r.releaseLabel) } : null,
32114
- rollback: full && isRecord27(r.revoked) ? str24(r.revoked.rollback) : null
32649
+ rollback: full && isRecord28(r.revoked) ? str24(r.revoked.rollback) : null
32115
32650
  });
32116
32651
  }
32117
32652
  }
@@ -32121,10 +32656,10 @@ function deployRecords(status2, env, full) {
32121
32656
  function releasesIn(doc, member, env) {
32122
32657
  const out = [];
32123
32658
  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);
32659
+ if (!isRecord28(r) || typeof r.releaseDigest !== "string" || typeof r.commit !== "string") continue;
32660
+ const here = arr2(r.environments).find((e) => isRecord28(e) && e.env === env);
32661
+ if (!isRecord28(here)) continue;
32662
+ const cuts = arr2(r.cuts).filter(isRecord28);
32128
32663
  const last = cuts.at(-1);
32129
32664
  out.push({
32130
32665
  member,
@@ -32141,9 +32676,9 @@ function releasesIn(doc, member, env) {
32141
32676
  function supersededGates(status2, env) {
32142
32677
  const out = [];
32143
32678
  for (const m of arr2(status2.members)) {
32144
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32679
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32145
32680
  for (const g of arr2(m.gates)) {
32146
- if (!isRecord27(g) || g.state !== "superseded" || g.env !== env) continue;
32681
+ if (!isRecord28(g) || g.state !== "superseded" || g.env !== env) continue;
32147
32682
  const op = str24(g.component);
32148
32683
  const gate = str24(g.name);
32149
32684
  const releaseDigest = str24(g.releaseDigest);
@@ -32158,11 +32693,11 @@ var releaseOf = (digest, label) => str24(digest) ? { releaseDigest: digest, labe
32158
32693
  function mixedIn(status2, env) {
32159
32694
  const out = [];
32160
32695
  for (const m of arr2(status2.members)) {
32161
- if (!isRecord27(m) || typeof m.name !== "string") continue;
32696
+ if (!isRecord28(m) || typeof m.name !== "string") continue;
32162
32697
  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;
32698
+ if (!isRecord28(e) || e.env !== env || !isRecord28(e.mixed)) continue;
32699
+ const components = arr2(e.mixed.components).filter(isRecord28).filter((c) => typeof c.component === "string").map((c) => {
32700
+ const a = isRecord28(c.attempt) ? c.attempt : null;
32166
32701
  return {
32167
32702
  component: c.component,
32168
32703
  release: releaseOf(c.releaseDigest, c.releaseLabel),
@@ -32182,23 +32717,23 @@ function mixedIn(status2, env) {
32182
32717
  }
32183
32718
  return out;
32184
32719
  }
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();
32720
+ 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
32721
  function releaseColumn(docs2, commits, environments, full) {
32187
32722
  const at2 = new Map(commits.map((c, i) => [c.sha, i]));
32188
32723
  const place = (commit) => at2.get(commit) ?? Number.POSITIVE_INFINITY;
32189
32724
  const rows = [];
32190
32725
  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);
32726
+ 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
32727
  const order = environments.filter((e) => e.members.includes(member)).map((e) => e.env);
32193
32728
  items.forEach(({ r, i }, k) => {
32194
32729
  const releaseDigest = r.releaseDigest;
32195
32730
  const commit = r.commit;
32196
32731
  const before = items[k + 1]?.r;
32197
32732
  const artifacts = artifactKey(r.artifactDigests);
32198
- const cuts = arr2(r.cuts).filter(isRecord27);
32733
+ const cuts = arr2(r.cuts).filter(isRecord28);
32199
32734
  const last = cuts.at(-1);
32200
- const check = last && isRecord27(last.signatureCheck) ? last.signatureCheck : null;
32201
- const ran = arr2(r.environments).filter(isRecord27);
32735
+ const check = last && isRecord28(last.signatureCheck) ? last.signatureCheck : null;
32736
+ const ran = arr2(r.environments).filter(isRecord28);
32202
32737
  const runs2 = [
32203
32738
  ...environments.map((e) => e.env),
32204
32739
  ...ran.map((e) => String(e.env ?? "")).filter((env) => !environments.some((e) => e.env === env))
@@ -32350,7 +32885,7 @@ init_chant_floors();
32350
32885
  var OVERLAY_READS = ["promotion order", "change set"];
32351
32886
  var BUCKET_OF = { create: "create", update: "change", replace: "change", delete: "delete", forget: "delete" };
32352
32887
  var STRENGTH = { create: 1, change: 2, delete: 3 };
32353
- var isRecord28 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32888
+ var isRecord29 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32354
32889
  var str25 = (v) => typeof v === "string" && v ? v : null;
32355
32890
  var arr3 = (v) => Array.isArray(v) ? v : [];
32356
32891
  function overlayFloorRefusal(version) {
@@ -32373,13 +32908,13 @@ function attributeOf(a) {
32373
32908
  }
32374
32909
  function showRefusal(doc, digest, member) {
32375
32910
  const shown = `chant change-set show ${digest} --member ${member}`;
32376
- if (isRecord28(doc.error)) {
32911
+ if (isRecord29(doc.error)) {
32377
32912
  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
32913
  }
32379
- if (isRecord28(doc.reason)) {
32914
+ if (isRecord29(doc.reason)) {
32380
32915
  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
32916
  }
32382
- if (!isRecord28(doc.changeSet)) {
32917
+ if (!isRecord29(doc.changeSet)) {
32383
32918
  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
32919
  }
32385
32920
  if (doc.changeSet.digest !== digest) {
@@ -32388,11 +32923,11 @@ function showRefusal(doc, digest, member) {
32388
32923
  return void 0;
32389
32924
  }
32390
32925
  function overlayFrom(gate, doc, at2) {
32391
- const cs = isRecord28(doc.changeSet) ? doc.changeSet : {};
32926
+ const cs = isRecord29(doc.changeSet) ? doc.changeSet : {};
32392
32927
  const entries = [];
32393
32928
  let unchanged = 0;
32394
32929
  for (const e of arr3(cs.entries)) {
32395
- if (!isRecord28(e) || typeof e.address !== "string") continue;
32930
+ if (!isRecord29(e) || typeof e.address !== "string") continue;
32396
32931
  const action = String(e.action ?? "");
32397
32932
  const bucket = BUCKET_OF[action];
32398
32933
  if (!bucket) {
@@ -32408,7 +32943,7 @@ function overlayFrom(gate, doc, at2) {
32408
32943
  node: str25(e.node),
32409
32944
  disruption: str25(e.disruption),
32410
32945
  deposed: str25(e.deposed),
32411
- attributes: arr3(e.attributes).filter(isRecord28).map(attributeOf)
32946
+ attributes: arr3(e.attributes).filter(isRecord29).map(attributeOf)
32412
32947
  });
32413
32948
  }
32414
32949
  const nodes = {};
@@ -32420,13 +32955,13 @@ function overlayFrom(gate, doc, at2) {
32420
32955
  if (STRENGTH[e.bucket] > STRENGTH[n.bucket]) n.bucket = e.bucket;
32421
32956
  n.actions[e.action] = (n.actions[e.action] ?? 0) + 1;
32422
32957
  }
32423
- const gaps = arr3(cs.members).filter(isRecord28).map((m) => ({
32958
+ const gaps = arr3(cs.members).filter(isRecord29).map((m) => ({
32424
32959
  member: String(m.member ?? ""),
32425
32960
  status: String(m.status ?? ""),
32426
32961
  error: str25(m.error),
32427
- holes: arr3(m.holes).filter(isRecord28).map((h) => ({ address: String(h.address ?? ""), reason: String(h.reason ?? "") }))
32962
+ holes: arr3(m.holes).filter(isRecord29).map((h) => ({ address: String(h.address ?? ""), reason: String(h.reason ?? "") }))
32428
32963
  })).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;
32964
+ const graph = isRecord29(cs.graph) ? { member: str25(cs.graph.member), at: str25(cs.graph.at) } : null;
32430
32965
  const planned = str25(cs.releaseDigest) && str25(cs.environment) ? { releaseDigest: str25(cs.releaseDigest), environment: str25(cs.environment) } : null;
32431
32966
  return {
32432
32967
  gate: {
@@ -32485,7 +33020,7 @@ async function readChangeSetOverlay(ws, opts) {
32485
33020
  // src/feature-flags.ts
32486
33021
  init_chant_floors();
32487
33022
  var FLAG_READS = ["feature flags", "promotion order", "change set"];
32488
- var isRecord29 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33023
+ var isRecord30 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32489
33024
  var str26 = (v) => typeof v === "string" && v ? v : null;
32490
33025
  var arr4 = (v) => Array.isArray(v) ? v : [];
32491
33026
  var isValue = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean";
@@ -32511,7 +33046,7 @@ function turnOnLines(flag2, env) {
32511
33046
  ];
32512
33047
  }
32513
33048
  function flagsFromStatus(status2) {
32514
- const members = arr4(status2.members).filter(isRecord29);
33049
+ const members = arr4(status2.members).filter(isRecord30);
32515
33050
  if (!members.some((m) => "featureFlags" in m)) return null;
32516
33051
  const flags = [];
32517
33052
  const unreadable = [];
@@ -32523,12 +33058,12 @@ function flagsFromStatus(status2) {
32523
33058
  continue;
32524
33059
  }
32525
33060
  for (const f of arr4(m.featureFlags)) {
32526
- if (!isRecord29(f) || !str26(f.id)) continue;
33061
+ if (!isRecord30(f) || !str26(f.id)) continue;
32527
33062
  const values = {};
32528
- if (isRecord29(f.values)) {
33063
+ if (isRecord30(f.values)) {
32529
33064
  for (const [env, v] of Object.entries(f.values)) if (isValue(v)) values[env] = v;
32530
33065
  }
32531
- const work = isRecord29(f.work) && str26(f.work.id) ? { id: str26(f.work.id), state: str26(f.work.state) } : null;
33066
+ const work = isRecord30(f.work) && str26(f.work.id) ? { id: str26(f.work.id), state: str26(f.work.state) } : null;
32532
33067
  flags.push({
32533
33068
  key: `${member}/${f.id}`,
32534
33069
  member,
@@ -32536,7 +33071,7 @@ function flagsFromStatus(status2) {
32536
33071
  param: String(f.param ?? ""),
32537
33072
  owner: String(f.owner ?? ""),
32538
33073
  work,
32539
- implements: arr4(f.implements).filter(isRecord29).map((d) => ({ id: String(d.id ?? ""), state: str26(d.state), confirmed: d.confirmed === true })),
33074
+ implements: arr4(f.implements).filter(isRecord30).map((d) => ({ id: String(d.id ?? ""), state: str26(d.state), confirmed: d.confirmed === true })),
32540
33075
  stale: f.stale === true,
32541
33076
  kind: String(f.kind ?? ""),
32542
33077
  path: String(f.path ?? ""),
@@ -32547,20 +33082,20 @@ function flagsFromStatus(status2) {
32547
33082
  return { flags, unreadable };
32548
33083
  }
32549
33084
  function paramMoves(doc, param) {
32550
- const cs = isRecord29(doc.changeSet) ? doc.changeSet : null;
33085
+ const cs = isRecord30(doc.changeSet) ? doc.changeSet : null;
32551
33086
  if (!cs) return null;
32552
33087
  const path = `param:${param}`;
32553
33088
  let found = null;
32554
33089
  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);
33090
+ if (!isRecord30(e)) continue;
33091
+ const a = arr4(e.attributes).find((x) => isRecord30(x) && x.path === path);
32557
33092
  if (!a) continue;
32558
33093
  found ??= { before: a.before, after: a.after, entries: [] };
32559
33094
  found.entries.push({ address: String(e.address ?? ""), node: str26(e.node) });
32560
33095
  }
32561
33096
  return found;
32562
33097
  }
32563
- var isRefusal3 = (v) => isRecord29(v) && typeof v.error === "string" && typeof v.code === "string" && typeof v.remedy === "string";
33098
+ var isRefusal3 = (v) => isRecord30(v) && typeof v.error === "string" && typeof v.code === "string" && typeof v.remedy === "string";
32564
33099
  var shownKey = (env, gate) => `${env}\0${gate}`;
32565
33100
  function flagsFrom(input) {
32566
33101
  const listed = flagsFromStatus(input.status);
@@ -32651,7 +33186,7 @@ async function readFeatureFlags(ws, opts) {
32651
33186
  // src/collision-marks.ts
32652
33187
  init_chant_floors();
32653
33188
  var COLLISION_READ = "work overlap";
32654
- var isRecord30 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33189
+ var isRecord31 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32655
33190
  var str27 = (v) => typeof v === "string" && v ? v : null;
32656
33191
  var arr5 = (v) => Array.isArray(v) ? v : [];
32657
33192
  var strs = (v) => arr5(v).filter((x) => typeof x === "string");
@@ -32664,7 +33199,7 @@ function overlapRefusal(status2) {
32664
33199
  if (!("overlap" in status2)) {
32665
33200
  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
33201
  }
32667
- if (status2.overlap === null || !isRecord30(status2.overlap)) {
33202
+ if (status2.overlap === null || !isRecord31(status2.overlap)) {
32668
33203
  return {
32669
33204
  error: "chant reported no overlap: the workspace declares no work kind, or chant could not read the work records or the history.",
32670
33205
  code: "overlap-unavailable",
@@ -32678,7 +33213,7 @@ function collisionsFrom(status2, at2) {
32678
33213
  const overlap = status2.overlap;
32679
33214
  const details = /* @__PURE__ */ new Map();
32680
33215
  for (const i of arr5(overlap.items)) {
32681
- if (!isRecord30(i) || !str27(i.item)) continue;
33216
+ if (!isRecord31(i) || !str27(i.item)) continue;
32682
33217
  details.set(String(i.item), { path: String(i.path ?? ""), state: str27(i.state), commits: strs(i.commits) });
32683
33218
  }
32684
33219
  const nodes = /* @__PURE__ */ new Map();
@@ -32686,7 +33221,7 @@ function collisionsFrom(status2, at2) {
32686
33221
  const files = [];
32687
33222
  const withs = /* @__PURE__ */ new Map();
32688
33223
  for (const p of arr5(overlap.pairs)) {
32689
- if (!isRecord30(p)) continue;
33224
+ if (!isRecord31(p)) continue;
32690
33225
  const pair = strs(p.items).sort(byString);
32691
33226
  if (pair.length !== 2) continue;
32692
33227
  const [a, b] = pair;
@@ -32694,7 +33229,7 @@ function collisionsFrom(status2, at2) {
32694
33229
  const shared2 = strs(p.files);
32695
33230
  if (shared2.length) files.push({ items: [a, b], files: shared2 });
32696
33231
  for (const e of arr5(p.addresses)) {
32697
- if (!isRecord30(e)) continue;
33232
+ if (!isRecord31(e)) continue;
32698
33233
  const entry = { changeSet: String(e.changeSet ?? ""), member: String(e.member ?? ""), address: String(e.address ?? ""), source: String(e.source ?? ""), items: pair };
32699
33234
  const node = str27(e.node);
32700
33235
  if (!node) {
@@ -32735,8 +33270,8 @@ async function readCollisions(ws, opts) {
32735
33270
  }
32736
33271
 
32737
33272
  // 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";
33273
+ import { existsSync as existsSync32, readdirSync as readdirSync19, readFileSync as readFileSync40 } from "node:fs";
33274
+ import { join as join52 } from "node:path";
32740
33275
  var YODEL_APPLY_OP = "yodel-apply";
32741
33276
  var YODEL_HEAD_PLANS_DIR = headPlansPath(YODEL_APPLY_OP, "").dir;
32742
33277
  function parseYodelWaves(text3, path = WAVES_SPEC_FILE) {
@@ -32768,17 +33303,17 @@ function parseYodelWaves(text3, path = WAVES_SPEC_FILE) {
32768
33303
  return { path, waves };
32769
33304
  }
32770
33305
  function readYodelWaves(checkout) {
32771
- const p = join51(checkout, WAVES_SPEC_FILE);
32772
- if (!existsSync31(p)) return void 0;
33306
+ const p = join52(checkout, WAVES_SPEC_FILE);
33307
+ if (!existsSync32(p)) return void 0;
32773
33308
  try {
32774
- return parseYodelWaves(readFileSync39(p, "utf8"));
33309
+ return parseYodelWaves(readFileSync40(p, "utf8"));
32775
33310
  } catch (e) {
32776
33311
  return { path: WAVES_SPEC_FILE, waves: [], error: e instanceof Error ? e.message : String(e) };
32777
33312
  }
32778
33313
  }
32779
33314
  function migrateOpEnvironments(checkout) {
32780
- const dir = join51(checkout, "ops");
32781
- if (!existsSync31(dir)) return [];
33315
+ const dir = join52(checkout, "ops");
33316
+ if (!existsSync32(dir)) return [];
32782
33317
  try {
32783
33318
  return readdirSync19(dir).map((f) => /^migrate-(.+)\.op\.ts$/.exec(f)?.[1]).filter((e) => !!e).sort();
32784
33319
  } catch {
@@ -32898,18 +33433,75 @@ function sqlYodelerLaneRoute(app, checkout, opts = {}) {
32898
33433
  });
32899
33434
  }
32900
33435
 
33436
+ // src/health-overlay.ts
33437
+ init_chant_floors();
33438
+ var HEALTH_READ_NAME = "runtime health";
33439
+ var HEALTH_TTL_MS = 3e4;
33440
+ async function readHealthOverlay(members, env, deps) {
33441
+ const floor = floorFor(HEALTH_READ_NAME);
33442
+ const reads2 = await Promise.all(
33443
+ members.map(async (m) => {
33444
+ const chant = deps.chantVersion(m.dir) ?? null;
33445
+ const base = { member: m.name ?? null, chant };
33446
+ if (!floorMet(floor, chant ?? void 0)) return { m, read: { ...base, refusal: floorRefusal(floor, chant ?? void 0) } };
33447
+ try {
33448
+ const doc = await deps.reader(m.dir).readHealth(env);
33449
+ return { m, doc, read: { ...base, observedAt: doc.observedAt, ...doc.summary ? { summary: doc.summary } : {} } };
33450
+ } catch (e) {
33451
+ 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." } } };
33452
+ if (e.refusal.code === "health-none") return { m, read: { ...base, none: true } };
33453
+ return { m, read: { ...base, refusal: e.refusal } };
33454
+ }
33455
+ })
33456
+ );
33457
+ const nodes = {};
33458
+ for (const r of reads2) if (r.doc) Object.assign(nodes, nodeHealthOf(r.doc, r.m.name));
33459
+ const rotation = {};
33460
+ await Promise.all(
33461
+ reads2.filter((r) => r.doc).map(async (r) => {
33462
+ const graph = await deps.graph(r.m.dir).catch(() => void 0);
33463
+ if (graph) Object.assign(rotation, rotationOf(graph, nodes, r.m.name));
33464
+ })
33465
+ );
33466
+ const answer = {
33467
+ env,
33468
+ nodes,
33469
+ rotation,
33470
+ members: reads2.map((r) => r.read),
33471
+ counts: healthCounts(nodes, rotation),
33472
+ readAt: (deps.now?.() ?? /* @__PURE__ */ new Date()).toISOString()
33473
+ };
33474
+ const tooOld = reads2.filter((r) => r.read.refusal?.code === "chant-too-old");
33475
+ if (reads2.length > 0 && tooOld.length === reads2.length) {
33476
+ answer.refusal = tooOld[0].read.refusal;
33477
+ answer.degraded = floor.degraded;
33478
+ }
33479
+ return answer;
33480
+ }
33481
+ var cache6 = /* @__PURE__ */ new Map();
33482
+ function cachedHealth(key3, now = Date.now()) {
33483
+ const hit = cache6.get(key3);
33484
+ return hit && now - hit.at < HEALTH_TTL_MS ? hit.answer : void 0;
33485
+ }
33486
+ function rememberHealth(key3, answer, now = Date.now()) {
33487
+ cache6.set(key3, { at: now, answer });
33488
+ }
33489
+ function invalidateHealth() {
33490
+ cache6.clear();
33491
+ }
33492
+
32901
33493
  // src/terragucci-estate.ts
32902
33494
  init_yaml();
32903
- import { existsSync as existsSync32, readFileSync as readFileSync40, statSync as statSync14 } from "node:fs";
33495
+ import { existsSync as existsSync33, readFileSync as readFileSync41, statSync as statSync14 } from "node:fs";
32904
33496
  import { createRequire as createRequire7 } from "node:module";
32905
- import { dirname as dirname16, extname as extname2, join as join52, resolve as resolve30 } from "node:path";
33497
+ import { dirname as dirname16, extname as extname2, join as join53, resolve as resolve31 } from "node:path";
32906
33498
  import { fileURLToPath as fileURLToPath11 } from "node:url";
32907
- import { Ajv2020 as Ajv20208 } from "ajv/dist/2020.js";
33499
+ import { Ajv2020 as Ajv20209 } from "ajv/dist/2020.js";
32908
33500
  var RUN_SCHEMA2 = "terragucci.run/v1";
32909
33501
  function configProjects(file) {
32910
33502
  let text3;
32911
33503
  try {
32912
- text3 = readFileSync40(file, "utf8");
33504
+ text3 = readFileSync41(file, "utf8");
32913
33505
  } catch {
32914
33506
  return void 0;
32915
33507
  }
@@ -32937,21 +33529,21 @@ function controlRepo(dirs, roots = () => checkoutRoots(dirs).length) {
32937
33529
  }
32938
33530
  return n === 0 ? { config, projects } : void 0;
32939
33531
  }
32940
- var isRecord31 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33532
+ var isRecord32 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
32941
33533
  var str28 = (v) => typeof v === "string";
32942
33534
  var int4 = (v) => typeof v === "number" && Number.isInteger(v);
32943
33535
  function structuralRun2(doc) {
32944
- if (!isRecord31(doc)) return "it is not a JSON object";
33536
+ if (!isRecord32(doc)) return "it is not a JSON object";
32945
33537
  if (doc.schema !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA2}`;
32946
33538
  if (!str28(doc.project) || !str28(doc.commit) || !str28(doc.updated)) return "it lacks project, commit or updated";
32947
33539
  if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
32948
33540
  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`;
33541
+ 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`;
33542
+ if (r.state !== void 0 && !(isRecord32(r.state) && str28(r.state.key))) return `root ${String(r.root)}'s state has no key`;
33543
+ 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
33544
  }
32953
33545
  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`;
33546
+ 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
33547
  }
32956
33548
  return void 0;
32957
33549
  }
@@ -32960,16 +33552,16 @@ function runViewValidator(dirs = []) {
32960
33552
  for (const from of [...dirs, dirname16(fileURLToPath11(import.meta.url))]) {
32961
33553
  let entry;
32962
33554
  try {
32963
- entry = createRequire7(join52(resolve30(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
33555
+ entry = createRequire7(join53(resolve31(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
32964
33556
  } catch {
32965
33557
  continue;
32966
33558
  }
32967
33559
  const dist = dirname16(entry);
32968
- const schema = join52(dist, "run.schema.json");
33560
+ const schema = join53(dist, "run.schema.json");
32969
33561
  let stamp;
32970
33562
  try {
32971
33563
  const st = statSync14(schema);
32972
- const pkg = statSync14(join52(dist, "..", "package.json"));
33564
+ const pkg = statSync14(join53(dist, "..", "package.json"));
32973
33565
  stamp = `${schema}\0${st.mtimeMs}:${st.size}\0${pkg.mtimeMs}`;
32974
33566
  } catch {
32975
33567
  continue;
@@ -32978,12 +33570,12 @@ function runViewValidator(dirs = []) {
32978
33570
  if (hit) return hit;
32979
33571
  let v;
32980
33572
  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")));
33573
+ const version = JSON.parse(readFileSync41(join53(dist, "..", "package.json"), "utf8")).version ?? "";
33574
+ const validate2 = new Ajv20209({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync41(schema, "utf8")));
32983
33575
  v = {
32984
33576
  validation: { by: "schema", terragucci: version },
32985
33577
  check(doc) {
32986
- const id = isRecord31(doc) ? doc.schema : void 0;
33578
+ const id = isRecord32(doc) ? doc.schema : void 0;
32987
33579
  if (id !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA2}`;
32988
33580
  if (validate2(doc)) return void 0;
32989
33581
  const e = validate2.errors?.[0];
@@ -33034,8 +33626,8 @@ function controlEdges(views) {
33034
33626
  function siblingCheckout(project, base, projectOf = checkoutProject) {
33035
33627
  const name = project.split("/").filter(Boolean).pop();
33036
33628
  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;
33629
+ const dir = join53(dirname16(resolve31(base)), name);
33630
+ if (dir === resolve31(base) || !existsSync33(join53(dir, ".git"))) return void 0;
33039
33631
  return projectOf(dir) === project ? dir : void 0;
33040
33632
  }
33041
33633
  var shellWord = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
@@ -33242,11 +33834,11 @@ function controlRepoInfo(dirs) {
33242
33834
  }
33243
33835
 
33244
33836
  // src/yodel-report.ts
33245
- import { readdirSync as readdirSync20, readFileSync as readFileSync41, statSync as statSync15 } from "node:fs";
33837
+ import { readdirSync as readdirSync20, readFileSync as readFileSync42, statSync as statSync15 } from "node:fs";
33246
33838
  import { createRequire as createRequire8 } from "node:module";
33247
- import { basename as basename6, dirname as dirname17, join as join53, resolve as resolve31 } from "node:path";
33839
+ import { basename as basename6, dirname as dirname17, join as join54, resolve as resolve32 } from "node:path";
33248
33840
  import { fileURLToPath as fileURLToPath12 } from "node:url";
33249
- import { Ajv2020 as Ajv20209 } from "ajv/dist/2020.js";
33841
+ import { Ajv2020 as Ajv202010 } from "ajv/dist/2020.js";
33250
33842
 
33251
33843
  // src/sql-yodeler-schemas/common.schema.json
33252
33844
  var common_schema_default = {
@@ -33655,7 +34247,7 @@ var refuse14 = (error, remedy) => {
33655
34247
  throw new YodelReadError({ error, code: "yodel-report", remedy });
33656
34248
  };
33657
34249
  function compile(schemas, validation) {
33658
- const ajv = new Ajv20209({ strict: false, allErrors: false });
34250
+ const ajv = new Ajv202010({ strict: false, allErrors: false });
33659
34251
  ajv.addSchema(schemas.common);
33660
34252
  const compiled4 = { report: ajv.compile(schemas.report), drift: ajv.compile(schemas.drift) };
33661
34253
  return {
@@ -33673,13 +34265,13 @@ var installed = /* @__PURE__ */ new Map();
33673
34265
  function packageRoot(from) {
33674
34266
  let entry;
33675
34267
  try {
33676
- entry = createRequire8(join53(resolve31(from), "noop.js")).resolve("@intentius/sql-yodeler");
34268
+ entry = createRequire8(join54(resolve32(from), "noop.js")).resolve("@intentius/sql-yodeler");
33677
34269
  } catch {
33678
34270
  return void 0;
33679
34271
  }
33680
34272
  for (let d = dirname17(entry); d !== dirname17(d); d = dirname17(d)) {
33681
34273
  try {
33682
- const pkg = JSON.parse(readFileSync41(join53(d, "package.json"), "utf8"));
34274
+ const pkg = JSON.parse(readFileSync42(join54(d, "package.json"), "utf8"));
33683
34275
  if (pkg.name === "@intentius/sql-yodeler") return d;
33684
34276
  } catch {
33685
34277
  }
@@ -33691,11 +34283,11 @@ function yodelValidator(dirs = []) {
33691
34283
  const root = packageRoot(from);
33692
34284
  if (!root) continue;
33693
34285
  try {
33694
- const version = JSON.parse(readFileSync41(join53(root, "package.json"), "utf8")).version ?? "";
34286
+ const version = JSON.parse(readFileSync42(join54(root, "package.json"), "utf8")).version ?? "";
33695
34287
  const key3 = `${root}\0${version}`;
33696
34288
  let v = installed.get(key3);
33697
34289
  if (!v) {
33698
- const load2 = (n) => JSON.parse(readFileSync41(join53(root, "schemas", `${n}.schema.json`), "utf8"));
34290
+ const load2 = (n) => JSON.parse(readFileSync42(join54(root, "schemas", `${n}.schema.json`), "utf8"));
33699
34291
  v = compile({ common: load2("common"), report: load2("report"), drift: load2("drift") }, { by: "schema", from: "package", sqlYodeler: version });
33700
34292
  installed.set(key3, v);
33701
34293
  }
@@ -33706,9 +34298,9 @@ function yodelValidator(dirs = []) {
33706
34298
  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
34299
  return pinned;
33708
34300
  }
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);
34301
+ var isRecord33 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
34302
+ var looksLikeReport = (d) => isRecord33(d) && "generatedAt" in d && "environments" in d;
34303
+ var looksLikeDrift = (d) => isRecord33(d) && "environment" in d && ("drifted" in d || "changed" in d);
33712
34304
  function filesOf(source2) {
33713
34305
  let st;
33714
34306
  try {
@@ -33717,11 +34309,11 @@ function filesOf(source2) {
33717
34309
  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
34310
  }
33719
34311
  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) };
34312
+ const files = readdirSync20(dir).filter((f) => f.endsWith(".json")).sort().map((f) => join54(dir, f));
34313
+ return st.isDirectory() ? { dir, files } : { dir, files, named: resolve32(source2) };
33722
34314
  }
33723
- function readYodelReport(source2, validator4) {
33724
- const { files, named } = filesOf(resolve31(source2));
34315
+ function readYodelReport(source2, validator5) {
34316
+ const { files, named } = filesOf(resolve32(source2));
33725
34317
  let report;
33726
34318
  const drifts = [];
33727
34319
  const ignored = [];
@@ -33729,7 +34321,7 @@ function readYodelReport(source2, validator4) {
33729
34321
  for (const file of files) {
33730
34322
  let doc;
33731
34323
  try {
33732
- doc = JSON.parse(readFileSync41(file, "utf8"));
34324
+ doc = JSON.parse(readFileSync42(file, "utf8"));
33733
34325
  } catch (e) {
33734
34326
  if (file === named) refuse14(`${basename6(file)} is not JSON: ${e instanceof Error ? e.message : String(e)}`, remedy);
33735
34327
  ignored.push(basename6(file));
@@ -33740,7 +34332,7 @@ function readYodelReport(source2, validator4) {
33740
34332
  ignored.push(basename6(file));
33741
34333
  continue;
33742
34334
  }
33743
- const why = validator4.check(kind, doc);
34335
+ const why = validator5.check(kind, doc);
33744
34336
  if (why) refuse14(`${basename6(file)} is not a SQL Yodeler ${kind} document: ${why}`, remedy);
33745
34337
  if (kind === "report") {
33746
34338
  if (report) refuse14(`${source2} holds two reports, ${basename6(report.file)} and ${basename6(file)}`, "Name the one to read: --yodel-report <file>.");
@@ -33794,7 +34386,7 @@ function readYodelReport(source2, validator4) {
33794
34386
  }
33795
34387
  return {
33796
34388
  source: source2,
33797
- validation: validator4.validation,
34389
+ validation: validator5.validation,
33798
34390
  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
34391
  environments,
33800
34392
  drift,
@@ -33816,24 +34408,24 @@ function yodelReportRoute(app, source2, dirs) {
33816
34408
 
33817
34409
  // src/demo-pins.ts
33818
34410
  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);
34411
+ 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";
34412
+ import { dirname as dirname18, join as join55, resolve as resolve33 } from "node:path";
34413
+ var isRecord34 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
33822
34414
  function linkDemoPins(work, probes = {}) {
33823
- const file = join54(work, "chant.workspace.json");
33824
- if (!existsSync33(file)) return { ok: true, linked: [] };
34415
+ const file = join55(work, "chant.workspace.json");
34416
+ if (!existsSync34(file)) return { ok: true, linked: [] };
33825
34417
  let decl;
33826
34418
  try {
33827
- decl = JSON.parse(readFileSync42(file, "utf8"));
34419
+ decl = JSON.parse(readFileSync43(file, "utf8"));
33828
34420
  } catch {
33829
34421
  return { ok: true, linked: [] };
33830
34422
  }
33831
- if (!isRecord33(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
34423
+ if (!isRecord34(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
33832
34424
  const find = probes.resolve ?? ((pkg) => resolvedPackage(pkg));
33833
34425
  const linked = [];
33834
34426
  let rewrite = false;
33835
34427
  for (const pin of decl.pins) {
33836
- if (!isRecord33(pin) || typeof pin.package !== "string") continue;
34428
+ if (!isRecord34(pin) || typeof pin.package !== "string") continue;
33837
34429
  const pkg = pin.package;
33838
34430
  if (pkg === TERRAFORM_LEXICON_PKG) {
33839
34431
  const refusal2 = (probes.reader ?? terraformReaderState)().refusal;
@@ -33847,7 +34439,7 @@ function linkDemoPins(work, probes = {}) {
33847
34439
  remedy: `Install ${pkg} beside behold, then load the demo again.`
33848
34440
  };
33849
34441
  }
33850
- const link = join54(work, "node_modules", ...pkg.split("/"));
34442
+ const link = join55(work, "node_modules", ...pkg.split("/"));
33851
34443
  if (!present(link)) {
33852
34444
  mkdirSync7(dirname18(link), { recursive: true });
33853
34445
  symlinkSync2(found.dir, link, "junction");
@@ -33875,26 +34467,26 @@ function present(path) {
33875
34467
  }
33876
34468
  function linksTo(link, target) {
33877
34469
  try {
33878
- return lstatSync2(link).isSymbolicLink() && resolve32(dirname18(link), readlinkSync2(link)) === resolve32(target);
34470
+ return lstatSync2(link).isSymbolicLink() && resolve33(dirname18(link), readlinkSync2(link)) === resolve33(target);
33879
34471
  } catch {
33880
34472
  return false;
33881
34473
  }
33882
34474
  }
33883
34475
 
33884
34476
  // 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";
34477
+ import { readFileSync as readFileSync44, existsSync as existsSync35, cpSync, mkdirSync as mkdirSync8 } from "node:fs";
34478
+ import { dirname as dirname19, isAbsolute as isAbsolute7, join as join56, relative as relative11, resolve as resolve34, sep as sep9 } from "node:path";
33887
34479
  import { spawn as spawn9, spawnSync as spawnSync3 } from "node:child_process";
33888
34480
  function readCatalog(file, catalog) {
33889
34481
  let raw;
33890
34482
  try {
33891
- raw = JSON.parse(readFileSync43(file, "utf8"));
34483
+ raw = JSON.parse(readFileSync44(file, "utf8"));
33892
34484
  } catch {
33893
34485
  return [];
33894
34486
  }
33895
34487
  const list4 = raw?.demos;
33896
34488
  if (!Array.isArray(list4)) return [];
33897
- const catalogDir = dirname19(resolve33(file));
34489
+ const catalogDir = dirname19(resolve34(file));
33898
34490
  return list4.filter((e) => validEntry(e)).map((e) => ({ ...e, catalog, catalogDir }));
33899
34491
  }
33900
34492
  function validEntry(e) {
@@ -33929,10 +34521,10 @@ function validEntry(e) {
33929
34521
  return true;
33930
34522
  }
33931
34523
  function loadDemoRegistry(pkgRoot3) {
33932
- const merged = readCatalog(join55(pkgRoot3, "demos.json"), "demos");
34524
+ const merged = readCatalog(join56(pkgRoot3, "demos.json"), "demos");
33933
34525
  const seen = new Set(merged.map((e) => e.name));
33934
34526
  const named = process.env.BEHOLD_WORKBENCH;
33935
- for (const e of [...readCatalog(join55(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve33(named), "workbench") : []]) {
34527
+ for (const e of [...readCatalog(join56(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve34(named), "workbench") : []]) {
33936
34528
  if (seen.has(e.name)) {
33937
34529
  process.stderr.write(`behold: workbench entry "${e.name}" collides with a demo already in the catalog \u2014 dropped
33938
34530
  `);
@@ -33945,17 +34537,17 @@ function loadDemoRegistry(pkgRoot3) {
33945
34537
  }
33946
34538
  function demoLocalPath(entry) {
33947
34539
  if (entry.source !== "local" || !entry.path) return void 0;
33948
- return isAbsolute7(entry.path) ? entry.path : resolve33(entry.catalogDir ?? process.cwd(), entry.path);
34540
+ return isAbsolute7(entry.path) ? entry.path : resolve34(entry.catalogDir ?? process.cwd(), entry.path);
33949
34541
  }
33950
34542
  function missingRequirements(entry) {
33951
34543
  const bins = entry.source === "git" && !entry.requires.includes("git") ? [...entry.requires, "git"] : entry.requires;
33952
34544
  const finder = process.platform === "win32" ? "where" : "which";
33953
34545
  const missing = bins.filter((bin) => {
33954
- if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync34(process.env.CHOUDOUFU_BIN)) return false;
34546
+ if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync35(process.env.CHOUDOUFU_BIN)) return false;
33955
34547
  return spawnSync3(finder, [bin], { stdio: "ignore" }).status !== 0;
33956
34548
  });
33957
34549
  const local = demoLocalPath(entry);
33958
- if (local && !existsSync34(local)) missing.push(`${entry.path} (not checked out)`);
34550
+ if (local && !existsSync35(local)) missing.push(`${entry.path} (not checked out)`);
33959
34551
  return missing;
33960
34552
  }
33961
34553
  function fetchesFromNetwork(entry) {
@@ -33964,9 +34556,9 @@ function fetchesFromNetwork(entry) {
33964
34556
  function demoTargetDir(entry, cwd = process.cwd()) {
33965
34557
  const inPlace = entry.inPlace ? demoLocalPath(entry) : void 0;
33966
34558
  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);
34559
+ const legacy = resolve34(cwd, "behold-demo");
34560
+ if (entry.name === "writes" && existsSync35(legacy)) return legacy;
34561
+ return resolve34(cwd, "behold-demos", entry.name);
33970
34562
  }
33971
34563
  async function loadDemo(entry, opts) {
33972
34564
  const { pkgRoot: pkgRoot3, target } = opts;
@@ -33975,12 +34567,12 @@ async function loadDemo(entry, opts) {
33975
34567
  const inPlace = entry.source === "local" && entry.inPlace;
33976
34568
  const work = inPlace ? local : target;
33977
34569
  if (inPlace) {
33978
- if (!existsSync34(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
34570
+ if (!existsSync35(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
33979
34571
  say(`serving ${work} where it is \u2014 nothing copied`);
33980
- } else if (!existsSync34(target)) {
34572
+ } else if (!existsSync35(target)) {
33981
34573
  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})` };
34574
+ const from = entry.source === "bundled" ? join56(pkgRoot3, entry.dir) : local;
34575
+ 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
34576
  say(`copying to ${target} (it's yours \u2014 edit it)`);
33985
34577
  try {
33986
34578
  cpSync(from, target, {
@@ -34011,7 +34603,7 @@ async function loadDemo(entry, opts) {
34011
34603
  if (!pins.ok) return { ok: false, error: `${pins.error} ${pins.remedy}` };
34012
34604
  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
34605
  }
34014
- if (!inPlace && existsSync34(join55(work, "package.json")) && !existsSync34(join55(work, "node_modules"))) {
34606
+ if (!inPlace && existsSync35(join56(work, "package.json")) && !existsSync35(join56(work, "node_modules"))) {
34015
34607
  say("npm install\u2026");
34016
34608
  if (await runStep("npm", ["install"], { cwd: work, shell: process.platform === "win32" }) !== 0) {
34017
34609
  return { ok: false, error: `npm install failed in ${work}` };
@@ -34028,7 +34620,7 @@ async function loadDemo(entry, opts) {
34028
34620
  return { ok: false, error: `setup failed (${entry.setup})` };
34029
34621
  }
34030
34622
  }
34031
- return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join55(work, d)) : [work] };
34623
+ return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join56(work, d)) : [work] };
34032
34624
  }
34033
34625
  function runStep(cmd, args, opts = {}) {
34034
34626
  return new Promise((res) => {
@@ -34039,8 +34631,8 @@ function runStep(cmd, args, opts = {}) {
34039
34631
  }
34040
34632
 
34041
34633
  // src/server.ts
34042
- var pkgRoot = join56(dirname20(fileURLToPath13(import.meta.url)), "..");
34043
- var webRoot2 = join56(pkgRoot, "web");
34634
+ var pkgRoot = join57(dirname20(fileURLToPath13(import.meta.url)), "..");
34635
+ var webRoot2 = join57(pkgRoot, "web");
34044
34636
  var execFileP = async (cmd, args) => (await promisify3(execFile6)(cmd, args, { encoding: "utf8", timeout: 1e4 })).stdout;
34045
34637
  function optsFromQuery(url, tierEnvVar, projectDir) {
34046
34638
  const q = url.searchParams;
@@ -34091,7 +34683,7 @@ function tierFailure(tier, message2) {
34091
34683
  function beholdVersion() {
34092
34684
  try {
34093
34685
  const here = dirname20(fileURLToPath13(import.meta.url));
34094
- return JSON.parse(readFileSync44(join56(here, "..", "package.json"), "utf8")).version ?? "unknown";
34686
+ return JSON.parse(readFileSync45(join57(here, "..", "package.json"), "utf8")).version ?? "unknown";
34095
34687
  } catch {
34096
34688
  return "unknown";
34097
34689
  }
@@ -34127,6 +34719,7 @@ function deployTargets(lexicons = [], k8sTarget) {
34127
34719
  async function captureFrame(projectDir, env, frames, broadcaster) {
34128
34720
  try {
34129
34721
  invalidateOverlay();
34722
+ invalidateHealth();
34130
34723
  const ir = await graphIr(projectDir, env ? { live: true, overlay: true, env } : {});
34131
34724
  const captured = frames.capture(ir) !== null;
34132
34725
  if (captured) broadcaster.emit("frames");
@@ -34139,11 +34732,11 @@ async function captureFrame(projectDir, env, frames, broadcaster) {
34139
34732
  }
34140
34733
  function terralithRoutes(app, demo) {
34141
34734
  app.get("/api/terralith", (c) => c.json(readTerralith(demo.root)));
34142
- app.get("/terralith", serveStatic({ path: join56(relative12(process.cwd(), webRoot2) || ".", "terralith.html") }));
34735
+ app.get("/terralith", serveStatic({ path: join57(relative12(process.cwd(), webRoot2) || ".", "terralith.html") }));
34143
34736
  app.get("/", (c) => c.redirect("/terralith"));
34144
34737
  }
34145
34738
  function carveRoutes(app, reportPath, demo) {
34146
- const load2 = () => readCarveReport(reportPath, (p) => readFileSync44(p, "utf8"));
34739
+ const load2 = () => readCarveReport(reportPath, (p) => readFileSync45(p, "utf8"));
34147
34740
  const carveDirs = [dirname20(reportPath), ...demo ? [demo.out] : []];
34148
34741
  const carveStates = () => readCarveStates(carveDirs, nodeCarveIo, 0);
34149
34742
  const emittedNodes = async (states) => {
@@ -34581,9 +35174,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34581
35174
  return c.json({ started: true, name, ran: label });
34582
35175
  });
34583
35176
  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)) {
35177
+ const down = join57(cfg.projectDir, "scripts/local/local-down.sh");
35178
+ const up = join57(cfg.projectDir, "scripts/local/local-up.sh");
35179
+ if (!existsSync36(down) || !existsSync36(up)) {
34587
35180
  return c.json({ error: "no local-down.sh / local-up.sh in scripts/local \u2014 reset is only for local emulator projects" }, 400);
34588
35181
  }
34589
35182
  if (!runner.bringUp("reset local emulator", "bash", ["-c", "bash scripts/local/local-down.sh && bash scripts/local/local-up.sh"], cfg.projectDir)) {
@@ -34607,7 +35200,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34607
35200
  const dirs = [];
34608
35201
  const declared2 = [];
34609
35202
  for (const f of discoverOpIrs(estateDirs())) {
34610
- const parsed = readOpIr(f.path, (p) => readFileSync44(p, "utf8"));
35203
+ const parsed = readOpIr(f.path, (p) => readFileSync45(p, "utf8"));
34611
35204
  if (!parsed.ok) continue;
34612
35205
  const mine = declaredConvergeOps([parsed.ir]);
34613
35206
  if (!mine.length) continue;
@@ -34856,9 +35449,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34856
35449
  recent: recent2.map(({ dir, ...rest }) => ({ dir: relative12(cfg.projectDir, dir) || ".", ...rest }))
34857
35450
  }
34858
35451
  };
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 });
35452
+ const cache7 = memberIrCacheStats();
35453
+ if (readsOnly) return c.json({ reads: reads2, cache: cache7 });
35454
+ return c.json({ ...await diagnose(cfg.projectDir), reads: reads2, cache: cache7 });
34862
35455
  });
34863
35456
  app.get("/api/project", async (c) => {
34864
35457
  const { environments: declaredEnvs, lexicons, stacks, k8sProfiles } = await detectProject(cfg.projectDir);
@@ -34997,9 +35590,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
34997
35590
  app.post("/api/project/open", async (c) => {
34998
35591
  if (cfg.previewMode) return c.json({ error: "switching projects is locked in preview mode" }, 403);
34999
35592
  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"))) {
35593
+ const dir = typeof body.dir === "string" && body.dir.trim() ? resolve35(body.dir.trim()) : "";
35594
+ if (!dir || !existsSync36(dir)) return c.json({ error: `no such directory: ${dir || "(no dir given)"}` }, 400);
35595
+ if (!existsSync36(join57(dir, "chant.config.ts"))) {
35003
35596
  return c.json({ error: `${dir} doesn't look like a chant project \u2014 no chant.config.ts` }, 400);
35004
35597
  }
35005
35598
  switchServedProject([dir]);
@@ -35022,7 +35615,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35022
35615
  };
35023
35616
  app.post("/api/project/reveal", async (c) => {
35024
35617
  const body = await c.req.json().catch(() => ({}));
35025
- const dir = typeof body.dir === "string" && body.dir.trim() ? resolve34(body.dir.trim()) : cfg.projectDir;
35618
+ const dir = typeof body.dir === "string" && body.dir.trim() ? resolve35(body.dir.trim()) : cfg.projectDir;
35026
35619
  const known = /* @__PURE__ */ new Set([cfg.projectDir, ...cfg.projectDirs ?? [], ...listRecents().map((r) => r.dir)]);
35027
35620
  if (!known.has(dir)) return c.json({ error: "not a served or recent project directory" }, 400);
35028
35621
  const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
@@ -35050,7 +35643,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35050
35643
  fetches: fetchesFromNetwork(e),
35051
35644
  ...e.repo ? { repo: e.repo } : {},
35052
35645
  target,
35053
- loaded: existsSync35(target),
35646
+ loaded: existsSync36(target),
35054
35647
  satisfiable: missing.length === 0,
35055
35648
  // #254: the carve walkthrough runs fine here — it just isn't a project
35056
35649
  // to switch INTO. Carve mode claims `/api/graph` and `/api/project` at
@@ -35101,8 +35694,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35101
35694
  return c.json({ error: `${entry.name} loaded to ${target} but ${dirs[0]} is neither a chant project nor a choudoufu estate` }, 500);
35102
35695
  }
35103
35696
  if (entry.serve.local) {
35104
- if (cfg.emulators?.length) await emulatorDown(cfg.projectDir).catch(() => {
35105
- });
35697
+ if (cfg.emulators?.length) await emulatorsDown(emulatorDirs(cfg.workspace?.root ?? cfg.projectDir, cfg.workspace));
35106
35698
  cfg.local = true;
35107
35699
  cfg.emulators = await bootLocalEmulators(dirs[0], `behold demo ${entry.name} --local`);
35108
35700
  }
@@ -35218,6 +35810,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35218
35810
  },
35219
35811
  { method: "GET", path: "/api/layout", desc: "hand-layout sidecar (.behold/layout.json): ?lens=<key> \u2192 {lens, deltas, writable}; no lens \u2192 every lens" },
35220
35812
  { 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)" },
35813
+ { 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
35814
  { method: "GET", path: "/api/diff", desc: "per-node live diff for ?env= \u2014 {env, nodes: {<id>: {observed, diff, health, fieldDrift}}}" },
35222
35815
  { method: "GET", path: "/api/reconcile", desc: "pending-change summary for ?env=" },
35223
35816
  { method: "GET", path: "/api/resources", desc: "component \u2192 declared resources" },
@@ -35364,7 +35957,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35364
35957
  }
35365
35958
  const parsedOps = [];
35366
35959
  for (const f of files) {
35367
- const parsed = readOpIr(f.path, (p) => readFileSync44(p, "utf8"));
35960
+ const parsed = readOpIr(f.path, (p) => readFileSync45(p, "utf8"));
35368
35961
  if (!parsed.ok) return c.json(parsed.refusal, 422);
35369
35962
  parsedOps.push(parsed.ir);
35370
35963
  }
@@ -35377,8 +35970,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35377
35970
  }
35378
35971
  const runState = runner.runState;
35379
35972
  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;
35973
+ const join62 = ranOp ? joinRun(ranOp, runState.steps, runState.gate, { guessNext: runState.source !== "events" }) : null;
35974
+ const opsIr = join62 ? paintPlayhead(declaredIr, join62, runState.gate) : declaredIr;
35382
35975
  const { svg: svg2 } = renderGraph(opsIr, { boxes: "byStack" });
35383
35976
  const operator = runner.noteDeclaredConvergeOps(declaredConvergeOps(parsedOps));
35384
35977
  return c.json({
@@ -35391,7 +35984,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35391
35984
  target: null,
35392
35985
  mode: "ops",
35393
35986
  ops: parsedOps.length,
35394
- note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join61)} ${operatorNote(operator)}`,
35987
+ note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join62)} ${operatorNote(operator)}`,
35395
35988
  // The operator strip's own model: the ConvergeOps this project
35396
35989
  // declares, plus whatever the last status read said. `declared`
35397
35990
  // without a `strip` is the honest starting state — a loop exists and
@@ -35504,7 +36097,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35504
36097
  srcCompositeEdgesAttached = 0;
35505
36098
  }
35506
36099
  }
35507
- if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync35(join56(cfg.projectDir, "chant.config.ts"))) {
36100
+ if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync36(join57(cfg.projectDir, "chant.config.ts"))) {
35508
36101
  return c.json(noProjectError(cfg.projectDir), 404);
35509
36102
  }
35510
36103
  const radial = new URL(c.req.url).searchParams.get("radial") === "1";
@@ -35938,6 +36531,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35938
36531
  if (url.searchParams.get("notify") === "1") {
35939
36532
  invalidateMember();
35940
36533
  invalidateOverlay();
36534
+ invalidateHealth();
35941
36535
  broadcaster.emit("changed", "");
35942
36536
  return c.json({ notified: true });
35943
36537
  }
@@ -35971,6 +36565,24 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
35971
36565
  captured: result.captured
35972
36566
  });
35973
36567
  });
36568
+ app.get("/api/health", async (c) => {
36569
+ const url = new URL(c.req.url);
36570
+ const env = optsFromQuery(url).env ?? cfg.env;
36571
+ if (!env) return c.json({ error: "health needs an environment: pick one, or start with --env", code: "env" }, 400);
36572
+ if (!isEnvName(env)) return c.json({ error: `${JSON.stringify(env)} isn't an env name`, code: "env" }, 400);
36573
+ const ws = servedWorkspace();
36574
+ 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 }] : [];
36575
+ const key3 = `${ws?.root ?? cfg.projectDir}\0${env}`;
36576
+ const hit = url.searchParams.get("fresh") === "1" ? void 0 : cachedHealth(key3);
36577
+ if (hit) return c.json({ ...hit, cached: true });
36578
+ const answer = await readHealthOverlay(members, env, {
36579
+ chantVersion: (dir) => resolveChant(dir).version,
36580
+ reader: (dir) => rootReader(dir),
36581
+ graph: (dir) => memberIr(dir, { detail: 2 })
36582
+ });
36583
+ rememberHealth(key3, answer);
36584
+ return c.json(answer);
36585
+ });
35974
36586
  app.get("/api/diff", async (c) => {
35975
36587
  const env = optsFromQuery(new URL(c.req.url)).env ?? cfg.env;
35976
36588
  if (!env) return c.json({ error: "diff needs an environment \u2014 pick one, or start with --env" }, 400);
@@ -36021,9 +36633,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
36021
36633
  });
36022
36634
  const choudoufuPlanPath = (plan) => {
36023
36635
  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);
36636
+ const abs = resolve35(cfg.projectDir, plan);
36025
36637
  const members = (cfg.projectDirs ?? [cfg.projectDir]).filter((d) => memberKindOf(d) === "choudoufu");
36026
- const inside = members.some((d) => abs.startsWith(resolve34(d) + sep10));
36638
+ const inside = members.some((d) => abs.startsWith(resolve35(d) + sep10));
36027
36639
  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
36640
  return { path: abs };
36029
36641
  };
@@ -36162,13 +36774,13 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
36162
36774
  if (!c.req.path.startsWith("/api/") && c.res.ok && !c.res.headers.has("cache-control")) c.res.headers.set("cache-control", "no-cache");
36163
36775
  });
36164
36776
  app.use("/*", serveStatic({ root: rel }));
36165
- app.get("/", serveStatic({ path: join56(rel, "index.html") }));
36777
+ app.get("/", serveStatic({ path: join57(rel, "index.html") }));
36166
36778
  if (cfg.terragucci || cfg.chantDemo) vendorFallback(app);
36167
36779
  return app;
36168
36780
  }
36169
- async function bootLocalEmulators(dir, who) {
36781
+ async function bootLocalEmulators(dir, who, workspace) {
36170
36782
  try {
36171
- const emulators = await emulatorUp(dir);
36783
+ const emulators = await emulatorsUp(emulatorDirs(dir, workspace));
36172
36784
  if (emulators.length === 0) {
36173
36785
  process.stderr.write(`${who}: no configured lexicon has a local emulator \u2014 serving without one.
36174
36786
  `);
@@ -36190,9 +36802,9 @@ async function bootLocalEmulators(dir, who) {
36190
36802
  }
36191
36803
  }
36192
36804
  async function startServer(cfg) {
36193
- if (cfg.local) cfg.emulators = await bootLocalEmulators(cfg.projectDir, "behold serve --local");
36805
+ if (cfg.local) cfg.emulators = await bootLocalEmulators(cfg.workspace?.root ?? cfg.projectDir, "behold serve --local", cfg.workspace);
36194
36806
  for (const dir of cfg.projectDirs ?? [cfg.projectDir]) {
36195
- if (existsSync35(join56(dir, "chant.config.ts"))) addRecent(dir);
36807
+ if (existsSync36(join57(dir, "chant.config.ts"))) addRecent(dir);
36196
36808
  }
36197
36809
  const broadcaster = new Broadcaster();
36198
36810
  const frames = new FrameBuffer();
@@ -36304,10 +36916,7 @@ async function startServer(cfg) {
36304
36916
  stopPoll();
36305
36917
  const downs = [];
36306
36918
  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
- );
36919
+ downs.push(emulatorsDown(emulatorDirs(cfg.workspace?.root ?? cfg.projectDir, cfg.workspace)));
36311
36920
  }
36312
36921
  if (cfg.carveDemo?.live) downs.push(teardownScratchFloci().catch(() => void 0));
36313
36922
  void Promise.all(downs).finally(() => process.exit(0));
@@ -36377,8 +36986,8 @@ init_chant();
36377
36986
 
36378
36987
  // src/workspace-convert.ts
36379
36988
  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";
36989
+ import { existsSync as existsSync37, mkdirSync as mkdirSync9, readFileSync as readFileSync46, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
36990
+ import { basename as basename8, dirname as dirname21, join as join58, relative as relative13, resolve as resolve36, sep as sep11 } from "node:path";
36382
36991
  import { shortStackNames as shortStackNames2 } from "@intentius/pinhole";
36383
36992
  init_project();
36384
36993
  init_terraform_member();
@@ -36395,11 +37004,11 @@ function unique(name, taken) {
36395
37004
  }
36396
37005
  var posix5 = (p) => p.split(sep11).join("/");
36397
37006
  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)) {
37007
+ for (let at2 = resolve36(dir); ; at2 = dirname21(at2)) {
37008
+ const manifest = join58(at2, "node_modules", ...pkg.split("/"), "package.json");
37009
+ if (existsSync37(manifest)) {
36401
37010
  try {
36402
- const v = JSON.parse(readFileSync45(manifest, "utf8")).version;
37011
+ const v = JSON.parse(readFileSync46(manifest, "utf8")).version;
36403
37012
  return typeof v === "string" ? v : void 0;
36404
37013
  } catch {
36405
37014
  return void 0;
@@ -36409,14 +37018,14 @@ function installedVersion(pkg, dir) {
36409
37018
  }
36410
37019
  }
36411
37020
  function planConversion(rootArg) {
36412
- const root = resolve35(rootArg);
36413
- const existing = DECLARATION_FILES.find((f) => existsSync36(join57(root, f)));
37021
+ const root = resolve36(rootArg);
37022
+ const existing = DECLARATION_FILES.find((f) => existsSync37(join58(root, f)));
36414
37023
  if (existing) return { ok: false, error: `${root} already has ${existing}; there is nothing to convert.` };
36415
37024
  const shape = detectProjectShape(root);
36416
37025
  if (shape.kind !== "estate" || !shape.members?.length || shape.membersFrom === "itself") {
36417
37026
  return { ok: false, error: `${root} is not an estate root with a member list, so there is no member list to convert.` };
36418
37027
  }
36419
- const abs = shape.members.map((m) => resolve35(root, m.dir));
37028
+ const abs = shape.members.map((m) => resolve36(root, m.dir));
36420
37029
  const shorts = shortStackNames2(abs);
36421
37030
  const taken = /* @__PURE__ */ new Set();
36422
37031
  const members = [];
@@ -36431,10 +37040,10 @@ function planConversion(rootArg) {
36431
37040
  const scan = discoverTerraformRoots(abs[i]);
36432
37041
  for (const r of scan.roots) {
36433
37042
  const name2 = unique(declarationName(r.name), taken);
36434
- members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join57(dir, r.dir)), kind: "terraform" });
37043
+ members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join58(dir, r.dir)), kind: "terraform" });
36435
37044
  moves.push({ from: `${short}/${r.name}/`, to: `${name2}/${name2}/` });
36436
37045
  }
36437
- for (const s of scan.skipped) notes.push(`${posix5(join57(dir, s.dir))} is not declared: ${s.why}.`);
37046
+ for (const s of scan.skipped) notes.push(`${posix5(join58(dir, s.dir))} is not declared: ${s.why}.`);
36438
37047
  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
37048
  return;
36440
37049
  }
@@ -36462,7 +37071,7 @@ function planConversion(rootArg) {
36462
37071
  };
36463
37072
  const firstLayout = layoutPath(abs[0]);
36464
37073
  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 } };
37074
+ return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...existsSync37(firstLayout) ? { layoutFrom: firstLayout } : {}, notes } };
36466
37075
  }
36467
37076
  function moveLayoutIds(file, moves) {
36468
37077
  const lenses = {};
@@ -36477,18 +37086,18 @@ function moveLayoutIds(file, moves) {
36477
37086
  return { version: 1, lenses };
36478
37087
  }
36479
37088
  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`);
37089
+ const declarationFile = join58(plan.root, DECLARATION_FILES[0]);
37090
+ if (existsSync37(declarationFile)) throw new Error(`${declarationFile} appeared while converting; nothing was written`);
36482
37091
  writeFileSync7(declarationFile, `${JSON.stringify(plan.declaration, null, 2)}
36483
37092
  `);
36484
37093
  let layout;
36485
37094
  const target = layoutPath(plan.root);
36486
37095
  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` };
37096
+ else if (resolve36(plan.layoutFrom) === resolve36(target)) layout = { skipped: "the saved layout is already in the root" };
37097
+ else if (existsSync37(target)) layout = { skipped: `${target} already exists; the layout in ${plan.layoutFrom} was left alone` };
36489
37098
  else {
36490
37099
  const moved = moveLayoutIds(readLayoutFile(dirname21(dirname21(plan.layoutFrom))), plan.moves);
36491
- mkdirSync9(join57(plan.root, LAYOUT_DIR), { recursive: true });
37100
+ mkdirSync9(join58(plan.root, LAYOUT_DIR), { recursive: true });
36492
37101
  const tmp = `${target}.tmp`;
36493
37102
  writeFileSync7(tmp, `${JSON.stringify(moved, null, 2)}
36494
37103
  `);
@@ -36499,9 +37108,9 @@ function applyConversion(plan) {
36499
37108
  }
36500
37109
 
36501
37110
  // 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";
37111
+ 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
37112
  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";
37113
+ import { join as join59, dirname as dirname22, basename as basename9, relative as relative14, resolve as resolve37, sep as sep12 } from "node:path";
36505
37114
  import { createHash as createHash11 } from "node:crypto";
36506
37115
  import { fileURLToPath as fileURLToPath14 } from "node:url";
36507
37116
  var LENS_PARAMS = ["collapse", "components", "detail", "env", "logical", "ops", "radial", "stacks", "tier"];
@@ -36528,6 +37137,7 @@ function captureKeys(axes) {
36528
37137
  if (axes.terragucci || axes.sqlYodeler) add("/api/lifecycle/history", {});
36529
37138
  if (axes.yodelReport) add("/api/yodel-report", {});
36530
37139
  if (axes.sqlYodeler) add("/api/sql-yodeler/lifecycle", {});
37140
+ for (const env of axes.environments) add("/api/health", { env });
36531
37141
  const tiers = axes.tiers && axes.tiers.length ? axes.tiers : [""];
36532
37142
  const envs = ["", ...axes.environments];
36533
37143
  for (const env of envs) {
@@ -36558,34 +37168,66 @@ function captureKeys(axes) {
36558
37168
  return [...keys];
36559
37169
  }
36560
37170
  function webDir() {
36561
- return join58(dirname22(fileURLToPath14(import.meta.url)), "..", "web");
37171
+ return join59(dirname22(fileURLToPath14(import.meta.url)), "..", "web");
36562
37172
  }
36563
37173
  function pkgRoot2() {
36564
- return join58(dirname22(fileURLToPath14(import.meta.url)), "..");
37174
+ return join59(dirname22(fileURLToPath14(import.meta.url)), "..");
36565
37175
  }
36566
37176
  var NOTICE_FILES = ["LICENSE", "THIRD_PARTY.md"];
36567
37177
  function copyNotices(outDir, root = pkgRoot2()) {
36568
37178
  const copied = [];
36569
37179
  for (const f of NOTICE_FILES) {
36570
- if (!existsSync37(join58(root, f))) continue;
36571
- copyFileSync(join58(root, f), join58(outDir, f));
37180
+ if (!existsSync38(join59(root, f))) continue;
37181
+ copyFileSync(join59(root, f), join59(outDir, f));
36572
37182
  copied.push(f);
36573
37183
  }
36574
- const lic = join58(root, "licenses");
36575
- if (existsSync37(lic)) {
36576
- mkdirSync10(join58(outDir, "licenses"), { recursive: true });
37184
+ const lic = join59(root, "licenses");
37185
+ if (existsSync38(lic)) {
37186
+ mkdirSync10(join59(outDir, "licenses"), { recursive: true });
36577
37187
  for (const f of readdirSync21(lic)) {
36578
- copyFileSync(join58(lic, f), join58(outDir, "licenses", f));
37188
+ copyFileSync(join59(lic, f), join59(outDir, "licenses", f));
36579
37189
  copied.push(`licenses/${f}`);
36580
37190
  }
36581
37191
  }
36582
37192
  return copied;
36583
37193
  }
36584
37194
  function workerName(project, override) {
36585
- const raw = override ?? `behold-${basename9(project)}`;
37195
+ const raw = override ?? `behold-${project}`;
36586
37196
  const name = raw.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63);
36587
37197
  return name || "behold-export";
36588
37198
  }
37199
+ function bundleIdentity(cfg) {
37200
+ if (cfg.workspace) return { projectDir: basename9(cfg.workspace.root), worker: cfg.workspace.name, workspace: cfg.workspace.name };
37201
+ return { projectDir: basename9(cfg.projectDir), worker: basename9(cfg.projectDir) };
37202
+ }
37203
+ var OPENING_ZOOMS = ["components", "logical", "composites", "resources", "attributes"];
37204
+ var ExportRefusal = class extends Error {
37205
+ };
37206
+ function settleOpening(want, axes) {
37207
+ const opening = {};
37208
+ if (want.env !== void 0) {
37209
+ if (!axes.environments.includes(want.env)) {
37210
+ const has = axes.environments.length ? `it captures ${axes.environments.join(", ")}` : "it captures no environment, only the source graph";
37211
+ return { error: `--open-env ${want.env} isn't an environment this export captures: ${has}` };
37212
+ }
37213
+ opening.env = want.env;
37214
+ }
37215
+ if (want.zoom !== void 0) {
37216
+ const zooms = [...OPENING_ZOOMS, ...axes.ops ? ["ops"] : []];
37217
+ if (!zooms.includes(want.zoom)) return { error: `--open-zoom ${want.zoom} isn't a zoom this export captures: it takes ${zooms.join(", ")}` };
37218
+ opening.zoom = want.zoom;
37219
+ }
37220
+ return { opening };
37221
+ }
37222
+ var NOTE_MAX = 200;
37223
+ function settleNote(note) {
37224
+ if (note === void 0) return {};
37225
+ const text3 = note.trim();
37226
+ if (!text3) return { error: "--note needs the line the page shows at its foot" };
37227
+ if (/[\r\n]/.test(text3)) return { error: "--note takes one line" };
37228
+ if (text3.length > NOTE_MAX) return { error: `--note takes at most ${NOTE_MAX} characters, not ${text3.length}` };
37229
+ return { note: text3 };
37230
+ }
36589
37231
  var VIEWS_REPORTS_BASE = "../../";
36590
37232
  async function runExport(cfg, outDir, opts = {}) {
36591
37233
  const app = createApp({ ...cfg, layoutWrites: false });
@@ -36599,8 +37241,13 @@ async function runExport(cfg, outDir, opts = {}) {
36599
37241
  ...proj.yodelReport ? { yodelReport: true } : {},
36600
37242
  ...proj.sqlYodeler ? { sqlYodeler: true } : {}
36601
37243
  };
37244
+ const settled = settleOpening(opts.open ?? {}, axes);
37245
+ if ("error" in settled) throw new ExportRefusal(settled.error);
37246
+ const opening = settled.opening;
37247
+ const settledNote = settleNote(opts.note);
37248
+ if ("error" in settledNote) throw new ExportRefusal(settledNote.error);
36602
37249
  const scrub = exportScrubber(cfg);
36603
- const snapDir = join58(outDir, "snapshots");
37250
+ const snapDir = join59(outDir, "snapshots");
36604
37251
  mkdirSync10(snapDir, { recursive: true });
36605
37252
  const keyToFile = {};
36606
37253
  let ok = 0;
@@ -36609,7 +37256,7 @@ async function runExport(cfg, outDir, opts = {}) {
36609
37256
  const res = await app.request(`${key3}${key3.includes("?") ? "&" : "?"}layout=1`);
36610
37257
  const body = scrub(shapeSnapshot(key3, await res.text(), opts));
36611
37258
  const file = slug3(key3, body);
36612
- writeFileSync8(join58(snapDir, file), body);
37259
+ writeFileSync8(join59(snapDir, file), body);
36613
37260
  keyToFile[key3] = `snapshots/${file}`;
36614
37261
  if (res.ok) ok++;
36615
37262
  else failed++;
@@ -36624,36 +37271,40 @@ async function runExport(cfg, outDir, opts = {}) {
36624
37271
  ${refusal2.remedy}` : ""}`);
36625
37272
  }
36626
37273
  }
37274
+ const identity = bundleIdentity(cfg);
36627
37275
  const manifest = {
36628
37276
  static: true,
36629
37277
  capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
36630
- projectDir: basename9(cfg.projectDir),
37278
+ projectDir: identity.projectDir,
37279
+ ...identity.workspace ? { workspace: identity.workspace } : {},
37280
+ ...Object.keys(opening).length ? { opening } : {},
37281
+ ...settledNote.note ? { note: settledNote.note } : {},
36631
37282
  axes,
36632
37283
  keyToFile
36633
37284
  };
36634
- writeFileSync8(join58(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
36635
- const html = readFileSync46(join58(webDir(), "index.html"), "utf8").replace(
37285
+ writeFileSync8(join59(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
37286
+ const html = readFileSync47(join59(webDir(), "index.html"), "utf8").replace(
36636
37287
  /<\/head>/i,
36637
37288
  ` <script>window.__BEHOLD_STATIC__ = true;</script>
36638
37289
  </head>`
36639
37290
  );
36640
- writeFileSync8(join58(outDir, "index.html"), html);
37291
+ writeFileSync8(join59(outDir, "index.html"), html);
36641
37292
  for (const f of readdirSync21(webDir())) {
36642
37293
  if (f === "index.html" || f.endsWith(".test.js")) continue;
36643
- cpSync2(join58(webDir(), f), join58(outDir, f), { recursive: true });
37294
+ cpSync2(join59(webDir(), f), join59(outDir, f), { recursive: true });
36644
37295
  }
36645
- writeFileSync8(join58(outDir, "README.md"), BUNDLE_README);
37296
+ writeFileSync8(join59(outDir, "README.md"), BUNDLE_README);
36646
37297
  copyNotices(outDir);
36647
- const name = workerName(cfg.projectDir, opts.name);
37298
+ const name = workerName(identity.worker, opts.name);
36648
37299
  writeFileSync8(
36649
- join58(outDir, "wrangler.jsonc"),
37300
+ join59(outDir, "wrangler.jsonc"),
36650
37301
  JSON.stringify(
36651
37302
  { $schema: "node_modules/wrangler/config-schema.json", name, compatibility_date: "2025-06-01", assets: { directory: "." } },
36652
37303
  null,
36653
37304
  2
36654
37305
  ) + "\n"
36655
37306
  );
36656
- writeFileSync8(join58(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
37307
+ writeFileSync8(join59(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
36657
37308
  process.stdout.write(
36658
37309
  `behold export \u2192 ${outDir}
36659
37310
  ${ok} snapshots${failed ? ` (${failed} endpoint error(s) captured as-is)` : ""}
@@ -36662,11 +37313,11 @@ async function runExport(cfg, outDir, opts = {}) {
36662
37313
  `
36663
37314
  );
36664
37315
  }
36665
- var isRecord34 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
37316
+ var isRecord35 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
36666
37317
  function dropSource(v) {
36667
37318
  if (Array.isArray(v)) return v.forEach(dropSource);
36668
- if (!isRecord34(v)) return;
36669
- if (isRecord34(v.attrs)) delete v.attrs.source;
37319
+ if (!isRecord35(v)) return;
37320
+ if (isRecord35(v.attrs)) delete v.attrs.source;
36670
37321
  for (const x of Object.values(v)) dropSource(x);
36671
37322
  }
36672
37323
  function shapeSnapshot(key3, body, opts = {}) {
@@ -36676,7 +37327,7 @@ function shapeSnapshot(key3, body, opts = {}) {
36676
37327
  } catch {
36677
37328
  return body;
36678
37329
  }
36679
- if (!isRecord34(doc)) return body;
37330
+ if (!isRecord35(doc)) return body;
36680
37331
  if (key3 === "/api/project") {
36681
37332
  delete doc.recents;
36682
37333
  delete doc.approver;
@@ -36688,11 +37339,11 @@ function shapeSnapshot(key3, body, opts = {}) {
36688
37339
  function exportScrubber(cfg, home = homedir4()) {
36689
37340
  const dirs = [cfg.projectDir, ...cfg.projectDirs ?? [], ...cfg.workspace ? [cfg.workspace.root] : []];
36690
37341
  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));
37342
+ if (tg && !/^[a-z0-9]+:\/\//i.test(tg)) dirs.push(resolve37(tg));
37343
+ if (cfg.yodelReport) dirs.push(resolve37(cfg.yodelReport));
36693
37344
  const pairs = /* @__PURE__ */ new Map();
36694
37345
  for (const d of dirs) {
36695
- for (const p of [resolve36(d), safeRealpath(d)]) if (p && p !== "/") pairs.set(p, basename9(p));
37346
+ for (const p of [resolve37(d), safeRealpath(d)]) if (p && p !== "/") pairs.set(p, basename9(p));
36696
37347
  }
36697
37348
  const ordered = [...pairs].sort((a, b) => b[0].length - a[0].length);
36698
37349
  return (text3) => {
@@ -36746,11 +37397,11 @@ function manifestFiles(text3) {
36746
37397
  } catch {
36747
37398
  return [];
36748
37399
  }
36749
- const map = isRecord34(doc) && isRecord34(doc.keyToFile) ? doc.keyToFile : {};
37400
+ const map = isRecord35(doc) && isRecord35(doc.keyToFile) ? doc.keyToFile : {};
36750
37401
  return Object.values(map).filter((f) => typeof f === "string" && /^snapshots\/[A-Za-z0-9=_.-]+$/.test(f) && !f.includes(".."));
36751
37402
  }
36752
37403
  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();
37404
+ 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
37405
  }
36755
37406
  async function publishBundle(outDir, target, client) {
36756
37407
  const files = bundleFiles(outDir);
@@ -36766,7 +37417,7 @@ async function publishBundle(outDir, target, client) {
36766
37417
  }
36767
37418
  const last = ["manifest.json", "index.html"];
36768
37419
  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);
37420
+ for (const f of order) await client.put(at2(f), readFileSync47(join59(outDir, f)), contentType(f), CONTENT_ADDRESSED.test(f) ? IMMUTABLE : NO_CACHE);
36770
37421
  const wrote = new Set(files);
36771
37422
  const removed = [];
36772
37423
  for (const f of previous) {
@@ -36818,8 +37469,8 @@ It's just files \u2014 GitHub Pages, S3, nginx, or Cloudflare Pages
36818
37469
 
36819
37470
  // src/publish-snapshots.ts
36820
37471
  import { execFileSync as execFileSync4 } from "node:child_process";
36821
- import { readFileSync as readFileSync47 } from "node:fs";
36822
- import { join as join59 } from "node:path";
37472
+ import { readFileSync as readFileSync48 } from "node:fs";
37473
+ import { join as join60 } from "node:path";
36823
37474
  var DEFAULT_KEEP = 30;
36824
37475
  var SNAPSHOT_REPORTS_BASE = "../../../";
36825
37476
  var COMMIT2 = /^[0-9a-f]{7,64}$/;
@@ -36844,12 +37495,12 @@ function resolveCommit2(dir, given) {
36844
37495
  return { sha };
36845
37496
  }
36846
37497
  }
36847
- var isRecord35 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
37498
+ var isRecord36 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
36848
37499
  function parseHistory(text3) {
36849
37500
  const doc = JSON.parse(text3);
36850
37501
  if (!Array.isArray(doc)) throw new Error("history.json is not an array");
36851
37502
  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) }));
37503
+ 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
37504
  }
36854
37505
  function nextHistory(old, entry, keep) {
36855
37506
  const all = [entry, ...old.filter((e) => e.commit !== entry.commit)];
@@ -36861,9 +37512,9 @@ var BUNDLE_PATH = /^[A-Za-z0-9=_.@+-]+(\/[A-Za-z0-9=_.@+-]+)*$/;
36861
37512
  var insideBundle = (f) => typeof f === "string" && BUNDLE_PATH.test(f) && !f.split("/").some((p) => p === "." || p === "..");
36862
37513
  function commitFiles(manifestText) {
36863
37514
  const doc = JSON.parse(manifestText);
36864
- if (!isRecord35(doc)) return ["manifest.json"];
37515
+ if (!isRecord36(doc)) return ["manifest.json"];
36865
37516
  const listed = Array.isArray(doc.files) ? doc.files.filter(insideBundle) : [];
36866
- const snaps = isRecord35(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
37517
+ const snaps = isRecord36(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
36867
37518
  const rest = [.../* @__PURE__ */ new Set([...listed, ...snaps])].filter((f) => f !== "index.html" && f !== "manifest.json").sort();
36868
37519
  return ["index.html", ...rest, "manifest.json"];
36869
37520
  }
@@ -36907,7 +37558,7 @@ async function publishSnapshot(outDir, target, commit, client, opts = {}) {
36907
37558
  const keep = opts.keep ?? DEFAULT_KEEP;
36908
37559
  if (!Number.isInteger(keep) || keep < 1) throw new Error(`--keep takes a whole number of at least 1, not ${keep}`);
36909
37560
  const at2 = (f) => `${target.prefix}/${f}`;
36910
- const local = JSON.parse(readFileSync47(join59(outDir, "manifest.json"), "utf8"));
37561
+ const local = JSON.parse(readFileSync48(join60(outDir, "manifest.json"), "utf8"));
36911
37562
  const generated = local.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString();
36912
37563
  const entry = { commit: sha, at: commit.at ?? generated, project: opts.project ?? local.projectDir ?? "", generated };
36913
37564
  const bundle = await publishBundle(outDir, { bucket: target.bucket, prefix: at2(sha) }, client);
@@ -36972,7 +37623,7 @@ Usage:
36972
37623
  behold preview [project-dir] [--port <n>] [--emulator]
36973
37624
  behold export [project-dir] [--out <dir>] [--env <name>] [--name <worker>] [--emulator]
36974
37625
  [--terragucci <src> [--terragucci-project <p>] [--reports-base <rel>]] [--no-source]
36975
- [--yodel-report <file|dir>]
37626
+ [--yodel-report <file|dir>] [--open-env <env>] [--open-zoom <zoom>] [--note <text>]
36976
37627
  [--publish s3://<bucket>/<prefix>/views/<name> [--commit <sha>] [--keep <n>]]
36977
37628
  behold serve <project-dir\u2026> [--port <n>] [--host <addr>] [--allow-host <name,\u2026>] [--hud <url>] [--env <name>] [--poll <secs>] [--local]
36978
37629
  [--public] [--terragucci <src> [--terragucci-project <p>] [--terragucci-poll <secs>] [--terragucci-runs <src>]]
@@ -37222,7 +37873,16 @@ Options:
37222
37873
  bundle at <prefix>/views/behold/; ../../../ with
37223
37874
  --publish, whose bundle sits one commit deeper).
37224
37875
  --name <worker> export only: Cloudflare Worker name in the generated
37225
- wrangler.jsonc.
37876
+ wrangler.jsonc (default behold-<directory>, or
37877
+ behold-<workspace name> for a declared workspace).
37878
+ --open-env <env> export only: the environment the bundle opens on, one
37879
+ it captures (a declared one). Default: the source graph.
37880
+ --open-zoom <zoom> export only: the zoom the bundle opens on: components,
37881
+ logical, composites, resources or attributes, or ops
37882
+ when the estate has emitted Ops.
37883
+ --note <text> export only: one line the page shows at its foot, such
37884
+ as how to run the estate yourself; a span in backticks
37885
+ is drawn as code. At most 200 characters.
37226
37886
  -h, --help This text.
37227
37887
  -v, --version Print the behold version.
37228
37888
  `;
@@ -37425,7 +38085,7 @@ ${USAGE}`);
37425
38085
  process.stderr.write("behold serve: --repos serves one checkout per request, beside one <project-dir>\n");
37426
38086
  process.exit(2);
37427
38087
  }
37428
- const dirs = projectDirs.map((d) => resolve37(d));
38088
+ const dirs = projectDirs.map((d) => resolve38(d));
37429
38089
  for (const [flag2, v] of Object.entries({ "--as": approverFlags2.as, "--signing-key": approverFlags2.signingKey, "--identity-header": approverFlags2.header, "--identity-forge": approverFlags2.headerForge })) {
37430
38090
  if (v !== void 0 && (!v || v.startsWith("--"))) {
37431
38091
  process.stderr.write(`behold serve: ${flag2} needs a value
@@ -37450,7 +38110,7 @@ ${USAGE}`);
37450
38110
  ` : `behold: the runs pane reads chant's run index at ${target.ciReportUrlDeclared}, the declaration's ci.reportUrl
37451
38111
  `);
37452
38112
  }
37453
- const viewRepos = reposParent !== void 0 ? await serveRepos(resolve37(reposParent), target) : void 0;
38113
+ const viewRepos = reposParent !== void 0 ? await serveRepos(resolve38(reposParent), target) : void 0;
37454
38114
  await startServer({
37455
38115
  ...target,
37456
38116
  ...viewRepos ? { viewRepos } : {},
@@ -37466,7 +38126,7 @@ ${USAGE}`);
37466
38126
  ...Object.keys(approver).length ? { approver } : {},
37467
38127
  ...prometheus ? { prometheus } : {},
37468
38128
  ...tempo ? { tempo } : {},
37469
- ...yodelReport ? { yodelReport: resolve37(yodelReport) } : {},
38129
+ ...yodelReport ? { yodelReport: resolve38(yodelReport) } : {},
37470
38130
  ...chantReportUrl ? { chantReportUrl } : {},
37471
38131
  ...chantDemo ? { chantDemo } : {},
37472
38132
  ...ciReportUrl ? { ciReportUrl } : {},
@@ -37476,7 +38136,7 @@ ${USAGE}`);
37476
38136
  async function serveRepos(parent, primary) {
37477
38137
  const repos = /* @__PURE__ */ new Map();
37478
38138
  for (const c of listCheckouts(parent)) {
37479
- if (resolve37(c.dir) === resolve37(primary.projectDir) && !primary.workspace) {
38139
+ if (resolve38(c.dir) === resolve38(primary.projectDir) && !primary.workspace) {
37480
38140
  repos.set(c.name, { projectDir: primary.projectDir, ...primary.projectDirs ? { projectDirs: primary.projectDirs } : {} });
37481
38141
  continue;
37482
38142
  }
@@ -37547,7 +38207,7 @@ function warnIfNotChantProject(dir) {
37547
38207
  if (shape.kind === "estate") {
37548
38208
  process.stderr.write(
37549
38209
  `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(" ")}
38210
+ Serve its members composed: behold serve ${shape.members.map((m) => join61(dir, m.dir)).join(" ")}
37551
38211
  `
37552
38212
  );
37553
38213
  return;
@@ -37582,8 +38242,8 @@ async function runCarve(rest) {
37582
38242
  );
37583
38243
  process.exit(2);
37584
38244
  }
37585
- const reportPath = resolve37(fileArg);
37586
- const parsed = readCarveReport(reportPath, (p) => readFileSync48(p, "utf8"));
38245
+ const reportPath = resolve38(fileArg);
38246
+ const parsed = readCarveReport(reportPath, (p) => readFileSync49(p, "utf8"));
37587
38247
  if (!parsed.ok) {
37588
38248
  process.stderr.write(`behold carve: ${parsed.refusal.error}
37589
38249
  ${parsed.refusal.remedy}
@@ -37612,8 +38272,8 @@ async function runDoctor(rest) {
37612
38272
  }
37613
38273
  }
37614
38274
  const dir = dirArg ?? ".";
37615
- if (!existsSync38(resolve37(dir))) {
37616
- process.stderr.write(`behold doctor: no such directory: ${resolve37(dir)}
38275
+ if (!existsSync39(resolve38(dir))) {
38276
+ process.stderr.write(`behold doctor: no such directory: ${resolve38(dir)}
37617
38277
  `);
37618
38278
  process.exit(2);
37619
38279
  }
@@ -37649,7 +38309,7 @@ ${check.stdout || check.stderr}
37649
38309
  if (check.code !== 0) process.exitCode = 1;
37650
38310
  }
37651
38311
  async function runDemo(rest) {
37652
- const pkgRoot3 = join60(dirname23(fileURLToPath15(import.meta.url)), "..");
38312
+ const pkgRoot3 = join61(dirname23(fileURLToPath15(import.meta.url)), "..");
37653
38313
  const registry2 = loadDemoRegistry(pkgRoot3);
37654
38314
  let port = 4600;
37655
38315
  let live2 = false;
@@ -37712,7 +38372,7 @@ async function runDemo(rest) {
37712
38372
  `);
37713
38373
  process.exit(2);
37714
38374
  }
37715
- const target = dirArg ? resolve37(dirArg) : demoTargetDir(entry);
38375
+ const target = dirArg ? resolve38(dirArg) : demoTargetDir(entry);
37716
38376
  const loaded = await loadDemo(entry, { pkgRoot: pkgRoot3, target, log: (line) => process.stdout.write(line + "\n") });
37717
38377
  if (!loaded.ok) {
37718
38378
  process.stderr.write(`behold demo ${entry.name}: ${loaded.error}
@@ -37754,7 +38414,7 @@ async function serveTerralithDemo(target, port) {
37754
38414
  await startServer({ projectDir: target, terralithDemo: { root: target, endpoint }, port });
37755
38415
  }
37756
38416
  async function serveCarveDemo(target, carve, port, live2 = false) {
37757
- const at2 = (rel) => resolve37(target, rel);
38417
+ const at2 = (rel) => resolve38(target, rel);
37758
38418
  const project = at2(carve.project);
37759
38419
  const from = at2(carve.from);
37760
38420
  const state = carve.state ? at2(carve.state) : void 0;
@@ -37794,7 +38454,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37794
38454
  };
37795
38455
  process.stdout.write("behold demo carve --live \u2192 the tfstate is real now; the advisor reads what terraform wrote.\n");
37796
38456
  }
37797
- if (existsSync38(join60(project, "package.json")) && !existsSync38(join60(project, "node_modules"))) {
38457
+ if (existsSync39(join61(project, "package.json")) && !existsSync39(join61(project, "node_modules"))) {
37798
38458
  process.stdout.write(`behold demo carve \u2192 npm install in ${carve.project}/ (the chant this walkthrough shells)\u2026
37799
38459
  `);
37800
38460
  const code = await spawnStep("npm", ["install"], project);
@@ -37805,7 +38465,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37805
38465
  }
37806
38466
  }
37807
38467
  let degraded;
37808
- if (!existsSync38(join60(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
38468
+ if (!existsSync39(join61(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
37809
38469
  process.stdout.write(`behold demo carve \u2192 npm install ${HCL_PARSER_PKG} (chant's HCL parser, ~2MB, once)\u2026
37810
38470
  `);
37811
38471
  const code = await spawnStep("npm", ["install", "--no-save", "--no-package-lock", HCL_PARSER_PKG], target);
@@ -37822,7 +38482,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37822
38482
  );
37823
38483
  if (code !== 0) degraded = `chant carve advise exited ${code}`;
37824
38484
  }
37825
- const serving = !degraded && existsSync38(report) ? report : committed;
38485
+ const serving = !degraded && existsSync39(report) ? report : committed;
37826
38486
  if (degraded) {
37827
38487
  process.stderr.write(
37828
38488
  `behold demo carve: ${degraded}
@@ -37830,7 +38490,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
37830
38490
  `
37831
38491
  );
37832
38492
  }
37833
- if (!existsSync38(serving)) {
38493
+ if (!existsSync39(serving)) {
37834
38494
  process.stderr.write(`behold demo carve: no carve report at ${serving}
37835
38495
  `);
37836
38496
  process.exit(2);
@@ -37875,8 +38535,8 @@ async function runPreview(rest) {
37875
38535
  process.stderr.write("behold preview: --port must be a number\n");
37876
38536
  process.exit(2);
37877
38537
  }
37878
- const projectDir = resolve37(dirArg ?? process.cwd());
37879
- if (!existsSync38(projectDir)) {
38538
+ const projectDir = resolve38(dirArg ?? process.cwd());
38539
+ if (!existsSync39(projectDir)) {
37880
38540
  process.stderr.write(`behold preview: project not found at ${projectDir}
37881
38541
  `);
37882
38542
  process.exit(2);
@@ -37896,7 +38556,7 @@ async function runPreview(rest) {
37896
38556
  await startServer({ projectDir, port, env: "local", previewMode: true });
37897
38557
  }
37898
38558
  async function runExportCmd(rest) {
37899
- let outDir = resolve37("behold-export");
38559
+ let outDir = resolve38("behold-export");
37900
38560
  let env;
37901
38561
  let name;
37902
38562
  let dirArg;
@@ -37910,9 +38570,15 @@ async function runExportCmd(rest) {
37910
38570
  let noSource = false;
37911
38571
  let yodelReport;
37912
38572
  let chantReportUrl;
38573
+ let openEnv;
38574
+ let openZoom;
38575
+ let note;
37913
38576
  for (let i = 0; i < rest.length; i++) {
37914
38577
  const a = rest[i];
37915
- if (a === "--out") outDir = resolve37(rest[++i]);
38578
+ if (a === "--out") outDir = resolve38(rest[++i]);
38579
+ else if (a === "--note") note = rest[++i] ?? "";
38580
+ else if (a === "--open-env") openEnv = rest[++i] ?? "";
38581
+ else if (a === "--open-zoom") openZoom = rest[++i] ?? "";
37916
38582
  else if (a === "--yodel-report") yodelReport = rest[++i];
37917
38583
  else if (a === "--env") env = rest[++i];
37918
38584
  else if (a === "--name") name = rest[++i];
@@ -37931,6 +38597,21 @@ async function runExportCmd(rest) {
37931
38597
  process.stderr.write("behold export: --yodel-report needs the file `yodel report --json` wrote, or the directory holding it\n");
37932
38598
  process.exit(2);
37933
38599
  }
38600
+ if (openEnv !== void 0 && !openEnv) {
38601
+ process.stderr.write("behold export: --open-env needs an environment the export captures\n");
38602
+ process.exit(2);
38603
+ }
38604
+ if (openZoom !== void 0 && ![...OPENING_ZOOMS, "ops"].includes(openZoom)) {
38605
+ process.stderr.write(`behold export: --open-zoom ${openZoom || "(nothing)"} isn't a zoom an export opens on: it takes ${[...OPENING_ZOOMS, "ops"].join(", ")}
38606
+ `);
38607
+ process.exit(2);
38608
+ }
38609
+ const settledNote = settleNote(note);
38610
+ if ("error" in settledNote) {
38611
+ process.stderr.write(`behold export: ${settledNote.error}
38612
+ `);
38613
+ process.exit(2);
38614
+ }
37934
38615
  if ((terragucciProject || reportsBase !== void 0) && !terragucci) {
37935
38616
  process.stderr.write("behold export: --terragucci-project and --reports-base need --terragucci\n");
37936
38617
  process.exit(2);
@@ -37957,7 +38638,7 @@ async function runExportCmd(rest) {
37957
38638
  );
37958
38639
  process.exit(2);
37959
38640
  }
37960
- const projectDir = resolve37(dirArg ?? process.cwd());
38641
+ const projectDir = resolve38(dirArg ?? process.cwd());
37961
38642
  const commit = destination ? resolveCommit2(projectDir, commitArg) : void 0;
37962
38643
  if (commit && "error" in commit) {
37963
38644
  process.stderr.write(`behold export: ${commit.error}
@@ -37968,27 +38649,35 @@ async function runExportCmd(rest) {
37968
38649
  injectEmulatorEnv(env);
37969
38650
  env ??= "local";
37970
38651
  }
37971
- if (!existsSync38(projectDir)) {
38652
+ if (!existsSync39(projectDir)) {
37972
38653
  process.stderr.write(`behold export: project not found at ${projectDir}
37973
38654
  `);
37974
38655
  process.exit(2);
37975
38656
  }
37976
38657
  const target = await serveTarget([projectDir], "export");
38658
+ const open = { ...openEnv !== void 0 ? { env: openEnv } : {}, ...openZoom !== void 0 ? { zoom: openZoom } : {} };
37977
38659
  await runExport(
37978
38660
  {
37979
38661
  ...target,
37980
38662
  port: 0,
37981
38663
  ...env ? { env } : {},
37982
38664
  ...terragucci ? { terragucci: { source: terragucci, ...terragucciProject ? { project: terragucciProject } : {} } } : {},
37983
- ...yodelReport ? { yodelReport: resolve37(yodelReport) } : {}
38665
+ ...yodelReport ? { yodelReport: resolve38(yodelReport) } : {}
37984
38666
  },
37985
38667
  outDir,
37986
38668
  {
37987
38669
  ...name ? { name } : {},
37988
38670
  ...noSource ? { noSource } : {},
37989
- ...reportsBase !== void 0 ? { reportsBase } : destination ? { reportsBase: SNAPSHOT_REPORTS_BASE } : {}
38671
+ ...reportsBase !== void 0 ? { reportsBase } : destination ? { reportsBase: SNAPSHOT_REPORTS_BASE } : {},
38672
+ ...Object.keys(open).length ? { open } : {},
38673
+ ...settledNote.note ? { note: settledNote.note } : {}
37990
38674
  }
37991
- );
38675
+ ).catch((e) => {
38676
+ if (!(e instanceof ExportRefusal)) throw e;
38677
+ process.stderr.write(`behold export: ${e.message}
38678
+ `);
38679
+ process.exit(2);
38680
+ });
37992
38681
  if (destination && !("error" in destination) && commit && !("error" in commit)) {
37993
38682
  const done = await publishSnapshot(outDir, destination, commit, new S3Object(s3FromEnv(destination.bucket)), { keep });
37994
38683
  process.stdout.write(