@intentius/chant-lexicon-terraform 0.124.79 → 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.
@@ -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
@@ -142,7 +147,7 @@ export interface TerraformApplyStepInput {
142
147
  root: string;
143
148
  /** Input variables, after the root's var files. See `TerraformPlanArgs.vars`. */
144
149
  vars?: Record<string, unknown>;
145
- /** Where the `chant.config.*` search starts. Default: the current directory. */
150
+ /** 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
151
  cwd?: string;
147
152
  /** 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
153
  dir?: string;
@@ -152,6 +157,46 @@ export interface TerraformApplyStepInput {
152
157
  cone?: string;
153
158
  /** Vars read from other roots' outputs (#4545), Atmos's `!terraform.state`. The step's `vars` win over them. */
154
159
  reads?: TerraformStateRead[];
160
+ /**
161
+ * The workspace the root plans and applies in (chant#4854), such as an
162
+ * Atmos instance's. `init` runs in `default`, then `workspace select
163
+ * -or-create=true` selects it, creating it when the backend does not list
164
+ * it yet, and plan, apply and output run with `TF_WORKSPACE` set to it.
165
+ * Absent: the entry's `workspace`, or the run's environment, as before.
166
+ */
167
+ workspace?: string;
168
+ /**
169
+ * The binary the root runs, a name on `PATH` or a path, in place of
170
+ * `terraform.binary` (terragucci issue 1303): a root that pins its own
171
+ * terraform or tofu release. A product's {@link TerraformRootResolver}
172
+ * sets it per root. Absent: `terraform.binary`, as before.
173
+ */
174
+ binary?: string;
175
+ }
176
+ /** What a root runs in place of the step's (terragucci issue 1303). An unset field runs the step's. */
177
+ export interface TerraformRootTools {
178
+ /** The binary, a name on `PATH` or a path. See {@link TerraformApplyStepInput.binary}. */
179
+ binary?: string;
180
+ /**
181
+ * The environment a read of this root's state runs with over the job's,
182
+ * when another root's `reads` name it as their upstream (terragucci issue
183
+ * 1303): its role's credentials, never the reader's. The root's own plan
184
+ * and apply take theirs from the run hooks (`DeployContext.processEnv`).
185
+ */
186
+ readEnv?: Record<string, string>;
187
+ }
188
+ /**
189
+ * What a root runs (terragucci issue 1303), asked once per plan and per
190
+ * apply with the root and the step's input, as `terragrunt-apply`'s
191
+ * `resolveUnit` is asked per unit. A product passes its own, which installs
192
+ * a pinned release and checks its version, so a root runs what it plans
193
+ * with whatever `chant.config.ts` names.
194
+ */
195
+ export type TerraformRootResolver = (root: string, input: TerraformApplyStepInput) => TerraformRootTools | Promise<TerraformRootTools>;
196
+ /** What {@link terraformApplyCapabilityWith} takes. */
197
+ export interface TerraformApplyDeps {
198
+ /** What each root runs. Default: the step's `binary`, else `terraform.binary`. */
199
+ resolveRoot?: TerraformRootResolver;
155
200
  }
156
201
  /** What `terraform-apply` returns. `outputs` is what a dependent's `stackOutput()` reads. */
157
202
  export interface TerraformApplyStepOutput {
@@ -193,6 +238,17 @@ export declare const PREVIEW_PLAN_FILE = ".chant-preview.tfplan";
193
238
  export interface TerraformShapeArtifact extends PlanShapeArtifact {
194
239
  kind: "terraform-apply-shape";
195
240
  }
241
+ /**
242
+ * The step's input with `cwd` set to the caller's directory when it names
243
+ * none (chant#4854, `DeployContext.cwd`): an op wave run in process for
244
+ * another directory finds that directory's `chant.config.*`, not the
245
+ * process's. The input core passed is remembered, so `defaultLockGrain`,
246
+ * `lockGrainRefusal` and `traceFacts`, which get the input alone, read the
247
+ * same config.
248
+ */
249
+ export declare function withContextCwd(ctx: {
250
+ cwd?: string;
251
+ } | undefined, input: TerraformApplyStepInput): TerraformApplyStepInput;
196
252
  /**
197
253
  * choudoufu refused the plan `run` was handed by its wave (its exit 3)
198
254
  * because the live system moved since the plan. Nothing was applied.
@@ -206,6 +262,15 @@ export declare class TerraformPlanMovedError extends Error {
206
262
  readonly planMoved = true;
207
263
  constructor(root: string, message: string);
208
264
  }
265
+ /**
266
+ * `terraform-apply` with `deps` in place of the defaults (terragucci issue
267
+ * 1303). `resolveRoot` answers what each root runs, so a product whose roots
268
+ * pin their own releases passes its resolver, as it passes `resolveUnit` to
269
+ * `terragruntApplyCapability`. A composed group (`together`) runs the
270
+ * project's binary, as before.
271
+ */
272
+ export declare function terraformApplyCapabilityWith(deps?: TerraformApplyDeps): Capability<TerraformApplyStepInput, TerraformApplyStepOutput>;
273
+ /** `terraform-apply` with each root on the step's `binary`, else `terraform.binary`. */
209
274
  export declare const terraformApplyCapability: Capability<TerraformApplyStepInput, TerraformApplyStepOutput>;
210
275
  export declare const TERRAFORM_VERB_FAMILIES: {
211
276
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAiC,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,KAAK,EAAmB,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AA0BlI,OAAO,EAA0D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,oBAAoB,CAEhI;AAID;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBAInC,CAAC;AA4BF,4GAA4G;AAC5G,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAEzD,iHAAiH;AACjH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAUD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,EAAE,KAAK,EAAE,uBAAuB,GAAG,uBAAuB,CAKzH;AAmGD;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;aAEpB,IAAI,EAAE,MAAM;IADxC,QAAQ,CAAC,SAAS,QAAQ;IAC1B,YAA4B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAGxD;CACF;AA6DD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,kBAAuB,GAAG,UAAU,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,CAyIzI;AAED,wFAAwF;AACxF,eAAO,MAAM,wBAAwB,EAAE,UAAU,CAAC,uBAAuB,EAAE,wBAAwB,CAAkC,CAAC;AAEtI,eAAO,MAAM,uBAAuB;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
@@ -170,15 +175,24 @@ function lockTimeoutOf(input) {
170
175
  * read once, the values under the step's own `vars`. `waiting` when an
171
176
  * upstream has no such output yet. Throws when a state cannot be read.
172
177
  */
173
- async function withReads(input) {
178
+ async function withReads(input, resolveRoot) {
174
179
  const reads = input.reads ?? [];
175
180
  if (reads.length === 0)
176
181
  return { input };
177
182
  const problems = stateReadsProblems(reads);
178
183
  if (problems.length > 0)
179
184
  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 } : {}) };
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
+ };
182
196
  await terraformInit(at);
183
197
  return terraformOutputs(at);
184
198
  });
@@ -197,11 +211,24 @@ function waitingOnReads(ctx, input, waiting) {
197
211
  };
198
212
  return { member: input.root, planDigest, changeSet };
199
213
  }
200
- const rootArgs = (input, env) => ({ root: input.root, ...(input.cwd ? { cwd: input.cwd } : {}), ...(input.dir ? { dir: input.dir } : {}), ...(env ? { env } : {}) });
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
+ });
201
222
  function requireRoot(input) {
202
223
  if (typeof input.root !== "string" || input.root === "") {
203
224
  throw new Error('terraform-apply: "root" is required and names an entry in terraform.roots');
204
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
+ }
205
232
  }
206
233
  async function planRoot(input, targets, at = {}) {
207
234
  requireRoot(input);
@@ -327,8 +354,41 @@ function isShapeArtifact(value) {
327
354
  const v = value;
328
355
  return v?.kind === "terraform-apply-shape" && typeof v.digest === "string" && typeof v.shape === "object" && v.shape !== null;
329
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
+ }
330
389
  /** The root's directory, as `terraform.roots` names it from the nearest `chant.config.*`, and the configured binary. */
331
- async function rootDir(input) {
390
+ async function rootDir(given) {
391
+ const input = filledInputs.get(given) ?? given;
332
392
  const start = resolve(input.cwd ?? process.cwd());
333
393
  const { config, configPath } = await loadChantConfigUpward(start);
334
394
  const terraform = config.terraform;
@@ -337,7 +397,8 @@ async function rootDir(input) {
337
397
  if (declared === undefined)
338
398
  return undefined;
339
399
  const dir = input.dir ?? declared;
340
- 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 } : {}) };
341
402
  }
342
403
  const firstLines = (err) => {
343
404
  const text = (err instanceof Error ? err.message : String(err)).trim();
@@ -457,8 +518,8 @@ async function runChoudoufuWave(ctx, input, planned) {
457
518
  return { root: input.root, planDigest: planned.planDigest, fromWavePlan: true, outputs };
458
519
  }
459
520
  /** 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);
521
+ async function readsForRun(input, resolveRoot) {
522
+ const read = await withReads(input, resolveRoot);
462
523
  if ("waiting" in read)
463
524
  throw new Error(`terraform-apply: root "${input.root}": ${read.waiting}`);
464
525
  return read.input;
@@ -471,137 +532,162 @@ async function plannerOf(input, plan) {
471
532
  const planner = plan?.changeSet?.member.planner;
472
533
  return planner === "terraform" || planner === "tofu" || planner === "choudoufu" ? planner : "terraform";
473
534
  }
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),
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 } : {}),
510
596
  };
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) });
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) });
581
674
  if (!applied.applied) {
582
- 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);
583
683
  }
584
684
  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
- };
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();
605
691
  export const TERRAFORM_VERB_FAMILIES = {
606
692
  apply: ["terraform-apply"],
607
693
  // #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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"compose-group.d.ts","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M,EAAE,GAAG,aAAa,GAAG,SAAS,CAYrG;AAuBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,WAAW,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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 };