@intentius/chant-lexicon-terraform 0.124.78 → 0.124.80

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 (45) hide show
  1. package/dist/change-set.d.ts +1 -0
  2. package/dist/change-set.d.ts.map +1 -1
  3. package/dist/change-set.js +19 -0
  4. package/dist/components/capability-plugin.d.ts +75 -2
  5. package/dist/components/capability-plugin.d.ts.map +1 -1
  6. package/dist/components/capability-plugin.js +250 -142
  7. package/dist/components/compose-group.d.ts +2 -1
  8. package/dist/components/compose-group.d.ts.map +1 -1
  9. package/dist/components/compose-group.js +6 -6
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3 -1
  13. package/dist/integrity.json +2 -2
  14. package/dist/manifest.json +1 -1
  15. package/dist/op/activities/terraform.d.ts +33 -0
  16. package/dist/op/activities/terraform.d.ts.map +1 -1
  17. package/dist/op/activities/terraform.js +37 -5
  18. package/dist/state-reads.d.ts +20 -3
  19. package/dist/state-reads.d.ts.map +1 -1
  20. package/dist/state-reads.js +20 -4
  21. package/dist/terragrunt/capability.d.ts +129 -0
  22. package/dist/terragrunt/capability.d.ts.map +1 -0
  23. package/dist/terragrunt/capability.js +352 -0
  24. package/dist/terragrunt/index.d.ts +3 -1
  25. package/dist/terragrunt/index.d.ts.map +1 -1
  26. package/dist/terragrunt/index.js +3 -1
  27. package/dist/terragrunt/units.d.ts +9 -0
  28. package/dist/terragrunt/units.d.ts.map +1 -1
  29. package/dist/terragrunt/units.js +25 -0
  30. package/package.json +2 -2
  31. package/src/change-set.test.ts +27 -1
  32. package/src/change-set.ts +19 -0
  33. package/src/components/capability-plugin.test.ts +61 -6
  34. package/src/components/capability-plugin.ts +290 -139
  35. package/src/components/compose-group.ts +8 -7
  36. package/src/components/compose-op-wave.test.ts +134 -0
  37. package/src/components/terraform-apply-op-wave.test.ts +295 -0
  38. package/src/index.ts +5 -0
  39. package/src/op/activities/terraform.test.ts +21 -0
  40. package/src/op/activities/terraform.ts +64 -4
  41. package/src/state-reads.ts +23 -5
  42. package/src/terragrunt/capability.test.ts +348 -0
  43. package/src/terragrunt/capability.ts +437 -0
  44. package/src/terragrunt/index.ts +3 -1
  45. package/src/terragrunt/units.ts +25 -0
@@ -119,6 +119,19 @@
119
119
  * yet makes the member a hole naming it, so the root is never planned on a
120
120
  * stand-in.
121
121
  *
122
+ * - `workspace`: the workspace the root runs in (chant#4854). `init` runs in
123
+ * `default`, then `workspace select -or-create=true` selects it, creating
124
+ * it when the backend does not list it yet, and the plan, apply and
125
+ * output run in it. Such a root plans with `plan`, never as a one-root set.
126
+ *
127
+ * A wave's run hooks in the product's process (chant#4842) reach the step
128
+ * through its context. `processEnv` goes to every command for the root (a
129
+ * role's credentials, values from a secret store), and `afterInit` is
130
+ * called after `init` and before `plan`, or before `live-plan-set`, which
131
+ * inits and plans in one command. A `root` with no `terraform.roots` entry
132
+ * plans the step's `dir` as its directory, so a product can name each root
133
+ * by its path without writing an entry for it.
134
+ *
122
135
  * Every plan also writes its `show -json` beside the plan file and names it
123
136
  * as `artifact.planJson`, the document a wave's cost hold prices
124
137
  * (`../cost-hold.ts`).
@@ -147,6 +160,7 @@ import { conePlanDigest } from "../cone.js";
147
160
  import { fillStateReads, stateReadsProblems, waitingReadsReason } from "../state-reads.js";
148
161
  import { terraformStateOpCapabilities } from "../state-ops.js";
149
162
  import { terraformActionCapability } from "../action-ops.js";
163
+ import { terragruntApply } from "../terragrunt/capability.js";
150
164
  /** The lock timeout a step's plan and apply pass (#4545). */
151
165
  function lockTimeoutOf(input) {
152
166
  if (input.lockTimeout === false)
@@ -161,15 +175,24 @@ function lockTimeoutOf(input) {
161
175
  * read once, the values under the step's own `vars`. `waiting` when an
162
176
  * upstream has no such output yet. Throws when a state cannot be read.
163
177
  */
164
- async function withReads(input) {
178
+ async function withReads(input, resolveRoot) {
165
179
  const reads = input.reads ?? [];
166
180
  if (reads.length === 0)
167
181
  return { input };
168
182
  const problems = stateReadsProblems(reads);
169
183
  if (problems.length > 0)
170
184
  throw new Error(`terraform-apply: root "${input.root}": ${problems.join("; ")}`);
171
- const filled = await fillStateReads(reads, async (root) => {
172
- const at = { root, ...(input.cwd ? { cwd: input.cwd } : {}) };
185
+ const filled = await fillStateReads(reads, async (root, read) => {
186
+ // terragucci issue 1303: the upstream's own directory, workspace, binary and environment, as terragucci's upstreamOutputs reads it.
187
+ const tools = resolveRoot ? await resolveRoot(root, { root, ...(input.cwd ? { cwd: input.cwd } : {}), ...(read.dir ? { dir: read.dir } : {}), ...(read.workspace ? { workspace: read.workspace } : {}) }) : undefined;
188
+ const at = {
189
+ root,
190
+ ...(input.cwd ? { cwd: input.cwd } : {}),
191
+ ...(read.dir ? { dir: read.dir } : {}),
192
+ ...(read.workspace ? { workspace: read.workspace } : {}),
193
+ ...(tools?.binary ? { binary: tools.binary } : {}),
194
+ ...(tools?.readEnv ? { env: tools.readEnv } : {}),
195
+ };
173
196
  await terraformInit(at);
174
197
  return terraformOutputs(at);
175
198
  });
@@ -188,20 +211,35 @@ function waitingOnReads(ctx, input, waiting) {
188
211
  };
189
212
  return { member: input.root, planDigest, changeSet };
190
213
  }
191
- const rootArgs = (input) => ({ root: input.root, ...(input.cwd ? { cwd: input.cwd } : {}), ...(input.dir ? { dir: input.dir } : {}) });
214
+ const rootArgs = (input, env) => ({
215
+ root: input.root,
216
+ ...(input.cwd ? { cwd: input.cwd } : {}),
217
+ ...(input.dir ? { dir: input.dir } : {}),
218
+ ...(env ? { env } : {}),
219
+ ...(input.workspace ? { workspace: input.workspace } : {}),
220
+ ...(input.binary ? { binary: input.binary } : {}),
221
+ });
192
222
  function requireRoot(input) {
193
223
  if (typeof input.root !== "string" || input.root === "") {
194
224
  throw new Error('terraform-apply: "root" is required and names an entry in terraform.roots');
195
225
  }
226
+ if (input.workspace !== undefined && (typeof input.workspace !== "string" || input.workspace.trim() === "")) {
227
+ throw new Error(`terraform-apply: root "${input.root}": workspace must name a workspace`);
228
+ }
229
+ if (input.binary !== undefined && (typeof input.binary !== "string" || input.binary.trim() === "")) {
230
+ throw new Error(`terraform-apply: root "${input.root}": binary must name a binary or its path`);
231
+ }
196
232
  }
197
- async function planRoot(input, targets) {
233
+ async function planRoot(input, targets, at = {}) {
198
234
  requireRoot(input);
199
- await terraformInit(rootArgs(input));
235
+ await terraformInit(rootArgs(input, at.env));
236
+ // chant#4842: the run hook's check, once init fetched the modules and providers and before the plan runs their code.
237
+ await at.afterInit?.();
200
238
  // One `show -json` per plan (#4479): its document is the digest, the change
201
239
  // set, the planned outputs and the shape. Nothing here reads the
202
240
  // `-no-color` render, so the plan skips it.
203
241
  const planned = await terraformPlan({
204
- ...rootArgs(input),
242
+ ...rootArgs(input, at.env),
205
243
  ...(input.vars ? { vars: input.vars } : {}),
206
244
  ...(targets && targets.length > 0 ? { targets } : {}),
207
245
  ...lockTimeoutOf(input),
@@ -316,16 +354,51 @@ function isShapeArtifact(value) {
316
354
  const v = value;
317
355
  return v?.kind === "terraform-apply-shape" && typeof v.digest === "string" && typeof v.shape === "object" && v.shape !== null;
318
356
  }
357
+ /** Each step input core passed, as it was filled (chant#4854, terragucci issue 1303), for the methods core calls with the input alone. */
358
+ const filledInputs = new WeakMap();
359
+ /**
360
+ * The step's input with `cwd` set to the caller's directory when it names
361
+ * none (chant#4854, `DeployContext.cwd`): an op wave run in process for
362
+ * another directory finds that directory's `chant.config.*`, not the
363
+ * process's. The input core passed is remembered, so `defaultLockGrain`,
364
+ * `lockGrainRefusal` and `traceFacts`, which get the input alone, read the
365
+ * same config.
366
+ */
367
+ export function withContextCwd(ctx, input) {
368
+ if (!input || typeof input !== "object" || input.cwd !== undefined || ctx?.cwd === undefined)
369
+ return input;
370
+ const filled = { ...input, cwd: ctx.cwd };
371
+ filledInputs.set(input, { ...filledInputs.get(input), ...filled });
372
+ return filled;
373
+ }
374
+ /** The step's input with `cwd` from the context and what `resolveRoot` answers for the root (terragucci issue 1303), remembered for the input core passed. */
375
+ async function filledInput(resolveRoot, ctx, input) {
376
+ const at = withContextCwd(ctx, input);
377
+ if (!resolveRoot || !at || typeof at !== "object" || typeof at.root !== "string" || at.root === "")
378
+ return at;
379
+ const tools = await resolveRoot(at.root, at);
380
+ if (tools?.binary !== undefined && (typeof tools.binary !== "string" || tools.binary.trim() === "")) {
381
+ throw new Error(`terraform-apply: root "${at.root}": the product's resolveRoot answered a binary that names nothing`);
382
+ }
383
+ if (!tools?.binary)
384
+ return at;
385
+ const filled = { ...at, binary: tools.binary };
386
+ filledInputs.set(input, filled);
387
+ return filled;
388
+ }
319
389
  /** The root's directory, as `terraform.roots` names it from the nearest `chant.config.*`, and the configured binary. */
320
- async function rootDir(input) {
390
+ async function rootDir(given) {
391
+ const input = filledInputs.get(given) ?? given;
321
392
  const start = resolve(input.cwd ?? process.cwd());
322
393
  const { config, configPath } = await loadChantConfigUpward(start);
323
394
  const terraform = config.terraform;
324
- const declared = terraform?.roots?.[input.root]?.dir;
395
+ // chant#4842: a root with no entry and a dir of its own is that directory.
396
+ const declared = terraform?.roots?.[input.root]?.dir ?? input.dir;
325
397
  if (declared === undefined)
326
398
  return undefined;
327
399
  const dir = input.dir ?? declared;
328
- return { dir: resolve(configPath ? dirname(configPath) : start, dir), ...(terraform?.binary ? { binary: terraform.binary } : {}) };
400
+ const binary = input.binary ?? terraform?.binary;
401
+ return { dir: resolve(configPath ? dirname(configPath) : start, dir), ...(binary ? { binary } : {}) };
329
402
  }
330
403
  const firstLines = (err) => {
331
404
  const text = (err instanceof Error ? err.message : String(err)).trim();
@@ -350,9 +423,10 @@ async function previewRoot(ctx, input, unresolved, targets) {
350
423
  return waitingRoot(ctx, input, unresolved, stand);
351
424
  let planned;
352
425
  try {
353
- await terraformInit(rootArgs(input));
426
+ await terraformInit(rootArgs(input, ctx.processEnv));
427
+ await ctx.afterInit?.();
354
428
  planned = await terraformPlan({
355
- ...rootArgs(input),
429
+ ...rootArgs(input, ctx.processEnv),
356
430
  vars: stand.vars,
357
431
  planFile: PREVIEW_PLAN_FILE,
358
432
  ...(targets ? { targets } : {}),
@@ -427,7 +501,7 @@ function isChoudoufuWavePlan(value) {
427
501
  /** Apply a choudoufu root through `live-wave-apply`, carrying its resume file either way. */
428
502
  async function runChoudoufuWave(ctx, input, planned) {
429
503
  const applied = await choudoufuWaveApply({
430
- ...rootArgs(input),
504
+ ...rootArgs(input, ctx.processEnv),
431
505
  planSetFile: planned.choudoufu.planSetFile,
432
506
  setDigest: planned.choudoufu.setDigest,
433
507
  ...(ctx.carried?.[input.root] !== undefined ? { carried: ctx.carried[input.root] } : {}),
@@ -440,12 +514,12 @@ async function runChoudoufuWave(ctx, input, planned) {
440
514
  throw new TerraformPlanMovedError(input.root, message);
441
515
  throw new Error(message);
442
516
  }
443
- const outputs = await terraformOutputs(rootArgs(input));
517
+ const outputs = await terraformOutputs(rootArgs(input, ctx.processEnv));
444
518
  return { root: input.root, planDigest: planned.planDigest, fromWavePlan: true, outputs };
445
519
  }
446
520
  /** The input a `run` that plans for itself plans with (#4545): its reads filled, or an error naming the upstream to apply first. */
447
- async function readsForRun(input) {
448
- const read = await withReads(input);
521
+ async function readsForRun(input, resolveRoot) {
522
+ const read = await withReads(input, resolveRoot);
449
523
  if ("waiting" in read)
450
524
  throw new Error(`terraform-apply: root "${input.root}": ${read.waiting}`);
451
525
  return read.input;
@@ -458,134 +532,162 @@ async function plannerOf(input, plan) {
458
532
  const planner = plan?.changeSet?.member.planner;
459
533
  return planner === "terraform" || planner === "tofu" || planner === "choudoufu" ? planner : "terraform";
460
534
  }
461
- export const terraformApplyCapability = {
462
- kind: "terraform-apply",
463
- // A root's apply has no undo short of applying the previous configuration,
464
- // which is a change of its own. COMP003 asks the component to say so.
465
- rollbackPolicy: "needs-opt-out",
466
- // #4300: `--target` passes through as `-target`, and the saved plan holds those addresses alone.
467
- targets: "accept",
468
- // #4627: `plan` refreshes the root's state before it plans unless told `-refresh=false`, which chant never passes,
469
- // so `--refresh` asks for what every plan does and the digest still binds it. `-target` plans a resource with what it
470
- // depends on and never what depends on it, so `--target-dependents` has nothing to map onto.
471
- planFlags: {
472
- refresh: "accept",
473
- targetDependents: { refuse: "terraform and tofu plan a -target with what it depends on, never what depends on it, so there is no flag to widen it to its dependents; name each dependent with --target" },
474
- },
475
- async plan(ctx, given) {
476
- requireRoot(given);
477
- // #4545: a root reading an upstream's output that is not there yet is a hole naming the upstream.
478
- const read = await withReads(given);
479
- if ("waiting" in read)
480
- return waitingOnReads(ctx, given, read);
481
- const { input } = read;
482
- const unresolved = [...(ctx.unresolvedInputs ?? [])].sort();
483
- const targets = ctx.targets && ctx.targets.length > 0 ? ctx.targets : undefined;
484
- if (unresolved.length > 0)
485
- return previewRoot(ctx, input, unresolved, targets);
486
- // A targeted root plans with `plan -target`, and a cone plan with `plan -cone` (#4545), never as a choudoufu one-root set.
487
- const wave = targets || input.cone ? { wave: false } : await choudoufuWaveRoot({ ...rootArgs(input), ...(input.vars ? { vars: input.vars } : {}) });
488
- if (wave.wave) {
489
- const set = await choudoufuPlanSet(rootArgs(input));
490
- const artifact = {
491
- planDigest: set.planDigest,
492
- choudoufu: { planSetFile: set.planSetFile, setDigest: set.setDigest },
493
- lockRows: terraformLockRows(input.root, set.changeSet.member.scope, set.json),
535
+ /**
536
+ * `terraform-apply` with `deps` in place of the defaults (terragucci issue
537
+ * 1303). `resolveRoot` answers what each root runs, so a product whose roots
538
+ * pin their own releases passes its resolver, as it passes `resolveUnit` to
539
+ * `terragruntApplyCapability`. A composed group (`together`) runs the
540
+ * project's binary, as before.
541
+ */
542
+ export function terraformApplyCapabilityWith(deps = {}) {
543
+ return {
544
+ kind: "terraform-apply",
545
+ // A root's apply has no undo short of applying the previous configuration,
546
+ // which is a change of its own. COMP003 asks the component to say so.
547
+ rollbackPolicy: "needs-opt-out",
548
+ // #4300: `--target` passes through as `-target`, and the saved plan holds those addresses alone.
549
+ targets: "accept",
550
+ // #4627: `plan` refreshes the root's state before it plans unless told `-refresh=false`, which chant never passes,
551
+ // so `--refresh` asks for what every plan does and the digest still binds it. `-target` plans a resource with what it
552
+ // depends on and never what depends on it, so `--target-dependents` has nothing to map onto.
553
+ planFlags: {
554
+ refresh: "accept",
555
+ targetDependents: { refuse: "terraform and tofu plan a -target with what it depends on, never what depends on it, so there is no flag to widen it to its dependents; name each dependent with --target" },
556
+ },
557
+ async plan(ctx, step) {
558
+ const given = await filledInput(deps.resolveRoot, ctx, step);
559
+ requireRoot(given);
560
+ // #4545: a root reading an upstream's output that is not there yet is a hole naming the upstream.
561
+ const read = await withReads(given, deps.resolveRoot);
562
+ if ("waiting" in read)
563
+ return waitingOnReads(ctx, given, read);
564
+ const { input } = read;
565
+ const unresolved = [...(ctx.unresolvedInputs ?? [])].sort();
566
+ const targets = ctx.targets && ctx.targets.length > 0 ? ctx.targets : undefined;
567
+ if (unresolved.length > 0)
568
+ return previewRoot(ctx, input, unresolved, targets);
569
+ // A targeted root plans with `plan -target`, and a cone plan with `plan -cone` (#4545), never as a choudoufu one-root set.
570
+ const env = ctx.processEnv;
571
+ const wave = targets || input.cone ? { wave: false } : await choudoufuWaveRoot({ ...rootArgs(input, env), ...(input.vars ? { vars: input.vars } : {}) });
572
+ if (wave.wave) {
573
+ // chant#4842: live-plan-set inits and plans in one command, so the run hook's check comes before it.
574
+ await ctx.afterInit?.();
575
+ const set = await choudoufuPlanSet(rootArgs(input, env));
576
+ const artifact = {
577
+ planDigest: set.planDigest,
578
+ choudoufu: { planSetFile: set.planSetFile, setDigest: set.setDigest },
579
+ lockRows: terraformLockRows(input.root, set.changeSet.member.scope, set.json),
580
+ };
581
+ return { member: input.root, planDigest: set.planDigest, artifact, changeSet: set.changeSet, outputs: terraformPlannedOutputs(set.json), shape: terraformPlanShape(set.json, input.root) };
582
+ }
583
+ const { changeSet, json, ...planned } = await planRoot(input, targets, { env, ...(ctx.afterInit ? { afterInit: ctx.afterInit } : {}) });
584
+ // #4552: a choudoufu root's rows, keyed from the plan document while it is at hand.
585
+ const lockRows = changeSet?.member.planner === "choudoufu" ? terraformLockRows(input.root, changeSet.member.scope, json) : undefined;
586
+ return {
587
+ member: input.root,
588
+ planDigest: planned.planDigest,
589
+ artifact: { ...planned, ...(lockRows ? { lockRows } : {}) },
590
+ ...(changeSet ? { changeSet } : {}),
591
+ // plywood#55: each changed resource's own digest, which a merged wave compares with the pull request's per resource.
592
+ resourceDigests: terraformResourceDigests(json),
593
+ outputs: terraformPlannedOutputs(json),
594
+ shape: terraformPlanShape(json, input.root),
595
+ ...(targets ? { targets } : {}),
494
596
  };
495
- return { member: input.root, planDigest: set.planDigest, artifact, changeSet: set.changeSet, outputs: terraformPlannedOutputs(set.json), shape: terraformPlanShape(set.json, input.root) };
496
- }
497
- const { changeSet, json, ...planned } = await planRoot(input, targets);
498
- // #4552: a choudoufu root's rows, keyed from the plan document while it is at hand.
499
- const lockRows = changeSet?.member.planner === "choudoufu" ? terraformLockRows(input.root, changeSet.member.scope, json) : undefined;
500
- return {
501
- member: input.root,
502
- planDigest: planned.planDigest,
503
- artifact: { ...planned, ...(lockRows ? { lockRows } : {}) },
504
- ...(changeSet ? { changeSet } : {}),
505
- // plywood#55: each changed resource's own digest, which a merged wave compares with the pull request's per resource.
506
- resourceDigests: terraformResourceDigests(json),
507
- outputs: terraformPlannedOutputs(json),
508
- shape: terraformPlanShape(json, input.root),
509
- ...(targets ? { targets } : {}),
510
- };
511
- },
512
- // The root's outputs as its state holds them now (#3183): what a dependent
513
- // planned before this root applies reads through `stackOutput()`.
514
- async outputs(_ctx, input) {
515
- requireRoot(input);
516
- await terraformInit(rootArgs(input));
517
- return terraformOutputs(rootArgs(input));
518
- },
519
- // #4447 (ws-107): a group core forms of components that read each other plans and applies as one composed run
520
- // when `terraform.compose.enabled` is set (./compose-group.ts). Delegates, so the methods are read when called.
521
- groupReads: (ctx, members) => terraformComposeGroup.groupReads(ctx, members),
522
- // #4542: a member pointed at a release's recorded copy plans alone, since a composition reads the declared roots.
523
- groupFallback: async (ctx, members) => members.some((m) => typeof m.step.dir === "string")
524
- ? { kind: "release-copy", reason: "a member deploys a release's recorded copy of its root, which a composition does not read" }
525
- : terraformComposeGroup.groupFallback(ctx, members),
526
- // #4542: the root's files, which a release cut records and a promote under it plans.
527
- releaseInputs: (input, ctx) => terraformReleaseInputs(input, ctx),
528
- // #4552: resource under choudoufu, the root under Terraform, tofu and Terragrunt, which refuse resource by name.
529
- async defaultLockGrain(input, plan) {
530
- return terraformDefaultLockGrain(await plannerOf(input, plan));
531
- },
532
- async lockGrainRefusal(input, grain, plan) {
533
- if (grain !== "resource")
534
- return undefined;
535
- const binary = (await rootDir(input).catch(() => undefined))?.binary;
536
- return terraformLockGrainRefusal(grain, await plannerOf(input, plan), binary);
537
- },
538
- // The ruling for ci-products (2026-10-28): a Terraform, tofu or Terragrunt root waits for its root row on the ledger in place of
539
- // the backend's lock. A choudoufu root stays on the resource grain and never asks for this row.
540
- targetLockRow(input) {
541
- return typeof input?.root === "string" && input.root !== "" ? { key: rootRowKey(input.root), target: input.root, address: input.root } : undefined;
542
- },
543
- lockRows(input, plan) {
544
- const kept = plan.artifact?.lockRows;
545
- if (Array.isArray(kept))
546
- return kept;
547
- return plan.changeSet ? terraformLockRowsFromPart(input.root, plan.changeSet) : [];
548
- },
549
- // #4555: the root and the binary, for the step's span and run record.
550
- traceFacts: async (input, outcome) => terraformTraceFacts(input, outcome, (await rootDir(input).catch(() => undefined))?.binary),
551
- planGroup: (ctx, members) => terraformComposeGroup.planGroup(ctx, members),
552
- runGroup: (ctx, run, members) => terraformComposeGroup.runGroup(ctx, run, members),
553
- async run(ctx, input) {
554
- const fromWave = ctx.plans?.[input.root];
555
- if (isChoudoufuWavePlan(fromWave))
556
- return runChoudoufuWave(ctx, input, fromWave);
557
- if (isShapeArtifact(fromWave)) {
558
- // A root previewed with stand-ins (#4463): plan it now with the real
559
- // values, and apply that plan only when it is within the preview's shape.
560
- const fresh = await planRoot(await readsForRun(input), ctx.targets);
561
- const differences = planShapeDifferences(fromWave.shape, terraformPlanShape(fresh.json, input.root));
562
- if (differences.length > 0)
563
- throw new PlanShapeMovedError(input.root, differences);
564
- const applied = await terraformApply({ ...rootArgs(input), planFile: fresh.planFile, ...lockTimeoutOf(input) });
597
+ },
598
+ // The root's outputs as its state holds them now (#3183): what a dependent
599
+ // planned before this root applies reads through `stackOutput()`.
600
+ async outputs(ctx, step) {
601
+ const input = await filledInput(deps.resolveRoot, ctx, step);
602
+ requireRoot(input);
603
+ await terraformInit(rootArgs(input, ctx.processEnv));
604
+ return terraformOutputs(rootArgs(input, ctx.processEnv));
605
+ },
606
+ // #4447 (ws-107): a group core forms of components that read each other plans and applies as one composed run
607
+ // when `terraform.compose.enabled` is set (./compose-group.ts). Delegates, so the methods are read when called.
608
+ groupReads: (ctx, members) => terraformComposeGroup.groupReads(ctx, members),
609
+ // #4542: a member pointed at a release's recorded copy plans alone, since a composition reads the declared roots.
610
+ groupFallback: async (ctx, members) => members.some((m) => typeof m.step.dir === "string")
611
+ ? { kind: "release-copy", reason: "a member deploys a release's recorded copy of its root, which a composition does not read" }
612
+ : terraformComposeGroup.groupFallback(ctx, members),
613
+ // #4542: the root's files, which a release cut records and a promote under it plans.
614
+ releaseInputs: (input, ctx) => terraformReleaseInputs(input, ctx),
615
+ // #4552: resource under choudoufu, the root under Terraform, tofu and Terragrunt, which refuse resource by name.
616
+ async defaultLockGrain(input, plan) {
617
+ return terraformDefaultLockGrain(await plannerOf(input, plan));
618
+ },
619
+ async lockGrainRefusal(input, grain, plan) {
620
+ if (grain !== "resource")
621
+ return undefined;
622
+ const binary = (await rootDir(input).catch(() => undefined))?.binary;
623
+ return terraformLockGrainRefusal(grain, await plannerOf(input, plan), binary);
624
+ },
625
+ // The ruling for ci-products (2026-10-28): a Terraform, tofu or Terragrunt root waits for its root row on the ledger in place of
626
+ // the backend's lock. A choudoufu root stays on the resource grain and never asks for this row.
627
+ targetLockRow(input) {
628
+ return typeof input?.root === "string" && input.root !== "" ? { key: rootRowKey(input.root), target: input.root, address: input.root } : undefined;
629
+ },
630
+ lockRows(input, plan) {
631
+ const kept = plan.artifact?.lockRows;
632
+ if (Array.isArray(kept))
633
+ return kept;
634
+ return plan.changeSet ? terraformLockRowsFromPart(input.root, plan.changeSet) : [];
635
+ },
636
+ // #4555: the root and the binary, for the step's span and run record.
637
+ traceFacts: async (input, outcome) => terraformTraceFacts(input, outcome, (await rootDir(input).catch(() => undefined))?.binary),
638
+ planGroup: (ctx, members) => {
639
+ // chant#4854: each member's lock grain reads the config at the wave's directory too.
640
+ for (const m of members)
641
+ if (m.input)
642
+ withContextCwd(m.ctx ?? ctx, m.input);
643
+ return terraformComposeGroup.planGroup(ctx, members);
644
+ },
645
+ runGroup: (ctx, run, members) => {
646
+ for (const m of members)
647
+ if (m.input)
648
+ withContextCwd(m.ctx ?? ctx, m.input);
649
+ return terraformComposeGroup.runGroup(ctx, run, members);
650
+ },
651
+ async run(ctx, step) {
652
+ const input = await filledInput(deps.resolveRoot, ctx, step);
653
+ const fromWave = ctx.plans?.[input.root];
654
+ if (isChoudoufuWavePlan(fromWave))
655
+ return runChoudoufuWave(ctx, input, fromWave);
656
+ if (isShapeArtifact(fromWave)) {
657
+ // A root previewed with stand-ins (#4463): plan it now with the real
658
+ // values, and apply that plan only when it is within the preview's shape.
659
+ const fresh = await planRoot(await readsForRun(input, deps.resolveRoot), ctx.targets, { env: ctx.processEnv });
660
+ const differences = planShapeDifferences(fromWave.shape, terraformPlanShape(fresh.json, input.root));
661
+ if (differences.length > 0)
662
+ throw new PlanShapeMovedError(input.root, differences);
663
+ const applied = await terraformApply({ ...rootArgs(input, ctx.processEnv), planFile: fresh.planFile, ...lockTimeoutOf(input) });
664
+ if (!applied.applied) {
665
+ throw new Error(`terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ${applied.refusal ?? ""}`);
666
+ }
667
+ const outputs = await terraformOutputs(rootArgs(input, ctx.processEnv));
668
+ return { root: input.root, planDigest: fresh.planDigest, fromWavePlan: false, outputs };
669
+ }
670
+ const planned = isPlannedRoot(fromWave)
671
+ ? fromWave
672
+ : await planRoot(await readsForRun(input, deps.resolveRoot), ctx.targets, { env: ctx.processEnv }).then(({ planFile, planDigest }) => ({ planFile, planDigest }));
673
+ const applied = await terraformApply({ ...rootArgs(input, ctx.processEnv), planFile: planned.planFile, ...lockTimeoutOf(input) });
565
674
  if (!applied.applied) {
566
- throw new Error(`terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ${applied.refusal ?? ""}`);
675
+ const message = `terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ` +
676
+ (applied.refusal ?? "");
677
+ // A plan the wave approved that choudoufu refuses as no longer matching
678
+ // moved since the approval (#4553: one made against another estate is a
679
+ // failure). One this run made itself is planned afresh by the next run.
680
+ if (applied.refused === "approval-mismatch" && isPlannedRoot(fromWave))
681
+ throw new TerraformPlanMovedError(input.root, message);
682
+ throw new Error(message);
567
683
  }
568
- const outputs = await terraformOutputs(rootArgs(input));
569
- return { root: input.root, planDigest: fresh.planDigest, fromWavePlan: false, outputs };
570
- }
571
- const planned = isPlannedRoot(fromWave)
572
- ? fromWave
573
- : await planRoot(await readsForRun(input), ctx.targets).then(({ planFile, planDigest }) => ({ planFile, planDigest }));
574
- const applied = await terraformApply({ ...rootArgs(input), planFile: planned.planFile, ...lockTimeoutOf(input) });
575
- if (!applied.applied) {
576
- const message = `terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ` +
577
- (applied.refusal ?? "");
578
- // A plan the wave approved that choudoufu refuses as no longer matching
579
- // moved since the approval (#4553: one made against another estate is a
580
- // failure). One this run made itself is planned afresh by the next run.
581
- if (applied.refused === "approval-mismatch" && isPlannedRoot(fromWave))
582
- throw new TerraformPlanMovedError(input.root, message);
583
- throw new Error(message);
584
- }
585
- const outputs = await terraformOutputs(rootArgs(input));
586
- return { root: input.root, planDigest: planned.planDigest, fromWavePlan: isPlannedRoot(fromWave), outputs };
587
- },
588
- };
684
+ const outputs = await terraformOutputs(rootArgs(input, ctx.processEnv));
685
+ return { root: input.root, planDigest: planned.planDigest, fromWavePlan: isPlannedRoot(fromWave), outputs };
686
+ },
687
+ };
688
+ }
689
+ /** `terraform-apply` with each root on the step's `binary`, else `terraform.binary`. */
690
+ export const terraformApplyCapability = terraformApplyCapabilityWith();
589
691
  export const TERRAFORM_VERB_FAMILIES = {
590
692
  apply: ["terraform-apply"],
591
693
  // #4618: the binary runs outside waves, each a fixed operation; the two that change state on their own run under a gated request.
@@ -600,7 +702,13 @@ export const terraformCapabilityPlugin = {
600
702
  return ownPackageVersion(import.meta.url);
601
703
  },
602
704
  capabilities() {
603
- return [terraformApplyCapability, ...terraformStateOpCapabilities.map((c) => c), terraformActionCapability];
705
+ return [
706
+ terraformApplyCapability,
707
+ ...terraformStateOpCapabilities.map((c) => c),
708
+ terraformActionCapability,
709
+ // #4842: Terragrunt units as an op wave's step, found at plan time and run with one run --all.
710
+ terragruntApply,
711
+ ];
604
712
  },
605
713
  families() {
606
714
  return TERRAFORM_VERB_FAMILIES;
@@ -70,7 +70,8 @@ export interface GroupRunnerOptions extends ComposeProject {
70
70
  /** What the group methods use, each replaceable in a test. */
71
71
  export interface ComposeGroupDeps {
72
72
  /** The project's config. Default: `loadChantConfigUpward` from the current directory. */
73
- project?: () => Promise<ComposeProject>;
73
+ /** The project at the group's directory (`GroupContext.cwd`, chant#4854), else at `process.cwd()`. */
74
+ project?: (cwd?: string) => Promise<ComposeProject>;
74
75
  /** The run for a composition. Default: `EstateRun` when `estate` is set, else `ComposedRun`. */
75
76
  runner?: (o: GroupRunnerOptions) => ComposedRunner;
76
77
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"compose-group.d.ts","sourceRoot":"","sources":["../../src/components/compose-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EAEnB,YAAY,EAEZ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AAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAWlH;AAiCD,+JAA+J;AAC/J,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,SAAS,QAAQ;IAC1B,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,IAAI,GAAE,gBAAqB,GAAG,mBAAmB,CAoI7E;AAED,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,EAAE,mBAAoC,CAAC"}
@@ -48,8 +48,8 @@ import { runBinary } from "../state/exec.js";
48
48
  import { estateVersionFallback, EstateRun } from "../compose/estate.js";
49
49
  import { ComposedRun } from "../compose/run.js";
50
50
  import { relPath, rootTexts } from "../compose/hcl.js";
51
- async function loadProject() {
52
- const start = resolve(process.cwd());
51
+ async function loadProject(cwd) {
52
+ const start = resolve(cwd ?? process.cwd());
53
53
  const { config, configPath } = await loadChantConfigUpward(start);
54
54
  const projectRoot = configPath ? dirname(configPath) : start;
55
55
  const terraform = config.terraform;
@@ -277,7 +277,7 @@ export function composeGroup(deps = {}) {
277
277
  }
278
278
  /** The composition the group plans as, or throws when it does not compose. */
279
279
  async function composed(ctx, members) {
280
- const p = await project();
280
+ const p = await project(ctx.cwd);
281
281
  const off = composeOff(p.terraform);
282
282
  if (off)
283
283
  throw new Error(off.reason);
@@ -313,14 +313,14 @@ export function composeGroup(deps = {}) {
313
313
  }
314
314
  }
315
315
  return {
316
- async groupReads(_ctx, members) {
317
- const p = await project();
316
+ async groupReads(ctx, members) {
317
+ const p = await project(ctx.cwd);
318
318
  if (composeOff(p.terraform))
319
319
  return [];
320
320
  return hclGroupReads(p, members);
321
321
  },
322
322
  async groupFallback(ctx, members) {
323
- const p = await project();
323
+ const p = await project(ctx.cwd);
324
324
  const off = composeOff(p.terraform);
325
325
  if (off)
326
326
  return { kind: off.kind, reason: off.reason };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { terraformPlugin } from "./plugin.js";
2
- export { terraformCapabilityPlugin, terraformApplyCapability, TerraformPlanMovedError, TERRAFORM_VERB_FAMILIES, choudoufuOutputSource, choudoufuMemberPlannedOutputs, type TerraformApplyStepInput, type TerraformApplyStepOutput, } from "./components/capability-plugin.js";
2
+ export { terraformCapabilityPlugin, terraformApplyCapability, terraformApplyCapabilityWith, type TerraformApplyDeps, type TerraformRootResolver, type TerraformRootTools, TerraformPlanMovedError, TERRAFORM_VERB_FAMILIES, choudoufuOutputSource, choudoufuMemberPlannedOutputs, type TerraformApplyStepInput, type TerraformApplyStepOutput, } from "./components/capability-plugin.js";
3
3
  export { mergeStates, splitState, splitStates, derivedLineage, COMPOSE_LINEAGE, type SplitState } from "./compose/state-merge.js";
4
4
  export { slicePlan as sliceComposedPlan, sliceText, planCounts, composedReads, composedMemberPlans, type PlanCounts, type ComposedMemberRead, type ComposedMemberPlan, type ComposedMemberPlansOptions, } from "./compose/slice.js";
5
5
  export { readApplyEvents, memberApply, composedApplyOutcomes, type ApplyEvents, type MemberApply, type MemberApplyOutcome } from "./compose/apply-events.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EAEvB,qBAAqB,EACrB,6BAA6B,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,gCAAgC,CAAC;AAIxC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/H,OAAO,EACL,SAAS,IAAI,iBAAiB,EAC9B,SAAS,EACT,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KA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2BAA2B,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAKzH,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAQnE,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,gCAAgC,EACrC,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,9 @@ export { terraformPlugin } from "./plugin.js";
4
4
  // capability-plugin seam. Core loads `terraformCapabilityPlugin` when a
5
5
  // project's chant.config lists this lexicon, so a component can deploy a root
6
6
  // and a fan-out can run many of them in gated waves.
7
- export { terraformCapabilityPlugin, terraformApplyCapability, TerraformPlanMovedError, TERRAFORM_VERB_FAMILIES,
7
+ export { terraformCapabilityPlugin, terraformApplyCapability,
8
+ // terragucci issue 1303: a product's resolver of what each root runs.
9
+ terraformApplyCapabilityWith, TerraformPlanMovedError, TERRAFORM_VERB_FAMILIES,
8
10
  // #4455: a choudoufu member's outputs, read for core's `member-outputs`.
9
11
  choudoufuOutputSource, choudoufuMemberPlannedOutputs, } from "./components/capability-plugin.js";
10
12
  // Composed runs (#4442): the working state merged and split, the composed