@intentius/behold 0.29.25 → 0.29.27

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.
Files changed (33) hide show
  1. package/AGENTS.md +3 -1
  2. package/demos.json +15 -0
  3. package/dist/cli.js +697 -371
  4. package/example-choudoufu-estate/README.md +2 -2
  5. package/example-choudoufu-estate/scripts/choudoufu-up.sh +2 -2
  6. package/example-terralith/README.md +33 -0
  7. package/example-terralith/phases/adopt/migrations/adopt.yml +12 -0
  8. package/example-terralith/phases/adopt/terralith/main.tf +138 -0
  9. package/example-terralith/phases/plan/team-a/main.tf +58 -0
  10. package/example-terralith/phases/plan/team-b/main.tf +58 -0
  11. package/example-terralith/phases/plan/team-c/main.tf +58 -0
  12. package/example-terralith/phases/plan/terralith/main.tf +32 -0
  13. package/example-terralith/phases/split/migrations/split.yml +29 -0
  14. package/example-terralith/phases/split/team-a/main.tf +52 -0
  15. package/example-terralith/phases/split/team-b/main.tf +52 -0
  16. package/example-terralith/phases/split/team-c/main.tf +52 -0
  17. package/example-terralith/phases/split/terralith/main.tf +27 -0
  18. package/example-terralith/scripts/lib.sh +65 -0
  19. package/example-terralith/scripts/terralith-down.sh +9 -0
  20. package/example-terralith/scripts/terralith-step.sh +139 -0
  21. package/example-terralith/scripts/terralith-up.sh +50 -0
  22. package/example-terralith/terralith/main.tf +141 -0
  23. package/package.json +2 -1
  24. package/web/app.js +83 -9
  25. package/web/identity-mark.js +61 -0
  26. package/web/identity-mark.test.js +32 -0
  27. package/web/pending.js +54 -0
  28. package/web/pending.test.js +47 -1
  29. package/web/terralith-steps.js +142 -0
  30. package/web/terralith-steps.test.js +97 -0
  31. package/web/terralith.html +125 -0
  32. package/web/terralith.js +301 -0
  33. /package/example-choudoufu-estate/monolith/{carve.json → split.json} +0 -0
package/dist/cli.js CHANGED
@@ -3066,11 +3066,18 @@ function verdictFor(address, ls, plan) {
3066
3066
  const listing = gap ? { listing: gap.detail } : {};
3067
3067
  if (bound) {
3068
3068
  const id = bound.identity || item?.id;
3069
+ const marked = !!item;
3069
3070
  return {
3070
3071
  _status: "good",
3071
3072
  ...id ? { physicalId: id } : {},
3072
3073
  ownership: "owned",
3073
- attrs: { bound: BOUND_WORDS[bound.source] ?? bound.source, ...bound.identity_values ? { identity: bound.identity_values } : {}, ...listing }
3074
+ attrs: {
3075
+ bound: BOUND_WORDS[bound.source] ?? bound.source,
3076
+ marker: marked ? MARKER_ON : MARKER_NONE,
3077
+ _identity: { source: bound.source, marked },
3078
+ ...bound.identity_values ? { identity: bound.identity_values } : {},
3079
+ ...listing
3080
+ }
3074
3081
  };
3075
3082
  }
3076
3083
  if (omission) {
@@ -3126,10 +3133,10 @@ function verdictFor(address, ls, plan) {
3126
3133
  return void 0;
3127
3134
  }
3128
3135
  function paintChoudoufu(ir, ls, plan, estate) {
3129
- const declared = /* @__PURE__ */ new Set();
3136
+ const declared2 = /* @__PURE__ */ new Set();
3130
3137
  for (const n of ir.nodes) {
3131
3138
  if (n.lexicon !== CHOUDOUFU_LEXICON || isRecord3(n.attrs.producer)) continue;
3132
- declared.add(n.id);
3139
+ declared2.add(n.id);
3133
3140
  const v = verdictFor(n.id, ls, plan) ?? {
3134
3141
  _status: "neutral",
3135
3142
  _unobserved: plan ? "not mentioned by live-plan or live-ls" : "no live-plan document for this estate",
@@ -3140,8 +3147,8 @@ function paintChoudoufu(ir, ls, plan, estate) {
3140
3147
  if (v.ownership) n.ownership = v.ownership;
3141
3148
  }
3142
3149
  for (const item of ls?.items ?? []) {
3143
- if (!item.address || declared.has(item.address)) continue;
3144
- declared.add(item.address);
3150
+ if (!item.address || declared2.has(item.address)) continue;
3151
+ declared2.add(item.address);
3145
3152
  ir.nodes.push({
3146
3153
  id: item.address,
3147
3154
  kind: item.type,
@@ -3212,7 +3219,7 @@ function choudoufuDiffNodes(check, ls, plan, member, drift) {
3212
3219
  seen.add(i.address);
3213
3220
  const v = verdictFor(i.address, ls, plan);
3214
3221
  const health = !v ? "unknown" : v._status === "good" ? "healthy" : v._status === "warn" ? "degraded" : "unknown";
3215
- const detail = !v ? "not mentioned by live-plan or live-ls" : typeof v.attrs.bound === "string" ? `bound ${v.attrs.bound}` : typeof v.attrs.omission === "string" ? `${v.attrs.omission}: ${String(v.attrs.detail ?? "")}` : v._unobserved ?? (typeof v.attrs.listing === "string" ? v.attrs.listing : void 0);
3222
+ const detail = !v ? "not mentioned by live-plan or live-ls" : typeof v.attrs.bound === "string" ? `bound ${v.attrs.bound}${v.attrs.marker === MARKER_NONE ? `; ${MARKER_NONE}` : ""}` : typeof v.attrs.omission === "string" ? `${v.attrs.omission}: ${String(v.attrs.detail ?? "")}` : v._unobserved ?? (typeof v.attrs.listing === "string" ? v.attrs.listing : void 0);
3216
3223
  out[key2(i.address)] = {
3217
3224
  observed: v ? {
3218
3225
  type: i.type,
@@ -3244,7 +3251,7 @@ function choudoufuDiffNodes(check, ls, plan, member, drift) {
3244
3251
  }
3245
3252
  return out;
3246
3253
  }
3247
- var isRecord3, refuse3, CREDS, REASON_TONE, UNOBSERVED_REASONS, BOUND_WORDS, choudoufuVia, choudoufuSpec;
3254
+ var isRecord3, refuse3, CREDS, REASON_TONE, UNOBSERVED_REASONS, BOUND_WORDS, MARKER_ON, MARKER_NONE, choudoufuVia, choudoufuSpec;
3248
3255
  var init_choudoufu_live = __esm({
3249
3256
  "src/choudoufu-live.ts"() {
3250
3257
  "use strict";
@@ -3268,16 +3275,20 @@ var init_choudoufu_live = __esm({
3268
3275
  UNOBSERVED_REASONS = /* @__PURE__ */ new Set(["FAILED", "CYCLE", "SUPERSEDED", "UNREADABLE", "INCOMPLETE_BLOCK"]);
3269
3276
  BOUND_WORDS = {
3270
3277
  marker: "by its marker (the estate-wide tag sweep)",
3271
- // #393 item 8: this is the whole of an unadopted estate's green. 84 of the
3272
- // terralith's cards are bound this way and none of them carries a marker —
3273
- // choudoufu matched the live object by the identity the configuration
3274
- // states, which is correct and is NOT ownership. The card is painted good
3275
- // and counted bound, per choudoufu; the pane has to say the consequence out
3276
- // loud, or a reader takes a third of the estate for already adopted.
3277
- derived: "by derived identity (the name the configuration states) \u2014 no marker on the object yet",
3278
+ // #393 item 8 read this as "no marker yet", and that holds only for an
3279
+ // object that carries none. choudoufu binds a named instance (an IAM role,
3280
+ // a log group) by the name the configuration states whether or not a
3281
+ // marker is on it (internal/command/views/live_plan.go,
3282
+ // LivePlanBoundDerived: "no marker sweep and no record store involved"),
3283
+ // and a stamped log group still reads `derived`. Whether the object
3284
+ // carries the marker is live-ls's answer, so it is its own row, `marker`,
3285
+ // below.
3286
+ derived: "by derived identity (the name the configuration states)",
3278
3287
  record: "from the estate's record store",
3279
3288
  cache: "from the local state cache"
3280
3289
  };
3290
+ MARKER_ON = "on the object (tofu-estate, tofu-address)";
3291
+ MARKER_NONE = "no marker on the object";
3281
3292
  choudoufuVia = {
3282
3293
  tool: () => {
3283
3294
  const v = choudoufuVersion();
@@ -3548,12 +3559,12 @@ function readWorkspaces(projectDir) {
3548
3559
  function detectProjectShape(projectDir) {
3549
3560
  const configFile = chantConfigPath(projectDir);
3550
3561
  if (configFile) return { kind: "project", configFile };
3551
- const declared = loadBeholdConfig(projectDir).members;
3552
- const from = declared ? "behold-config" : "workspaces";
3562
+ const declared2 = loadBeholdConfig(projectDir).members;
3563
+ const from = declared2 ? "behold-config" : "workspaces";
3553
3564
  const members = [];
3554
3565
  const invalid = [];
3555
- if (declared) {
3556
- for (const m of declared) {
3566
+ if (declared2) {
3567
+ for (const m of declared2) {
3557
3568
  if ("invalid" in m) {
3558
3569
  invalid.push(m);
3559
3570
  continue;
@@ -11201,8 +11212,8 @@ var init_declaration = __esm({
11201
11212
  });
11202
11213
 
11203
11214
  // src/cli.ts
11204
- import { resolve as resolve35, dirname as dirname21, join as join55 } from "node:path";
11205
- import { realpathSync as realpathSync3, existsSync as existsSync34, readFileSync as readFileSync43, rmSync as rmSync4 } from "node:fs";
11215
+ import { resolve as resolve35, dirname as dirname21, join as join56 } from "node:path";
11216
+ import { realpathSync as realpathSync3, existsSync as existsSync35, readFileSync as readFileSync44, rmSync as rmSync4 } from "node:fs";
11206
11217
  import { fileURLToPath as fileURLToPath12 } from "node:url";
11207
11218
  import { spawn as spawn9, spawnSync as spawnSync4 } from "node:child_process";
11208
11219
 
@@ -11239,13 +11250,13 @@ async function k8sClient() {
11239
11250
  }
11240
11251
  }
11241
11252
  function resolveK8sTarget(profiles, env, kubeconfig) {
11242
- const declared = env ? profiles?.[env]?.context : void 0;
11243
- const context = declared ?? kubeconfig.currentContext;
11253
+ const declared2 = env ? profiles?.[env]?.context : void 0;
11254
+ const context = declared2 ?? kubeconfig.currentContext;
11244
11255
  if (!context) return void 0;
11245
11256
  const cluster = kubeconfig.contexts.get(context);
11246
11257
  const endpoint = cluster ? kubeconfig.servers.get(cluster) : void 0;
11247
11258
  if (!endpoint) return void 0;
11248
- return { name: "k8s", label: context, endpoint, source: declared ? "profile" : "current-context" };
11259
+ return { name: "k8s", label: context, endpoint, source: declared2 ? "profile" : "current-context" };
11249
11260
  }
11250
11261
  function contextBindsCluster(context, clusterName) {
11251
11262
  if (!clusterName) return void 0;
@@ -11260,8 +11271,8 @@ import { serve } from "@hono/node-server";
11260
11271
  import { fileURLToPath as fileURLToPath10 } from "node:url";
11261
11272
  import { execFile as execFile5 } from "node:child_process";
11262
11273
  import { promisify as promisify3 } from "node:util";
11263
- import { existsSync as existsSync31, readFileSync as readFileSync39 } from "node:fs";
11264
- import { basename as basename6, dirname as dirname18, join as join51, relative as relative11, resolve as resolve32, sep as sep10 } from "node:path";
11274
+ import { existsSync as existsSync32, readFileSync as readFileSync40 } from "node:fs";
11275
+ import { basename as basename6, dirname as dirname18, join as join52, relative as relative11, resolve as resolve32, sep as sep10 } from "node:path";
11265
11276
 
11266
11277
  // src/recents.ts
11267
11278
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
@@ -11361,9 +11372,9 @@ function declaredChartNames(ir) {
11361
11372
  }
11362
11373
  return names;
11363
11374
  }
11364
- function matchesDeclaredChart(chart, declared) {
11375
+ function matchesDeclaredChart(chart, declared2) {
11365
11376
  if (typeof chart !== "string" || chart.length === 0) return false;
11366
- for (const name of declared) {
11377
+ for (const name of declared2) {
11367
11378
  if (chart === name || chart.startsWith(`${name}-`)) return true;
11368
11379
  }
11369
11380
  return false;
@@ -11404,14 +11415,14 @@ function discoverReleaseUnits(projectDir) {
11404
11415
  }
11405
11416
  function synthesizeHelmReleases(ir, observed, owners) {
11406
11417
  if (!observed) return 0;
11407
- const declared = declaredChartNames(ir);
11418
+ const declared2 = declaredChartNames(ir);
11408
11419
  const have = new Set(ir.nodes.map((n) => n.id));
11409
11420
  let added = 0;
11410
11421
  for (const [key2, o] of Object.entries(observed)) {
11411
11422
  const m = RELEASE_KEY.exec(key2);
11412
11423
  if (!m || have.has(key2)) continue;
11413
11424
  const [, namespace, name] = m;
11414
- if (matchesDeclaredChart(o.attributes?.chart, declared)) continue;
11425
+ if (matchesDeclaredChart(o.attributes?.chart, declared2)) continue;
11415
11426
  const component = owners.get(name);
11416
11427
  const deployed = o.status === "deployed";
11417
11428
  const node = {
@@ -12601,8 +12612,8 @@ function addValueMatchEdges(ir) {
12601
12612
  }
12602
12613
  }
12603
12614
  if (owner.size === 0) return ir;
12604
- const declared = /* @__PURE__ */ new Set();
12605
- for (const e of ir.edges) declared.add(`${e.from}\0${e.to}`);
12615
+ const declared2 = /* @__PURE__ */ new Set();
12616
+ for (const e of ir.edges) declared2.add(`${e.from}\0${e.to}`);
12606
12617
  const added = /* @__PURE__ */ new Set();
12607
12618
  for (const a of nodes) {
12608
12619
  for (const { path, value } of stringLeaves(a.attrs)) {
@@ -12610,7 +12621,7 @@ function addValueMatchEdges(ir) {
12610
12621
  const b = owner.get(value);
12611
12622
  if (!b || b === a.id) continue;
12612
12623
  const key2 = `${a.id}\0${b}`;
12613
- if (declared.has(key2) || added.has(key2)) continue;
12624
+ if (declared2.has(key2) || added.has(key2)) continue;
12614
12625
  added.add(key2);
12615
12626
  ir.edges.push({ from: a.id, to: b, kind: "ref", viaAttr: path, inferred: true });
12616
12627
  }
@@ -13526,8 +13537,8 @@ function estateMembers(projectDirs) {
13526
13537
  return projectDirs.map((dir, i) => ({ name: names[i], dir, kind: kindOf2(dir) }));
13527
13538
  }
13528
13539
  function estateMemberNames(projectDirs) {
13529
- const declared = projectDirs.map((d) => workspaceMemberOf(d)?.name);
13530
- if (declared.every((n) => n !== void 0)) return declared;
13540
+ const declared2 = projectDirs.map((d) => workspaceMemberOf(d)?.name);
13541
+ if (declared2.every((n) => n !== void 0)) return declared2;
13531
13542
  return shortStackNames([...projectDirs]);
13532
13543
  }
13533
13544
  function unreadableStacks(projectDirs) {
@@ -13537,10 +13548,10 @@ function unreadableStacks(projectDirs) {
13537
13548
  }
13538
13549
  var memberViaFor = (dir) => {
13539
13550
  const own = memberKindSpec(memberKindOf(dir) ?? "chant")?.via ?? chantVia;
13540
- const declared = workspaceMemberOf(dir);
13551
+ const declared2 = workspaceMemberOf(dir);
13541
13552
  const ws = servedWorkspace();
13542
- if (!declared || !ws || !CONTRACT_READ_KINDS.has(declared.kind)) return own;
13543
- return declared.kind === "choudoufu" ? choudoufuWorkspaceVia(declared, ws.root) : workspaceVia(declared, ws.root, own);
13553
+ if (!declared2 || !ws || !CONTRACT_READ_KINDS.has(declared2.kind)) return own;
13554
+ return declared2.kind === "choudoufu" ? choudoufuWorkspaceVia(declared2, ws.root) : workspaceVia(declared2, ws.root, own);
13544
13555
  };
13545
13556
  function forMember(dir, opts) {
13546
13557
  if (!opts.traffic || memberTakesTraffic(dir, memberKindOf(dir) ?? "chant")) return opts;
@@ -13630,8 +13641,8 @@ function declaredSegments(path) {
13630
13641
  if (segs.length === 0 || segs.includes("..")) return void 0;
13631
13642
  return segs;
13632
13643
  }
13633
- function pathAlignment(declared, dir, isDir = realIsDir) {
13634
- const want = declaredSegments(declared);
13644
+ function pathAlignment(declared2, dir, isDir = realIsDir) {
13645
+ const want = declaredSegments(declared2);
13635
13646
  if (!want) return 0;
13636
13647
  const root = resolve11(dir);
13637
13648
  const have = root.split(sep5).filter(Boolean);
@@ -13667,10 +13678,10 @@ function joinNamespaceBindings(members, isDir = realIsDir) {
13667
13678
  if (!winner || tied) continue;
13668
13679
  const prev = best.get(winner.dir);
13669
13680
  if (prev === "ambiguous") continue;
13670
- const join56 = { dir: winner.dir, namespace: b.namespace, path: b.path, declaredBy: b.declaredBy };
13671
- if (!prev) best.set(winner.dir, { score: winner.score, join: join56 });
13681
+ const join57 = { dir: winner.dir, namespace: b.namespace, path: b.path, declaredBy: b.declaredBy };
13682
+ if (!prev) best.set(winner.dir, { score: winner.score, join: join57 });
13672
13683
  else if (prev.join.namespace !== b.namespace) best.set(winner.dir, "ambiguous");
13673
- else if (winner.score > prev.score) best.set(winner.dir, { score: winner.score, join: join56 });
13684
+ else if (winner.score > prev.score) best.set(winner.dir, { score: winner.score, join: join57 });
13674
13685
  }
13675
13686
  return [...best.values()].filter((v) => v !== "ambiguous").map((v) => v.join);
13676
13687
  }
@@ -13746,7 +13757,7 @@ async function composeEstateOverlay(projectDirs, opts, classify, observe = {}) {
13746
13757
 
13747
13758
  // src/helm-drift.ts
13748
13759
  function renderIdentity(record, observed) {
13749
- const declared = {
13760
+ const declared2 = {
13750
13761
  ...record.inputDigest ? { inputDigest: record.inputDigest } : {},
13751
13762
  ...record.contentDigest ? { contentDigest: record.contentDigest } : {}
13752
13763
  };
@@ -13756,14 +13767,14 @@ function renderIdentity(record, observed) {
13756
13767
  ...typeof a.inputDigest === "string" ? { inputDigest: a.inputDigest } : {},
13757
13768
  ...typeof a.contentDigest === "string" ? { contentDigest: a.contentDigest } : {}
13758
13769
  };
13759
- const base = { declared, observed: obs };
13760
- if (!declared.inputDigest && !declared.contentDigest) return { match: "unpinned", ...base };
13770
+ const base = { declared: declared2, observed: obs };
13771
+ if (!declared2.inputDigest && !declared2.contentDigest) return { match: "unpinned", ...base };
13761
13772
  if (!obs.inputDigest && !obs.contentDigest) return { match: "unrecorded", ...base };
13762
- if (declared.contentDigest && obs.contentDigest) {
13763
- return { match: declared.contentDigest === obs.contentDigest ? "content" : "mismatch", ...base };
13773
+ if (declared2.contentDigest && obs.contentDigest) {
13774
+ return { match: declared2.contentDigest === obs.contentDigest ? "content" : "mismatch", ...base };
13764
13775
  }
13765
- if (declared.inputDigest && obs.inputDigest) {
13766
- return { match: declared.inputDigest === obs.inputDigest ? "input" : "mismatch", ...base };
13776
+ if (declared2.inputDigest && obs.inputDigest) {
13777
+ return { match: declared2.inputDigest === obs.inputDigest ? "input" : "mismatch", ...base };
13767
13778
  }
13768
13779
  return { match: "unrecorded", ...base };
13769
13780
  }
@@ -15078,14 +15089,14 @@ function componentRepresentatives(ir, dag) {
15078
15089
  }
15079
15090
  function addCompositeDeps(ir, dag) {
15080
15091
  const compToNode = componentRepresentatives(ir, dag);
15081
- const declared = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
15092
+ const declared2 = new Set(ir.edges.map((e) => `${e.from}\0${e.to}`));
15082
15093
  for (const e of dag.edges) {
15083
15094
  const from = compToNode.get(e.from);
15084
15095
  const to = compToNode.get(e.to);
15085
15096
  if (!from || !to || from === to) continue;
15086
15097
  const key2 = `${from}\0${to}`;
15087
- if (declared.has(key2)) continue;
15088
- declared.add(key2);
15098
+ if (declared2.has(key2)) continue;
15099
+ declared2.add(key2);
15089
15100
  ir.edges.push({ from, to, kind: "ref", viaAttr: "dependsOn", inferred: true });
15090
15101
  }
15091
15102
  return ir;
@@ -15209,8 +15220,8 @@ function configKeys(file) {
15209
15220
  };
15210
15221
  }
15211
15222
  function pipelineForge(decl, dir, config) {
15212
- const declared = forgeOfName(decl?.pipeline.forge);
15213
- if (declared) return { forge: declared, from: "declared" };
15223
+ const declared2 = forgeOfName(decl?.pipeline.forge);
15224
+ if (declared2) return { forge: declared2, from: "declared" };
15214
15225
  const configured = forgeOfName(configKeys(config).forge);
15215
15226
  if (configured) return { forge: configured, from: "config" };
15216
15227
  const byPath = decl?.pipeline.path ? forgeOfPipelinePath(decl.pipeline.path) : void 0;
@@ -18666,13 +18677,13 @@ function predicateText(predicate) {
18666
18677
  function actionText(action) {
18667
18678
  return action.kind === "run" ? `run(${action.op})` : `report: ${action.reason}`;
18668
18679
  }
18669
- function ruleStatus(rule, declared) {
18680
+ function ruleStatus(rule, declared2) {
18670
18681
  if (rule.then.kind !== "run") return "neutral";
18671
- return declared.has(rule.then.op) ? "accent" : "warn";
18682
+ return declared2.has(rule.then.op) ? "accent" : "warn";
18672
18683
  }
18673
- function ruleNode(op, table, rule, declared) {
18674
- const dispatches = rule.then.kind === "run" && declared.has(rule.then.op) ? rule.then.op : void 0;
18675
- const dangling = rule.then.kind === "run" && !declared.has(rule.then.op) ? rule.then.op : void 0;
18684
+ function ruleNode(op, table, rule, declared2) {
18685
+ const dispatches = rule.then.kind === "run" && declared2.has(rule.then.op) ? rule.then.op : void 0;
18686
+ const dangling = rule.then.kind === "run" && !declared2.has(rule.then.op) ? rule.then.op : void 0;
18676
18687
  return {
18677
18688
  id: ruleId(op.name, rule),
18678
18689
  // The card's kind, as an activity's is its `fn`: a converge rule is what
@@ -18680,7 +18691,7 @@ function ruleNode(op, table, rule, declared) {
18680
18691
  kind: "ConvergeRule",
18681
18692
  lexicon: "op",
18682
18693
  attrs: {
18683
- _status: ruleStatus(rule, declared),
18694
+ _status: ruleStatus(rule, declared2),
18684
18695
  _step: "rule",
18685
18696
  rule: rule.id,
18686
18697
  op: op.name,
@@ -18792,7 +18803,7 @@ function opsToIr(ops) {
18792
18803
  const edges = [];
18793
18804
  const byStack = {};
18794
18805
  const endpoints = /* @__PURE__ */ new Map();
18795
- const declared = new Set(ops.map((o) => o.name));
18806
+ const declared2 = new Set(ops.map((o) => o.name));
18796
18807
  const dispatches = [];
18797
18808
  for (const op of ops) {
18798
18809
  const placed = placeSteps(op);
@@ -18817,7 +18828,7 @@ function opsToIr(ops) {
18817
18828
  const table = convergeTable(op);
18818
18829
  if (!table) continue;
18819
18830
  for (const rule of table.rules) {
18820
- const node = ruleNode(op, table, rule, declared);
18831
+ const node = ruleNode(op, table, rule, declared2);
18821
18832
  nodes.push(node);
18822
18833
  (byStack[RULE_BOX(op.name)] ??= []).push(node.id);
18823
18834
  edges.push({ from: table.tickStepId, to: node.id, kind: "ref", viaAttr: "rule" });
@@ -18845,7 +18856,7 @@ function opsToIr(ops) {
18845
18856
  function opCardFields(node) {
18846
18857
  const step = node.attrs._step;
18847
18858
  const phase2 = typeof node.attrs.phase === "string" ? node.attrs.phase : void 0;
18848
- const declared = step === "gate" ? [
18859
+ const declared2 = step === "gate" ? [
18849
18860
  { label: "gate", value: String(node.attrs.gate ?? "") },
18850
18861
  { label: "timeout", value: String(node.attrs.timeout ?? "") }
18851
18862
  ] : step === "effect" ? [
@@ -18864,9 +18875,9 @@ function opCardFields(node) {
18864
18875
  { label: "then", value: String(node.attrs.then ?? "") }
18865
18876
  ] : void 0
18866
18877
  );
18867
- if (!declared) return void 0;
18878
+ if (!declared2) return void 0;
18868
18879
  const run3 = typeof node.attrs.run === "string" ? node.attrs.run : void 0;
18869
- return run3 ? [{ label: "run", value: run3 }, ...declared.slice(0, 1)] : declared;
18880
+ return run3 ? [{ label: "run", value: run3 }, ...declared2.slice(0, 1)] : declared2;
18870
18881
  }
18871
18882
  function opsNote(ops, ir) {
18872
18883
  const gates = ir.nodes.filter((n) => n.attrs._step === "gate").length;
@@ -19927,6 +19938,7 @@ function composeMembersEstate(members) {
19927
19938
  boxes: boxes.map((b) => ({ ...b, y: height - b.y }))
19928
19939
  };
19929
19940
  }
19941
+ var spawnedBoxTitle = (estate) => `${estate} \u2014 new estate`;
19930
19942
  function renderMoveMorph(members, moves, opts = {}) {
19931
19943
  const estateOf = opts.estateOf ?? ((m) => m.panel);
19932
19944
  const prefixed = members.map((m) => {
@@ -19943,10 +19955,24 @@ function renderMoveMorph(members, moves, opts = {}) {
19943
19955
  });
19944
19956
  const before = composeMembersEstate(prefixed);
19945
19957
  const after2 = prefixed.map((m) => ({ ...m, ir: { ...m.ir, nodes: [...m.ir.nodes], edges: [...m.ir.edges] } }));
19958
+ const spawned = /* @__PURE__ */ new Map();
19959
+ const servedBox = (estate) => after2.find((m) => ![...spawned.values()].includes(m) && estateOf(m) === estate);
19960
+ const destination = (estate) => {
19961
+ const served2 = servedBox(estate);
19962
+ if (served2) return served2;
19963
+ let box = spawned.get(estate);
19964
+ if (!box) {
19965
+ box = { name: `new:${estate}`, title: spawnedBoxTitle(estate), panel: `estate ${estate}`, ir: { nodes: [], edges: [], groups: {} } };
19966
+ spawned.set(estate, box);
19967
+ after2.push(box);
19968
+ }
19969
+ return box;
19970
+ };
19946
19971
  for (const mv of moves) {
19947
- const src = after2.find((m) => estateOf(m) === mv.from);
19948
- const dst = after2.find((m) => estateOf(m) === mv.to);
19949
- if (!src || !dst || src === dst) continue;
19972
+ const src = servedBox(mv.from);
19973
+ if (!src || !src.ir.nodes.some((n) => n.id === `${src.name}/${mv.address}`)) continue;
19974
+ const dst = destination(mv.to);
19975
+ if (src === dst) continue;
19950
19976
  const ids = new Set([mv.address, ...mv.followers ?? []].map((a) => `${src.name}/${a}`));
19951
19977
  const moving = src.ir.nodes.filter((n) => ids.has(n.id));
19952
19978
  if (!moving.length) continue;
@@ -21251,11 +21277,11 @@ var RAN = { ok: "ok", fail: "failed", skipped: "skipped" };
21251
21277
  function tookLabel(ms) {
21252
21278
  return ms < 1e3 ? `${ms}ms` : `${(ms / 1e3).toFixed(1)}s`;
21253
21279
  }
21254
- function paintPlayhead(ir, join56, gate) {
21255
- if (!join56.byNode.size && !join56.at) return ir;
21280
+ function paintPlayhead(ir, join57, gate) {
21281
+ if (!join57.byNode.size && !join57.at) return ir;
21256
21282
  const nodes = ir.nodes.map((node) => {
21257
- const run3 = join56.byNode.get(node.id);
21258
- const here = join56.at === node.id;
21283
+ const run3 = join57.byNode.get(node.id);
21284
+ const here = join57.at === node.id;
21259
21285
  if (!run3 && !here) return node;
21260
21286
  const isGate = node.attrs?._step === "gate";
21261
21287
  const attrs = { ...node.attrs };
@@ -21270,7 +21296,7 @@ function paintPlayhead(ir, join56, gate) {
21270
21296
  if (here) {
21271
21297
  attrs._playhead = true;
21272
21298
  attrs._status = isGate && gate ? "warn" : "accent";
21273
- attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join56.atReason ?? "here";
21299
+ attrs.run = isGate && gate ? `waiting for approval since ${gate.since}` : join57.atReason ?? "here";
21274
21300
  if (isGate && gate?.description) attrs.gateDescription = gate.description;
21275
21301
  }
21276
21302
  return { ...node, attrs };
@@ -21292,11 +21318,11 @@ function pendingGateCard(op, gate, ir) {
21292
21318
  }
21293
21319
  };
21294
21320
  }
21295
- function playheadNote(state, join56) {
21321
+ function playheadNote(state, join57) {
21296
21322
  if (!state.op) {
21297
21323
  return "No run state: nothing has been run from this behold session, so every step paints as declared.";
21298
21324
  }
21299
- const settled = join56 ? join56.byNode.size : state.records.length;
21325
+ const settled = join57 ? join57.byNode.size : state.records.length;
21300
21326
  const bits = [];
21301
21327
  const head = state.status === "idle" ? `Run state for ${state.op}: no per-step records \u2014 this behold session didn't start the run, so only the gate query answers` : `Run: ${state.op} (${state.mode === "temporal" ? "durable" : "local executor"}) \u2014 ${settled} step${settled === 1 ? "" : "s"} settled`;
21302
21328
  if (state.status === "running") {
@@ -21312,9 +21338,9 @@ function playheadNote(state, join56) {
21312
21338
  } else if (state.gateNote) {
21313
21339
  bits.push(`gate state unavailable \u2014 ${state.gateNote}`);
21314
21340
  }
21315
- if (join56?.unplaced.length) {
21341
+ if (join57?.unplaced.length) {
21316
21342
  bits.push(
21317
- `${join56.unplaced.length} record${join56.unplaced.length === 1 ? "" : "s"} matched no declared step and ${join56.unplaced.length === 1 ? "is" : "are"} not painted`
21343
+ `${join57.unplaced.length} record${join57.unplaced.length === 1 ? "" : "s"} matched no declared step and ${join57.unplaced.length === 1 ? "is" : "are"} not painted`
21318
21344
  );
21319
21345
  }
21320
21346
  if (!bits.length) return `${head}.`;
@@ -21805,8 +21831,8 @@ var OpRunner = class {
21805
21831
  * thing that gates the strip. Broadcast on a change so a project rebuilt (or
21806
21832
  * switched, #195) under an open tab grows or loses its strip without a reload.
21807
21833
  */
21808
- noteDeclaredConvergeOps(declared) {
21809
- return this.foldOperator({ ...this.lastOperatorState, declared });
21834
+ noteDeclaredConvergeOps(declared2) {
21835
+ return this.foldOperator({ ...this.lastOperatorState, declared: declared2 });
21810
21836
  }
21811
21837
  /**
21812
21838
  * Fold a `chant operator status --json` read (src/operator.ts's
@@ -22035,8 +22061,8 @@ var REFUSED_READS = [
22035
22061
  [/^\/api\/substrates$/, "it probes this machine's tools"],
22036
22062
  [/^\/api\/history$/, "it runs git against the checkout"],
22037
22063
  [/^\/api\/workspace\/(gates|why)$/, "it runs chant against the workspace"],
22038
- [/^\/api\/choudoufu\/moves$/, "it runs choudoufu"],
22039
- [/^\/choudoufu\/morph$/, "it runs choudoufu"],
22064
+ [/^\/api\/choudoufu\/(moves|split)$/, "it runs choudoufu"],
22065
+ [/^\/choudoufu\/(morph|split)$/, "it runs choudoufu"],
22040
22066
  [/^\/api\/sql-yodeler\/lifecycle$/, "a public view shows a terragucci repo"]
22041
22067
  ];
22042
22068
  var LIVE_PARAMS = ["env", "target", "consistent", "plan", "live"];
@@ -22647,8 +22673,8 @@ async function predictMember(member, env, traffic, deps, fresh = false) {
22647
22673
  const dir = resolve19(member.dir);
22648
22674
  if (member.kind === "terraform") {
22649
22675
  try {
22650
- const declared = reportFromIr(await memberIr(dir, { traffic }, terraformVia));
22651
- return declared ? { declared } : {};
22676
+ const declared2 = reportFromIr(await memberIr(dir, { traffic }, terraformVia));
22677
+ return declared2 ? { declared: declared2 } : {};
22652
22678
  } catch (err) {
22653
22679
  return { note: `declared prediction unavailable: ${said2(err)}` };
22654
22680
  }
@@ -22665,13 +22691,13 @@ async function predictMember(member, env, traffic, deps, fresh = false) {
22665
22691
  return void 0;
22666
22692
  }
22667
22693
  };
22668
- const [live2, declared] = await Promise.all([env === void 0 ? void 0 : side("live"), side("declared")]);
22669
- return { ...live2 ? { live: live2 } : {}, ...declared ? { declared } : {}, ...notes.length ? { note: notes.join("; ") } : {} };
22694
+ const [live2, declared2] = await Promise.all([env === void 0 ? void 0 : side("live"), side("declared")]);
22695
+ return { ...live2 ? { live: live2 } : {}, ...declared2 ? { declared: declared2 } : {}, ...notes.length ? { note: notes.join("; ") } : {} };
22670
22696
  }
22671
22697
  if (member.kind === "chant" && memberTakesTraffic(dir, "chant")) {
22672
22698
  try {
22673
- const declared = reportFromIr(await memberIr(dir, { traffic }));
22674
- return declared ? { declared } : {};
22699
+ const declared2 = reportFromIr(await memberIr(dir, { traffic }));
22700
+ return declared2 ? { declared: declared2 } : {};
22675
22701
  } catch (err) {
22676
22702
  return { note: `declared prediction unavailable: ${said2(err)}` };
22677
22703
  }
@@ -22705,17 +22731,17 @@ function figureOf(meta, blocks, onMixed) {
22705
22731
  }
22706
22732
  return { perHour: round62(blocks.reduce((sum, b) => sum + b.cost.perHour, 0)), currency: currencies[0], basis: "sum" };
22707
22733
  }
22708
- function deltaOf(live2, declared, label, diagnostics) {
22709
- if (!live2 || !declared) return void 0;
22710
- if (live2.currency !== declared.currency) {
22711
- diagnostics.push(`no delta for ${label}: the live figure is in ${live2.currency} and the declared one in ${declared.currency}`);
22734
+ function deltaOf(live2, declared2, label, diagnostics) {
22735
+ if (!live2 || !declared2) return void 0;
22736
+ if (live2.currency !== declared2.currency) {
22737
+ diagnostics.push(`no delta for ${label}: the live figure is in ${live2.currency} and the declared one in ${declared2.currency}`);
22712
22738
  return void 0;
22713
22739
  }
22714
- if (live2.basis !== declared.basis) {
22740
+ if (live2.basis !== declared2.basis) {
22715
22741
  diagnostics.push(`no delta for ${label}: one side is the engine's own total and the other is behold's sum, and those are not the same kind of figure`);
22716
22742
  return void 0;
22717
22743
  }
22718
- return { perHour: round62(live2.perHour - declared.perHour), currency: live2.currency };
22744
+ return { perHour: round62(live2.perHour - declared2.perHour), currency: live2.currency };
22719
22745
  }
22720
22746
  function attachBehaviourDelta(ir, members, behaviour) {
22721
22747
  const diagnostics = [...behaviour.diagnostics ?? []];
@@ -22728,7 +22754,7 @@ function attachBehaviourDelta(ir, members, behaviour) {
22728
22754
  const liveMeta = m.liveMeta === void 0 ? void 0 : validateBehaviourMeta(m.liveMeta);
22729
22755
  const liveBlocks = slice.map((n) => n.attrs?._behaviour).filter((b) => !!b);
22730
22756
  const live3 = behaviour.refusal ? void 0 : figureOf(liveMeta?.ok ? liveMeta.value : void 0, liveBlocks, (cs) => diagnostics.push(`no live figure for ${label}: the figures are in ${cs.join(" and ")}`));
22731
- let declared2;
22757
+ let declared3;
22732
22758
  const report = m.prediction.declared;
22733
22759
  if (report) {
22734
22760
  const meta = validateBehaviourMeta(report.meta);
@@ -22746,11 +22772,11 @@ function attachBehaviourDelta(ir, members, behaviour) {
22746
22772
  const node = byId.get(idFor(m.name, address));
22747
22773
  if (node) node.attrs = { ...node.attrs, [DECLARED_ATTR]: v.value };
22748
22774
  }
22749
- declared2 = figureOf(meta.value, blocks, (cs) => diagnostics.push(`no declared figure for ${label}: the figures are in ${cs.join(" and ")}`));
22775
+ declared3 = figureOf(meta.value, blocks, (cs) => diagnostics.push(`no declared figure for ${label}: the figures are in ${cs.join(" and ")}`));
22750
22776
  }
22751
22777
  }
22752
- const delta2 = deltaOf(live3, declared2, label, diagnostics);
22753
- if (live3 || declared2) perMember[label] = { ...live3 ? { live: live3 } : {}, ...declared2 ? { declared: declared2 } : {}, ...delta2 ? { delta: delta2 } : {} };
22778
+ const delta2 = deltaOf(live3, declared3, label, diagnostics);
22779
+ if (live3 || declared3) perMember[label] = { ...live3 ? { live: live3 } : {}, ...declared3 ? { declared: declared3 } : {}, ...delta2 ? { delta: delta2 } : {} };
22754
22780
  }
22755
22781
  const rows = Object.values(perMember);
22756
22782
  const addUp = (side) => {
@@ -22761,9 +22787,9 @@ function attachBehaviourDelta(ir, members, behaviour) {
22761
22787
  return { perHour: round62(figures.reduce((sum, f) => sum + f.perHour, 0)), currency: figures[0].currency, basis };
22762
22788
  };
22763
22789
  const live2 = addUp("live");
22764
- const declared = addUp("declared");
22790
+ const declared2 = addUp("declared");
22765
22791
  const allDeltas = rows.length > 0 && rows.every((r) => r.delta);
22766
- const delta = live2 && declared && allDeltas ? { perHour: round62(live2.perHour - declared.perHour), currency: live2.currency } : void 0;
22792
+ const delta = live2 && declared2 && allDeltas ? { perHour: round62(live2.perHour - declared2.perHour), currency: live2.currency } : void 0;
22767
22793
  const out = { ...behaviour };
22768
22794
  const stated = rows.filter((r) => r.live?.basis === "total").length;
22769
22795
  if (live2 && stated > 1) {
@@ -22772,7 +22798,7 @@ function attachBehaviourDelta(ir, members, behaviour) {
22772
22798
  if (at2 >= 0) diagnostics.splice(at2, 1);
22773
22799
  }
22774
22800
  if (live2) out.live = live2;
22775
- if (declared) out.declared = declared;
22801
+ if (declared2) out.declared = declared2;
22776
22802
  if (delta) out.delta = delta;
22777
22803
  if (rows.length && members.some((m) => m.name !== void 0)) out.members = perMember;
22778
22804
  if (diagnostics.length) out.diagnostics = diagnostics;
@@ -22810,8 +22836,8 @@ function attachDeclaredBehaviour(ir, members) {
22810
22836
  const node = byId.get(idFor(m.name, address));
22811
22837
  if (node) node.attrs = { ...node.attrs, _behaviour: v.value };
22812
22838
  }
22813
- const declared2 = figureOf(meta.value, blocks, (cs) => diagnostics.push(`no declared figure for ${label}: the figures are in ${cs.join(" and ")}`));
22814
- if (declared2) perMember[label] = { declared: declared2 };
22839
+ const declared3 = figureOf(meta.value, blocks, (cs) => diagnostics.push(`no declared figure for ${label}: the figures are in ${cs.join(" and ")}`));
22840
+ if (declared3) perMember[label] = { declared: declared3 };
22815
22841
  }
22816
22842
  if (!first) {
22817
22843
  return {
@@ -22821,12 +22847,12 @@ function attachDeclaredBehaviour(ir, members) {
22821
22847
  }
22822
22848
  const figures = Object.values(perMember).map((r) => r.declared);
22823
22849
  const oneCurrency = new Set(figures.map((f) => f.currency)).size === 1;
22824
- const declared = figures.length && oneCurrency ? { perHour: round62(figures.reduce((sum, f) => sum + f.perHour, 0)), currency: figures[0].currency, basis: figures.length === 1 ? figures[0].basis : "sum" } : void 0;
22850
+ const declared2 = figures.length && oneCurrency ? { perHour: round62(figures.reduce((sum, f) => sum + f.perHour, 0)), currency: figures[0].currency, basis: figures.length === 1 ? figures[0].basis : "sum" } : void 0;
22825
22851
  return {
22826
22852
  ...first.engine ? { engine: first.engine } : {},
22827
22853
  ...first.version ? { version: first.version } : {},
22828
22854
  ...first.at ? { at: first.at } : {},
22829
- ...declared ? { declared } : {},
22855
+ ...declared2 ? { declared: declared2 } : {},
22830
22856
  ...members.some((m) => m.name !== void 0) && figures.length ? { members: perMember } : {},
22831
22857
  ...diagnostics.length ? { diagnostics } : {}
22832
22858
  };
@@ -23048,18 +23074,273 @@ function cacheChoudoufuPlan(dir, stamp, drift) {
23048
23074
  // src/server.ts
23049
23075
  init_choudoufu_refs();
23050
23076
 
23077
+ // src/terralith-demo.ts
23078
+ import { existsSync as existsSync23, readdirSync as readdirSync15, readFileSync as readFileSync27 } from "node:fs";
23079
+ import { join as join36 } from "node:path";
23080
+ var TERRALITH_PHASES = [
23081
+ { id: "stock", n: 1, dir: "1-stock" },
23082
+ { id: "adopt", n: 2, dir: "2-adopt" },
23083
+ { id: "split", n: 3, dir: "3-split" },
23084
+ { id: "plan", n: 4, dir: "4-plan" }
23085
+ ];
23086
+ var isRecord12 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23087
+ function readJson(path, notes, label) {
23088
+ if (!existsSync23(path)) return void 0;
23089
+ try {
23090
+ return JSON.parse(readFileSync27(path, "utf8"));
23091
+ } catch (err) {
23092
+ notes.push(`${label}: ${err instanceof Error ? err.message : String(err)}`);
23093
+ return void 0;
23094
+ }
23095
+ }
23096
+ function parseRatification(text2) {
23097
+ const out = /* @__PURE__ */ new Map();
23098
+ let status2;
23099
+ for (const line of text2.split("\n")) {
23100
+ const head = /^([A-Z_]+) \(\d+\) - /.exec(line);
23101
+ if (head) {
23102
+ status2 = ["VERIFIED", "DRIFTED", "MISSING", "UNTAGGABLE", "UNADMITTED_TYPE"].includes(head[1]) ? head[1] : void 0;
23103
+ continue;
23104
+ }
23105
+ if (/eligible for stamping/.test(line)) status2 = void 0;
23106
+ const row = /^ {2}(\S+)\s+(\S+)\s+live id: (\S+)\s*$/.exec(line);
23107
+ if (status2 && row) out.set(row[1], { status: status2.toLowerCase(), ...row[3] !== "-" ? { liveId: row[3] } : {} });
23108
+ }
23109
+ return out;
23110
+ }
23111
+ function declared(doc) {
23112
+ if (!isRecord12(doc) || !Array.isArray(doc.instances)) return [];
23113
+ return doc.instances.flatMap((i) => isRecord12(i) && typeof i.address === "string" ? [{ address: i.address, type: typeof i.type === "string" ? i.type : i.address.split(".")[0] }] : []);
23114
+ }
23115
+ function stateIds(doc) {
23116
+ const out = /* @__PURE__ */ new Map();
23117
+ const walk = (mod) => {
23118
+ if (!isRecord12(mod)) return;
23119
+ for (const r of Array.isArray(mod.resources) ? mod.resources : []) {
23120
+ if (isRecord12(r) && typeof r.address === "string" && r.mode === "managed") {
23121
+ const id = isRecord12(r.values) && typeof r.values.id === "string" ? r.values.id : "";
23122
+ out.set(r.address, id);
23123
+ }
23124
+ }
23125
+ for (const c of Array.isArray(mod.child_modules) ? mod.child_modules : []) walk(c);
23126
+ };
23127
+ if (isRecord12(doc) && isRecord12(doc.values)) walk(doc.values.root_module);
23128
+ return out;
23129
+ }
23130
+ var cardOrder = (a, b) => {
23131
+ const name = (c) => c.id.split(".").slice(1).join(".");
23132
+ return name(a).localeCompare(name(b)) || a.type.localeCompare(b.type);
23133
+ };
23134
+ function retagsOf(dir, notes) {
23135
+ const out = /* @__PURE__ */ new Map();
23136
+ const mv = join36(dir, "live-mv");
23137
+ if (!existsSync23(mv)) return out;
23138
+ for (const f of readdirSync15(mv).sort()) {
23139
+ if (!f.endsWith(".json") || f.endsWith(".dry-run.json")) continue;
23140
+ const doc = readJson(join36(mv, f), notes, `live-mv/${f}`);
23141
+ if (!isRecord12(doc) || !isRecord12(doc.from) || !isRecord12(doc.to) || doc.written !== true) continue;
23142
+ const from = String(doc.from.estate ?? "");
23143
+ const to = String(doc.to.estate ?? "");
23144
+ const address = String(doc.to.address ?? doc.from.address ?? "");
23145
+ if (!address) continue;
23146
+ out.set(address, { from, to });
23147
+ for (const fo of Array.isArray(doc.followers) ? doc.followers : []) {
23148
+ if (isRecord12(fo) && typeof fo.address === "string") out.set(fo.address, { from, to, follows: address });
23149
+ }
23150
+ }
23151
+ return out;
23152
+ }
23153
+ function plannedChanges(plan) {
23154
+ const out = /* @__PURE__ */ new Map();
23155
+ if (!isRecord12(plan) || !Array.isArray(plan.resource_changes)) return out;
23156
+ for (const rc of plan.resource_changes) {
23157
+ if (!isRecord12(rc) || typeof rc.address !== "string" || !isRecord12(rc.change)) continue;
23158
+ const actions = Array.isArray(rc.change.actions) ? rc.change.actions.filter((a) => typeof a === "string") : [];
23159
+ if (!actions.length || actions.every((a) => a === "no-op" || a === "read")) continue;
23160
+ const before = isRecord12(rc.change.before) ? rc.change.before : {};
23161
+ const after2 = isRecord12(rc.change.after) ? rc.change.after : {};
23162
+ const unknown = isRecord12(rc.change.after_unknown) ? rc.change.after_unknown : {};
23163
+ const keys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after2), ...Object.keys(unknown)]);
23164
+ const attributes = [...keys].filter((k) => unknown[k] === true || JSON.stringify(before[k]) !== JSON.stringify(after2[k])).sort();
23165
+ out.set(rc.address, { actions, attributes });
23166
+ }
23167
+ return out;
23168
+ }
23169
+ function outputReads(plan) {
23170
+ if (!isRecord12(plan) || !isRecord12(plan.configuration) || !isRecord12(plan.configuration.root_module)) return [];
23171
+ const resources = plan.configuration.root_module.resources;
23172
+ return (Array.isArray(resources) ? resources : []).flatMap((r) => {
23173
+ if (!isRecord12(r) || r.mode !== "data" || r.type !== "terraform_estate_outputs" || !isRecord12(r.expressions)) return [];
23174
+ const estate = isRecord12(r.expressions.estate) ? r.expressions.estate.constant_value : void 0;
23175
+ const names = isRecord12(r.expressions.names) ? r.expressions.names.constant_value : void 0;
23176
+ return typeof estate === "string" ? [{ estate, names: Array.isArray(names) ? names.filter((n) => typeof n === "string") : [] }] : [];
23177
+ });
23178
+ }
23179
+ function coneFallback(log) {
23180
+ const text2 = log.replace(/\x1b\[[0-9;]*m/g, "").replace(/^[│╷╵ ]+/gm, "");
23181
+ const m = /Cone plan fell back to a full plan\s+This plan covers the whole estate \(guard ([a-z-]+)\):\s*([\s\S]*?)(?:\n\s*\n|$)/.exec(text2);
23182
+ return m ? { kind: m[1], reason: m[2].replace(/\s+/g, " ").trim() } : void 0;
23183
+ }
23184
+ function readTerralithPhase(snapshots, phase2, before) {
23185
+ const dir = join36(snapshots, phase2.dir);
23186
+ const notes = [];
23187
+ const meta = readJson(join36(dir, "phase.json"), notes, "phase.json");
23188
+ if (!isRecord12(meta)) return void 0;
23189
+ const roots = Array.isArray(meta.roots) ? meta.roots.filter((r) => typeof r === "string") : [];
23190
+ const retags = retagsOf(dir, notes);
23191
+ const set = readJson(join36(dir, "set.json"), notes, "set.json");
23192
+ const setPlans = /* @__PURE__ */ new Map();
23193
+ if (isRecord12(set) && Array.isArray(set.roots)) {
23194
+ for (const r of set.roots) if (isRecord12(r) && typeof r.root === "string") setPlans.set(r.root, r.plan);
23195
+ }
23196
+ const planOf = (root) => setPlans.get(root) ?? readJson(join36(dir, root, "plan.json"), notes, `${root}/plan.json`);
23197
+ const seen = new Set(before?.boxes.map((b) => b.id) ?? []);
23198
+ const boxes = roots.map((root) => {
23199
+ const at2 = (f) => join36(dir, root, f);
23200
+ const check = readJson(at2("live-check.json"), notes, `${root}/live-check.json`);
23201
+ const estate = isRecord12(check) && typeof check.estate === "string" && check.estate ? check.estate : void 0;
23202
+ const state = readJson(at2("state.json"), notes, `${root}/state.json`);
23203
+ const ls = readJson(at2("live-ls.json"), notes, `${root}/live-ls.json`);
23204
+ const plan = readJson(at2("live-plan.json"), notes, `${root}/live-plan.json`);
23205
+ const ratified = existsSync23(at2("live-import.txt")) ? parseRatification(readFileSync27(at2("live-import.txt"), "utf8")) : /* @__PURE__ */ new Map();
23206
+ const ids = stateIds(state);
23207
+ const cone = readJson(at2("cone.json"), notes, `${root}/cone.json`);
23208
+ const planDoc = planOf(root);
23209
+ const changes = plannedChanges(planDoc);
23210
+ const inCone = new Set(isRecord12(cone) && isRecord12(cone.guard) && cone.guard.full !== true && Array.isArray(cone.targets) ? cone.targets.filter((t2) => typeof t2 === "string") : []);
23211
+ const listed = /* @__PURE__ */ new Map();
23212
+ if (isRecord12(ls) && Array.isArray(ls.items)) {
23213
+ for (const i of ls.items) {
23214
+ if (isRecord12(i) && typeof i.address === "string" && isRecord12(i.tags) && i.tags["tofu-estate"] === estate) listed.set(i.address, String(i.id ?? ""));
23215
+ }
23216
+ }
23217
+ const bound = /* @__PURE__ */ new Map();
23218
+ if (isRecord12(plan) && Array.isArray(plan.bound)) {
23219
+ for (const b of plan.bound) {
23220
+ if (isRecord12(b) && typeof b.addr === "string") bound.set(b.addr, { source: String(b.source ?? ""), ...typeof b.identity === "string" ? { identity: b.identity } : {} });
23221
+ }
23222
+ }
23223
+ const cards = declared(check).map((d) => {
23224
+ const b = bound.get(d.address);
23225
+ const r = ratified.get(d.address);
23226
+ const source2 = !estate ? "state" : b && ["marker", "derived", "record", "cache"].includes(b.source) ? b.source : "unbound";
23227
+ const liveId = b?.identity || listed.get(d.address) || ids.get(d.address) || r?.liveId;
23228
+ const moved = retags.get(d.address);
23229
+ return {
23230
+ id: d.address,
23231
+ type: d.type,
23232
+ root,
23233
+ identity: { source: source2, marked: listed.has(d.address) },
23234
+ ...liveId ? { liveId } : {},
23235
+ ...r ? { ratified: r.status } : {},
23236
+ ...moved && moved.to === estate ? { moved } : {},
23237
+ ...changes.has(d.address) ? { planned: changes.get(d.address) } : {},
23238
+ ...inCone.has(d.address) ? { inCone: true } : {}
23239
+ };
23240
+ });
23241
+ cards.sort(cardOrder);
23242
+ const log = existsSync23(at2("plan.log")) ? readFileSync27(at2("plan.log"), "utf8") : "";
23243
+ const fallback = log ? coneFallback(log) : void 0;
23244
+ const rootPlan = isRecord12(cone) || planDoc !== void 0 ? {
23245
+ ...isRecord12(cone) && isRecord12(cone.guard) ? {
23246
+ cone: {
23247
+ full: cone.guard.full === true,
23248
+ ...typeof cone.guard.kind === "string" ? { kind: cone.guard.kind } : {},
23249
+ ...typeof cone.guard.reason === "string" ? { reason: cone.guard.reason } : {},
23250
+ blocks: typeof cone.blocks === "number" ? cone.blocks : 0,
23251
+ coneBlocks: typeof cone.cone_blocks === "number" ? cone.cone_blocks : 0
23252
+ }
23253
+ } : {},
23254
+ ...fallback ? { fallback } : {},
23255
+ changes: changes.size
23256
+ } : void 0;
23257
+ return { id: root, ...estate ? { estate } : {}, stock: !estate, spawned: !!before && !seen.has(root), cards, ...rootPlan ? { plan: rootPlan } : {} };
23258
+ });
23259
+ const summary = readJson(join36(dir, "summary.json"), notes, "summary.json");
23260
+ const groups = isRecord12(summary) && Array.isArray(summary.groups) ? summary.groups.flatMap(
23261
+ (g) => isRecord12(g) && typeof g.id === "number" && Array.isArray(g.members) ? [
23262
+ {
23263
+ id: g.id,
23264
+ members: g.members.filter((m) => typeof m === "string"),
23265
+ changes: (Array.isArray(g.changes) ? g.changes : []).flatMap((c) => isRecord12(c) && typeof c.line === "string" ? [{ line: c.line, action: String(c.action ?? "") }] : [])
23266
+ }
23267
+ ] : []
23268
+ ) : [];
23269
+ for (const g of groups) for (const m of g.members) {
23270
+ const box = boxes.find((b) => b.id === m);
23271
+ if (box?.plan) box.plan.group = g.id;
23272
+ }
23273
+ const outputs = [];
23274
+ for (const box of boxes) {
23275
+ for (const read of outputReads(planOf(box.id))) {
23276
+ const producer = boxes.find((b) => b.estate === read.estate);
23277
+ const planned = producer ? planOf(producer.id) : void 0;
23278
+ const values = isRecord12(planned) && isRecord12(planned.planned_values) && isRecord12(planned.planned_values.outputs) ? planned.planned_values.outputs : {};
23279
+ for (const name of read.names) {
23280
+ let o = outputs.find((x) => x.estate === read.estate && x.name === name);
23281
+ if (!o) {
23282
+ const v = values[name];
23283
+ const known = isRecord12(v) && "value" in v && v.sensitive !== true;
23284
+ o = { estate: read.estate, ...producer ? { root: producer.id } : {}, name, ...known ? { value: v.value } : {}, known, readers: [] };
23285
+ outputs.push(o);
23286
+ }
23287
+ o.readers.push(box.id);
23288
+ }
23289
+ }
23290
+ }
23291
+ const all = boxes.flatMap((b) => b.cards);
23292
+ return {
23293
+ id: phase2.id,
23294
+ n: phase2.n,
23295
+ ...typeof meta.at === "string" ? { at: meta.at } : {},
23296
+ ...typeof meta.choudoufu === "string" ? { choudoufu: meta.choudoufu } : {},
23297
+ boxes,
23298
+ counts: {
23299
+ cards: all.length,
23300
+ marked: all.filter((c) => c.identity.marked).length,
23301
+ marker: all.filter((c) => c.identity.source === "marker").length,
23302
+ derived: all.filter((c) => c.identity.source === "derived").length,
23303
+ state: all.filter((c) => c.identity.source === "state").length,
23304
+ moved: all.filter((c) => c.moved).length,
23305
+ planned: all.filter((c) => c.planned).length
23306
+ },
23307
+ ...groups.length || outputs.length ? { plan: { groups, outputs } } : {},
23308
+ notes
23309
+ };
23310
+ }
23311
+ function phaseCommand(id) {
23312
+ return id === "stock" ? "bash scripts/terralith-up.sh" : `bash scripts/terralith-step.sh ${id}`;
23313
+ }
23314
+ function readTerralith(root) {
23315
+ const snapshots = join36(root, "snapshots");
23316
+ const phases = [];
23317
+ for (const p of TERRALITH_PHASES) {
23318
+ const read = readTerralithPhase(snapshots, p, phases[phases.length - 1]);
23319
+ if (!read) break;
23320
+ phases.push(read);
23321
+ }
23322
+ const nextPhase = TERRALITH_PHASES[phases.length];
23323
+ const notes = [];
23324
+ const split = readJson(join36(root, "split.json"), notes, "split.json");
23325
+ return {
23326
+ phases,
23327
+ ...nextPhase ? { next: { id: nextPhase.id, n: nextPhase.n, command: phaseCommand(nextPhase.id) } } : {},
23328
+ ...isRecord12(split) && Array.isArray(split.moves) ? { split: { moves: split.moves.length, estates: Array.isArray(split.estates) ? split.estates.filter((e) => typeof e === "string") : [] } } : {}
23329
+ };
23330
+ }
23331
+
23051
23332
  // src/choudoufu-moves.ts
23052
23333
  init_choudoufu_member();
23053
23334
  init_choudoufu_live();
23054
- import { existsSync as existsSync23, readFileSync as readFileSync27 } from "node:fs";
23055
- import { join as join36, relative as relative7 } from "node:path";
23056
- var isRecord12 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23335
+ import { existsSync as existsSync24, readFileSync as readFileSync28 } from "node:fs";
23336
+ import { join as join37, relative as relative7 } from "node:path";
23337
+ var isRecord13 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
23057
23338
  var refuse8 = (error, remedy) => ({ ok: false, refusal: { error, code: "choudoufu-live-check", remedy } });
23058
- var HOW_TO_GET_ONE2 = "A plan is the live-mv workbench's carve.json: `{from, estates[], moves[{address, from, to}]}` \u2014 the workbench's plan phase writes one, or write it by hand.";
23059
- function parseCarvePlan(value) {
23060
- if (!isRecord12(value)) return refuse8("That file is not a move plan \u2014 its top level is not a JSON object.", HOW_TO_GET_ONE2);
23339
+ 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.";
23340
+ function parseSplitPlan(value) {
23341
+ if (!isRecord13(value)) return refuse8("That file is not a move plan \u2014 its top level is not a JSON object.", HOW_TO_GET_ONE2);
23061
23342
  if (!Array.isArray(value.moves)) return refuse8("That JSON is not a move plan \u2014 it has no `moves` array.", HOW_TO_GET_ONE2);
23062
- const bad2 = value.moves.findIndex((m) => !isRecord12(m) || typeof m.address !== "string" || typeof m.from !== "string" || typeof m.to !== "string");
23343
+ const bad2 = value.moves.findIndex((m) => !isRecord13(m) || typeof m.address !== "string" || typeof m.from !== "string" || typeof m.to !== "string");
23063
23344
  if (bad2 >= 0) return refuse8(`moves[${bad2}] is not a move (needs string \`address\`, \`from\` and \`to\`).`, HOW_TO_GET_ONE2);
23064
23345
  const moves = value.moves;
23065
23346
  return {
@@ -23072,7 +23353,7 @@ function parseCarvePlan(value) {
23072
23353
  }
23073
23354
  };
23074
23355
  }
23075
- function readCarvePlan(path, readFile2 = (p) => readFileSync27(p, "utf8")) {
23356
+ function readSplitPlan(path, readFile2 = (p) => readFileSync28(p, "utf8")) {
23076
23357
  let text2;
23077
23358
  try {
23078
23359
  text2 = readFile2(path);
@@ -23080,16 +23361,17 @@ function readCarvePlan(path, readFile2 = (p) => readFileSync27(p, "utf8")) {
23080
23361
  return refuse8(`Couldn't read ${path}: ${err instanceof Error ? err.message : String(err)}`, HOW_TO_GET_ONE2);
23081
23362
  }
23082
23363
  try {
23083
- return parseCarvePlan(JSON.parse(text2));
23364
+ return parseSplitPlan(JSON.parse(text2));
23084
23365
  } catch (err) {
23085
23366
  return refuse8(`${path} is not JSON: ${err instanceof Error ? err.message : String(err)}`, HOW_TO_GET_ONE2);
23086
23367
  }
23087
23368
  }
23088
- function discoverCarvePlans(memberDirs, base) {
23369
+ var SPLIT_PLAN_FILES = ["split.json", "carve.json"];
23370
+ function discoverSplitPlans(memberDirs, base) {
23089
23371
  const out = [];
23090
23372
  for (const dir of memberDirs) {
23091
- const p = join36(dir, "carve.json");
23092
- if (existsSync23(p)) out.push(relative7(base, p));
23373
+ const file = SPLIT_PLAN_FILES.find((f) => existsSync24(join37(dir, f)));
23374
+ if (file) out.push(relative7(base, join37(dir, file)));
23093
23375
  }
23094
23376
  return out;
23095
23377
  }
@@ -23103,7 +23385,7 @@ function parseLiveMv(run3, what) {
23103
23385
  } catch {
23104
23386
  return refuse8(`choudoufu live-mv printed something that is not JSON for ${what}.`, "Run the line by hand to see choudoufu's own words.");
23105
23387
  }
23106
- if (!isRecord12(json2) || !isRecord12(json2.from) || !isRecord12(json2.to) || typeof json2.dry_run !== "boolean") {
23388
+ if (!isRecord13(json2) || !isRecord13(json2.from) || !isRecord13(json2.to) || typeof json2.dry_run !== "boolean") {
23107
23389
  return refuse8(`That is not a live-mv document (${what}).`, "Upgrade choudoufu to 0.16.0 or newer.");
23108
23390
  }
23109
23391
  return { ok: true, doc: json2 };
@@ -23258,7 +23540,7 @@ async function readPolicyOverride(dir, g, read = gitLifecycleReader) {
23258
23540
  }
23259
23541
 
23260
23542
  // src/workspace-gates.ts
23261
- var isRecord13 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
23543
+ var isRecord14 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
23262
23544
  var str10 = (v) => typeof v === "string" && v ? v : null;
23263
23545
  function gateKey(member, op, gate) {
23264
23546
  return `${member}/${op}/${gate}`;
@@ -23269,16 +23551,16 @@ function approveArgs(g) {
23269
23551
  function gatesFromStatus(doc, root) {
23270
23552
  const contract = contractRefusal(doc, "status");
23271
23553
  if (contract) return { ok: false, refusal: contract };
23272
- if (isRecord13(doc.error)) {
23554
+ if (isRecord14(doc.error)) {
23273
23555
  const code = String(doc.error.code ?? "unknown");
23274
23556
  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." } };
23275
23557
  }
23276
23558
  const gates = [];
23277
23559
  for (const m of Array.isArray(doc.members) ? doc.members : []) {
23278
- if (!isRecord13(m) || typeof m.name !== "string") continue;
23560
+ if (!isRecord14(m) || typeof m.name !== "string") continue;
23279
23561
  const dir = typeof m.dir === "string" ? m.dir === "." ? resolve20(root) : resolve20(root, m.dir) : resolve20(root);
23280
23562
  for (const g of Array.isArray(m.gates) ? m.gates : []) {
23281
- if (!isRecord13(g)) continue;
23563
+ if (!isRecord14(g)) continue;
23282
23564
  const op = str10(g.component);
23283
23565
  const gate = str10(g.name);
23284
23566
  if (!op || !gate) continue;
@@ -23286,7 +23568,7 @@ function gatesFromStatus(doc, root) {
23286
23568
  if (g.state !== void 0 && g.state !== "pending" && !keepApproved) continue;
23287
23569
  const env = str10(g.env);
23288
23570
  const planDigest = str10(g.planDigest);
23289
- const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord13).map((a) => ({
23571
+ const approvals = (Array.isArray(g.approvals) ? g.approvals : []).filter(isRecord14).map((a) => ({
23290
23572
  principal: String(a.principal ?? "unknown"),
23291
23573
  at: str10(a.at),
23292
23574
  channel: str10(a.channel)
@@ -23303,11 +23585,11 @@ function gatesFromStatus(doc, root) {
23303
23585
  needed: typeof g.needed === "number" ? g.needed : 1,
23304
23586
  recordedAt: str10(g.recordedAt),
23305
23587
  expiresAt: str10(g.expiresAt),
23306
- signed: isRecord13(g.signed),
23588
+ signed: isRecord14(g.signed),
23307
23589
  // status's line already carries --sign for a signed gate; only the
23308
23590
  // line built here needs it added.
23309
23591
  state: keepApproved ? "approved" : "pending",
23310
- approve: str10(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord13(g.signed) ? ["--sign"] : []].join(" ")
23592
+ approve: str10(g.approve) ?? ["chant", ...approveArgs({ op, gate, env, planDigest }), ...isRecord14(g.signed) ? ["--sign"] : []].join(" ")
23311
23593
  });
23312
23594
  }
23313
23595
  }
@@ -23343,7 +23625,7 @@ function localApprover(env = process.env) {
23343
23625
 
23344
23626
  // src/workspace-why.ts
23345
23627
  var WHY_COMMITS_SHOWN = 8;
23346
- var isRecord14 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
23628
+ var isRecord15 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
23347
23629
  var str11 = (v) => typeof v === "string" && v ? v : null;
23348
23630
  var num2 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
23349
23631
  var strings3 = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
@@ -23368,12 +23650,12 @@ function hudReviewUrl(hud, record) {
23368
23650
  return `${hud.replace(/\/+$/, "")}/decisions#${encodeURIComponent(record)}`;
23369
23651
  }
23370
23652
  function whyFromIntent(doc, hud = null) {
23371
- if (isRecord14(doc.error)) {
23653
+ if (isRecord15(doc.error)) {
23372
23654
  const code = String(doc.error.code ?? "unknown");
23373
23655
  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.");
23374
23656
  }
23375
23657
  const nodes = /* @__PURE__ */ new Map();
23376
- for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (isRecord14(n) && typeof n.id === "string") nodes.set(n.id, n);
23658
+ for (const n of Array.isArray(doc.nodes) ? doc.nodes : []) if (isRecord15(n) && typeof n.id === "string") nodes.set(n.id, n);
23377
23659
  const regionId = String(doc.region ?? "");
23378
23660
  const regionNode = nodes.get(regionId);
23379
23661
  const base = {
@@ -23383,12 +23665,12 @@ function whyFromIntent(doc, hud = null) {
23383
23665
  chant: String(doc.chant ?? "")
23384
23666
  };
23385
23667
  const why = doc.why;
23386
- if (!isRecord14(why)) {
23668
+ if (!isRecord15(why)) {
23387
23669
  return { ok: true, why: { ...base, answered: false, explained: false, decisions: [], runs: [], commits: [], commitsTotal: 0, uncommittedLines: 0, gaps: [] } };
23388
23670
  }
23389
23671
  const decisions = [];
23390
23672
  for (const d of Array.isArray(why.decisions) ? why.decisions : []) {
23391
- if (!isRecord14(d) || typeof d.decision !== "string") continue;
23673
+ if (!isRecord15(d) || typeof d.decision !== "string") continue;
23392
23674
  const n = nodes.get(d.decision) ?? {};
23393
23675
  const id = str11(n.record) ?? after(d.decision, "record:").replace(/^[^/]*\//, "");
23394
23676
  const state = str11(n.state);
@@ -23407,28 +23689,28 @@ function whyFromIntent(doc, hud = null) {
23407
23689
  }
23408
23690
  const commitOf = (id) => {
23409
23691
  const n = nodes.get(id) ?? {};
23410
- const joins = isRecord14(n.joins) ? n.joins : {};
23692
+ const joins = isRecord15(n.joins) ? n.joins : {};
23411
23693
  return {
23412
23694
  sha: str11(n.sha) ?? after(id, "commit:"),
23413
23695
  subject: str11(n.subject),
23414
23696
  date: str11(n.date),
23415
- author: isRecord14(n.author) ? str11(n.author.name) : null,
23697
+ author: isRecord15(n.author) ? str11(n.author.name) : null,
23416
23698
  pullRequest: typeof n.pullRequest === "number" ? n.pullRequest : null,
23417
23699
  run: str11(joins.run)
23418
23700
  };
23419
23701
  };
23420
23702
  const runs2 = [];
23421
23703
  for (const r of Array.isArray(why.runs) ? why.runs : []) {
23422
- if (!isRecord14(r) || typeof r.run !== "string") continue;
23704
+ if (!isRecord15(r) || typeof r.run !== "string") continue;
23423
23705
  const n = nodes.get(r.run) ?? {};
23424
- const unit = isRecord14(r.unit) ? str11(r.unit.id) : null;
23706
+ const unit = isRecord15(r.unit) ? str11(r.unit.id) : null;
23425
23707
  runs2.push({
23426
23708
  id: str11(n.run) ?? after(r.run, "run:"),
23427
23709
  lines: num2(r.lines),
23428
23710
  commits: strings3(r.commits).map((c) => commitOf(c).sha),
23429
23711
  unit,
23430
23712
  by: str11(n.by),
23431
- harness: isRecord14(n.harness) ? str11(n.harness.name) : null,
23713
+ harness: isRecord15(n.harness) ? str11(n.harness.name) : null,
23432
23714
  model: str11(n.model),
23433
23715
  outcome: str11(n.outcome),
23434
23716
  startedAt: str11(n.startedAt),
@@ -23436,7 +23718,7 @@ function whyFromIntent(doc, hud = null) {
23436
23718
  decisions: strings3(r.decisions).map((d) => str11(nodes.get(d)?.record) ?? after(d, "record:"))
23437
23719
  });
23438
23720
  }
23439
- const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord14);
23721
+ const blame = (Array.isArray(why.blame) ? why.blame : []).filter(isRecord15);
23440
23722
  let uncommittedLines = 0;
23441
23723
  const ids = [];
23442
23724
  for (const span of blame) {
@@ -23463,7 +23745,7 @@ function whyFromIntent(doc, hud = null) {
23463
23745
  commits: commits.slice(0, WHY_COMMITS_SHOWN),
23464
23746
  commitsTotal: commits.length,
23465
23747
  uncommittedLines,
23466
- gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord14).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") }))
23748
+ gaps: (Array.isArray(why.gaps) ? why.gaps : []).filter(isRecord15).map((g) => ({ code: String(g.code ?? ""), message: String(g.message ?? "") }))
23467
23749
  }
23468
23750
  };
23469
23751
  }
@@ -23589,10 +23871,10 @@ function chantCheck(root, targets, estate) {
23589
23871
  }
23590
23872
  return { name: "chant", status: "pass", detail: `${versions}${floor ? ` (behold's floor ${floor})` : ""}` };
23591
23873
  }
23592
- function lexiconCheck(root, declared, estate) {
23874
+ function lexiconCheck(root, declared2, estate) {
23593
23875
  const missing = [];
23594
23876
  const found = [];
23595
- for (const [target, lexicons] of declared) {
23877
+ for (const [target, lexicons] of declared2) {
23596
23878
  const label = labelFor(root, target, estate);
23597
23879
  for (const r of resolveLexicons(target, lexicons)) {
23598
23880
  (r.installed ? found : missing).push(`${label}${r.lexicon}${r.installed && r.version ? ` ${r.version}` : ""}`);
@@ -23611,8 +23893,8 @@ function lexiconCheck(root, declared, estate) {
23611
23893
  }
23612
23894
  return { name: "lexicons", status: "pass", detail: `${found.length} installed: ${list2(found)}` };
23613
23895
  }
23614
- function targetCheck(declared) {
23615
- const lexicons = [...new Set([...declared.values()].flat())].sort();
23896
+ function targetCheck(declared2) {
23897
+ const lexicons = [...new Set([...declared2.values()].flat())].sort();
23616
23898
  const routable = new Set(SUBSTRATE_TARGET_VARS.map((t2) => t2.lexicon));
23617
23899
  const unlisted = lexicons.filter((l) => !routable.has(l) && !(l in NO_AMBIENT_TARGET));
23618
23900
  if (!lexicons.length) return { name: "targets", status: "pass", detail: "no lexicon declared \u2014 nothing to aim" };
@@ -23863,7 +24145,7 @@ async function diagnose(dir, probes = {}) {
23863
24145
  fix: kindsFix
23864
24146
  } : { name: "project", status: "pass", detail: `${emptyDeclaration}${estateDetail}` } : { name: "project", status: "pass", detail: `${emptyDeclaration}chant project (${relative8(root, shape.configFile)})` };
23865
24147
  const infos = await Promise.all(chantTargets.map(async (t2) => ({ target: t2, info: await detectProject(t2) })));
23866
- const declared = new Map(infos.map(({ target, info }) => [target, info.lexicons]));
24148
+ const declared2 = new Map(infos.map(({ target, info }) => [target, info.lexicons]));
23867
24149
  const lexicons = [...new Set(infos.flatMap(({ info }) => info.lexicons))];
23868
24150
  const envs = [...new Set(infos.flatMap(({ info }) => info.environments))];
23869
24151
  const profiles = {};
@@ -23875,8 +24157,8 @@ async function diagnose(dir, probes = {}) {
23875
24157
  const checks = [
23876
24158
  projectCheck,
23877
24159
  chantCheck(root, chantTargets, estate),
23878
- lexiconCheck(root, declared, estate),
23879
- targetCheck(declared),
24160
+ lexiconCheck(root, declared2, estate),
24161
+ targetCheck(declared2),
23880
24162
  // An estate root is not itself servable — the hint has to name its members
23881
24163
  // (`behold serve a b c`, #31), which is what a stranger would otherwise
23882
24164
  // discover by having the root serve nothing. The `.` member (#387) is the
@@ -23912,8 +24194,8 @@ init_read_stats();
23912
24194
  init_foreign();
23913
24195
 
23914
24196
  // src/events.ts
23915
- import { watch, existsSync as existsSync24 } from "node:fs";
23916
- import { join as join37 } from "node:path";
24197
+ import { watch, existsSync as existsSync25 } from "node:fs";
24198
+ import { join as join38 } from "node:path";
23917
24199
  var Broadcaster = class {
23918
24200
  listeners = /* @__PURE__ */ new Set();
23919
24201
  subscribe(fn) {
@@ -23931,7 +24213,7 @@ var Broadcaster = class {
23931
24213
  };
23932
24214
  var IGNORE = /(^|[\\/])(node_modules|dist|\.git)([\\/]|$)/;
23933
24215
  function watchSource(projectDir, onChange, debounceMs = 200) {
23934
- const dir = existsSync24(join37(projectDir, "src")) ? join37(projectDir, "src") : projectDir;
24216
+ const dir = existsSync25(join38(projectDir, "src")) ? join38(projectDir, "src") : projectDir;
23935
24217
  let timer;
23936
24218
  const watcher = watch(dir, { recursive: true }, (_event, file) => {
23937
24219
  const name = typeof file === "string" ? file : "";
@@ -24235,13 +24517,13 @@ async function emulatorDown(projectDir) {
24235
24517
 
24236
24518
  // src/terragucci-view.ts
24237
24519
  import { execFileSync as execFileSync3 } from "node:child_process";
24238
- import { dirname as dirname13, join as join43, relative as relative9, sep as sep8 } from "node:path";
24520
+ import { dirname as dirname13, join as join44, relative as relative9, sep as sep8 } from "node:path";
24239
24521
  init_terraform_member();
24240
24522
 
24241
24523
  // src/terragucci-reports.ts
24242
- import { readFileSync as readFileSync28, statSync as statSync11 } from "node:fs";
24524
+ import { readFileSync as readFileSync29, statSync as statSync11 } from "node:fs";
24243
24525
  import { createRequire as createRequire4 } from "node:module";
24244
- import { dirname as dirname10, join as join38, resolve as resolve22 } from "node:path";
24526
+ import { dirname as dirname10, join as join39, resolve as resolve22 } from "node:path";
24245
24527
  import { fileURLToPath as fileURLToPath5 } from "node:url";
24246
24528
  import { Ajv2020 } from "ajv/dist/2020.js";
24247
24529
  var REPORT_SCHEMA = "terragucci.report/v1";
@@ -24274,34 +24556,34 @@ function attributeValues(a) {
24274
24556
  }
24275
24557
  var SCHEMA_FILES = { report: "report.schema.json", index: "report-index.schema.json", estate: "estate.schema.json" };
24276
24558
  var SCHEMA_IDS = { report: REPORT_SCHEMA, index: INDEX_SCHEMA, estate: ESTATE_SCHEMA };
24277
- var isRecord15 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
24559
+ var isRecord16 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
24278
24560
  var str12 = (v) => typeof v === "string";
24279
24561
  function structural(name, doc) {
24280
- if (!isRecord15(doc)) return "it is not a JSON object";
24562
+ if (!isRecord16(doc)) return "it is not a JSON object";
24281
24563
  if (doc.schema !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(doc.schema)}, not ${SCHEMA_IDS[name]}`;
24282
24564
  if (name === "index") {
24283
24565
  if (!Array.isArray(doc.reports)) return "it has no reports array";
24284
24566
  for (const [i, r] of doc.reports.entries()) {
24285
- if (!isRecord15(r) || !str12(r.project) || !str12(r.commit) || !str12(r.stage) || !str12(r.finished) || !str12(r.path)) return `row ${i} lacks project, commit, stage, finished or path`;
24567
+ if (!isRecord16(r) || !str12(r.project) || !str12(r.commit) || !str12(r.stage) || !str12(r.finished) || !str12(r.path)) return `row ${i} lacks project, commit, stage, finished or path`;
24286
24568
  }
24287
24569
  } else if (name === "report") {
24288
24570
  const run3 = doc.run;
24289
- if (!isRecord15(run3) || !str12(run3.project) || !str12(run3.commit) || !str12(run3.stage) || !str12(run3.finished)) return "its run lacks project, commit, stage or finished";
24571
+ if (!isRecord16(run3) || !str12(run3.project) || !str12(run3.commit) || !str12(run3.stage) || !str12(run3.finished)) return "its run lacks project, commit, stage or finished";
24290
24572
  if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
24291
24573
  for (const [i, r] of doc.roots.entries()) {
24292
- if (!isRecord15(r) || !str12(r.path) || r.status !== "planned" && r.status !== "failed" || !Array.isArray(r.changes)) return `root ${i} lacks path, status or changes`;
24293
- for (const c of r.changes) if (!isRecord15(c) || !str12(c.address) || !str12(c.action)) return `a change in root ${String(r.path)} lacks address or action`;
24574
+ if (!isRecord16(r) || !str12(r.path) || r.status !== "planned" && r.status !== "failed" || !Array.isArray(r.changes)) return `root ${i} lacks path, status or changes`;
24575
+ for (const c of r.changes) if (!isRecord16(c) || !str12(c.address) || !str12(c.action)) return `a change in root ${String(r.path)} lacks address or action`;
24294
24576
  }
24295
24577
  } else {
24296
- if (!str12(doc.generated) || !isRecord15(doc.totals) || !Array.isArray(doc.projects)) return "it lacks generated, totals or projects";
24297
- for (const p of doc.projects) if (!isRecord15(p) || !str12(p.project) || !Array.isArray(p.waiting)) return "a project lacks project or waiting";
24578
+ if (!str12(doc.generated) || !isRecord16(doc.totals) || !Array.isArray(doc.projects)) return "it lacks generated, totals or projects";
24579
+ for (const p of doc.projects) if (!isRecord16(p) || !str12(p.project) || !Array.isArray(p.waiting)) return "a project lacks project or waiting";
24298
24580
  }
24299
24581
  return void 0;
24300
24582
  }
24301
24583
  var compiledSchemas = /* @__PURE__ */ new Map();
24302
24584
  function schemaStamp(dist) {
24303
24585
  try {
24304
- const files = [join38(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join38(dist, f))];
24586
+ const files = [join39(dist, "..", "package.json"), ...Object.values(SCHEMA_FILES).map((f) => join39(dist, f))];
24305
24587
  return [dist, ...files.map((f) => {
24306
24588
  const st = statSync11(f);
24307
24589
  return `${st.mtimeMs}:${st.size}`;
@@ -24311,15 +24593,15 @@ function schemaStamp(dist) {
24311
24593
  }
24312
24594
  }
24313
24595
  function compileSchemas(dist) {
24314
- const version = JSON.parse(readFileSync28(join38(dist, "..", "package.json"), "utf8")).version ?? "";
24596
+ const version = JSON.parse(readFileSync29(join39(dist, "..", "package.json"), "utf8")).version ?? "";
24315
24597
  const ajv = new Ajv2020({ strict: false, allErrors: false });
24316
24598
  const compiled4 = Object.fromEntries(
24317
- Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync28(join38(dist, SCHEMA_FILES[n]), "utf8")))])
24599
+ Object.keys(SCHEMA_FILES).map((n) => [n, ajv.compile(JSON.parse(readFileSync29(join39(dist, SCHEMA_FILES[n]), "utf8")))])
24318
24600
  );
24319
24601
  return {
24320
24602
  validation: { by: "schema", terragucci: version },
24321
24603
  check(name, doc) {
24322
- const id = isRecord15(doc) ? doc.schema : void 0;
24604
+ const id = isRecord16(doc) ? doc.schema : void 0;
24323
24605
  if (id !== SCHEMA_IDS[name]) return `its schema is ${JSON.stringify(id)}, not ${SCHEMA_IDS[name]}`;
24324
24606
  if (compiled4[name](doc)) return void 0;
24325
24607
  const e = compiled4[name].errors?.[0];
@@ -24331,7 +24613,7 @@ function terragucciValidator(dirs = []) {
24331
24613
  for (const from of [...dirs, dirname10(fileURLToPath5(import.meta.url))]) {
24332
24614
  let entry;
24333
24615
  try {
24334
- entry = createRequire4(join38(resolve22(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
24616
+ entry = createRequire4(join39(resolve22(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
24335
24617
  } catch {
24336
24618
  continue;
24337
24619
  }
@@ -24688,9 +24970,9 @@ function joinTerragucci(read, nodes, roots) {
24688
24970
  }
24689
24971
 
24690
24972
  // src/terragucci-timeline.ts
24691
- import { readFileSync as readFileSync29, statSync as statSync12 } from "node:fs";
24973
+ import { readFileSync as readFileSync30, statSync as statSync12 } from "node:fs";
24692
24974
  import { createRequire as createRequire5 } from "node:module";
24693
- import { dirname as dirname11, join as join39, resolve as resolve23 } from "node:path";
24975
+ import { dirname as dirname11, join as join40, resolve as resolve23 } from "node:path";
24694
24976
  import { fileURLToPath as fileURLToPath6 } from "node:url";
24695
24977
  import { Ajv2020 as Ajv20202 } from "ajv/dist/2020.js";
24696
24978
  var AUDIT_SCHEMA = "terragucci.audit/v1";
@@ -24700,17 +24982,17 @@ var WHAT_IS_ROOT = /* @__PURE__ */ new Set(["override-requested", "override", "o
24700
24982
  var TIMELINE_LIMIT = 200;
24701
24983
  var TIMELINE_MAX = 1e3;
24702
24984
  var TIMELINE_TTL_MS = 3e4;
24703
- var isRecord16 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
24985
+ var isRecord17 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
24704
24986
  var str13 = (v) => typeof v === "string";
24705
24987
  function structuralAudit(doc) {
24706
- if (!isRecord16(doc)) return "it is not a JSON object";
24988
+ if (!isRecord17(doc)) return "it is not a JSON object";
24707
24989
  if (doc.schema !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${AUDIT_SCHEMA}`;
24708
24990
  for (const f of ["id", "kind", "project", "at", "what", "result"]) if (!str13(doc[f])) return `its ${f} is not a string`;
24709
24991
  if (Number.isNaN(Date.parse(doc.at))) return `its at, ${JSON.stringify(doc.at)}, is not a time`;
24710
24992
  if (doc.who !== null && !str13(doc.who)) return "its who is neither a string nor null";
24711
24993
  if (doc.digest !== null && !str13(doc.digest)) return "its digest is neither a string nor null";
24712
- if (!isRecord16(doc.evidence) || !str13(doc.evidence.source)) return "its evidence has no source";
24713
- if (doc.detail !== void 0 && !isRecord16(doc.detail)) return "its detail is not an object";
24994
+ if (!isRecord17(doc.evidence) || !str13(doc.evidence.source)) return "its evidence has no source";
24995
+ if (doc.detail !== void 0 && !isRecord17(doc.detail)) return "its detail is not an object";
24714
24996
  return void 0;
24715
24997
  }
24716
24998
  function compileAuditSchema(schema, version) {
@@ -24718,7 +25000,7 @@ function compileAuditSchema(schema, version) {
24718
25000
  return {
24719
25001
  validation: { by: "schema", terragucci: version },
24720
25002
  check(doc) {
24721
- const id = isRecord16(doc) ? doc.schema : void 0;
25003
+ const id = isRecord17(doc) ? doc.schema : void 0;
24722
25004
  if (id !== AUDIT_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${AUDIT_SCHEMA}`;
24723
25005
  if (v(doc)) return void 0;
24724
25006
  const e = v.errors?.[0];
@@ -24731,12 +25013,12 @@ function auditValidator(dirs = []) {
24731
25013
  for (const from of [...dirs, dirname11(fileURLToPath6(import.meta.url))]) {
24732
25014
  let dist;
24733
25015
  try {
24734
- dist = dirname11(createRequire5(join39(resolve23(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
25016
+ dist = dirname11(createRequire5(join40(resolve23(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
24735
25017
  } catch {
24736
25018
  continue;
24737
25019
  }
24738
- const pkg = join39(dist, "..", "package.json");
24739
- const file = join39(dist, AUDIT_SCHEMA_FILE);
25020
+ const pkg = join40(dist, "..", "package.json");
25021
+ const file = join40(dist, AUDIT_SCHEMA_FILE);
24740
25022
  let stamp;
24741
25023
  try {
24742
25024
  stamp = [dist, ...[pkg, file].map((f) => {
@@ -24750,8 +25032,8 @@ function auditValidator(dirs = []) {
24750
25032
  if (hit) return hit;
24751
25033
  let v;
24752
25034
  try {
24753
- const version = JSON.parse(readFileSync29(pkg, "utf8")).version ?? "";
24754
- v = compileAuditSchema(JSON.parse(readFileSync29(file, "utf8")), version);
25035
+ const version = JSON.parse(readFileSync30(pkg, "utf8")).version ?? "";
25036
+ v = compileAuditSchema(JSON.parse(readFileSync30(file, "utf8")), version);
24755
25037
  } catch {
24756
25038
  continue;
24757
25039
  }
@@ -24793,8 +25075,8 @@ function ownRoots(e) {
24793
25075
  if (Array.isArray(listed)) {
24794
25076
  for (const r of listed) {
24795
25077
  if (str13(r)) roots.add(r);
24796
- else if (isRecord16(r) && str13(r.root)) roots.add(r.root);
24797
- else if (isRecord16(r) && str13(r.path)) roots.add(r.path);
25078
+ else if (isRecord17(r) && str13(r.root)) roots.add(r.root);
25079
+ else if (isRecord17(r) && str13(r.path)) roots.add(r.path);
24798
25080
  }
24799
25081
  }
24800
25082
  if (WHAT_IS_ROOT.has(e.kind)) roots.add(e.what);
@@ -24947,7 +25229,7 @@ function terragucciTimelineRoute(app, source2, opts = {}) {
24947
25229
  // src/terragucci-poll.ts
24948
25230
  import { createHash as createHash10 } from "node:crypto";
24949
25231
  import { stat } from "node:fs/promises";
24950
- import { join as join40, resolve as resolve24 } from "node:path";
25232
+ import { join as join41, resolve as resolve24 } from "node:path";
24951
25233
  import { streamSSE } from "hono/streaming";
24952
25234
  var TERRAGUCCI_POLL_SECS = 30;
24953
25235
  var INDEX_KEY = "index.json";
@@ -24998,7 +25280,7 @@ function indexProbe(spec2, opts = {}) {
24998
25280
  return verdict2(prev, etag);
24999
25281
  };
25000
25282
  }
25001
- const file = join40(resolve24(opts.cwd ?? process.cwd(), spec2), name);
25283
+ const file = join41(resolve24(opts.cwd ?? process.cwd(), spec2), name);
25002
25284
  return async (prev) => {
25003
25285
  try {
25004
25286
  const s = await stat(file);
@@ -25153,29 +25435,29 @@ function terragucciLaneRoutes(app, o, base, forget) {
25153
25435
  }
25154
25436
 
25155
25437
  // src/terragucci-progress.ts
25156
- import { readFileSync as readFileSync30, statSync as statSync13 } from "node:fs";
25438
+ import { readFileSync as readFileSync31, statSync as statSync13 } from "node:fs";
25157
25439
  import { createRequire as createRequire6 } from "node:module";
25158
- import { dirname as dirname12, join as join41, resolve as resolve25 } from "node:path";
25440
+ import { dirname as dirname12, join as join42, resolve as resolve25 } from "node:path";
25159
25441
  import { fileURLToPath as fileURLToPath7 } from "node:url";
25160
25442
  import { Ajv2020 as Ajv20203 } from "ajv/dist/2020.js";
25161
25443
  var RUN_SCHEMA = "terragucci.run/v1";
25162
25444
  var RUN_SCHEMA_FILE = "run.schema.json";
25163
25445
  var PROGRESS_TTL_MS = 3e4;
25164
25446
  var PROGRESS_STATUSES = ["done", "in-flight", "waiting", "not-applied"];
25165
- var isRecord17 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
25447
+ var isRecord18 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
25166
25448
  var str14 = (v) => typeof v === "string";
25167
25449
  function structuralRun(doc) {
25168
- if (!isRecord17(doc)) return "it is not a JSON object";
25450
+ if (!isRecord18(doc)) return "it is not a JSON object";
25169
25451
  if (doc.schema !== RUN_SCHEMA) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA}`;
25170
25452
  for (const f of ["project", "commit", "updated"]) if (!str14(doc[f])) return `its ${f} is not a string`;
25171
25453
  if (!Array.isArray(doc.waves)) return "it has no waves array";
25172
25454
  for (const [i, w] of doc.waves.entries()) {
25173
- if (!isRecord17(w) || typeof w.number !== "number" || !str14(w.state) || !str14(w.gate) || !Array.isArray(w.roots)) return `wave ${i} lacks number, state, gate or roots`;
25455
+ if (!isRecord18(w) || typeof w.number !== "number" || !str14(w.state) || !str14(w.gate) || !Array.isArray(w.roots)) return `wave ${i} lacks number, state, gate or roots`;
25174
25456
  if (w.progress === void 0) continue;
25175
25457
  const p = w.progress;
25176
- if (!isRecord17(p) || !str14(p.read) || !Array.isArray(p.resources)) return `wave ${String(w.number)}'s progress lacks read or resources`;
25458
+ if (!isRecord18(p) || !str14(p.read) || !Array.isArray(p.resources)) return `wave ${String(w.number)}'s progress lacks read or resources`;
25177
25459
  for (const r of p.resources) {
25178
- if (!isRecord17(r) || !str14(r.root) || !str14(r.address) || !str14(r.action)) return `a resource of wave ${String(w.number)}'s progress lacks root, address or action`;
25460
+ if (!isRecord18(r) || !str14(r.root) || !str14(r.address) || !str14(r.action)) return `a resource of wave ${String(w.number)}'s progress lacks root, address or action`;
25179
25461
  if (!PROGRESS_STATUSES.includes(r.status)) return `a resource of wave ${String(w.number)}'s progress has status ${JSON.stringify(r.status)}`;
25180
25462
  if (r.done_at !== void 0 && !str14(r.done_at)) return `a resource of wave ${String(w.number)}'s progress has a done_at that is not a string`;
25181
25463
  }
@@ -25187,7 +25469,7 @@ function compileRunSchema(schema, version) {
25187
25469
  return {
25188
25470
  validation: { by: "schema", terragucci: version },
25189
25471
  check(doc) {
25190
- const id = isRecord17(doc) ? doc.schema : void 0;
25472
+ const id = isRecord18(doc) ? doc.schema : void 0;
25191
25473
  if (id !== RUN_SCHEMA) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA}`;
25192
25474
  if (v(doc)) return void 0;
25193
25475
  const e = v.errors?.[0];
@@ -25200,12 +25482,12 @@ function runValidator(dirs = []) {
25200
25482
  for (const from of [...dirs, dirname12(fileURLToPath7(import.meta.url))]) {
25201
25483
  let dist;
25202
25484
  try {
25203
- dist = dirname12(createRequire6(join41(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
25485
+ dist = dirname12(createRequire6(join42(resolve25(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json"));
25204
25486
  } catch {
25205
25487
  continue;
25206
25488
  }
25207
- const pkg = join41(dist, "..", "package.json");
25208
- const file = join41(dist, RUN_SCHEMA_FILE);
25489
+ const pkg = join42(dist, "..", "package.json");
25490
+ const file = join42(dist, RUN_SCHEMA_FILE);
25209
25491
  let stamp;
25210
25492
  try {
25211
25493
  stamp = [dist, ...[pkg, file].map((f) => {
@@ -25219,8 +25501,8 @@ function runValidator(dirs = []) {
25219
25501
  if (hit) return hit;
25220
25502
  let v;
25221
25503
  try {
25222
- const version = JSON.parse(readFileSync30(pkg, "utf8")).version ?? "";
25223
- v = compileRunSchema(JSON.parse(readFileSync30(file, "utf8")), version);
25504
+ const version = JSON.parse(readFileSync31(pkg, "utf8")).version ?? "";
25505
+ v = compileRunSchema(JSON.parse(readFileSync31(file, "utf8")), version);
25224
25506
  } catch {
25225
25507
  continue;
25226
25508
  }
@@ -25513,19 +25795,19 @@ function terragucciProgressRoute(app, progress) {
25513
25795
  }
25514
25796
 
25515
25797
  // src/terragucci-demo.ts
25516
- import { readFileSync as readFileSync31 } from "node:fs";
25517
- import { join as join42 } from "node:path";
25798
+ import { readFileSync as readFileSync32 } from "node:fs";
25799
+ import { join as join43 } from "node:path";
25518
25800
  var DEMO_KEY = "demo.json";
25519
25801
  var DEMO_READ_TTL_MS = 2e3;
25520
25802
  var DEMO_STEPS = ["pull-request", "planned", "merged", "applying", "waiting", "approved", "failed", "resumed", "applied", "reset", "stalled"];
25521
25803
  var DEMO_ABOUT_FIELDS = ["changes", "watch", "shows"];
25522
25804
  var UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
25523
- var isRecord18 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
25805
+ var isRecord19 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
25524
25806
  var str15 = (v) => typeof v === "string";
25525
25807
  var int2 = (v) => typeof v === "number" && Number.isInteger(v);
25526
25808
  var positive = (v) => int2(v) && v > 0 ? v : null;
25527
25809
  function demoProblem(doc) {
25528
- if (!isRecord18(doc)) return "it is not an object";
25810
+ if (!isRecord19(doc)) return "it is not an object";
25529
25811
  if (!int2(doc.cycle)) return "cycle is not an integer";
25530
25812
  if (!str15(doc.scenario) || !doc.scenario) return "scenario is not a string";
25531
25813
  if (!str15(doc.title)) return "title is not a string";
@@ -25533,14 +25815,14 @@ function demoProblem(doc) {
25533
25815
  if (!str15(doc.label)) return "label is not a string";
25534
25816
  if (!str15(doc.started_at) || !UTC.test(doc.started_at)) return "started_at is not a UTC time (YYYY-MM-DDTHH:MM:SSZ)";
25535
25817
  if (doc.next !== null) {
25536
- if (!isRecord18(doc.next)) return "next is neither an object nor null";
25818
+ if (!isRecord19(doc.next)) return "next is neither an object nor null";
25537
25819
  if (!str15(doc.next.action)) return "next.action is not a string";
25538
25820
  if (doc.next.at !== null && !(str15(doc.next.at) && UTC.test(doc.next.at))) return "next.at is neither a UTC time nor null";
25539
25821
  }
25540
25822
  if (doc.pull !== null && !int2(doc.pull)) return "pull is neither an integer nor null";
25541
25823
  if (doc.commit !== null && !str15(doc.commit)) return "commit is neither a string nor null";
25542
25824
  if (doc.about !== void 0 && doc.about !== null) {
25543
- if (!isRecord18(doc.about)) return "about is neither an object nor null";
25825
+ if (!isRecord19(doc.about)) return "about is neither an object nor null";
25544
25826
  for (const f of DEMO_ABOUT_FIELDS) if (!str15(doc.about[f]) || !doc.about[f].trim()) return `about.${f} is not a non-empty string`;
25545
25827
  }
25546
25828
  return void 0;
@@ -25604,7 +25886,7 @@ function kioskRoute(app, webRoot2, enabled) {
25604
25886
  if (!enabled) {
25605
25887
  return c.html(disabledPage, 404);
25606
25888
  }
25607
- return new Response(readFileSync31(join42(webRoot2, "kiosk.html"), "utf8"), { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
25889
+ return new Response(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
25608
25890
  });
25609
25891
  }
25610
25892
  var VENDOR_TOOLS = ["terraform", "terragrunt", "cdk-terrain", "choudoufu", "chant"];
@@ -25613,7 +25895,7 @@ var cycleKey = (tool) => `cycles/${tool}/latest.json`;
25613
25895
  var CYCLE_READ_TTL_MS = 1e4;
25614
25896
  var timeOrNull2 = (v) => v === null || v === void 0 || str15(v) && UTC.test(v);
25615
25897
  function cycleProblem(doc, tool) {
25616
- if (!isRecord18(doc)) return "it is not an object";
25898
+ if (!isRecord19(doc)) return "it is not an object";
25617
25899
  if (doc.schema !== void 0 && doc.schema !== "demo.cycle/v1") return `schema is ${JSON.stringify(doc.schema)}, not demo.cycle/v1`;
25618
25900
  if (doc.tool !== tool) return `tool is ${JSON.stringify(doc.tool)}, not ${tool}`;
25619
25901
  if (!str15(doc.repo) || !doc.repo) return "repo is not a string";
@@ -25684,7 +25966,7 @@ function vendorRoutes(app, webRoot2, enabled) {
25684
25966
  for (const tool of VENDOR_TOOLS) {
25685
25967
  app.get(`/${tool}`, (c) => {
25686
25968
  if (!enabled) return c.html(disabledPage, 404);
25687
- const html = vendorPage(readFileSync31(join42(webRoot2, "kiosk.html"), "utf8"), tool);
25969
+ const html = vendorPage(readFileSync32(join43(webRoot2, "kiosk.html"), "utf8"), tool);
25688
25970
  return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" } });
25689
25971
  });
25690
25972
  }
@@ -25733,7 +26015,7 @@ function checkoutRoots(dirs, base = repoBase(dirs)) {
25733
26015
  for (const m of estateMembers(dirs)) {
25734
26016
  if (m.kind !== "terraform") continue;
25735
26017
  for (const r of checkoutRootDirs(m.dir)) {
25736
- const path = relative9(base, join43(m.dir, r.dir)).split(sep8).join("/") || ".";
26018
+ const path = relative9(base, join44(m.dir, r.dir)).split(sep8).join("/") || ".";
25737
26019
  out.push({ member: m.name, name: r.name, path });
25738
26020
  }
25739
26021
  }
@@ -26040,8 +26322,8 @@ function metricsRoute(app, opts) {
26040
26322
 
26041
26323
  // src/view-repos.ts
26042
26324
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
26043
- import { existsSync as existsSync25, readdirSync as readdirSync15, readFileSync as readFileSync32 } from "node:fs";
26044
- import { join as join44, resolve as resolve26 } from "node:path";
26325
+ import { existsSync as existsSync26, readdirSync as readdirSync16, readFileSync as readFileSync33 } from "node:fs";
26326
+ import { join as join45, resolve as resolve26 } from "node:path";
26045
26327
  var NAME2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
26046
26328
  function repoName(value) {
26047
26329
  const v = value.trim().replace(/\.git$/, "");
@@ -26051,11 +26333,11 @@ function repoName(value) {
26051
26333
  function listCheckouts(parent) {
26052
26334
  let names;
26053
26335
  try {
26054
- names = readdirSync15(parent, { withFileTypes: true }).filter((e) => e.isDirectory() && NAME2.test(e.name)).map((e) => e.name).sort();
26336
+ names = readdirSync16(parent, { withFileTypes: true }).filter((e) => e.isDirectory() && NAME2.test(e.name)).map((e) => e.name).sort();
26055
26337
  } catch {
26056
26338
  return [];
26057
26339
  }
26058
- return names.map((name) => ({ name, dir: resolve26(parent, name) })).filter((c) => existsSync25(join44(c.dir, ".git")));
26340
+ return names.map((name) => ({ name, dir: resolve26(parent, name) })).filter((c) => existsSync26(join45(c.dir, ".git")));
26059
26341
  }
26060
26342
  var scope = new AsyncLocalStorage2();
26061
26343
  function scopeServedDirs(cfg) {
@@ -26097,7 +26379,7 @@ var SHA = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
26097
26379
  function checkoutCommit(dir) {
26098
26380
  const read = (f) => {
26099
26381
  try {
26100
- return readFileSync32(join44(dir, ".git", f), "utf8");
26382
+ return readFileSync33(join45(dir, ".git", f), "utf8");
26101
26383
  } catch {
26102
26384
  return void 0;
26103
26385
  }
@@ -26127,8 +26409,8 @@ function viewRepoFacts(repos, servedDir) {
26127
26409
  }
26128
26410
 
26129
26411
  // src/lifecycle-releases.ts
26130
- import { existsSync as existsSync26, readFileSync as readFileSync33 } from "node:fs";
26131
- import { join as join45 } from "node:path";
26412
+ import { existsSync as existsSync27, readFileSync as readFileSync34 } from "node:fs";
26413
+ import { join as join46 } from "node:path";
26132
26414
 
26133
26415
  // node_modules/@intentius/chant/src/lifecycle/legacy-digest.ts
26134
26416
  import { resolve as resolve27 } from "node:path";
@@ -26241,10 +26523,10 @@ function memberNote(l) {
26241
26523
  // src/lifecycle-releases.ts
26242
26524
  var WAVES_SPEC_FILE = "yodel-waves.json";
26243
26525
  function waveOrder(checkout) {
26244
- const p = join45(checkout, WAVES_SPEC_FILE);
26245
- if (!existsSync26(p)) return void 0;
26526
+ const p = join46(checkout, WAVES_SPEC_FILE);
26527
+ if (!existsSync27(p)) return void 0;
26246
26528
  try {
26247
- const doc = JSON.parse(readFileSync33(p, "utf8"));
26529
+ const doc = JSON.parse(readFileSync34(p, "utf8"));
26248
26530
  const names = (doc.waves ?? []).map((w) => w?.name).filter((n) => typeof n === "string" && n.length > 0);
26249
26531
  return names.length ? [...new Set(names)] : void 0;
26250
26532
  } catch {
@@ -26252,7 +26534,7 @@ function waveOrder(checkout) {
26252
26534
  }
26253
26535
  }
26254
26536
  function hasReleaseLedgerHint(checkout) {
26255
- return existsSync26(join45(checkout, "yodel.config.ts")) || existsSync26(join45(checkout, WAVES_SPEC_FILE));
26537
+ return existsSync27(join46(checkout, "yodel.config.ts")) || existsSync27(join46(checkout, WAVES_SPEC_FILE));
26256
26538
  }
26257
26539
  function orderEnvironments(envs, waves) {
26258
26540
  const seen = new Set(envs);
@@ -26294,7 +26576,7 @@ function releaseCells(ledgers, order, sources) {
26294
26576
  }
26295
26577
  async function copyCheckoutRef(git3, checkout, cache6) {
26296
26578
  assertScratch(cache6.split(/[\\/]/).pop());
26297
- if (!existsSync26(join45(cache6, "HEAD"))) {
26579
+ if (!existsSync27(join46(cache6, "HEAD"))) {
26298
26580
  const init = await git3(["init", "--bare", "-q", cache6]);
26299
26581
  if (init.code !== 0) return false;
26300
26582
  }
@@ -26397,8 +26679,8 @@ function releasesRoutes(app, base, opts = {}) {
26397
26679
  }
26398
26680
 
26399
26681
  // src/sql-yodeler-lane.ts
26400
- import { existsSync as existsSync27, readdirSync as readdirSync16, readFileSync as readFileSync34 } from "node:fs";
26401
- import { join as join46 } from "node:path";
26682
+ import { existsSync as existsSync28, readdirSync as readdirSync17, readFileSync as readFileSync35 } from "node:fs";
26683
+ import { join as join47 } from "node:path";
26402
26684
  var YODEL_APPLY_OP = "yodel-apply";
26403
26685
  var YODEL_HEAD_PLANS_DIR = headPlansPath(YODEL_APPLY_OP, "").dir;
26404
26686
  function parseYodelWaves(text2, path = WAVES_SPEC_FILE) {
@@ -26430,19 +26712,19 @@ function parseYodelWaves(text2, path = WAVES_SPEC_FILE) {
26430
26712
  return { path, waves };
26431
26713
  }
26432
26714
  function readYodelWaves(checkout) {
26433
- const p = join46(checkout, WAVES_SPEC_FILE);
26434
- if (!existsSync27(p)) return void 0;
26715
+ const p = join47(checkout, WAVES_SPEC_FILE);
26716
+ if (!existsSync28(p)) return void 0;
26435
26717
  try {
26436
- return parseYodelWaves(readFileSync34(p, "utf8"));
26718
+ return parseYodelWaves(readFileSync35(p, "utf8"));
26437
26719
  } catch (e) {
26438
26720
  return { path: WAVES_SPEC_FILE, waves: [], error: e instanceof Error ? e.message : String(e) };
26439
26721
  }
26440
26722
  }
26441
26723
  function migrateOpEnvironments(checkout) {
26442
- const dir = join46(checkout, "ops");
26443
- if (!existsSync27(dir)) return [];
26724
+ const dir = join47(checkout, "ops");
26725
+ if (!existsSync28(dir)) return [];
26444
26726
  try {
26445
- return readdirSync16(dir).map((f) => /^migrate-(.+)\.op\.ts$/.exec(f)?.[1]).filter((e) => !!e).sort();
26727
+ return readdirSync17(dir).map((f) => /^migrate-(.+)\.op\.ts$/.exec(f)?.[1]).filter((e) => !!e).sort();
26446
26728
  } catch {
26447
26729
  return [];
26448
26730
  }
@@ -26562,16 +26844,16 @@ function sqlYodelerLaneRoute(app, checkout, opts = {}) {
26562
26844
 
26563
26845
  // src/terragucci-estate.ts
26564
26846
  init_yaml();
26565
- import { existsSync as existsSync28, readFileSync as readFileSync35, statSync as statSync14 } from "node:fs";
26847
+ import { existsSync as existsSync29, readFileSync as readFileSync36, statSync as statSync14 } from "node:fs";
26566
26848
  import { createRequire as createRequire7 } from "node:module";
26567
- import { dirname as dirname14, extname as extname2, join as join47, resolve as resolve28 } from "node:path";
26849
+ import { dirname as dirname14, extname as extname2, join as join48, resolve as resolve28 } from "node:path";
26568
26850
  import { fileURLToPath as fileURLToPath8 } from "node:url";
26569
26851
  import { Ajv2020 as Ajv20204 } from "ajv/dist/2020.js";
26570
26852
  var RUN_SCHEMA2 = "terragucci.run/v1";
26571
26853
  function configProjects(file) {
26572
26854
  let text2;
26573
26855
  try {
26574
- text2 = readFileSync35(file, "utf8");
26856
+ text2 = readFileSync36(file, "utf8");
26575
26857
  } catch {
26576
26858
  return void 0;
26577
26859
  }
@@ -26599,21 +26881,21 @@ function controlRepo(dirs, roots = () => checkoutRoots(dirs).length) {
26599
26881
  }
26600
26882
  return n === 0 ? { config, projects } : void 0;
26601
26883
  }
26602
- var isRecord19 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
26884
+ var isRecord20 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
26603
26885
  var str16 = (v) => typeof v === "string";
26604
26886
  var int3 = (v) => typeof v === "number" && Number.isInteger(v);
26605
26887
  function structuralRun2(doc) {
26606
- if (!isRecord19(doc)) return "it is not a JSON object";
26888
+ if (!isRecord20(doc)) return "it is not a JSON object";
26607
26889
  if (doc.schema !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(doc.schema)}, not ${RUN_SCHEMA2}`;
26608
26890
  if (!str16(doc.project) || !str16(doc.commit) || !str16(doc.updated)) return "it lacks project, commit or updated";
26609
26891
  if (!Array.isArray(doc.roots) || !Array.isArray(doc.waves)) return "it has no roots or waves array";
26610
26892
  for (const [i, r] of doc.roots.entries()) {
26611
- if (!isRecord19(r) || !str16(r.root) || !int3(r.wave) || !Array.isArray(r.reads) || !r.reads.every(str16)) return `root ${i} lacks root, wave or reads`;
26612
- if (r.state !== void 0 && !(isRecord19(r.state) && str16(r.state.key))) return `root ${String(r.root)}'s state has no key`;
26613
- if (r.external !== void 0 && !(Array.isArray(r.external) && r.external.every((x) => isRecord19(x) && str16(x.data) && str16(x.key)))) return `root ${String(r.root)}'s external reads lack data or key`;
26893
+ if (!isRecord20(r) || !str16(r.root) || !int3(r.wave) || !Array.isArray(r.reads) || !r.reads.every(str16)) return `root ${i} lacks root, wave or reads`;
26894
+ if (r.state !== void 0 && !(isRecord20(r.state) && str16(r.state.key))) return `root ${String(r.root)}'s state has no key`;
26895
+ if (r.external !== void 0 && !(Array.isArray(r.external) && r.external.every((x) => isRecord20(x) && str16(x.data) && str16(x.key)))) return `root ${String(r.root)}'s external reads lack data or key`;
26614
26896
  }
26615
26897
  for (const [i, w] of doc.waves.entries()) {
26616
- if (!isRecord19(w) || !int3(w.number) || !Array.isArray(w.roots) || !Array.isArray(w.reads) || !str16(w.state) || !str16(w.gate)) return `wave ${i} lacks number, roots, reads, state or gate`;
26898
+ if (!isRecord20(w) || !int3(w.number) || !Array.isArray(w.roots) || !Array.isArray(w.reads) || !str16(w.state) || !str16(w.gate)) return `wave ${i} lacks number, roots, reads, state or gate`;
26617
26899
  }
26618
26900
  return void 0;
26619
26901
  }
@@ -26622,16 +26904,16 @@ function runViewValidator(dirs = []) {
26622
26904
  for (const from of [...dirs, dirname14(fileURLToPath8(import.meta.url))]) {
26623
26905
  let entry;
26624
26906
  try {
26625
- entry = createRequire7(join47(resolve28(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
26907
+ entry = createRequire7(join48(resolve28(from), "noop.js")).resolve("@intentius/terragucci/report.schema.json");
26626
26908
  } catch {
26627
26909
  continue;
26628
26910
  }
26629
26911
  const dist = dirname14(entry);
26630
- const schema = join47(dist, "run.schema.json");
26912
+ const schema = join48(dist, "run.schema.json");
26631
26913
  let stamp;
26632
26914
  try {
26633
26915
  const st = statSync14(schema);
26634
- const pkg = statSync14(join47(dist, "..", "package.json"));
26916
+ const pkg = statSync14(join48(dist, "..", "package.json"));
26635
26917
  stamp = `${schema}\0${st.mtimeMs}:${st.size}\0${pkg.mtimeMs}`;
26636
26918
  } catch {
26637
26919
  continue;
@@ -26640,12 +26922,12 @@ function runViewValidator(dirs = []) {
26640
26922
  if (hit) return hit;
26641
26923
  let v;
26642
26924
  try {
26643
- const version = JSON.parse(readFileSync35(join47(dist, "..", "package.json"), "utf8")).version ?? "";
26644
- const validate = new Ajv20204({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync35(schema, "utf8")));
26925
+ const version = JSON.parse(readFileSync36(join48(dist, "..", "package.json"), "utf8")).version ?? "";
26926
+ const validate = new Ajv20204({ strict: false, allErrors: false }).compile(JSON.parse(readFileSync36(schema, "utf8")));
26645
26927
  v = {
26646
26928
  validation: { by: "schema", terragucci: version },
26647
26929
  check(doc) {
26648
- const id = isRecord19(doc) ? doc.schema : void 0;
26930
+ const id = isRecord20(doc) ? doc.schema : void 0;
26649
26931
  if (id !== RUN_SCHEMA2) return `its schema is ${JSON.stringify(id)}, not ${RUN_SCHEMA2}`;
26650
26932
  if (validate(doc)) return void 0;
26651
26933
  const e = validate.errors?.[0];
@@ -26696,8 +26978,8 @@ function controlEdges(views) {
26696
26978
  function siblingCheckout(project, base, projectOf = checkoutProject) {
26697
26979
  const name = project.split("/").filter(Boolean).pop();
26698
26980
  if (!name) return void 0;
26699
- const dir = join47(dirname14(resolve28(base)), name);
26700
- if (dir === resolve28(base) || !existsSync28(join47(dir, ".git"))) return void 0;
26981
+ const dir = join48(dirname14(resolve28(base)), name);
26982
+ if (dir === resolve28(base) || !existsSync29(join48(dir, ".git"))) return void 0;
26701
26983
  return projectOf(dir) === project ? dir : void 0;
26702
26984
  }
26703
26985
  var shellWord = (s) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`;
@@ -26904,9 +27186,9 @@ function controlRepoInfo(dirs) {
26904
27186
  }
26905
27187
 
26906
27188
  // src/yodel-report.ts
26907
- import { readdirSync as readdirSync17, readFileSync as readFileSync36, statSync as statSync15 } from "node:fs";
27189
+ import { readdirSync as readdirSync18, readFileSync as readFileSync37, statSync as statSync15 } from "node:fs";
26908
27190
  import { createRequire as createRequire8 } from "node:module";
26909
- import { basename as basename5, dirname as dirname15, join as join48, resolve as resolve29 } from "node:path";
27191
+ import { basename as basename5, dirname as dirname15, join as join49, resolve as resolve29 } from "node:path";
26910
27192
  import { fileURLToPath as fileURLToPath9 } from "node:url";
26911
27193
  import { Ajv2020 as Ajv20205 } from "ajv/dist/2020.js";
26912
27194
 
@@ -27335,13 +27617,13 @@ var installed = /* @__PURE__ */ new Map();
27335
27617
  function packageRoot(from) {
27336
27618
  let entry;
27337
27619
  try {
27338
- entry = createRequire8(join48(resolve29(from), "noop.js")).resolve("@intentius/sql-yodeler");
27620
+ entry = createRequire8(join49(resolve29(from), "noop.js")).resolve("@intentius/sql-yodeler");
27339
27621
  } catch {
27340
27622
  return void 0;
27341
27623
  }
27342
27624
  for (let d = dirname15(entry); d !== dirname15(d); d = dirname15(d)) {
27343
27625
  try {
27344
- const pkg = JSON.parse(readFileSync36(join48(d, "package.json"), "utf8"));
27626
+ const pkg = JSON.parse(readFileSync37(join49(d, "package.json"), "utf8"));
27345
27627
  if (pkg.name === "@intentius/sql-yodeler") return d;
27346
27628
  } catch {
27347
27629
  }
@@ -27353,11 +27635,11 @@ function yodelValidator(dirs = []) {
27353
27635
  const root = packageRoot(from);
27354
27636
  if (!root) continue;
27355
27637
  try {
27356
- const version = JSON.parse(readFileSync36(join48(root, "package.json"), "utf8")).version ?? "";
27638
+ const version = JSON.parse(readFileSync37(join49(root, "package.json"), "utf8")).version ?? "";
27357
27639
  const key2 = `${root}\0${version}`;
27358
27640
  let v = installed.get(key2);
27359
27641
  if (!v) {
27360
- const load2 = (n) => JSON.parse(readFileSync36(join48(root, "schemas", `${n}.schema.json`), "utf8"));
27642
+ const load2 = (n) => JSON.parse(readFileSync37(join49(root, "schemas", `${n}.schema.json`), "utf8"));
27361
27643
  v = compile({ common: load2("common"), report: load2("report"), drift: load2("drift") }, { by: "schema", from: "package", sqlYodeler: version });
27362
27644
  installed.set(key2, v);
27363
27645
  }
@@ -27368,9 +27650,9 @@ function yodelValidator(dirs = []) {
27368
27650
  pinned ??= compile({ common: common_schema_default, report: report_schema_default, drift: drift_schema_default }, { by: "schema", from: "pinned", commit: PINNED_COMMIT.slice(0, 7) });
27369
27651
  return pinned;
27370
27652
  }
27371
- var isRecord20 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27372
- var looksLikeReport = (d) => isRecord20(d) && "generatedAt" in d && "environments" in d;
27373
- var looksLikeDrift = (d) => isRecord20(d) && "environment" in d && ("drifted" in d || "changed" in d);
27653
+ var isRecord21 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
27654
+ var looksLikeReport = (d) => isRecord21(d) && "generatedAt" in d && "environments" in d;
27655
+ var looksLikeDrift = (d) => isRecord21(d) && "environment" in d && ("drifted" in d || "changed" in d);
27374
27656
  function filesOf(source2) {
27375
27657
  let st;
27376
27658
  try {
@@ -27379,7 +27661,7 @@ function filesOf(source2) {
27379
27661
  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.");
27380
27662
  }
27381
27663
  const dir = st.isDirectory() ? source2 : dirname15(source2);
27382
- const files = readdirSync17(dir).filter((f) => f.endsWith(".json")).sort().map((f) => join48(dir, f));
27664
+ const files = readdirSync18(dir).filter((f) => f.endsWith(".json")).sort().map((f) => join49(dir, f));
27383
27665
  return st.isDirectory() ? { dir, files } : { dir, files, named: resolve29(source2) };
27384
27666
  }
27385
27667
  function readYodelReport(source2, validator2) {
@@ -27391,7 +27673,7 @@ function readYodelReport(source2, validator2) {
27391
27673
  for (const file of files) {
27392
27674
  let doc;
27393
27675
  try {
27394
- doc = JSON.parse(readFileSync36(file, "utf8"));
27676
+ doc = JSON.parse(readFileSync37(file, "utf8"));
27395
27677
  } catch (e) {
27396
27678
  if (file === named) refuse14(`${basename5(file)} is not JSON: ${e instanceof Error ? e.message : String(e)}`, remedy);
27397
27679
  ignored.push(basename5(file));
@@ -27478,24 +27760,24 @@ function yodelReportRoute(app, source2, dirs) {
27478
27760
 
27479
27761
  // src/demo-pins.ts
27480
27762
  init_terraform_member();
27481
- import { existsSync as existsSync29, lstatSync as lstatSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync37, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
27482
- import { dirname as dirname16, join as join49, resolve as resolve30 } from "node:path";
27483
- var isRecord21 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27763
+ import { existsSync as existsSync30, lstatSync as lstatSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync38, readlinkSync as readlinkSync2, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
27764
+ import { dirname as dirname16, join as join50, resolve as resolve30 } from "node:path";
27765
+ var isRecord22 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27484
27766
  function linkDemoPins(work, probes = {}) {
27485
- const file = join49(work, "chant.workspace.json");
27486
- if (!existsSync29(file)) return { ok: true, linked: [] };
27767
+ const file = join50(work, "chant.workspace.json");
27768
+ if (!existsSync30(file)) return { ok: true, linked: [] };
27487
27769
  let decl;
27488
27770
  try {
27489
- decl = JSON.parse(readFileSync37(file, "utf8"));
27771
+ decl = JSON.parse(readFileSync38(file, "utf8"));
27490
27772
  } catch {
27491
27773
  return { ok: true, linked: [] };
27492
27774
  }
27493
- if (!isRecord21(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
27775
+ if (!isRecord22(decl) || !Array.isArray(decl.pins)) return { ok: true, linked: [] };
27494
27776
  const find = probes.resolve ?? ((pkg) => resolvedPackage(pkg));
27495
27777
  const linked = [];
27496
27778
  let rewrite = false;
27497
27779
  for (const pin of decl.pins) {
27498
- if (!isRecord21(pin) || typeof pin.package !== "string") continue;
27780
+ if (!isRecord22(pin) || typeof pin.package !== "string") continue;
27499
27781
  const pkg = pin.package;
27500
27782
  if (pkg === TERRAFORM_LEXICON_PKG) {
27501
27783
  const refusal2 = (probes.reader ?? terraformReaderState)().refusal;
@@ -27509,7 +27791,7 @@ function linkDemoPins(work, probes = {}) {
27509
27791
  remedy: `Install ${pkg} beside behold, then load the demo again.`
27510
27792
  };
27511
27793
  }
27512
- const link = join49(work, "node_modules", ...pkg.split("/"));
27794
+ const link = join50(work, "node_modules", ...pkg.split("/"));
27513
27795
  if (!present(link)) {
27514
27796
  mkdirSync7(dirname16(link), { recursive: true });
27515
27797
  symlinkSync2(found.dir, link, "junction");
@@ -27544,13 +27826,13 @@ function linksTo(link, target) {
27544
27826
  }
27545
27827
 
27546
27828
  // src/demos.ts
27547
- import { readFileSync as readFileSync38, existsSync as existsSync30, cpSync, mkdirSync as mkdirSync8 } from "node:fs";
27548
- import { dirname as dirname17, isAbsolute as isAbsolute5, join as join50, relative as relative10, resolve as resolve31, sep as sep9 } from "node:path";
27829
+ import { readFileSync as readFileSync39, existsSync as existsSync31, cpSync, mkdirSync as mkdirSync8 } from "node:fs";
27830
+ import { dirname as dirname17, isAbsolute as isAbsolute5, join as join51, relative as relative10, resolve as resolve31, sep as sep9 } from "node:path";
27549
27831
  import { spawn as spawn8, spawnSync as spawnSync3 } from "node:child_process";
27550
27832
  function readCatalog(file, catalog) {
27551
27833
  let raw;
27552
27834
  try {
27553
- raw = JSON.parse(readFileSync38(file, "utf8"));
27835
+ raw = JSON.parse(readFileSync39(file, "utf8"));
27554
27836
  } catch {
27555
27837
  return [];
27556
27838
  }
@@ -27579,6 +27861,7 @@ function validEntry(e) {
27579
27861
  if (d.serve.dirs !== void 0 && (!Array.isArray(d.serve.dirs) || d.serve.dirs.some((x) => typeof x !== "string") || !d.serve.dirs.length)) return false;
27580
27862
  if (d.serve.spawnEnv !== void 0 && (typeof d.serve.spawnEnv !== "object" || d.serve.spawnEnv === null || Array.isArray(d.serve.spawnEnv) || Object.values(d.serve.spawnEnv).some((v) => typeof v !== "string")))
27581
27863
  return false;
27864
+ if (d.serve.terralith !== void 0 && typeof d.serve.terralith !== "boolean") return false;
27582
27865
  if (d.serve.carve !== void 0) {
27583
27866
  const c = d.serve.carve;
27584
27867
  const rel = (v) => typeof v === "string" && !!v && !v.startsWith("/") && !v.split("/").includes("..");
@@ -27590,10 +27873,10 @@ function validEntry(e) {
27590
27873
  return true;
27591
27874
  }
27592
27875
  function loadDemoRegistry(pkgRoot3) {
27593
- const merged = readCatalog(join50(pkgRoot3, "demos.json"), "demos");
27876
+ const merged = readCatalog(join51(pkgRoot3, "demos.json"), "demos");
27594
27877
  const seen = new Set(merged.map((e) => e.name));
27595
27878
  const named = process.env.BEHOLD_WORKBENCH;
27596
- for (const e of [...readCatalog(join50(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve31(named), "workbench") : []]) {
27879
+ for (const e of [...readCatalog(join51(pkgRoot3, "workbench.json"), "workbench"), ...named ? readCatalog(resolve31(named), "workbench") : []]) {
27597
27880
  if (seen.has(e.name)) {
27598
27881
  process.stderr.write(`behold: workbench entry "${e.name}" collides with a demo already in the catalog \u2014 dropped
27599
27882
  `);
@@ -27612,11 +27895,11 @@ function missingRequirements(entry) {
27612
27895
  const bins = entry.source === "git" && !entry.requires.includes("git") ? [...entry.requires, "git"] : entry.requires;
27613
27896
  const finder = process.platform === "win32" ? "where" : "which";
27614
27897
  const missing = bins.filter((bin) => {
27615
- if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync30(process.env.CHOUDOUFU_BIN)) return false;
27898
+ if (bin === "choudoufu" && process.env.CHOUDOUFU_BIN && existsSync31(process.env.CHOUDOUFU_BIN)) return false;
27616
27899
  return spawnSync3(finder, [bin], { stdio: "ignore" }).status !== 0;
27617
27900
  });
27618
27901
  const local = demoLocalPath(entry);
27619
- if (local && !existsSync30(local)) missing.push(`${entry.path} (not checked out)`);
27902
+ if (local && !existsSync31(local)) missing.push(`${entry.path} (not checked out)`);
27620
27903
  return missing;
27621
27904
  }
27622
27905
  function fetchesFromNetwork(entry) {
@@ -27626,7 +27909,7 @@ function demoTargetDir(entry, cwd = process.cwd()) {
27626
27909
  const inPlace = entry.inPlace ? demoLocalPath(entry) : void 0;
27627
27910
  if (inPlace) return inPlace;
27628
27911
  const legacy = resolve31(cwd, "behold-demo");
27629
- if (entry.name === "writes" && existsSync30(legacy)) return legacy;
27912
+ if (entry.name === "writes" && existsSync31(legacy)) return legacy;
27630
27913
  return resolve31(cwd, "behold-demos", entry.name);
27631
27914
  }
27632
27915
  async function loadDemo(entry, opts) {
@@ -27636,12 +27919,12 @@ async function loadDemo(entry, opts) {
27636
27919
  const inPlace = entry.source === "local" && entry.inPlace;
27637
27920
  const work = inPlace ? local : target;
27638
27921
  if (inPlace) {
27639
- if (!existsSync30(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
27922
+ if (!existsSync31(work)) return { ok: false, error: `${entry.path} is not checked out (looked in ${work})` };
27640
27923
  say(`serving ${work} where it is \u2014 nothing copied`);
27641
- } else if (!existsSync30(target)) {
27924
+ } else if (!existsSync31(target)) {
27642
27925
  if (entry.source === "bundled" || entry.source === "local" && local) {
27643
- const from = entry.source === "bundled" ? join50(pkgRoot3, entry.dir) : local;
27644
- if (!existsSync30(from)) return { ok: false, error: entry.source === "bundled" ? `this install has no bundled ${entry.dir}` : `${entry.path} is not checked out (looked in ${from})` };
27926
+ const from = entry.source === "bundled" ? join51(pkgRoot3, entry.dir) : local;
27927
+ if (!existsSync31(from)) return { ok: false, error: entry.source === "bundled" ? `this install has no bundled ${entry.dir}` : `${entry.path} is not checked out (looked in ${from})` };
27645
27928
  say(`copying to ${target} (it's yours \u2014 edit it)`);
27646
27929
  try {
27647
27930
  cpSync(from, target, {
@@ -27672,7 +27955,7 @@ async function loadDemo(entry, opts) {
27672
27955
  if (!pins.ok) return { ok: false, error: `${pins.error} ${pins.remedy}` };
27673
27956
  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})` : ""}`);
27674
27957
  }
27675
- if (!inPlace && existsSync30(join50(work, "package.json")) && !existsSync30(join50(work, "node_modules"))) {
27958
+ if (!inPlace && existsSync31(join51(work, "package.json")) && !existsSync31(join51(work, "node_modules"))) {
27676
27959
  say("npm install\u2026");
27677
27960
  if (await runStep("npm", ["install"], { cwd: work, shell: process.platform === "win32" }) !== 0) {
27678
27961
  return { ok: false, error: `npm install failed in ${work}` };
@@ -27689,7 +27972,7 @@ async function loadDemo(entry, opts) {
27689
27972
  return { ok: false, error: `setup failed (${entry.setup})` };
27690
27973
  }
27691
27974
  }
27692
- return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join50(work, d)) : [work] };
27975
+ return { ok: true, serveDirs: entry.serve.dirs?.length ? entry.serve.dirs.map((d) => join51(work, d)) : [work] };
27693
27976
  }
27694
27977
  function runStep(cmd, args, opts = {}) {
27695
27978
  return new Promise((res) => {
@@ -27700,8 +27983,8 @@ function runStep(cmd, args, opts = {}) {
27700
27983
  }
27701
27984
 
27702
27985
  // src/server.ts
27703
- var pkgRoot = join51(dirname18(fileURLToPath10(import.meta.url)), "..");
27704
- var webRoot = join51(pkgRoot, "web");
27986
+ var pkgRoot = join52(dirname18(fileURLToPath10(import.meta.url)), "..");
27987
+ var webRoot = join52(pkgRoot, "web");
27705
27988
  var execFileP = async (cmd, args) => (await promisify3(execFile5)(cmd, args, { encoding: "utf8", timeout: 1e4 })).stdout;
27706
27989
  function optsFromQuery(url, tierEnvVar, projectDir) {
27707
27990
  const q = url.searchParams;
@@ -27752,7 +28035,7 @@ function tierFailure(tier, message2) {
27752
28035
  function beholdVersion() {
27753
28036
  try {
27754
28037
  const here = dirname18(fileURLToPath10(import.meta.url));
27755
- return JSON.parse(readFileSync39(join51(here, "..", "package.json"), "utf8")).version ?? "unknown";
28038
+ return JSON.parse(readFileSync40(join52(here, "..", "package.json"), "utf8")).version ?? "unknown";
27756
28039
  } catch {
27757
28040
  return "unknown";
27758
28041
  }
@@ -27798,8 +28081,13 @@ async function captureFrame(projectDir, env, frames, broadcaster) {
27798
28081
  return null;
27799
28082
  }
27800
28083
  }
28084
+ function terralithRoutes(app, demo) {
28085
+ app.get("/api/terralith", (c) => c.json(readTerralith(demo.root)));
28086
+ app.get("/terralith", serveStatic({ path: join52(relative11(process.cwd(), webRoot) || ".", "terralith.html") }));
28087
+ app.get("/", (c) => c.redirect("/terralith"));
28088
+ }
27801
28089
  function carveRoutes(app, reportPath, demo) {
27802
- const load2 = () => readCarveReport(reportPath, (p) => readFileSync39(p, "utf8"));
28090
+ const load2 = () => readCarveReport(reportPath, (p) => readFileSync40(p, "utf8"));
27803
28091
  const carveDirs = [dirname18(reportPath), ...demo ? [demo.out] : []];
27804
28092
  const carveStates = () => readCarveStates(carveDirs, nodeCarveIo, 0);
27805
28093
  const emittedNodes = async (states) => {
@@ -28099,6 +28387,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28099
28387
  const r = guardedRepo();
28100
28388
  return r?.product === "sql-yodeler" ? dirname18(r.config) : void 0;
28101
28389
  });
28390
+ if (cfg.terralithDemo) terralithRoutes(app, cfg.terralithDemo);
28102
28391
  if (cfg.carveReport) carveRoutes(app, cfg.carveReport, cfg.carveDemo);
28103
28392
  const predictDeps = cfg.behaviour ?? { read: graphIr };
28104
28393
  let beholdConfig = loadBeholdConfig(cfg.projectDir);
@@ -28215,9 +28504,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28215
28504
  return c.json({ started: true, name, ran: label });
28216
28505
  });
28217
28506
  app.post("/api/local/reset", (c) => {
28218
- const down = join51(cfg.projectDir, "scripts/local/local-down.sh");
28219
- const up = join51(cfg.projectDir, "scripts/local/local-up.sh");
28220
- if (!existsSync31(down) || !existsSync31(up)) {
28507
+ const down = join52(cfg.projectDir, "scripts/local/local-down.sh");
28508
+ const up = join52(cfg.projectDir, "scripts/local/local-up.sh");
28509
+ if (!existsSync32(down) || !existsSync32(up)) {
28221
28510
  return c.json({ error: "no local-down.sh / local-up.sh in scripts/local \u2014 reset is only for local emulator projects" }, 400);
28222
28511
  }
28223
28512
  if (!runner.bringUp("reset local emulator", "bash", ["-c", "bash scripts/local/local-down.sh && bash scripts/local/local-up.sh"], cfg.projectDir)) {
@@ -28236,20 +28525,20 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28236
28525
  });
28237
28526
  const convergeDirs = () => {
28238
28527
  const dirs = [];
28239
- const declared = [];
28528
+ const declared2 = [];
28240
28529
  for (const f of discoverOpIrs(estateDirs())) {
28241
- const parsed = readOpIr(f.path, (p) => readFileSync39(p, "utf8"));
28530
+ const parsed = readOpIr(f.path, (p) => readFileSync40(p, "utf8"));
28242
28531
  if (!parsed.ok) continue;
28243
28532
  const mine = declaredConvergeOps([parsed.ir]);
28244
28533
  if (!mine.length) continue;
28245
- declared.push(...mine);
28534
+ declared2.push(...mine);
28246
28535
  if (!dirs.includes(f.dir)) dirs.push(f.dir);
28247
28536
  }
28248
- return { dirs, declared };
28537
+ return { dirs, declared: declared2 };
28249
28538
  };
28250
28539
  app.get("/api/operator/status", async (c) => {
28251
- const { dirs, declared } = convergeDirs();
28252
- runner.noteDeclaredConvergeOps(declared);
28540
+ const { dirs, declared: declared2 } = convergeDirs();
28541
+ runner.noteDeclaredConvergeOps(declared2);
28253
28542
  if (!dirs.length) {
28254
28543
  const state2 = runner.noteOperator({
28255
28544
  ok: false,
@@ -28423,7 +28712,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28423
28712
  const axes = deployAxes(tierEnvVar, lexicons, k8sTarget);
28424
28713
  const emittedOps = discoverOpIrs(estateDirs()).length;
28425
28714
  const carveState = carveStatePayload(await carveStatesUnder(estateDirs()));
28426
- const plans = discoverCarvePlans(
28715
+ const plans = discoverSplitPlans(
28427
28716
  (cfg.projectDirs ?? [cfg.projectDir]).filter((d) => memberKindOf(d) === "choudoufu"),
28428
28717
  cfg.projectDir
28429
28718
  );
@@ -28546,8 +28835,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28546
28835
  if (cfg.previewMode) return c.json({ error: "switching projects is locked in preview mode" }, 403);
28547
28836
  const body = await c.req.json().catch(() => ({}));
28548
28837
  const dir = typeof body.dir === "string" && body.dir.trim() ? resolve32(body.dir.trim()) : "";
28549
- if (!dir || !existsSync31(dir)) return c.json({ error: `no such directory: ${dir || "(no dir given)"}` }, 400);
28550
- if (!existsSync31(join51(dir, "chant.config.ts"))) {
28838
+ if (!dir || !existsSync32(dir)) return c.json({ error: `no such directory: ${dir || "(no dir given)"}` }, 400);
28839
+ if (!existsSync32(join52(dir, "chant.config.ts"))) {
28551
28840
  return c.json({ error: `${dir} doesn't look like a chant project \u2014 no chant.config.ts` }, 400);
28552
28841
  }
28553
28842
  switchServedProject([dir]);
@@ -28598,14 +28887,14 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28598
28887
  fetches: fetchesFromNetwork(e),
28599
28888
  ...e.repo ? { repo: e.repo } : {},
28600
28889
  target,
28601
- loaded: existsSync31(target),
28890
+ loaded: existsSync32(target),
28602
28891
  satisfiable: missing.length === 0,
28603
28892
  // #254: the carve walkthrough runs fine here — it just isn't a project
28604
28893
  // to switch INTO. Carve mode claims `/api/graph` and `/api/project` at
28605
28894
  // app creation (see carveRoutes), so a running server cannot become one;
28606
28895
  // the row stays in the catalog, disabled, saying what to run instead.
28607
- ...e.serve.carve ? { switchable: false } : {},
28608
- ...missing.length ? { reason: `needs ${missing.join(", ")} on PATH` } : e.serve.carve ? { reason: `serves a carve report, not a project \u2014 run \`behold demo ${e.name}\`` } : {}
28896
+ ...e.serve.carve || e.serve.terralith ? { switchable: false } : {},
28897
+ ...missing.length ? { reason: `needs ${missing.join(", ")} on PATH` } : e.serve.carve ? { reason: `serves a carve report, not a project \u2014 run \`behold demo ${e.name}\`` } : e.serve.terralith ? { reason: `a walkthrough page of its own \u2014 run \`behold demo ${e.name}\`` } : {}
28609
28898
  };
28610
28899
  };
28611
28900
  app.get(
@@ -28635,6 +28924,9 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28635
28924
  400
28636
28925
  );
28637
28926
  }
28927
+ if (entry.serve.terralith) {
28928
+ return c.json({ error: `${entry.name} is a walkthrough page of its own, served by its own behold.`, remedy: `Run \`behold demo ${entry.name}\` in a terminal.` }, 400);
28929
+ }
28638
28930
  if (loadingDemo) return c.json({ error: `${loadingDemo} is still loading` }, 409);
28639
28931
  loadingDemo = entry.name;
28640
28932
  try {
@@ -28680,8 +28972,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28680
28972
  if (!(c.req.header("content-type") ?? "").includes("application/json")) {
28681
28973
  return c.json({ error: "send application/json", code: "bad-layout" }, 415);
28682
28974
  }
28683
- const declared = Number(c.req.header("content-length") ?? 0);
28684
- if (declared > MAX_BODY_BYTES) return c.json({ error: `a layout body is capped at ${MAX_BODY_BYTES} bytes`, code: "too-large" }, 413);
28975
+ const declared2 = Number(c.req.header("content-length") ?? 0);
28976
+ if (declared2 > MAX_BODY_BYTES) return c.json({ error: `a layout body is capped at ${MAX_BODY_BYTES} bytes`, code: "too-large" }, 413);
28685
28977
  const text2 = await c.req.text().catch(() => "");
28686
28978
  if (text2.length > MAX_BODY_BYTES) return c.json({ error: `a layout body is capped at ${MAX_BODY_BYTES} bytes`, code: "too-large" }, 413);
28687
28979
  let body;
@@ -28769,10 +29061,12 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28769
29061
  { method: "GET", path: "/api/components/compare", desc: "cross-env digest comparison: ?env=&to= \u2014 is one env running what the other tested (ledger-only)" },
28770
29062
  {
28771
29063
  method: "GET",
28772
- path: "/api/choudoufu/moves",
28773
- desc: "a choudoufu move plan (carve.json) as previews: ?plan=<path inside a served member> [&dryrun=1: choudoufu's own live-mv -dry-run per move] [&receipt=1: the listing after a human ran the lines]. The lines are handed back; there is no endpoint that runs live-mv."
29064
+ path: "/api/choudoufu/split",
29065
+ desc: "a choudoufu split plan (split.json, or the workbench's carve.json) as previews: ?plan=<path inside a served member> [&dryrun=1: choudoufu's own live-mv -dry-run per move] [&receipt=1: the listing after a human ran the lines]. The lines are handed back; there is no endpoint that runs live-mv."
28774
29066
  },
28775
- { method: "GET", path: "/choudoufu/morph", desc: "the move plan as a morph page: every member a box, the moved cards gliding to their destination \u2014 ?plan=<path>" },
29067
+ { method: "GET", path: "/api/choudoufu/moves", desc: "the same previews under their name from before the split rename" },
29068
+ { method: "GET", path: "/choudoufu/split", desc: "the split plan as a morph page: every member a box, a box for each estate the plan names that is not served yet, the moved cards gliding to their destination \u2014 ?plan=<path>" },
29069
+ { method: "GET", path: "/choudoufu/morph", desc: "redirects to /choudoufu/split, its name from before the split rename" },
28776
29070
  { method: "GET", path: "/api/ci", desc: "generated CI pipeline projection {stages, jobs, forge}" },
28777
29071
  { method: "GET", path: "/api/substrates", desc: "substrate readiness {substrates: [{name, label, status, detail, bringUp?}]}" },
28778
29072
  { method: "GET", path: "/api/ops", desc: "committed Ops + adopt lexicons + apply progress + run playhead" },
@@ -28902,7 +29196,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28902
29196
  }
28903
29197
  const parsedOps = [];
28904
29198
  for (const f of files) {
28905
- const parsed = readOpIr(f.path, (p) => readFileSync39(p, "utf8"));
29199
+ const parsed = readOpIr(f.path, (p) => readFileSync40(p, "utf8"));
28906
29200
  if (!parsed.ok) return c.json(parsed.refusal, 422);
28907
29201
  parsedOps.push(parsed.ir);
28908
29202
  }
@@ -28915,8 +29209,8 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28915
29209
  }
28916
29210
  const runState = runner.runState;
28917
29211
  const ranOp = runState.op ? parsedOps.find((o) => o.name === runState.op) : void 0;
28918
- const join56 = ranOp ? joinRun(ranOp, runState.records, runState.gate) : null;
28919
- const opsIr = join56 ? paintPlayhead(declaredIr, join56, runState.gate) : declaredIr;
29212
+ const join57 = ranOp ? joinRun(ranOp, runState.records, runState.gate) : null;
29213
+ const opsIr = join57 ? paintPlayhead(declaredIr, join57, runState.gate) : declaredIr;
28920
29214
  const { svg: svg2 } = renderGraph(opsIr, { boxes: "byStack" });
28921
29215
  const operator = runner.noteDeclaredConvergeOps(declaredConvergeOps(parsedOps));
28922
29216
  return c.json({
@@ -28929,7 +29223,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28929
29223
  target: null,
28930
29224
  mode: "ops",
28931
29225
  ops: parsedOps.length,
28932
- note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join56)} ${operatorNote(operator)}`,
29226
+ note: `${opsNote(parsedOps, opsIr)} ${playheadNote(runState, join57)} ${operatorNote(operator)}`,
28933
29227
  // The operator strip's own model: the ConvergeOps this project
28934
29228
  // declares, plus whatever the last status read said. `declared`
28935
29229
  // without a `strip` is the honest starting state — a loop exists and
@@ -29042,7 +29336,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
29042
29336
  srcCompositeEdgesAttached = 0;
29043
29337
  }
29044
29338
  }
29045
- if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync31(join51(cfg.projectDir, "chant.config.ts"))) {
29339
+ if (!multi && !components && !logical && !opts.lens && !ownKindVia && ir.nodes.length === 0 && !existsSync32(join52(cfg.projectDir, "chant.config.ts"))) {
29046
29340
  return c.json(noProjectError(cfg.projectDir), 404);
29047
29341
  }
29048
29342
  const radial = new URL(c.req.url).searchParams.get("radial") === "1";
@@ -29274,7 +29568,16 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
29274
29568
  // is already on screen, so this is id -> status and nothing more.
29275
29569
  statuses: Object.fromEntries(
29276
29570
  memberIrDoc.nodes.map((n) => [`${name}/${n.id}`, n.attrs?._status ?? "neutral"])
29277
- )
29571
+ ),
29572
+ // A choudoufu card's marker-vs-derived mark rides the same frame,
29573
+ // only for the cards that carry one.
29574
+ ...(() => {
29575
+ const ids = memberIrDoc.nodes.flatMap((n) => {
29576
+ const i = n.attrs?._identity;
29577
+ return i ? [[`${name}/${n.id}`, i]] : [];
29578
+ });
29579
+ return ids.length ? { identities: Object.fromEntries(ids) } : {};
29580
+ })()
29278
29581
  }));
29279
29582
  }
29280
29583
  }).catch((err) => broadcaster.emit("member", JSON.stringify({ error: err instanceof Error ? err.message.split("\n")[0] : String(err) })));
@@ -29548,11 +29851,11 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
29548
29851
  return c.json({ env, nodes });
29549
29852
  });
29550
29853
  const choudoufuPlanPath = (plan) => {
29551
- if (!plan) return { error: "no plan named", code: "choudoufu_no_plan", remedy: "pass ?plan=<path to a carve.json inside a served choudoufu member> \u2014 GET /api/project lists the ones found" };
29854
+ 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" };
29552
29855
  const abs = resolve32(cfg.projectDir, plan);
29553
29856
  const members = (cfg.projectDirs ?? [cfg.projectDir]).filter((d) => memberKindOf(d) === "choudoufu");
29554
29857
  const inside = members.some((d) => abs.startsWith(resolve32(d) + sep10));
29555
- 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 carve.json under one of the served members" };
29858
+ 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" };
29556
29859
  return { path: abs };
29557
29860
  };
29558
29861
  const choudoufuMembersServed = async () => {
@@ -29560,22 +29863,25 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
29560
29863
  const all = estateMembers(cfg.projectDirs ?? [cfg.projectDir]).filter((m) => m.kind === "choudoufu");
29561
29864
  return moveMembers(all, run3);
29562
29865
  };
29563
- app.get("/api/choudoufu/moves", async (c) => {
29866
+ const splitPreviews = async (c) => {
29564
29867
  const q = new URL(c.req.url).searchParams;
29565
29868
  const where = choudoufuPlanPath(q.get("plan") ?? void 0);
29566
29869
  if ("error" in where) return c.json(where, 400);
29567
- const parsed = readCarvePlan(where.path);
29870
+ const parsed = readSplitPlan(where.path);
29568
29871
  if (!parsed.ok) return c.json(parsed.refusal, 422);
29569
29872
  const members = await choudoufuMembersServed();
29570
29873
  const payload = await movesPayload(parsed.plan, members, { dryRun: q.get("dryrun") === "1", run: cfg.choudoufu?.run });
29571
29874
  const receipt = q.get("receipt") === "1" ? await moveReceipt(parsed.plan, members, cfg.choudoufu?.run) : void 0;
29572
29875
  return c.json({ planPath: relative11(cfg.projectDir, where.path), ...payload, ...receipt ? { receipt } : {} });
29573
- });
29574
- app.get("/choudoufu/morph", async (c) => {
29876
+ };
29877
+ app.get("/api/choudoufu/split", splitPreviews);
29878
+ app.get("/api/choudoufu/moves", splitPreviews);
29879
+ app.get("/choudoufu/morph", (c) => c.redirect(`/choudoufu/split${new URL(c.req.url).search}`, 301));
29880
+ app.get("/choudoufu/split", async (c) => {
29575
29881
  const q = new URL(c.req.url).searchParams;
29576
29882
  const where = choudoufuPlanPath(q.get("plan") ?? void 0);
29577
29883
  if ("error" in where) return c.json(where, 400);
29578
- const parsed = readCarvePlan(where.path);
29884
+ const parsed = readSplitPlan(where.path);
29579
29885
  if (!parsed.ok) return c.json(parsed.refusal, 422);
29580
29886
  const members = await choudoufuMembersServed();
29581
29887
  const morphMembers = await Promise.all(
@@ -29592,7 +29898,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
29592
29898
  ...p.newAddress ? { newAddress: p.newAddress } : {},
29593
29899
  ...p.dryRun && "followers" in p.dryRun && p.dryRun.followers ? { followers: p.dryRun.followers.map((f) => f.address) } : {}
29594
29900
  }));
29595
- const html = renderMoveMorph(morphMembers, moves, { title: `moves \u2014 ${relative11(cfg.projectDir, where.path)}`, estateOf: (m) => m.panel.replace(/^estate /, "") });
29901
+ const html = renderMoveMorph(morphMembers, moves, { title: `split \u2014 ${relative11(cfg.projectDir, where.path)}`, estateOf: (m) => m.panel.replace(/^estate /, "") });
29596
29902
  return c.html(html);
29597
29903
  });
29598
29904
  app.get("/api/diff/:node", async (c) => {
@@ -29687,7 +29993,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
29687
29993
  if (!c.req.path.startsWith("/api/") && c.res.ok && !c.res.headers.has("cache-control")) c.res.headers.set("cache-control", "no-cache");
29688
29994
  });
29689
29995
  app.use("/*", serveStatic({ root: rel }));
29690
- app.get("/", serveStatic({ path: join51(rel, "index.html") }));
29996
+ app.get("/", serveStatic({ path: join52(rel, "index.html") }));
29691
29997
  if (cfg.terragucci) vendorFallback(app);
29692
29998
  return app;
29693
29999
  }
@@ -29717,7 +30023,7 @@ async function bootLocalEmulators(dir, who) {
29717
30023
  async function startServer(cfg) {
29718
30024
  if (cfg.local) cfg.emulators = await bootLocalEmulators(cfg.projectDir, "behold serve --local");
29719
30025
  for (const dir of cfg.projectDirs ?? [cfg.projectDir]) {
29720
- if (existsSync31(join51(dir, "chant.config.ts"))) addRecent(dir);
30026
+ if (existsSync32(join52(dir, "chant.config.ts"))) addRecent(dir);
29721
30027
  }
29722
30028
  const broadcaster = new Broadcaster();
29723
30029
  const frames = new FrameBuffer();
@@ -29786,7 +30092,7 @@ async function startServer(cfg) {
29786
30092
  }
29787
30093
  }
29788
30094
  };
29789
- const carve = !!cfg.carveReport;
30095
+ const carve = !!cfg.carveReport || !!cfg.terralithDemo;
29790
30096
  let stopWatch = carve ? () => {
29791
30097
  } : watchSources(cfg.projectDirs ?? [cfg.projectDir], onMemberSourceChange);
29792
30098
  let pollScopes = /* @__PURE__ */ new Map();
@@ -29841,6 +30147,16 @@ async function startServer(cfg) {
29841
30147
  process.on("SIGTERM", shutdown);
29842
30148
  const hostname = cfg.host ?? process.env.BEHOLD_HOST ?? "127.0.0.1";
29843
30149
  const server = serve({ fetch: app.fetch, port: cfg.port, hostname }, (info) => {
30150
+ if (cfg.terralithDemo) {
30151
+ process.stdout.write(
30152
+ `behold \u2192 http://localhost:${info.port}/terralith
30153
+ terralith walkthrough: ${cfg.terralithDemo.root}
30154
+ reads snapshots/ in the copy; each phase is a script line you run there.
30155
+ scratch floci: ${cfg.terralithDemo.endpoint}. Ctrl-C stops behold; scripts/terralith-down.sh removes the emulator.
30156
+ `
30157
+ );
30158
+ return;
30159
+ }
29844
30160
  if (carve) {
29845
30161
  process.stdout.write(
29846
30162
  `behold \u2192 http://localhost:${info.port}
@@ -29892,8 +30208,8 @@ init_chant();
29892
30208
 
29893
30209
  // src/workspace-convert.ts
29894
30210
  init_chant();
29895
- import { existsSync as existsSync32, mkdirSync as mkdirSync9, readFileSync as readFileSync40, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
29896
- import { basename as basename7, dirname as dirname19, join as join52, relative as relative12, resolve as resolve33, sep as sep11 } from "node:path";
30211
+ import { existsSync as existsSync33, mkdirSync as mkdirSync9, readFileSync as readFileSync41, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
30212
+ import { basename as basename7, dirname as dirname19, join as join53, relative as relative12, resolve as resolve33, sep as sep11 } from "node:path";
29897
30213
  import { shortStackNames as shortStackNames2 } from "@intentius/pinhole";
29898
30214
  init_project();
29899
30215
  init_terraform_member();
@@ -29911,10 +30227,10 @@ function unique(name, taken) {
29911
30227
  var posix5 = (p) => p.split(sep11).join("/");
29912
30228
  function installedVersion(pkg, dir) {
29913
30229
  for (let at2 = resolve33(dir); ; at2 = dirname19(at2)) {
29914
- const manifest = join52(at2, "node_modules", ...pkg.split("/"), "package.json");
29915
- if (existsSync32(manifest)) {
30230
+ const manifest = join53(at2, "node_modules", ...pkg.split("/"), "package.json");
30231
+ if (existsSync33(manifest)) {
29916
30232
  try {
29917
- const v = JSON.parse(readFileSync40(manifest, "utf8")).version;
30233
+ const v = JSON.parse(readFileSync41(manifest, "utf8")).version;
29918
30234
  return typeof v === "string" ? v : void 0;
29919
30235
  } catch {
29920
30236
  return void 0;
@@ -29925,7 +30241,7 @@ function installedVersion(pkg, dir) {
29925
30241
  }
29926
30242
  function planConversion(rootArg) {
29927
30243
  const root = resolve33(rootArg);
29928
- const existing = DECLARATION_FILES.find((f) => existsSync32(join52(root, f)));
30244
+ const existing = DECLARATION_FILES.find((f) => existsSync33(join53(root, f)));
29929
30245
  if (existing) return { ok: false, error: `${root} already has ${existing}; there is nothing to convert.` };
29930
30246
  const shape = detectProjectShape(root);
29931
30247
  if (shape.kind !== "estate" || !shape.members?.length || shape.membersFrom === "itself") {
@@ -29946,10 +30262,10 @@ function planConversion(rootArg) {
29946
30262
  const scan = discoverTerraformRoots(abs[i]);
29947
30263
  for (const r of scan.roots) {
29948
30264
  const name2 = unique(declarationName(r.name), taken);
29949
- members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join52(dir, r.dir)), kind: "terraform" });
30265
+ members.push({ name: name2, dir: r.dir === "." ? dir : posix5(join53(dir, r.dir)), kind: "terraform" });
29950
30266
  moves.push({ from: `${short}/${r.name}/`, to: `${name2}/${name2}/` });
29951
30267
  }
29952
- for (const s of scan.skipped) notes.push(`${posix5(join52(dir, s.dir))} is not declared: ${s.why}.`);
30268
+ for (const s of scan.skipped) notes.push(`${posix5(join53(dir, s.dir))} is not declared: ${s.why}.`);
29953
30269
  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.`);
29954
30270
  return;
29955
30271
  }
@@ -29977,7 +30293,7 @@ function planConversion(rootArg) {
29977
30293
  };
29978
30294
  const firstLayout = layoutPath(abs[0]);
29979
30295
  moves.sort((a, b) => b.from.length - a.from.length);
29980
- return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...existsSync32(firstLayout) ? { layoutFrom: firstLayout } : {}, notes } };
30296
+ return { ok: true, plan: { root, from: shape.membersFrom === "behold-config" ? "behold-config" : "workspaces", declaration, moves, ...existsSync33(firstLayout) ? { layoutFrom: firstLayout } : {}, notes } };
29981
30297
  }
29982
30298
  function moveLayoutIds(file, moves) {
29983
30299
  const lenses = {};
@@ -29992,18 +30308,18 @@ function moveLayoutIds(file, moves) {
29992
30308
  return { version: 1, lenses };
29993
30309
  }
29994
30310
  function applyConversion(plan) {
29995
- const declarationFile = join52(plan.root, DECLARATION_FILES[0]);
29996
- if (existsSync32(declarationFile)) throw new Error(`${declarationFile} appeared while converting; nothing was written`);
30311
+ const declarationFile = join53(plan.root, DECLARATION_FILES[0]);
30312
+ if (existsSync33(declarationFile)) throw new Error(`${declarationFile} appeared while converting; nothing was written`);
29997
30313
  writeFileSync7(declarationFile, `${JSON.stringify(plan.declaration, null, 2)}
29998
30314
  `);
29999
30315
  let layout;
30000
30316
  const target = layoutPath(plan.root);
30001
30317
  if (!plan.layoutFrom) layout = { skipped: "no saved layout to move" };
30002
30318
  else if (resolve33(plan.layoutFrom) === resolve33(target)) layout = { skipped: "the saved layout is already in the root" };
30003
- else if (existsSync32(target)) layout = { skipped: `${target} already exists; the layout in ${plan.layoutFrom} was left alone` };
30319
+ else if (existsSync33(target)) layout = { skipped: `${target} already exists; the layout in ${plan.layoutFrom} was left alone` };
30004
30320
  else {
30005
30321
  const moved = moveLayoutIds(readLayoutFile(dirname19(dirname19(plan.layoutFrom))), plan.moves);
30006
- mkdirSync9(join52(plan.root, LAYOUT_DIR), { recursive: true });
30322
+ mkdirSync9(join53(plan.root, LAYOUT_DIR), { recursive: true });
30007
30323
  const tmp = `${target}.tmp`;
30008
30324
  writeFileSync7(tmp, `${JSON.stringify(moved, null, 2)}
30009
30325
  `);
@@ -30014,9 +30330,9 @@ function applyConversion(plan) {
30014
30330
  }
30015
30331
 
30016
30332
  // src/export.ts
30017
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, copyFileSync, cpSync as cpSync2, readFileSync as readFileSync41, readdirSync as readdirSync18, existsSync as existsSync33, realpathSync as realpathSync2 } from "node:fs";
30333
+ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, copyFileSync, cpSync as cpSync2, readFileSync as readFileSync42, readdirSync as readdirSync19, existsSync as existsSync34, realpathSync as realpathSync2 } from "node:fs";
30018
30334
  import { homedir as homedir3 } from "node:os";
30019
- import { join as join53, dirname as dirname20, basename as basename8, relative as relative13, resolve as resolve34, sep as sep12 } from "node:path";
30335
+ import { join as join54, dirname as dirname20, basename as basename8, relative as relative13, resolve as resolve34, sep as sep12 } from "node:path";
30020
30336
  import { createHash as createHash11 } from "node:crypto";
30021
30337
  import { fileURLToPath as fileURLToPath11 } from "node:url";
30022
30338
  var LENS_PARAMS = ["collapse", "components", "detail", "env", "logical", "ops", "radial", "stacks", "tier"];
@@ -30073,24 +30389,24 @@ function captureKeys(axes) {
30073
30389
  return [...keys];
30074
30390
  }
30075
30391
  function webDir() {
30076
- return join53(dirname20(fileURLToPath11(import.meta.url)), "..", "web");
30392
+ return join54(dirname20(fileURLToPath11(import.meta.url)), "..", "web");
30077
30393
  }
30078
30394
  function pkgRoot2() {
30079
- return join53(dirname20(fileURLToPath11(import.meta.url)), "..");
30395
+ return join54(dirname20(fileURLToPath11(import.meta.url)), "..");
30080
30396
  }
30081
30397
  var NOTICE_FILES = ["LICENSE", "THIRD_PARTY.md"];
30082
30398
  function copyNotices(outDir, root = pkgRoot2()) {
30083
30399
  const copied = [];
30084
30400
  for (const f of NOTICE_FILES) {
30085
- if (!existsSync33(join53(root, f))) continue;
30086
- copyFileSync(join53(root, f), join53(outDir, f));
30401
+ if (!existsSync34(join54(root, f))) continue;
30402
+ copyFileSync(join54(root, f), join54(outDir, f));
30087
30403
  copied.push(f);
30088
30404
  }
30089
- const lic = join53(root, "licenses");
30090
- if (existsSync33(lic)) {
30091
- mkdirSync10(join53(outDir, "licenses"), { recursive: true });
30092
- for (const f of readdirSync18(lic)) {
30093
- copyFileSync(join53(lic, f), join53(outDir, "licenses", f));
30405
+ const lic = join54(root, "licenses");
30406
+ if (existsSync34(lic)) {
30407
+ mkdirSync10(join54(outDir, "licenses"), { recursive: true });
30408
+ for (const f of readdirSync19(lic)) {
30409
+ copyFileSync(join54(lic, f), join54(outDir, "licenses", f));
30094
30410
  copied.push(`licenses/${f}`);
30095
30411
  }
30096
30412
  }
@@ -30115,7 +30431,7 @@ async function runExport(cfg, outDir, opts = {}) {
30115
30431
  ...proj.sqlYodeler ? { sqlYodeler: true } : {}
30116
30432
  };
30117
30433
  const scrub = exportScrubber(cfg);
30118
- const snapDir = join53(outDir, "snapshots");
30434
+ const snapDir = join54(outDir, "snapshots");
30119
30435
  mkdirSync10(snapDir, { recursive: true });
30120
30436
  const keyToFile = {};
30121
30437
  let ok = 0;
@@ -30124,7 +30440,7 @@ async function runExport(cfg, outDir, opts = {}) {
30124
30440
  const res = await app.request(`${key2}${key2.includes("?") ? "&" : "?"}layout=1`);
30125
30441
  const body = scrub(shapeSnapshot(key2, await res.text(), opts));
30126
30442
  const file = slug3(key2, body);
30127
- writeFileSync8(join53(snapDir, file), body);
30443
+ writeFileSync8(join54(snapDir, file), body);
30128
30444
  keyToFile[key2] = `snapshots/${file}`;
30129
30445
  if (res.ok) ok++;
30130
30446
  else failed++;
@@ -30146,29 +30462,29 @@ async function runExport(cfg, outDir, opts = {}) {
30146
30462
  axes,
30147
30463
  keyToFile
30148
30464
  };
30149
- writeFileSync8(join53(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
30150
- const html = readFileSync41(join53(webDir(), "index.html"), "utf8").replace(
30465
+ writeFileSync8(join54(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
30466
+ const html = readFileSync42(join54(webDir(), "index.html"), "utf8").replace(
30151
30467
  /<\/head>/i,
30152
30468
  ` <script>window.__BEHOLD_STATIC__ = true;</script>
30153
30469
  </head>`
30154
30470
  );
30155
- writeFileSync8(join53(outDir, "index.html"), html);
30156
- for (const f of readdirSync18(webDir())) {
30471
+ writeFileSync8(join54(outDir, "index.html"), html);
30472
+ for (const f of readdirSync19(webDir())) {
30157
30473
  if (f === "index.html" || f.endsWith(".test.js")) continue;
30158
- cpSync2(join53(webDir(), f), join53(outDir, f), { recursive: true });
30474
+ cpSync2(join54(webDir(), f), join54(outDir, f), { recursive: true });
30159
30475
  }
30160
- writeFileSync8(join53(outDir, "README.md"), BUNDLE_README);
30476
+ writeFileSync8(join54(outDir, "README.md"), BUNDLE_README);
30161
30477
  copyNotices(outDir);
30162
30478
  const name = workerName(cfg.projectDir, opts.name);
30163
30479
  writeFileSync8(
30164
- join53(outDir, "wrangler.jsonc"),
30480
+ join54(outDir, "wrangler.jsonc"),
30165
30481
  JSON.stringify(
30166
30482
  { $schema: "node_modules/wrangler/config-schema.json", name, compatibility_date: "2025-06-01", assets: { directory: "." } },
30167
30483
  null,
30168
30484
  2
30169
30485
  ) + "\n"
30170
30486
  );
30171
- writeFileSync8(join53(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
30487
+ writeFileSync8(join54(outDir, "manifest.json"), JSON.stringify({ ...manifest, files: bundleFiles(outDir).filter((f) => f !== "manifest.json") }, null, 2));
30172
30488
  process.stdout.write(
30173
30489
  `behold export \u2192 ${outDir}
30174
30490
  ${ok} snapshots${failed ? ` (${failed} endpoint error(s) captured as-is)` : ""}
@@ -30177,11 +30493,11 @@ async function runExport(cfg, outDir, opts = {}) {
30177
30493
  `
30178
30494
  );
30179
30495
  }
30180
- var isRecord22 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
30496
+ var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
30181
30497
  function dropSource(v) {
30182
30498
  if (Array.isArray(v)) return v.forEach(dropSource);
30183
- if (!isRecord22(v)) return;
30184
- if (isRecord22(v.attrs)) delete v.attrs.source;
30499
+ if (!isRecord23(v)) return;
30500
+ if (isRecord23(v.attrs)) delete v.attrs.source;
30185
30501
  for (const x of Object.values(v)) dropSource(x);
30186
30502
  }
30187
30503
  function shapeSnapshot(key2, body, opts = {}) {
@@ -30191,7 +30507,7 @@ function shapeSnapshot(key2, body, opts = {}) {
30191
30507
  } catch {
30192
30508
  return body;
30193
30509
  }
30194
- if (!isRecord22(doc)) return body;
30510
+ if (!isRecord23(doc)) return body;
30195
30511
  if (key2 === "/api/project") {
30196
30512
  delete doc.recents;
30197
30513
  delete doc.approver;
@@ -30261,11 +30577,11 @@ function manifestFiles(text2) {
30261
30577
  } catch {
30262
30578
  return [];
30263
30579
  }
30264
- const map = isRecord22(doc) && isRecord22(doc.keyToFile) ? doc.keyToFile : {};
30580
+ const map = isRecord23(doc) && isRecord23(doc.keyToFile) ? doc.keyToFile : {};
30265
30581
  return Object.values(map).filter((f) => typeof f === "string" && /^snapshots\/[A-Za-z0-9=_.-]+$/.test(f) && !f.includes(".."));
30266
30582
  }
30267
30583
  function bundleFiles(outDir) {
30268
- return readdirSync18(outDir, { recursive: true, withFileTypes: true }).filter((d) => d.isFile()).map((d) => relative13(outDir, join53(d.parentPath, d.name)).split(sep12).join("/")).sort();
30584
+ return readdirSync19(outDir, { recursive: true, withFileTypes: true }).filter((d) => d.isFile()).map((d) => relative13(outDir, join54(d.parentPath, d.name)).split(sep12).join("/")).sort();
30269
30585
  }
30270
30586
  async function publishBundle(outDir, target, client) {
30271
30587
  const files = bundleFiles(outDir);
@@ -30281,7 +30597,7 @@ async function publishBundle(outDir, target, client) {
30281
30597
  }
30282
30598
  const last = ["manifest.json", "index.html"];
30283
30599
  const order = [...files.filter((f) => !last.includes(f)), ...last.filter((f) => files.includes(f))];
30284
- for (const f of order) await client.put(at2(f), readFileSync41(join53(outDir, f)), contentType(f), CONTENT_ADDRESSED.test(f) ? IMMUTABLE : NO_CACHE);
30600
+ for (const f of order) await client.put(at2(f), readFileSync42(join54(outDir, f)), contentType(f), CONTENT_ADDRESSED.test(f) ? IMMUTABLE : NO_CACHE);
30285
30601
  const wrote = new Set(files);
30286
30602
  const removed = [];
30287
30603
  for (const f of previous) {
@@ -30333,8 +30649,8 @@ It's just files \u2014 GitHub Pages, S3, nginx, or Cloudflare Pages
30333
30649
 
30334
30650
  // src/publish-snapshots.ts
30335
30651
  import { execFileSync as execFileSync4 } from "node:child_process";
30336
- import { readFileSync as readFileSync42 } from "node:fs";
30337
- import { join as join54 } from "node:path";
30652
+ import { readFileSync as readFileSync43 } from "node:fs";
30653
+ import { join as join55 } from "node:path";
30338
30654
  var DEFAULT_KEEP = 30;
30339
30655
  var SNAPSHOT_REPORTS_BASE = "../../../";
30340
30656
  var COMMIT2 = /^[0-9a-f]{7,64}$/;
@@ -30359,12 +30675,12 @@ function resolveCommit2(dir, given) {
30359
30675
  return { sha };
30360
30676
  }
30361
30677
  }
30362
- var isRecord23 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
30678
+ var isRecord24 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
30363
30679
  function parseHistory(text2) {
30364
30680
  const doc = JSON.parse(text2);
30365
30681
  if (!Array.isArray(doc)) throw new Error("history.json is not an array");
30366
30682
  const str17 = (v) => typeof v === "string" ? v : "";
30367
- return doc.filter((e) => isRecord23(e) && typeof e.commit === "string" && COMMIT2.test(e.commit)).map((e) => ({ commit: e.commit, at: str17(e.at), project: str17(e.project), generated: str17(e.generated) }));
30683
+ return doc.filter((e) => isRecord24(e) && typeof e.commit === "string" && COMMIT2.test(e.commit)).map((e) => ({ commit: e.commit, at: str17(e.at), project: str17(e.project), generated: str17(e.generated) }));
30368
30684
  }
30369
30685
  function nextHistory(old, entry, keep) {
30370
30686
  const all = [entry, ...old.filter((e) => e.commit !== entry.commit)];
@@ -30376,9 +30692,9 @@ var BUNDLE_PATH = /^[A-Za-z0-9=_.@+-]+(\/[A-Za-z0-9=_.@+-]+)*$/;
30376
30692
  var insideBundle = (f) => typeof f === "string" && BUNDLE_PATH.test(f) && !f.split("/").some((p) => p === "." || p === "..");
30377
30693
  function commitFiles(manifestText) {
30378
30694
  const doc = JSON.parse(manifestText);
30379
- if (!isRecord23(doc)) return ["manifest.json"];
30695
+ if (!isRecord24(doc)) return ["manifest.json"];
30380
30696
  const listed = Array.isArray(doc.files) ? doc.files.filter(insideBundle) : [];
30381
- const snaps = isRecord23(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
30697
+ const snaps = isRecord24(doc.keyToFile) ? Object.values(doc.keyToFile).filter(insideBundle) : [];
30382
30698
  const rest = [.../* @__PURE__ */ new Set([...listed, ...snaps])].filter((f) => f !== "index.html" && f !== "manifest.json").sort();
30383
30699
  return ["index.html", ...rest, "manifest.json"];
30384
30700
  }
@@ -30422,7 +30738,7 @@ async function publishSnapshot(outDir, target, commit, client, opts = {}) {
30422
30738
  const keep = opts.keep ?? DEFAULT_KEEP;
30423
30739
  if (!Number.isInteger(keep) || keep < 1) throw new Error(`--keep takes a whole number of at least 1, not ${keep}`);
30424
30740
  const at2 = (f) => `${target.prefix}/${f}`;
30425
- const local = JSON.parse(readFileSync42(join54(outDir, "manifest.json"), "utf8"));
30741
+ const local = JSON.parse(readFileSync43(join55(outDir, "manifest.json"), "utf8"));
30426
30742
  const generated = local.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString();
30427
30743
  const entry = { commit: sha, at: commit.at ?? generated, project: opts.project ?? local.projectDir ?? "", generated };
30428
30744
  const bundle = await publishBundle(outDir, { bucket: target.bucket, prefix: at2(sha) }, client);
@@ -30938,7 +31254,7 @@ function warnIfNotChantProject(dir) {
30938
31254
  if (shape.kind === "estate") {
30939
31255
  process.stderr.write(
30940
31256
  `behold: warning \u2014 ${dir} is an estate root, not a chant project itself.
30941
- Serve its members composed: behold serve ${shape.members.map((m) => join55(dir, m.dir)).join(" ")}
31257
+ Serve its members composed: behold serve ${shape.members.map((m) => join56(dir, m.dir)).join(" ")}
30942
31258
  `
30943
31259
  );
30944
31260
  return;
@@ -30974,7 +31290,7 @@ async function runCarve(rest) {
30974
31290
  process.exit(2);
30975
31291
  }
30976
31292
  const reportPath = resolve35(fileArg);
30977
- const parsed = readCarveReport(reportPath, (p) => readFileSync43(p, "utf8"));
31293
+ const parsed = readCarveReport(reportPath, (p) => readFileSync44(p, "utf8"));
30978
31294
  if (!parsed.ok) {
30979
31295
  process.stderr.write(`behold carve: ${parsed.refusal.error}
30980
31296
  ${parsed.refusal.remedy}
@@ -31003,7 +31319,7 @@ async function runDoctor(rest) {
31003
31319
  }
31004
31320
  }
31005
31321
  const dir = dirArg ?? ".";
31006
- if (!existsSync34(resolve35(dir))) {
31322
+ if (!existsSync35(resolve35(dir))) {
31007
31323
  process.stderr.write(`behold doctor: no such directory: ${resolve35(dir)}
31008
31324
  `);
31009
31325
  process.exit(2);
@@ -31040,7 +31356,7 @@ ${check.stdout || check.stderr}
31040
31356
  if (check.code !== 0) process.exitCode = 1;
31041
31357
  }
31042
31358
  async function runDemo(rest) {
31043
- const pkgRoot3 = join55(dirname21(fileURLToPath12(import.meta.url)), "..");
31359
+ const pkgRoot3 = join56(dirname21(fileURLToPath12(import.meta.url)), "..");
31044
31360
  const registry2 = loadDemoRegistry(pkgRoot3);
31045
31361
  let port = 4600;
31046
31362
  let live2 = false;
@@ -31110,6 +31426,10 @@ async function runDemo(rest) {
31110
31426
  `);
31111
31427
  process.exit(1);
31112
31428
  }
31429
+ if (entry.serve.terralith) {
31430
+ await serveTerralithDemo(target, port);
31431
+ return;
31432
+ }
31113
31433
  if (entry.serve.carve) {
31114
31434
  await serveCarveDemo(target, entry.serve.carve, port, live2);
31115
31435
  return;
@@ -31134,6 +31454,12 @@ function spawnStep(cmd, args, cwd) {
31134
31454
  child.on("close", (code) => res(code ?? 1));
31135
31455
  });
31136
31456
  }
31457
+ async function serveTerralithDemo(target, port) {
31458
+ const endpoint = `http://127.0.0.1:${process.env.TERRALITH_PORT ?? "4652"}`;
31459
+ process.stdout.write(`behold demo terralith \u2192 serving the walkthrough. Next, in ${target}: bash scripts/terralith-step.sh adopt
31460
+ `);
31461
+ await startServer({ projectDir: target, terralithDemo: { root: target, endpoint }, port });
31462
+ }
31137
31463
  async function serveCarveDemo(target, carve, port, live2 = false) {
31138
31464
  const at2 = (rel) => resolve35(target, rel);
31139
31465
  const project = at2(carve.project);
@@ -31175,7 +31501,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
31175
31501
  };
31176
31502
  process.stdout.write("behold demo carve --live \u2192 the tfstate is real now; the advisor reads what terraform wrote.\n");
31177
31503
  }
31178
- if (existsSync34(join55(project, "package.json")) && !existsSync34(join55(project, "node_modules"))) {
31504
+ if (existsSync35(join56(project, "package.json")) && !existsSync35(join56(project, "node_modules"))) {
31179
31505
  process.stdout.write(`behold demo carve \u2192 npm install in ${carve.project}/ (the chant this walkthrough shells)\u2026
31180
31506
  `);
31181
31507
  const code = await spawnStep("npm", ["install"], project);
@@ -31186,7 +31512,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
31186
31512
  }
31187
31513
  }
31188
31514
  let degraded;
31189
- if (!existsSync34(join55(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
31515
+ if (!existsSync35(join56(target, "node_modules", ...HCL_PARSER_PKG.split("/")))) {
31190
31516
  process.stdout.write(`behold demo carve \u2192 npm install ${HCL_PARSER_PKG} (chant's HCL parser, ~2MB, once)\u2026
31191
31517
  `);
31192
31518
  const code = await spawnStep("npm", ["install", "--no-save", "--no-package-lock", HCL_PARSER_PKG], target);
@@ -31203,7 +31529,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
31203
31529
  );
31204
31530
  if (code !== 0) degraded = `chant carve advise exited ${code}`;
31205
31531
  }
31206
- const serving = !degraded && existsSync34(report) ? report : committed;
31532
+ const serving = !degraded && existsSync35(report) ? report : committed;
31207
31533
  if (degraded) {
31208
31534
  process.stderr.write(
31209
31535
  `behold demo carve: ${degraded}
@@ -31211,7 +31537,7 @@ async function serveCarveDemo(target, carve, port, live2 = false) {
31211
31537
  `
31212
31538
  );
31213
31539
  }
31214
- if (!existsSync34(serving)) {
31540
+ if (!existsSync35(serving)) {
31215
31541
  process.stderr.write(`behold demo carve: no carve report at ${serving}
31216
31542
  `);
31217
31543
  process.exit(2);
@@ -31257,7 +31583,7 @@ async function runPreview(rest) {
31257
31583
  process.exit(2);
31258
31584
  }
31259
31585
  const projectDir = resolve35(dirArg ?? process.cwd());
31260
- if (!existsSync34(projectDir)) {
31586
+ if (!existsSync35(projectDir)) {
31261
31587
  process.stderr.write(`behold preview: project not found at ${projectDir}
31262
31588
  `);
31263
31589
  process.exit(2);
@@ -31348,7 +31674,7 @@ async function runExportCmd(rest) {
31348
31674
  injectEmulatorEnv(env);
31349
31675
  env ??= "local";
31350
31676
  }
31351
- if (!existsSync34(projectDir)) {
31677
+ if (!existsSync35(projectDir)) {
31352
31678
  process.stderr.write(`behold export: project not found at ${projectDir}
31353
31679
  `);
31354
31680
  process.exit(2);