@intentius/chant-lexicon-terraform 0.124.79 → 0.124.81

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 (42) hide show
  1. package/dist/components/capability-plugin.d.ts +74 -1
  2. package/dist/components/capability-plugin.d.ts.map +1 -1
  3. package/dist/components/capability-plugin.js +239 -138
  4. package/dist/components/compose-group.d.ts +2 -1
  5. package/dist/components/compose-group.d.ts.map +1 -1
  6. package/dist/components/compose-group.js +6 -6
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -1
  10. package/dist/init-turn.d.ts +21 -0
  11. package/dist/init-turn.d.ts.map +1 -0
  12. package/dist/init-turn.js +30 -0
  13. package/dist/integrity.json +2 -2
  14. package/dist/manifest.json +1 -1
  15. package/dist/op/activities/terraform.d.ts +22 -0
  16. package/dist/op/activities/terraform.d.ts.map +1 -1
  17. package/dist/op/activities/terraform.js +29 -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 +5 -0
  22. package/dist/terragrunt/capability.d.ts.map +1 -1
  23. package/dist/terragrunt/capability.js +21 -7
  24. package/dist/terragrunt/run.d.ts +8 -0
  25. package/dist/terragrunt/run.d.ts.map +1 -1
  26. package/dist/terragrunt/run.js +12 -6
  27. package/dist/terragrunt/wave.d.ts +9 -0
  28. package/dist/terragrunt/wave.d.ts.map +1 -1
  29. package/dist/terragrunt/wave.js +22 -0
  30. package/package.json +2 -2
  31. package/src/components/capability-plugin.ts +279 -135
  32. package/src/components/compose-group.ts +8 -7
  33. package/src/components/terraform-apply-op-wave.test.ts +295 -0
  34. package/src/components/terraform-apply-parallel.test.ts +158 -0
  35. package/src/index.ts +5 -0
  36. package/src/init-turn.ts +36 -0
  37. package/src/op/activities/terraform.ts +45 -4
  38. package/src/state-reads.ts +23 -5
  39. package/src/terragrunt/capability.test.ts +94 -0
  40. package/src/terragrunt/capability.ts +22 -7
  41. package/src/terragrunt/run.ts +18 -4
  42. package/src/terragrunt/wave.ts +22 -0
@@ -119,6 +119,11 @@
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
+ *
122
127
  * A wave's run hooks in the product's process (chant#4842) reach the step
123
128
  * through its context. `processEnv` goes to every command for the root (a
124
129
  * role's credentials, values from a secret store), and `afterInit` is
@@ -127,6 +132,14 @@
127
132
  * plans the step's `dir` as its directory, so a product can name each root
128
133
  * by its path without writing an entry for it.
129
134
  *
135
+ * A wave that plans and applies several roots at once (chant#4864) gives
136
+ * each run its serial section (`DeployContext.serial`). Every `init` the
137
+ * step runs, a root's own and an upstream's for its `reads`, takes its turn
138
+ * there (`../init-turn.ts`): one at a time among the runs that share a
139
+ * provider cache, else one at a time per directory. A choudoufu one-root
140
+ * set's `live-plan-set` inits as it plans, so with a shared cache the whole
141
+ * command takes the turn.
142
+ *
130
143
  * Every plan also writes its `show -json` beside the plan file and names it
131
144
  * as `artifact.planJson`, the document a wave's cost hold prices
132
145
  * (`../cost-hold.ts`).
@@ -142,7 +155,7 @@ export interface TerraformApplyStepInput {
142
155
  root: string;
143
156
  /** Input variables, after the root's var files. See `TerraformPlanArgs.vars`. */
144
157
  vars?: Record<string, unknown>;
145
- /** Where the `chant.config.*` search starts. Default: the current directory. */
158
+ /** Where the `chant.config.*` search starts. Default: the directory the caller runs the step in (`DeployContext.cwd`, an op wave's `cwd`, chant#4854), else the current directory. */
146
159
  cwd?: string;
147
160
  /** The root's files from here instead of its entry's `dir` (#4542): a promote under a release sets it to the recorded copy. */
148
161
  dir?: string;
@@ -152,6 +165,46 @@ export interface TerraformApplyStepInput {
152
165
  cone?: string;
153
166
  /** Vars read from other roots' outputs (#4545), Atmos's `!terraform.state`. The step's `vars` win over them. */
154
167
  reads?: TerraformStateRead[];
168
+ /**
169
+ * The workspace the root plans and applies in (chant#4854), such as an
170
+ * Atmos instance's. `init` runs in `default`, then `workspace select
171
+ * -or-create=true` selects it, creating it when the backend does not list
172
+ * it yet, and plan, apply and output run with `TF_WORKSPACE` set to it.
173
+ * Absent: the entry's `workspace`, or the run's environment, as before.
174
+ */
175
+ workspace?: string;
176
+ /**
177
+ * The binary the root runs, a name on `PATH` or a path, in place of
178
+ * `terraform.binary` (terragucci issue 1303): a root that pins its own
179
+ * terraform or tofu release. A product's {@link TerraformRootResolver}
180
+ * sets it per root. Absent: `terraform.binary`, as before.
181
+ */
182
+ binary?: string;
183
+ }
184
+ /** What a root runs in place of the step's (terragucci issue 1303). An unset field runs the step's. */
185
+ export interface TerraformRootTools {
186
+ /** The binary, a name on `PATH` or a path. See {@link TerraformApplyStepInput.binary}. */
187
+ binary?: string;
188
+ /**
189
+ * The environment a read of this root's state runs with over the job's,
190
+ * when another root's `reads` name it as their upstream (terragucci issue
191
+ * 1303): its role's credentials, never the reader's. The root's own plan
192
+ * and apply take theirs from the run hooks (`DeployContext.processEnv`).
193
+ */
194
+ readEnv?: Record<string, string>;
195
+ }
196
+ /**
197
+ * What a root runs (terragucci issue 1303), asked once per plan and per
198
+ * apply with the root and the step's input, as `terragrunt-apply`'s
199
+ * `resolveUnit` is asked per unit. A product passes its own, which installs
200
+ * a pinned release and checks its version, so a root runs what it plans
201
+ * with whatever `chant.config.ts` names.
202
+ */
203
+ export type TerraformRootResolver = (root: string, input: TerraformApplyStepInput) => TerraformRootTools | Promise<TerraformRootTools>;
204
+ /** What {@link terraformApplyCapabilityWith} takes. */
205
+ export interface TerraformApplyDeps {
206
+ /** What each root runs. Default: the step's `binary`, else `terraform.binary`. */
207
+ resolveRoot?: TerraformRootResolver;
155
208
  }
156
209
  /** What `terraform-apply` returns. `outputs` is what a dependent's `stackOutput()` reads. */
157
210
  export interface TerraformApplyStepOutput {
@@ -193,6 +246,17 @@ export declare const PREVIEW_PLAN_FILE = ".chant-preview.tfplan";
193
246
  export interface TerraformShapeArtifact extends PlanShapeArtifact {
194
247
  kind: "terraform-apply-shape";
195
248
  }
249
+ /**
250
+ * The step's input with `cwd` set to the caller's directory when it names
251
+ * none (chant#4854, `DeployContext.cwd`): an op wave run in process for
252
+ * another directory finds that directory's `chant.config.*`, not the
253
+ * process's. The input core passed is remembered, so `defaultLockGrain`,
254
+ * `lockGrainRefusal` and `traceFacts`, which get the input alone, read the
255
+ * same config.
256
+ */
257
+ export declare function withContextCwd(ctx: {
258
+ cwd?: string;
259
+ } | undefined, input: TerraformApplyStepInput): TerraformApplyStepInput;
196
260
  /**
197
261
  * choudoufu refused the plan `run` was handed by its wave (its exit 3)
198
262
  * because the live system moved since the plan. Nothing was applied.
@@ -206,6 +270,15 @@ export declare class TerraformPlanMovedError extends Error {
206
270
  readonly planMoved = true;
207
271
  constructor(root: string, message: string);
208
272
  }
273
+ /**
274
+ * `terraform-apply` with `deps` in place of the defaults (terragucci issue
275
+ * 1303). `resolveRoot` answers what each root runs, so a product whose roots
276
+ * pin their own releases passes its resolver, as it passes `resolveUnit` to
277
+ * `terragruntApplyCapability`. A composed group (`together`) runs the
278
+ * project's binary, as before.
279
+ */
280
+ export declare function terraformApplyCapabilityWith(deps?: TerraformApplyDeps): Capability<TerraformApplyStepInput, TerraformApplyStepOutput>;
281
+ /** `terraform-apply` with each root on the step's `binary`, else `terraform.binary`. */
209
282
  export declare const terraformApplyCapability: Capability<TerraformApplyStepInput, TerraformApplyStepOutput>;
210
283
  export declare const TERRAFORM_VERB_FAMILIES: {
211
284
  readonly apply: readonly ["terraform-apply"];
@@ -1 +1 @@
1
- {"version":3,"file":"capability-plugin.d.ts","sourceRoot":"","sources":["../../src/components/capability-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAuB;aAClC,KAAK,YAAG,iBAAiB;aAEzB,KAAK,YAAG,wBAAwB,EAAE,sBAAsB;aACxD,IAAI,YAAG,gBAAgB;aAEvB,MAAM,YAAG,kBAAkB;CACnB,CAAC;AAEX,eAAO,MAAM,yBAAyB,EAAE,gBAoBvC,CAAC"}
@@ -119,6 +119,11 @@
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
+ *
122
127
  * A wave's run hooks in the product's process (chant#4842) reach the step
123
128
  * through its context. `processEnv` goes to every command for the root (a
124
129
  * role's credentials, values from a secret store), and `afterInit` is
@@ -127,6 +132,14 @@
127
132
  * plans the step's `dir` as its directory, so a product can name each root
128
133
  * by its path without writing an entry for it.
129
134
  *
135
+ * A wave that plans and applies several roots at once (chant#4864) gives
136
+ * each run its serial section (`DeployContext.serial`). Every `init` the
137
+ * step runs, a root's own and an upstream's for its `reads`, takes its turn
138
+ * there (`../init-turn.ts`): one at a time among the runs that share a
139
+ * provider cache, else one at a time per directory. A choudoufu one-root
140
+ * set's `live-plan-set` inits as it plans, so with a shared cache the whole
141
+ * command takes the turn.
142
+ *
130
143
  * Every plan also writes its `show -json` beside the plan file and names it
131
144
  * as `artifact.planJson`, the document a wave's cost hold prices
132
145
  * (`../cost-hold.ts`).
@@ -156,6 +169,7 @@ import { fillStateReads, stateReadsProblems, waitingReadsReason } from "../state
156
169
  import { terraformStateOpCapabilities } from "../state-ops.js";
157
170
  import { terraformActionCapability } from "../action-ops.js";
158
171
  import { terragruntApply } from "../terragrunt/capability.js";
172
+ import { inInitTurn, pluginCacheDir } from "../init-turn.js";
159
173
  /** The lock timeout a step's plan and apply pass (#4545). */
160
174
  function lockTimeoutOf(input) {
161
175
  if (input.lockTimeout === false)
@@ -170,16 +184,26 @@ function lockTimeoutOf(input) {
170
184
  * read once, the values under the step's own `vars`. `waiting` when an
171
185
  * upstream has no such output yet. Throws when a state cannot be read.
172
186
  */
173
- async function withReads(input) {
187
+ async function withReads(input, resolveRoot, serial) {
174
188
  const reads = input.reads ?? [];
175
189
  if (reads.length === 0)
176
190
  return { input };
177
191
  const problems = stateReadsProblems(reads);
178
192
  if (problems.length > 0)
179
193
  throw new Error(`terraform-apply: root "${input.root}": ${problems.join("; ")}`);
180
- const filled = await fillStateReads(reads, async (root) => {
181
- const at = { root, ...(input.cwd ? { cwd: input.cwd } : {}) };
182
- await terraformInit(at);
194
+ const filled = await fillStateReads(reads, async (root, read) => {
195
+ // terragucci issue 1303: the upstream's own directory, workspace, binary and environment, as terragucci's upstreamOutputs reads it.
196
+ const tools = resolveRoot ? await resolveRoot(root, { root, ...(input.cwd ? { cwd: input.cwd } : {}), ...(read.dir ? { dir: read.dir } : {}), ...(read.workspace ? { workspace: read.workspace } : {}) }) : undefined;
197
+ const at = {
198
+ root,
199
+ ...(input.cwd ? { cwd: input.cwd } : {}),
200
+ ...(read.dir ? { dir: read.dir } : {}),
201
+ ...(read.workspace ? { workspace: read.workspace } : {}),
202
+ ...(tools?.binary ? { binary: tools.binary } : {}),
203
+ ...(tools?.readEnv ? { env: tools.readEnv } : {}),
204
+ };
205
+ // chant#4864: runs that plan at once may read the same upstream, so its init takes a turn.
206
+ await inInitTurn(serial, at.env, initDir(at), () => terraformInit(at));
183
207
  return terraformOutputs(at);
184
208
  });
185
209
  if (filled.errors.length > 0)
@@ -197,15 +221,32 @@ function waitingOnReads(ctx, input, waiting) {
197
221
  };
198
222
  return { member: input.root, planDigest, changeSet };
199
223
  }
200
- const rootArgs = (input, env) => ({ root: input.root, ...(input.cwd ? { cwd: input.cwd } : {}), ...(input.dir ? { dir: input.dir } : {}), ...(env ? { env } : {}) });
224
+ const rootArgs = (input, env) => ({
225
+ root: input.root,
226
+ ...(input.cwd ? { cwd: input.cwd } : {}),
227
+ ...(input.dir ? { dir: input.dir } : {}),
228
+ ...(env ? { env } : {}),
229
+ ...(input.workspace ? { workspace: input.workspace } : {}),
230
+ ...(input.binary ? { binary: input.binary } : {}),
231
+ });
232
+ /** The directory an init runs in, as far as the step's input says, for its turn when no provider cache is shared (chant#4864). */
233
+ const initDir = (at) => join(at.cwd ?? process.cwd(), at.dir ?? at.root);
234
+ /** `terraform init` of `input`'s root in its turn (chant#4864). */
235
+ const initRoot = (input, env, serial) => inInitTurn(serial, env, initDir(rootArgs(input, env)), () => terraformInit(rootArgs(input, env)));
201
236
  function requireRoot(input) {
202
237
  if (typeof input.root !== "string" || input.root === "") {
203
238
  throw new Error('terraform-apply: "root" is required and names an entry in terraform.roots');
204
239
  }
240
+ if (input.workspace !== undefined && (typeof input.workspace !== "string" || input.workspace.trim() === "")) {
241
+ throw new Error(`terraform-apply: root "${input.root}": workspace must name a workspace`);
242
+ }
243
+ if (input.binary !== undefined && (typeof input.binary !== "string" || input.binary.trim() === "")) {
244
+ throw new Error(`terraform-apply: root "${input.root}": binary must name a binary or its path`);
245
+ }
205
246
  }
206
247
  async function planRoot(input, targets, at = {}) {
207
248
  requireRoot(input);
208
- await terraformInit(rootArgs(input, at.env));
249
+ await initRoot(input, at.env, at.serial);
209
250
  // chant#4842: the run hook's check, once init fetched the modules and providers and before the plan runs their code.
210
251
  await at.afterInit?.();
211
252
  // One `show -json` per plan (#4479): its document is the digest, the change
@@ -327,8 +368,41 @@ function isShapeArtifact(value) {
327
368
  const v = value;
328
369
  return v?.kind === "terraform-apply-shape" && typeof v.digest === "string" && typeof v.shape === "object" && v.shape !== null;
329
370
  }
371
+ /** Each step input core passed, as it was filled (chant#4854, terragucci issue 1303), for the methods core calls with the input alone. */
372
+ const filledInputs = new WeakMap();
373
+ /**
374
+ * The step's input with `cwd` set to the caller's directory when it names
375
+ * none (chant#4854, `DeployContext.cwd`): an op wave run in process for
376
+ * another directory finds that directory's `chant.config.*`, not the
377
+ * process's. The input core passed is remembered, so `defaultLockGrain`,
378
+ * `lockGrainRefusal` and `traceFacts`, which get the input alone, read the
379
+ * same config.
380
+ */
381
+ export function withContextCwd(ctx, input) {
382
+ if (!input || typeof input !== "object" || input.cwd !== undefined || ctx?.cwd === undefined)
383
+ return input;
384
+ const filled = { ...input, cwd: ctx.cwd };
385
+ filledInputs.set(input, { ...filledInputs.get(input), ...filled });
386
+ return filled;
387
+ }
388
+ /** 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. */
389
+ async function filledInput(resolveRoot, ctx, input) {
390
+ const at = withContextCwd(ctx, input);
391
+ if (!resolveRoot || !at || typeof at !== "object" || typeof at.root !== "string" || at.root === "")
392
+ return at;
393
+ const tools = await resolveRoot(at.root, at);
394
+ if (tools?.binary !== undefined && (typeof tools.binary !== "string" || tools.binary.trim() === "")) {
395
+ throw new Error(`terraform-apply: root "${at.root}": the product's resolveRoot answered a binary that names nothing`);
396
+ }
397
+ if (!tools?.binary)
398
+ return at;
399
+ const filled = { ...at, binary: tools.binary };
400
+ filledInputs.set(input, filled);
401
+ return filled;
402
+ }
330
403
  /** The root's directory, as `terraform.roots` names it from the nearest `chant.config.*`, and the configured binary. */
331
- async function rootDir(input) {
404
+ async function rootDir(given) {
405
+ const input = filledInputs.get(given) ?? given;
332
406
  const start = resolve(input.cwd ?? process.cwd());
333
407
  const { config, configPath } = await loadChantConfigUpward(start);
334
408
  const terraform = config.terraform;
@@ -337,7 +411,8 @@ async function rootDir(input) {
337
411
  if (declared === undefined)
338
412
  return undefined;
339
413
  const dir = input.dir ?? declared;
340
- return { dir: resolve(configPath ? dirname(configPath) : start, dir), ...(terraform?.binary ? { binary: terraform.binary } : {}) };
414
+ const binary = input.binary ?? terraform?.binary;
415
+ return { dir: resolve(configPath ? dirname(configPath) : start, dir), ...(binary ? { binary } : {}) };
341
416
  }
342
417
  const firstLines = (err) => {
343
418
  const text = (err instanceof Error ? err.message : String(err)).trim();
@@ -362,7 +437,7 @@ async function previewRoot(ctx, input, unresolved, targets) {
362
437
  return waitingRoot(ctx, input, unresolved, stand);
363
438
  let planned;
364
439
  try {
365
- await terraformInit(rootArgs(input, ctx.processEnv));
440
+ await initRoot(input, ctx.processEnv, ctx.serial);
366
441
  await ctx.afterInit?.();
367
442
  planned = await terraformPlan({
368
443
  ...rootArgs(input, ctx.processEnv),
@@ -457,8 +532,8 @@ async function runChoudoufuWave(ctx, input, planned) {
457
532
  return { root: input.root, planDigest: planned.planDigest, fromWavePlan: true, outputs };
458
533
  }
459
534
  /** The input a `run` that plans for itself plans with (#4545): its reads filled, or an error naming the upstream to apply first. */
460
- async function readsForRun(input) {
461
- const read = await withReads(input);
535
+ async function readsForRun(input, resolveRoot, serial) {
536
+ const read = await withReads(input, resolveRoot, serial);
462
537
  if ("waiting" in read)
463
538
  throw new Error(`terraform-apply: root "${input.root}": ${read.waiting}`);
464
539
  return read.input;
@@ -471,137 +546,163 @@ async function plannerOf(input, plan) {
471
546
  const planner = plan?.changeSet?.member.planner;
472
547
  return planner === "terraform" || planner === "tofu" || planner === "choudoufu" ? planner : "terraform";
473
548
  }
474
- export const terraformApplyCapability = {
475
- kind: "terraform-apply",
476
- // A root's apply has no undo short of applying the previous configuration,
477
- // which is a change of its own. COMP003 asks the component to say so.
478
- rollbackPolicy: "needs-opt-out",
479
- // #4300: `--target` passes through as `-target`, and the saved plan holds those addresses alone.
480
- targets: "accept",
481
- // #4627: `plan` refreshes the root's state before it plans unless told `-refresh=false`, which chant never passes,
482
- // so `--refresh` asks for what every plan does and the digest still binds it. `-target` plans a resource with what it
483
- // depends on and never what depends on it, so `--target-dependents` has nothing to map onto.
484
- planFlags: {
485
- refresh: "accept",
486
- 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" },
487
- },
488
- async plan(ctx, given) {
489
- requireRoot(given);
490
- // #4545: a root reading an upstream's output that is not there yet is a hole naming the upstream.
491
- const read = await withReads(given);
492
- if ("waiting" in read)
493
- return waitingOnReads(ctx, given, read);
494
- const { input } = read;
495
- const unresolved = [...(ctx.unresolvedInputs ?? [])].sort();
496
- const targets = ctx.targets && ctx.targets.length > 0 ? ctx.targets : undefined;
497
- if (unresolved.length > 0)
498
- return previewRoot(ctx, input, unresolved, targets);
499
- // A targeted root plans with `plan -target`, and a cone plan with `plan -cone` (#4545), never as a choudoufu one-root set.
500
- const env = ctx.processEnv;
501
- const wave = targets || input.cone ? { wave: false } : await choudoufuWaveRoot({ ...rootArgs(input, env), ...(input.vars ? { vars: input.vars } : {}) });
502
- if (wave.wave) {
503
- // chant#4842: live-plan-set inits and plans in one command, so the run hook's check comes before it.
504
- await ctx.afterInit?.();
505
- const set = await choudoufuPlanSet(rootArgs(input, env));
506
- const artifact = {
507
- planDigest: set.planDigest,
508
- choudoufu: { planSetFile: set.planSetFile, setDigest: set.setDigest },
509
- lockRows: terraformLockRows(input.root, set.changeSet.member.scope, set.json),
549
+ /**
550
+ * `terraform-apply` with `deps` in place of the defaults (terragucci issue
551
+ * 1303). `resolveRoot` answers what each root runs, so a product whose roots
552
+ * pin their own releases passes its resolver, as it passes `resolveUnit` to
553
+ * `terragruntApplyCapability`. A composed group (`together`) runs the
554
+ * project's binary, as before.
555
+ */
556
+ export function terraformApplyCapabilityWith(deps = {}) {
557
+ return {
558
+ kind: "terraform-apply",
559
+ // A root's apply has no undo short of applying the previous configuration,
560
+ // which is a change of its own. COMP003 asks the component to say so.
561
+ rollbackPolicy: "needs-opt-out",
562
+ // #4300: `--target` passes through as `-target`, and the saved plan holds those addresses alone.
563
+ targets: "accept",
564
+ // #4627: `plan` refreshes the root's state before it plans unless told `-refresh=false`, which chant never passes,
565
+ // so `--refresh` asks for what every plan does and the digest still binds it. `-target` plans a resource with what it
566
+ // depends on and never what depends on it, so `--target-dependents` has nothing to map onto.
567
+ planFlags: {
568
+ refresh: "accept",
569
+ 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" },
570
+ },
571
+ async plan(ctx, step) {
572
+ const given = await filledInput(deps.resolveRoot, ctx, step);
573
+ requireRoot(given);
574
+ // #4545: a root reading an upstream's output that is not there yet is a hole naming the upstream.
575
+ const read = await withReads(given, deps.resolveRoot, ctx.serial);
576
+ if ("waiting" in read)
577
+ return waitingOnReads(ctx, given, read);
578
+ const { input } = read;
579
+ const unresolved = [...(ctx.unresolvedInputs ?? [])].sort();
580
+ const targets = ctx.targets && ctx.targets.length > 0 ? ctx.targets : undefined;
581
+ if (unresolved.length > 0)
582
+ return previewRoot(ctx, input, unresolved, targets);
583
+ // A targeted root plans with `plan -target`, and a cone plan with `plan -cone` (#4545), never as a choudoufu one-root set.
584
+ const env = ctx.processEnv;
585
+ const wave = targets || input.cone ? { wave: false } : await choudoufuWaveRoot({ ...rootArgs(input, env), ...(input.vars ? { vars: input.vars } : {}) });
586
+ if (wave.wave) {
587
+ // chant#4842: live-plan-set inits and plans in one command, so the run hook's check comes before it.
588
+ await ctx.afterInit?.();
589
+ // chant#4864: live-plan-set inits too, so with a shared provider cache the whole command takes the init's turn.
590
+ const set = await inInitTurn(pluginCacheDir(env) ? ctx.serial : undefined, env, undefined, () => choudoufuPlanSet(rootArgs(input, env)));
591
+ const artifact = {
592
+ planDigest: set.planDigest,
593
+ choudoufu: { planSetFile: set.planSetFile, setDigest: set.setDigest },
594
+ lockRows: terraformLockRows(input.root, set.changeSet.member.scope, set.json),
595
+ };
596
+ return { member: input.root, planDigest: set.planDigest, artifact, changeSet: set.changeSet, outputs: terraformPlannedOutputs(set.json), shape: terraformPlanShape(set.json, input.root) };
597
+ }
598
+ const { changeSet, json, ...planned } = await planRoot(input, targets, { env, ...(ctx.afterInit ? { afterInit: ctx.afterInit } : {}), ...(ctx.serial ? { serial: ctx.serial } : {}) });
599
+ // #4552: a choudoufu root's rows, keyed from the plan document while it is at hand.
600
+ const lockRows = changeSet?.member.planner === "choudoufu" ? terraformLockRows(input.root, changeSet.member.scope, json) : undefined;
601
+ return {
602
+ member: input.root,
603
+ planDigest: planned.planDigest,
604
+ artifact: { ...planned, ...(lockRows ? { lockRows } : {}) },
605
+ ...(changeSet ? { changeSet } : {}),
606
+ // plywood#55: each changed resource's own digest, which a merged wave compares with the pull request's per resource.
607
+ resourceDigests: terraformResourceDigests(json),
608
+ outputs: terraformPlannedOutputs(json),
609
+ shape: terraformPlanShape(json, input.root),
610
+ ...(targets ? { targets } : {}),
510
611
  };
511
- return { member: input.root, planDigest: set.planDigest, artifact, changeSet: set.changeSet, outputs: terraformPlannedOutputs(set.json), shape: terraformPlanShape(set.json, input.root) };
512
- }
513
- const { changeSet, json, ...planned } = await planRoot(input, targets, { env, ...(ctx.afterInit ? { afterInit: ctx.afterInit } : {}) });
514
- // #4552: a choudoufu root's rows, keyed from the plan document while it is at hand.
515
- const lockRows = changeSet?.member.planner === "choudoufu" ? terraformLockRows(input.root, changeSet.member.scope, json) : undefined;
516
- return {
517
- member: input.root,
518
- planDigest: planned.planDigest,
519
- artifact: { ...planned, ...(lockRows ? { lockRows } : {}) },
520
- ...(changeSet ? { changeSet } : {}),
521
- // plywood#55: each changed resource's own digest, which a merged wave compares with the pull request's per resource.
522
- resourceDigests: terraformResourceDigests(json),
523
- outputs: terraformPlannedOutputs(json),
524
- shape: terraformPlanShape(json, input.root),
525
- ...(targets ? { targets } : {}),
526
- };
527
- },
528
- // The root's outputs as its state holds them now (#3183): what a dependent
529
- // planned before this root applies reads through `stackOutput()`.
530
- async outputs(ctx, input) {
531
- requireRoot(input);
532
- await terraformInit(rootArgs(input, ctx.processEnv));
533
- return terraformOutputs(rootArgs(input, ctx.processEnv));
534
- },
535
- // #4447 (ws-107): a group core forms of components that read each other plans and applies as one composed run
536
- // when `terraform.compose.enabled` is set (./compose-group.ts). Delegates, so the methods are read when called.
537
- groupReads: (ctx, members) => terraformComposeGroup.groupReads(ctx, members),
538
- // #4542: a member pointed at a release's recorded copy plans alone, since a composition reads the declared roots.
539
- groupFallback: async (ctx, members) => members.some((m) => typeof m.step.dir === "string")
540
- ? { kind: "release-copy", reason: "a member deploys a release's recorded copy of its root, which a composition does not read" }
541
- : terraformComposeGroup.groupFallback(ctx, members),
542
- // #4542: the root's files, which a release cut records and a promote under it plans.
543
- releaseInputs: (input, ctx) => terraformReleaseInputs(input, ctx),
544
- // #4552: resource under choudoufu, the root under Terraform, tofu and Terragrunt, which refuse resource by name.
545
- async defaultLockGrain(input, plan) {
546
- return terraformDefaultLockGrain(await plannerOf(input, plan));
547
- },
548
- async lockGrainRefusal(input, grain, plan) {
549
- if (grain !== "resource")
550
- return undefined;
551
- const binary = (await rootDir(input).catch(() => undefined))?.binary;
552
- return terraformLockGrainRefusal(grain, await plannerOf(input, plan), binary);
553
- },
554
- // 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
555
- // the backend's lock. A choudoufu root stays on the resource grain and never asks for this row.
556
- targetLockRow(input) {
557
- return typeof input?.root === "string" && input.root !== "" ? { key: rootRowKey(input.root), target: input.root, address: input.root } : undefined;
558
- },
559
- lockRows(input, plan) {
560
- const kept = plan.artifact?.lockRows;
561
- if (Array.isArray(kept))
562
- return kept;
563
- return plan.changeSet ? terraformLockRowsFromPart(input.root, plan.changeSet) : [];
564
- },
565
- // #4555: the root and the binary, for the step's span and run record.
566
- traceFacts: async (input, outcome) => terraformTraceFacts(input, outcome, (await rootDir(input).catch(() => undefined))?.binary),
567
- planGroup: (ctx, members) => terraformComposeGroup.planGroup(ctx, members),
568
- runGroup: (ctx, run, members) => terraformComposeGroup.runGroup(ctx, run, members),
569
- async run(ctx, input) {
570
- const fromWave = ctx.plans?.[input.root];
571
- if (isChoudoufuWavePlan(fromWave))
572
- return runChoudoufuWave(ctx, input, fromWave);
573
- if (isShapeArtifact(fromWave)) {
574
- // A root previewed with stand-ins (#4463): plan it now with the real
575
- // values, and apply that plan only when it is within the preview's shape.
576
- const fresh = await planRoot(await readsForRun(input), ctx.targets, { env: ctx.processEnv });
577
- const differences = planShapeDifferences(fromWave.shape, terraformPlanShape(fresh.json, input.root));
578
- if (differences.length > 0)
579
- throw new PlanShapeMovedError(input.root, differences);
580
- const applied = await terraformApply({ ...rootArgs(input, ctx.processEnv), planFile: fresh.planFile, ...lockTimeoutOf(input) });
612
+ },
613
+ // The root's outputs as its state holds them now (#3183): what a dependent
614
+ // planned before this root applies reads through `stackOutput()`.
615
+ async outputs(ctx, step) {
616
+ const input = await filledInput(deps.resolveRoot, ctx, step);
617
+ requireRoot(input);
618
+ await initRoot(input, ctx.processEnv, ctx.serial);
619
+ return terraformOutputs(rootArgs(input, ctx.processEnv));
620
+ },
621
+ // #4447 (ws-107): a group core forms of components that read each other plans and applies as one composed run
622
+ // when `terraform.compose.enabled` is set (./compose-group.ts). Delegates, so the methods are read when called.
623
+ groupReads: (ctx, members) => terraformComposeGroup.groupReads(ctx, members),
624
+ // #4542: a member pointed at a release's recorded copy plans alone, since a composition reads the declared roots.
625
+ groupFallback: async (ctx, members) => members.some((m) => typeof m.step.dir === "string")
626
+ ? { kind: "release-copy", reason: "a member deploys a release's recorded copy of its root, which a composition does not read" }
627
+ : terraformComposeGroup.groupFallback(ctx, members),
628
+ // #4542: the root's files, which a release cut records and a promote under it plans.
629
+ releaseInputs: (input, ctx) => terraformReleaseInputs(input, ctx),
630
+ // #4552: resource under choudoufu, the root under Terraform, tofu and Terragrunt, which refuse resource by name.
631
+ async defaultLockGrain(input, plan) {
632
+ return terraformDefaultLockGrain(await plannerOf(input, plan));
633
+ },
634
+ async lockGrainRefusal(input, grain, plan) {
635
+ if (grain !== "resource")
636
+ return undefined;
637
+ const binary = (await rootDir(input).catch(() => undefined))?.binary;
638
+ return terraformLockGrainRefusal(grain, await plannerOf(input, plan), binary);
639
+ },
640
+ // 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
641
+ // the backend's lock. A choudoufu root stays on the resource grain and never asks for this row.
642
+ targetLockRow(input) {
643
+ return typeof input?.root === "string" && input.root !== "" ? { key: rootRowKey(input.root), target: input.root, address: input.root } : undefined;
644
+ },
645
+ lockRows(input, plan) {
646
+ const kept = plan.artifact?.lockRows;
647
+ if (Array.isArray(kept))
648
+ return kept;
649
+ return plan.changeSet ? terraformLockRowsFromPart(input.root, plan.changeSet) : [];
650
+ },
651
+ // #4555: the root and the binary, for the step's span and run record.
652
+ traceFacts: async (input, outcome) => terraformTraceFacts(input, outcome, (await rootDir(input).catch(() => undefined))?.binary),
653
+ planGroup: (ctx, members) => {
654
+ // chant#4854: each member's lock grain reads the config at the wave's directory too.
655
+ for (const m of members)
656
+ if (m.input)
657
+ withContextCwd(m.ctx ?? ctx, m.input);
658
+ return terraformComposeGroup.planGroup(ctx, members);
659
+ },
660
+ runGroup: (ctx, run, members) => {
661
+ for (const m of members)
662
+ if (m.input)
663
+ withContextCwd(m.ctx ?? ctx, m.input);
664
+ return terraformComposeGroup.runGroup(ctx, run, members);
665
+ },
666
+ async run(ctx, step) {
667
+ const input = await filledInput(deps.resolveRoot, ctx, step);
668
+ const fromWave = ctx.plans?.[input.root];
669
+ if (isChoudoufuWavePlan(fromWave))
670
+ return runChoudoufuWave(ctx, input, fromWave);
671
+ if (isShapeArtifact(fromWave)) {
672
+ // A root previewed with stand-ins (#4463): plan it now with the real
673
+ // values, and apply that plan only when it is within the preview's shape.
674
+ const fresh = await planRoot(await readsForRun(input, deps.resolveRoot, ctx.serial), ctx.targets, { env: ctx.processEnv, ...(ctx.serial ? { serial: ctx.serial } : {}) });
675
+ const differences = planShapeDifferences(fromWave.shape, terraformPlanShape(fresh.json, input.root));
676
+ if (differences.length > 0)
677
+ throw new PlanShapeMovedError(input.root, differences);
678
+ const applied = await terraformApply({ ...rootArgs(input, ctx.processEnv), planFile: fresh.planFile, ...lockTimeoutOf(input) });
679
+ if (!applied.applied) {
680
+ throw new Error(`terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ${applied.refusal ?? ""}`);
681
+ }
682
+ const outputs = await terraformOutputs(rootArgs(input, ctx.processEnv));
683
+ return { root: input.root, planDigest: fresh.planDigest, fromWavePlan: false, outputs };
684
+ }
685
+ const planned = isPlannedRoot(fromWave)
686
+ ? fromWave
687
+ : await planRoot(await readsForRun(input, deps.resolveRoot, ctx.serial), ctx.targets, { env: ctx.processEnv, ...(ctx.serial ? { serial: ctx.serial } : {}) }).then(({ planFile, planDigest }) => ({ planFile, planDigest }));
688
+ const applied = await terraformApply({ ...rootArgs(input, ctx.processEnv), planFile: planned.planFile, ...lockTimeoutOf(input) });
581
689
  if (!applied.applied) {
582
- throw new Error(`terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ${applied.refusal ?? ""}`);
690
+ const message = `terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ` +
691
+ (applied.refusal ?? "");
692
+ // A plan the wave approved that choudoufu refuses as no longer matching
693
+ // moved since the approval (#4553: one made against another estate is a
694
+ // failure). One this run made itself is planned afresh by the next run.
695
+ if (applied.refused === "approval-mismatch" && isPlannedRoot(fromWave))
696
+ throw new TerraformPlanMovedError(input.root, message);
697
+ throw new Error(message);
583
698
  }
584
699
  const outputs = await terraformOutputs(rootArgs(input, ctx.processEnv));
585
- return { root: input.root, planDigest: fresh.planDigest, fromWavePlan: false, outputs };
586
- }
587
- const planned = isPlannedRoot(fromWave)
588
- ? fromWave
589
- : await planRoot(await readsForRun(input), ctx.targets, { env: ctx.processEnv }).then(({ planFile, planDigest }) => ({ planFile, planDigest }));
590
- const applied = await terraformApply({ ...rootArgs(input, ctx.processEnv), planFile: planned.planFile, ...lockTimeoutOf(input) });
591
- if (!applied.applied) {
592
- const message = `terraform-apply: root "${input.root}" refused the plan it was given (${applied.refused ?? "refused"}). ` +
593
- (applied.refusal ?? "");
594
- // A plan the wave approved that choudoufu refuses as no longer matching
595
- // moved since the approval (#4553: one made against another estate is a
596
- // failure). One this run made itself is planned afresh by the next run.
597
- if (applied.refused === "approval-mismatch" && isPlannedRoot(fromWave))
598
- throw new TerraformPlanMovedError(input.root, message);
599
- throw new Error(message);
600
- }
601
- const outputs = await terraformOutputs(rootArgs(input, ctx.processEnv));
602
- return { root: input.root, planDigest: planned.planDigest, fromWavePlan: isPlannedRoot(fromWave), outputs };
603
- },
604
- };
700
+ return { root: input.root, planDigest: planned.planDigest, fromWavePlan: isPlannedRoot(fromWave), outputs };
701
+ },
702
+ };
703
+ }
704
+ /** `terraform-apply` with each root on the step's `binary`, else `terraform.binary`. */
705
+ export const terraformApplyCapability = terraformApplyCapabilityWith();
605
706
  export const TERRAFORM_VERB_FAMILIES = {
606
707
  apply: ["terraform-apply"],
607
708
  // #4618: the binary runs outside waves, each a fixed operation; the two that change state on their own run under a gated request.
@@ -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
  /**