@intentius/chant 0.124.78 → 0.124.79

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 (150) hide show
  1. package/dist/action-pins.d.ts.map +1 -1
  2. package/dist/action-pins.js +1 -2
  3. package/dist/change-set.d.ts +10 -1
  4. package/dist/change-set.d.ts.map +1 -1
  5. package/dist/change-set.js +4 -1
  6. package/dist/ci-agent.d.ts +16 -2
  7. package/dist/ci-agent.d.ts.map +1 -1
  8. package/dist/ci-agent.js +6 -1
  9. package/dist/ci-commit.d.ts.map +1 -1
  10. package/dist/ci-commit.js +2 -3
  11. package/dist/ci-product.d.ts +6 -2
  12. package/dist/ci-product.d.ts.map +1 -1
  13. package/dist/ci-product.js +5 -1
  14. package/dist/cli/handlers/release.d.ts +8 -0
  15. package/dist/cli/handlers/release.d.ts.map +1 -1
  16. package/dist/cli/handlers/release.js +64 -2
  17. package/dist/cli/handlers/run-wave.js +1 -0
  18. package/dist/cli/main.d.ts.map +1 -1
  19. package/dist/cli/main.js +7 -0
  20. package/dist/cli/mcp/product-tools.d.ts +6 -0
  21. package/dist/cli/mcp/product-tools.d.ts.map +1 -1
  22. package/dist/cli/mcp/product-tools.js +7 -0
  23. package/dist/cli/mcp/read-only.d.ts +12 -0
  24. package/dist/cli/mcp/read-only.d.ts.map +1 -1
  25. package/dist/cli/mcp/read-only.js +16 -0
  26. package/dist/cli/mcp/server.d.ts +11 -0
  27. package/dist/cli/mcp/server.d.ts.map +1 -1
  28. package/dist/cli/mcp/server.js +26 -5
  29. package/dist/cli/mcp/types.d.ts +5 -1
  30. package/dist/cli/mcp/types.d.ts.map +1 -1
  31. package/dist/components/capability.d.ts +42 -0
  32. package/dist/components/capability.d.ts.map +1 -1
  33. package/dist/components/group-digest.d.ts +17 -0
  34. package/dist/components/group-digest.d.ts.map +1 -0
  35. package/dist/components/group-digest.js +18 -0
  36. package/dist/components/groups.d.ts +2 -11
  37. package/dist/components/groups.d.ts.map +1 -1
  38. package/dist/components/groups.js +2 -12
  39. package/dist/components/index.d.ts +1 -1
  40. package/dist/components/index.d.ts.map +1 -1
  41. package/dist/config.d.ts +14 -0
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +5 -0
  44. package/dist/lexicon.d.ts.map +1 -1
  45. package/dist/lexicon.js +1 -2
  46. package/dist/lifecycle/release-cut.d.ts +7 -1
  47. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  48. package/dist/lifecycle/release-cut.js +1 -0
  49. package/dist/lifecycle/release-images.d.ts +12 -3
  50. package/dist/lifecycle/release-images.d.ts.map +1 -1
  51. package/dist/lifecycle/release-images.js +6 -7
  52. package/dist/lifecycle/release-publish.d.ts +8 -1
  53. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  54. package/dist/lifecycle/release-publish.js +30 -3
  55. package/dist/lifecycle/release-version.d.ts +86 -0
  56. package/dist/lifecycle/release-version.d.ts.map +1 -0
  57. package/dist/lifecycle/release-version.js +209 -0
  58. package/dist/mcp/types.d.ts +26 -0
  59. package/dist/mcp/types.d.ts.map +1 -1
  60. package/dist/notify-product.d.ts.map +1 -1
  61. package/dist/notify-product.js +1 -2
  62. package/dist/op/activities/review-product.d.ts.map +1 -1
  63. package/dist/op/activities/review-product.js +1 -2
  64. package/dist/op/gate.d.ts +17 -0
  65. package/dist/op/gate.d.ts.map +1 -1
  66. package/dist/op/gate.js +36 -0
  67. package/dist/op/index.d.ts +8 -6
  68. package/dist/op/index.d.ts.map +1 -1
  69. package/dist/op/index.js +5 -4
  70. package/dist/op/op-waves-after-plan.d.ts +76 -1
  71. package/dist/op/op-waves-after-plan.d.ts.map +1 -1
  72. package/dist/op/op-waves-after-plan.js +142 -3
  73. package/dist/op/op-waves-capability-spec.js +1 -2
  74. package/dist/op/op-waves-capability.d.ts +89 -2
  75. package/dist/op/op-waves-capability.d.ts.map +1 -1
  76. package/dist/op/op-waves-capability.js +215 -7
  77. package/dist/op/op-waves-run-hooks.d.ts +104 -0
  78. package/dist/op/op-waves-run-hooks.d.ts.map +1 -0
  79. package/dist/op/op-waves-run-hooks.js +146 -0
  80. package/dist/op/op-waves-run.d.ts +21 -0
  81. package/dist/op/op-waves-run.d.ts.map +1 -1
  82. package/dist/op/op-waves-run.js +233 -13
  83. package/dist/op/op-waves.d.ts +11 -1
  84. package/dist/op/op-waves.d.ts.map +1 -1
  85. package/dist/op/op-waves.js +7 -1
  86. package/dist/op/runtime.d.ts +2 -0
  87. package/dist/op/runtime.d.ts.map +1 -1
  88. package/dist/pr-plan-note.d.ts.map +1 -1
  89. package/dist/pr-plan-note.js +1 -2
  90. package/dist/release-floors.d.ts +5 -1
  91. package/dist/release-floors.d.ts.map +1 -1
  92. package/dist/release-floors.js +9 -5
  93. package/dist/wave-runtime.mjs +314 -314
  94. package/dist/workspace/change-set.schema.json +7 -0
  95. package/dist/workspace/release-workflow.d.ts +7 -0
  96. package/dist/workspace/release-workflow.d.ts.map +1 -1
  97. package/dist/workspace/release-workflow.js +11 -1
  98. package/package.json +1 -1
  99. package/src/action-pins.test.ts +1 -2
  100. package/src/action-pins.ts +1 -3
  101. package/src/change-set.test.ts +20 -0
  102. package/src/change-set.ts +11 -1
  103. package/src/ci-agent.test.ts +9 -0
  104. package/src/ci-agent.ts +15 -2
  105. package/src/ci-commit.test.ts +2 -3
  106. package/src/ci-commit.ts +2 -3
  107. package/src/ci-product.ts +6 -2
  108. package/src/cli/handlers/release.ts +55 -2
  109. package/src/cli/handlers/run-wave.ts +1 -0
  110. package/src/cli/main.ts +7 -0
  111. package/src/cli/mcp/product-tools.test.ts +50 -0
  112. package/src/cli/mcp/product-tools.ts +8 -0
  113. package/src/cli/mcp/read-only.ts +19 -0
  114. package/src/cli/mcp/server.test.ts +30 -0
  115. package/src/cli/mcp/server.ts +28 -5
  116. package/src/cli/mcp/types.ts +6 -1
  117. package/src/components/capability.ts +41 -0
  118. package/src/components/group-digest.ts +20 -0
  119. package/src/components/groups.ts +3 -13
  120. package/src/components/index.ts +2 -0
  121. package/src/config.ts +15 -0
  122. package/src/lexicon.ts +1 -2
  123. package/src/lifecycle/release-cut.ts +11 -0
  124. package/src/lifecycle/release-images-dockerfile.test.ts +10 -2
  125. package/src/lifecycle/release-images.ts +12 -8
  126. package/src/lifecycle/release-publish.ts +34 -3
  127. package/src/lifecycle/release-version.test.ts +155 -0
  128. package/src/lifecycle/release-version.ts +227 -0
  129. package/src/mcp/types.ts +27 -0
  130. package/src/notify-message-words.test.ts +1 -2
  131. package/src/notify-product.ts +1 -2
  132. package/src/op/activities/review-product.ts +1 -2
  133. package/src/op/gate.ts +46 -0
  134. package/src/op/index.ts +10 -4
  135. package/src/op/op-waves-after-plan-wave.test.ts +226 -0
  136. package/src/op/op-waves-after-plan.ts +170 -5
  137. package/src/op/op-waves-capability-spec.ts +1 -1
  138. package/src/op/op-waves-capability.test.ts +6 -0
  139. package/src/op/op-waves-capability.ts +243 -10
  140. package/src/op/op-waves-run-hooks.test.ts +184 -0
  141. package/src/op/op-waves-run-hooks.ts +195 -0
  142. package/src/op/op-waves-run.ts +240 -16
  143. package/src/op/op-waves-step-wave.test.ts +277 -0
  144. package/src/op/op-waves.ts +15 -2
  145. package/src/op/runtime.ts +2 -0
  146. package/src/pr-plan-note.ts +1 -2
  147. package/src/release-floors.ts +11 -5
  148. package/src/workspace/change-set.schema.json +7 -0
  149. package/src/workspace/release-workflow.test.ts +18 -0
  150. package/src/workspace/release-workflow.ts +21 -1
@@ -0,0 +1,277 @@
1
+ /**
2
+ * A wave planned as one through a step (#4842): a `discover` wave whose
3
+ * runs the step's capability finds at plan time (a Terragrunt layer), and a
4
+ * `together` wave planned and applied in one call of the capability (a
5
+ * Terragrunt `run --all`, a composed run of roots).
6
+ */
7
+
8
+ import { describe, expect, test } from "vitest";
9
+ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ import { tmpdir } from "node:os";
12
+ import { assertOpWavesSpec, type OpWavesSpec } from "./op-waves";
13
+ import { runOpWave, opWavePlanPath, type OpWaveShowAtBase } from "./op-waves-run";
14
+ import { memoryGateLedgerPort } from "./gate";
15
+ import { CapabilityRegistry, type Capability, type CapabilityGroupOutcome, type DeployContext, type GroupContext, type GroupMember, type GroupRun, type RunDiscoveryContext } from "../components/capability";
16
+ import type { ChangeSetPart } from "../change-set";
17
+ import { groupDigest } from "../components/groups";
18
+ import { waveSetDigest } from "../wave-engine";
19
+ import { NEXT_RELEASE } from "../release-floors";
20
+ import type { OpWaveRunHooks } from "./op-waves-run-hooks";
21
+
22
+ const digest = (n: string) => `sha256:${n.repeat(64)}`;
23
+
24
+ const part = (member: string, action = "create"): ChangeSetPart => ({
25
+ member: { member, lexicon: "terraform", planner: "chant", status: "planned", planDigest: digest("9"), holes: [] },
26
+ entries: [{ member, address: `aws_s3_bucket.${member.replace(/\//g, "_")}`, type: "aws_s3_bucket", action } as ChangeSetPart["entries"][number]],
27
+ });
28
+
29
+ interface Seen {
30
+ discovered: Array<{ ctx: RunDiscoveryContext; input: Record<string, unknown> }>;
31
+ planned: string[];
32
+ groups: Array<{ ctx: GroupContext; members: Array<{ component: string; input: unknown; dependsOn?: string[]; env?: Record<string, string> }> }>;
33
+ runs: Array<{ run: GroupRun; members: Array<{ component: string; plans?: Record<string, unknown>; env?: Record<string, string> }> }>;
34
+ applied: string[];
35
+ order: string[];
36
+ }
37
+
38
+ /** A Terragrunt-shaped capability: `layers[k-1]` is what wave k finds; each unit's digest is `digests[unit]`. */
39
+ function capability(
40
+ layers: string[][],
41
+ digests: Record<string, string>,
42
+ opts: { group?: boolean; discover?: boolean; outcome?: (members: string[]) => CapabilityGroupOutcome; throwOnRun?: Error } = {},
43
+ ): { registry: CapabilityRegistry; seen: Seen } {
44
+ const seen: Seen = { discovered: [], planned: [], groups: [], runs: [], applied: [], order: [] };
45
+ const cap: Capability<Record<string, unknown>, unknown> = {
46
+ kind: "fake-terragrunt",
47
+ async plan(_ctx: DeployContext, input) {
48
+ const unit = String(input.unit);
49
+ seen.planned.push(unit);
50
+ return { member: unit, planDigest: digests[unit]!, artifact: { unit }, changeSet: part(unit) };
51
+ },
52
+ async run(_ctx: DeployContext, input) {
53
+ seen.applied.push(String(input.unit));
54
+ return { unit: input.unit };
55
+ },
56
+ ...(opts.discover === false
57
+ ? {}
58
+ : {
59
+ async discoverRuns(ctx: RunDiscoveryContext, input: Record<string, unknown>) {
60
+ seen.discovered.push({ ctx, input });
61
+ return { targets: layers[ctx.wave.number - 1] ?? [], waves: layers.length };
62
+ },
63
+ }),
64
+ ...(opts.group === false
65
+ ? {}
66
+ : {
67
+ async planGroup(ctx: GroupContext, members: readonly GroupMember<Record<string, unknown>>[]) {
68
+ seen.order.push("planGroup");
69
+ for (const m of members) await m.ctx.afterInit?.();
70
+ seen.groups.push({ ctx, members: members.map((m) => ({ component: m.component, input: m.input, ...(m.dependsOn ? { dependsOn: m.dependsOn } : {}), ...(m.ctx.processEnv ? { env: m.ctx.processEnv } : {}) })) });
71
+ return {
72
+ members: Object.fromEntries(members.map((m) => [m.component, { member: m.component, planDigest: digests[m.component]!, artifact: { planJson: `json/${m.component}/tfplan.json` }, changeSet: part(m.component) }])),
73
+ digest: digest("c"),
74
+ artifact: { workDir: ".chant/tg/wave", units: members.map((m) => m.component) },
75
+ };
76
+ },
77
+ async runGroup(ctx: GroupContext, run: GroupRun, members: readonly GroupMember<Record<string, unknown>>[]) {
78
+ seen.order.push("runGroup");
79
+ seen.runs.push({ run, members: members.map((m) => ({ component: m.component, ...(m.ctx.plans ? { plans: m.ctx.plans } : {}), ...(m.ctx.processEnv ? { env: m.ctx.processEnv } : {}) })) });
80
+ if (opts.throwOnRun) throw opts.throwOnRun;
81
+ const names = members.map((m) => m.component);
82
+ seen.applied.push(...names);
83
+ return opts.outcome?.(names) ?? { members: Object.fromEntries(names.map((n) => [n, { status: "applied" as const, outputs: { id: `${n}-1` } }])) };
84
+ },
85
+ }),
86
+ };
87
+ return { registry: new CapabilityRegistry().register(cap), seen };
88
+ }
89
+
90
+ const digests = { "live/a": digest("1"), "live/b": digest("2"), "live/c": digest("3") };
91
+
92
+ const discovering: OpWavesSpec = {
93
+ name: "tf-apply",
94
+ op: "tf-apply",
95
+ gateName: "wave-{k}",
96
+ step: { kind: "fake-terragrunt", unit: "{target}", dir: ".", wave: "{wave}" },
97
+ waves: [
98
+ { name: "layer", runs: [], discover: true, gate: "never" },
99
+ { name: "rest", runs: [], discover: true, rest: true, gate: "never" },
100
+ ],
101
+ };
102
+
103
+ function harness(s: OpWavesSpec) {
104
+ const cwd = mkdtempSync(join(tmpdir(), "op-waves-step-wave-"));
105
+ const show: OpWaveShowAtBase = () => ({ sha: "b".repeat(40), text: JSON.stringify(s) });
106
+ return { cwd, show, done: () => rmSync(cwd, { recursive: true, force: true }) };
107
+ }
108
+
109
+ const run = (h: ReturnType<typeof harness>, s: OpWavesSpec, registry: CapabilityRegistry, wave = 1, runHooks?: OpWaveRunHooks | OpWaveRunHooks[]) =>
110
+ runOpWave({ spec: s, specFile: "waves.json", wave, cwd: h.cwd, show: h.show, gates: memoryGateLedgerPort(), capabilities: registry, log: () => {}, ...(runHooks ? { runHooks } : {}) });
111
+
112
+ describe("a wave planned as one through a step (#4842)", () => {
113
+ test("the spec takes discover with a step and checks together", () => {
114
+ expect(() => assertOpWavesSpec(discovering)).not.toThrow();
115
+ const together: OpWavesSpec = { ...discovering, waves: [{ name: "w", runs: [{ target: "a" }], together: true }] };
116
+ expect(() => assertOpWavesSpec(together)).not.toThrow();
117
+ const { step: _s, ...commands } = together;
118
+ expect(() => assertOpWavesSpec({ ...commands, plan: ["p", "{plan}"] })).toThrow(/plans its runs together, which only a `step`'s capability does/);
119
+ expect(() => assertOpWavesSpec({ ...together, waves: [{ name: "w", runs: [{ target: "a" }], together: true, parallelism: 2 }] })).toThrow(/no parallelism over 1/);
120
+ expect(() => assertOpWavesSpec({ ...together, waves: [{ name: "w", runs: [{ target: "a" }], together: "yes" as never }] })).toThrow(/has together "yes"/);
121
+ });
122
+
123
+ test("a discovering wave plans the runs its capability finds, one at a time, and a rest wave walks to the waves found", async () => {
124
+ const h = harness(discovering);
125
+ const { registry, seen } = capability([["live/a", "live/b"], ["live/c"]], digests, { group: false });
126
+ const result = await run(h, discovering, registry, 2);
127
+ expect(result.exitCode).toBe(0);
128
+ // The input has {op} and {wave} filled and {target} as written; the wave number is the one planned.
129
+ expect(seen.discovered.map((d) => d.ctx)).toEqual([
130
+ { env: "rest", wave: { name: "rest", number: 2 } },
131
+ ]);
132
+ expect(seen.discovered[0]!.input).toEqual({ unit: "{target}", dir: ".", wave: "rest" });
133
+ expect(seen.planned).toEqual(["live/c"]);
134
+ expect(seen.applied).toEqual(["live/c"]);
135
+ expect(result.decision?.discovered).toEqual({ waves: 2 });
136
+ expect(result.decision?.members.map((m) => m.member)).toEqual(["live/c"]);
137
+ h.done();
138
+ });
139
+
140
+ test("a discovering rest wave goes on through every wave found", async () => {
141
+ const s: OpWavesSpec = { ...discovering, waves: [discovering.waves[1]!] };
142
+ const h = harness(s);
143
+ const { registry, seen } = capability([["live/a"], ["live/b"], ["live/c"]], digests, { group: false });
144
+ const result = await run(h, s, registry, 1);
145
+ expect(result.exitCode).toBe(0);
146
+ expect(seen.discovered.map((d) => d.ctx.wave.number)).toEqual([1, 2, 3]);
147
+ expect(seen.applied).toEqual(["live/a", "live/b", "live/c"]);
148
+ expect(result.rest?.map((r) => r.wave)).toEqual([1, 2, 3]);
149
+ h.done();
150
+ });
151
+
152
+ test("a wave number past the ones found finds no runs and applies nothing", async () => {
153
+ const h = harness(discovering);
154
+ const { registry, seen } = capability([["live/a"]], digests, { group: false });
155
+ const result = await run(h, { ...discovering, waves: [{ name: "layer", runs: [], discover: true, gate: "never" }, { name: "two", runs: [], discover: true, gate: "never" }] }, registry, 2);
156
+ expect(result.exitCode).toBe(0);
157
+ expect(result.applied).toEqual([]);
158
+ expect(seen.planned).toEqual([]);
159
+ h.done();
160
+ });
161
+
162
+ test("a capability that cannot find runs fails the wave before anything plans", async () => {
163
+ const h = harness(discovering);
164
+ const { registry, seen } = capability([["live/a"]], digests, { discover: false });
165
+ await expect(run(h, discovering, registry)).rejects.toThrow('wave 1 (layer) discovers its runs, and the capability "fake-terragrunt" cannot find them (it has no discoverRuns)');
166
+ expect(seen.planned).toEqual([]);
167
+ h.done();
168
+ });
169
+
170
+ test("a together wave plans in one call and applies in one, the group digest a member of its own", async () => {
171
+ const s: OpWavesSpec = { ...discovering, waves: [{ name: "layer", runs: [], discover: true, together: true, gate: "never" }] };
172
+ const h = harness(s);
173
+ const { registry, seen } = capability([["live/a", "live/b"]], digests);
174
+ const result = await run(h, s, registry);
175
+ expect(result.exitCode).toBe(0);
176
+ expect(seen.planned).toEqual([]);
177
+ expect(seen.groups).toHaveLength(1);
178
+ expect(seen.groups[0]!.ctx).toEqual({ env: "layer", components: ["live/a", "live/b"] });
179
+ expect(seen.groups[0]!.members.map((m) => m.input)).toEqual([
180
+ { unit: "live/a", dir: ".", wave: "layer" },
181
+ { unit: "live/b", dir: ".", wave: "layer" },
182
+ ]);
183
+ // runGroup gets the group's artifact and each member's own plan back.
184
+ expect(seen.runs).toHaveLength(1);
185
+ expect(seen.runs[0]!.run.artifact).toEqual({ workDir: ".chant/tg/wave", units: ["live/a", "live/b"] });
186
+ expect(seen.runs[0]!.members.map((m) => m.plans)).toEqual([{ "live/a": { planJson: "json/live/a/tfplan.json" } }, { "live/b": { planJson: "json/live/b/tfplan.json" } }]);
187
+ expect(result.applied).toEqual(["live/a", "live/b"]);
188
+ const group = groupDigest("fake-terragrunt", [{ component: "live/a", member: "live/a", planDigest: digests["live/a"] }, { component: "live/b", member: "live/b", planDigest: digests["live/b"] }], digest("c"));
189
+ expect(seen.runs[0]!.run.digest).toBe(group);
190
+ expect(result.decision?.digest).toBe(waveSetDigest([{ member: "(wave plan)", planDigest: group }, { member: "live/a", planDigest: digests["live/a"] }, { member: "live/b", planDigest: digests["live/b"] }]));
191
+ // Each run has its plan file, as a per-run plan writes it.
192
+ const file = JSON.parse(readFileSync(join(h.cwd, opWavePlanPath(s, 1, "live/a")), "utf-8")) as { planDigest: string; artifact: unknown };
193
+ expect(file).toMatchObject({ planDigest: digests["live/a"], artifact: { planJson: "json/live/a/tfplan.json" } });
194
+ h.done();
195
+ });
196
+
197
+ test("a together wave of listed runs keeps their order within the wave, and each run's hooks reach its member", async () => {
198
+ const s: OpWavesSpec = { ...discovering, waves: [{ name: "w", runs: [{ target: "live/a" }, { target: "live/b", dependsOn: ["live/a"] }], together: true, gate: "never" }] };
199
+ const h = harness(s);
200
+ const { registry, seen } = capability([], digests);
201
+ const files: string[] = [];
202
+ const result = await run(h, s, registry, 1, {
203
+ name: "roles",
204
+ beforePlan: (r) => ({ env: { ROLE: r.target }, afterInit: async () => void seen.order.push(`check ${r.target}`) }),
205
+ beforeApply: (r) => void seen.order.push(`before ${r.target}`),
206
+ afterApply: (r) => {
207
+ seen.order.push(`after ${r.target} ${r.outcome}`);
208
+ files.push(r.target);
209
+ return { files: [`report/${r.target.replace("/", "_")}.json`] };
210
+ },
211
+ });
212
+ expect(result.exitCode).toBe(0);
213
+ expect(seen.groups[0]!.members).toEqual([
214
+ { component: "live/a", input: { unit: "live/a", dir: ".", wave: "w" }, env: { ROLE: "live/a" } },
215
+ { component: "live/b", input: { unit: "live/b", dir: ".", wave: "w" }, dependsOn: ["live/a"], env: { ROLE: "live/b" } },
216
+ ]);
217
+ expect(seen.runs[0]!.members.map((m) => m.env)).toEqual([{ ROLE: "live/a" }, { ROLE: "live/b" }]);
218
+ expect(seen.order).toEqual(["planGroup", "check live/a", "check live/b", "before live/a", "before live/b", "runGroup", "after live/a applied", "after live/b applied"]);
219
+ expect(files).toEqual(["live/a", "live/b"]);
220
+ h.done();
221
+ });
222
+
223
+ test("a before-apply hook that stops one run of a together wave applies none of them", async () => {
224
+ const s: OpWavesSpec = { ...discovering, waves: [{ name: "w", runs: [{ target: "live/a" }, { target: "live/b" }], together: true, gate: "never" }] };
225
+ const h = harness(s);
226
+ const { registry, seen } = capability([], digests);
227
+ const result = await run(h, s, registry, 1, { name: "freeze", beforeApply: (r) => { if (r.target === "live/b") throw new Error("change freeze"); } });
228
+ expect(result.exitCode).toBe(1);
229
+ expect(seen.runs).toEqual([]);
230
+ expect(result.failed).toEqual(["live/a", "live/b"]);
231
+ h.done();
232
+ });
233
+
234
+ test("each run of a together wave ends as its part of the apply did", async () => {
235
+ const s: OpWavesSpec = { ...discovering, waves: [{ name: "w", runs: [{ target: "live/a" }, { target: "live/b" }, { target: "live/c" }], together: true, gate: "never" }] };
236
+ const h = harness(s);
237
+ const { registry } = capability([], digests, {
238
+ outcome: () => ({ members: { "live/a": { status: "no-changes", outputs: {} }, "live/b": { status: "failed", error: "Error: AccessDenied" } } }),
239
+ });
240
+ const result = await run(h, s, registry);
241
+ expect(result.exitCode).toBe(1);
242
+ expect(result.applied).toEqual(["live/a"]);
243
+ expect(result.failed).toEqual(["live/b", "live/c"]);
244
+ expect(Object.fromEntries(Object.entries(result.targets ?? {}).map(([t, o]) => [t, o.error]))).toEqual({
245
+ "live/a": undefined,
246
+ "live/b": "its part of the wave's apply failed: Error: AccessDenied",
247
+ "live/c": "fake-terragrunt said nothing of it",
248
+ });
249
+ h.done();
250
+ });
251
+
252
+ test("a together wave whose plan moved applies nothing and exits 4", async () => {
253
+ const s: OpWavesSpec = { ...discovering, waves: [{ name: "w", runs: [{ target: "live/a" }, { target: "live/b" }], together: true, gate: "never" }] };
254
+ const h = harness(s);
255
+ const moved = Object.assign(new Error("the composed plan moved since it was approved"), { planMoved: true });
256
+ const { registry } = capability([], digests, { throwOnRun: moved });
257
+ const result = await run(h, s, registry);
258
+ expect(result.exitCode).toBe(4);
259
+ expect(result.moved).toEqual(["live/a", "live/b"]);
260
+ expect(result.applied).toEqual([]);
261
+ h.done();
262
+ });
263
+
264
+ test("a together wave through a capability with no group methods fails before anything plans", async () => {
265
+ const s: OpWavesSpec = { ...discovering, waves: [{ name: "w", runs: [{ target: "live/a" }], together: true, gate: "never" }] };
266
+ const h = harness(s);
267
+ const { registry, seen } = capability([], digests, { group: false });
268
+ await expect(run(h, s, registry)).rejects.toThrow('wave "w" plans its runs together, and the capability "fake-terragrunt" cannot (it needs planGroup and runGroup)');
269
+ expect(seen.planned).toEqual([]);
270
+ h.done();
271
+ });
272
+
273
+ test("the floor is the next release", async () => {
274
+ const entry = await import("./index");
275
+ expect(entry.OP_WAVE_STEP_WAVE_FLOOR).toBe(NEXT_RELEASE);
276
+ });
277
+ });
@@ -360,9 +360,19 @@ export interface OpWave {
360
360
  * The runs come from the product at plan time (#3821): `planWave` gets a
361
361
  * runs file with no runs and `discover: true`, and plans the runs it finds
362
362
  * for wave k (a Terragrunt repo's dependency layer from `terragrunt find`).
363
- * Needs `planWave`.
363
+ * Needs `planWave`, or a `step` whose capability has `discoverRuns`
364
+ * (#4842).
364
365
  */
365
366
  discover?: boolean;
367
+ /**
368
+ * With a `step` (#4842): plan the wave's runs in one call of the step's
369
+ * capability (`planGroup`) and apply them in one (`runGroup`), in place
370
+ * of one plan and one apply per run. For a tool that plans a wave as one,
371
+ * such as Terragrunt's `run --all` over a layer's units or a composed run
372
+ * of roots that read each other. The capability's digest of the whole is
373
+ * a digest member of its own, `(wave plan)`. Not with `parallelism` over 1.
374
+ */
375
+ together?: boolean;
366
376
  /**
367
377
  * The last wave only, with `discover` (#3821): once it applies, the job
368
378
  * goes on to wave k+1, k+2, ... while `planWave` reports more waves
@@ -1067,8 +1077,11 @@ export function assertOpWavesSpec(spec: OpWavesSpec): void {
1067
1077
  if (wave.jobs !== undefined) assertOpWaveJobGroups(where, wave);
1068
1078
  if (wave.discover !== undefined && typeof wave.discover !== "boolean") throw new Error(`${where}: wave "${wave.name}" has discover ${JSON.stringify(wave.discover)}; use true or false.`);
1069
1079
  if (wave.rest !== undefined && typeof wave.rest !== "boolean") throw new Error(`${where}: wave "${wave.name}" has rest ${JSON.stringify(wave.rest)}; use true or false.`);
1080
+ if (wave.together !== undefined && typeof wave.together !== "boolean") throw new Error(`${where}: wave "${wave.name}" has together ${JSON.stringify(wave.together)}; use true or false.`);
1081
+ if (wave.together && spec.step === undefined) throw new Error(`${where}: wave "${wave.name}" plans its runs together, which only a \`step\`'s capability does. Give step.`);
1082
+ if (wave.together && (wave.parallelism ?? 1) > 1) throw new Error(`${where}: wave "${wave.name}" plans and applies its runs together in one call, so it has no parallelism over 1.`);
1070
1083
  if (wave.discover) {
1071
- if (spec.planWave === undefined) throw new Error(`${where}: wave "${wave.name}" discovers its runs, which only \`planWave\` can report. Give planWave.`);
1084
+ if (spec.planWave === undefined && spec.step === undefined) throw new Error(`${where}: wave "${wave.name}" discovers its runs, which only \`planWave\` can report. Give planWave.`);
1072
1085
  if ((wave.runs ?? []).length > 0) throw new Error(`${where}: wave "${wave.name}" discovers its runs, so it lists none.`);
1073
1086
  }
1074
1087
  if (wave.rest) {
package/src/op/runtime.ts CHANGED
@@ -298,6 +298,8 @@ export interface OpRunWaveTarget {
298
298
  error?: string;
299
299
  /** The resources the engine reported failed (#4629), by name or id. */
300
300
  failedResources?: string[];
301
+ /** Files a run hook wrote after the apply (#4842), relative to the job's directory. */
302
+ files?: string[];
301
303
  }
302
304
 
303
305
  /** The first chant that writes {@link OpRunRecord.wave}, a run record per op wave job (#4551). */
@@ -26,10 +26,9 @@
26
26
  import { renderPrNote as renderPrLoopNote, type PrReport } from "./pr-loop";
27
27
  import { GITHUB_COMMENT_LIMIT } from "./plan-summary";
28
28
  import { activeProductWords, approveLine, overrideLine, type CiProductWords } from "./ci-product-words";
29
- import { NEXT_RELEASE } from "./release-floors";
30
29
 
31
30
  /** The first chant with the product plan note (#4810). */
32
- export const PR_PLAN_NOTE_FLOOR = NEXT_RELEASE;
31
+ export const PR_PLAN_NOTE_FLOOR = "0.124.78";
33
32
 
34
33
  /** The read contract a {@link PrPlanNote} follows. */
35
34
  export const PR_PLAN_NOTE_CONTRACT = 1;
@@ -19,16 +19,22 @@
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
21
  */
22
- export const NEXT_RELEASE = "0.124.78";
22
+ export const NEXT_RELEASE = "0.124.79";
23
+
24
+ /** The first chant whose change-set member can carry `outputs`, the outputs its plan changes, and counts a member with any as a change (#4849). */
25
+ export const CHANGE_SET_OUTPUTS_FLOOR = NEXT_RELEASE;
26
+
27
+ /** The first chant whose terraform lexicon's `terragruntApplyCapability` takes `resolveUnit` and plans a wave as one `run --all` per pair of pinned releases (#4849). */
28
+ export const TERRAGRUNT_UNIT_PINS_FLOOR = NEXT_RELEASE;
23
29
 
24
30
  /** The first chant whose sql lexicon's `yodelCommitSpec("new", ...)` takes `envs`, so `--replace-own` reads those histories as the reader (#4815). */
25
- export const YODEL_NEW_ENVS_FLOOR = NEXT_RELEASE;
31
+ export const YODEL_NEW_ENVS_FLOOR = "0.124.78";
26
32
 
27
33
  /** The first chant whose sql lexicon's `yodelRefusalReply` reads yodel rebase's conflict refusal as yodel prints it, `<a> and the migrations after <p> up to <b>` or `<a> and the chain ending at <b>` (#4821). */
28
- export const YODEL_CONFLICT_REPLY_FLOOR = NEXT_RELEASE;
34
+ export const YODEL_CONFLICT_REPLY_FLOOR = "0.124.78";
29
35
 
30
36
  /** The first chant whose `@intentius/chant/pr-forge-reads` exports the forge reads beside the clients (#4809). */
31
- export const PR_FORGE_READS_FLOOR = NEXT_RELEASE;
37
+ export const PR_FORGE_READS_FLOOR = "0.124.78";
32
38
 
33
39
  /** The first chant whose GitLab `scheduledRuns` takes `schedule`, the selector of an Op's `gitlab.scheduleRule` (#4813). */
34
- export const SCHEDULED_RUNS_SELECTOR_FLOOR = NEXT_RELEASE;
40
+ export const SCHEDULED_RUNS_SELECTOR_FLOOR = "0.124.78";
@@ -155,6 +155,13 @@
155
155
  },
156
156
  "description": "Added in contract 1 by #4463, written by chant 0.124.54 and newer. The inputs the member was previewed with stand-in values for (#4463), as var.<name>, sorted. Every attribute they drive is marked unknown in its entries, and its planDigest covers them."
157
157
  },
158
+ "outputs": {
159
+ "type": "array",
160
+ "items": {
161
+ "type": "string"
162
+ },
163
+ "description": "Added in contract 1 by #4849, written by chant 0.124.79 and newer. The outputs the member's plan changes, by name, sorted. Absent when it changes none. A member with any is a change even when every entry is a no-op. Its planDigest covers them."
164
+ },
158
165
  "holes": {
159
166
  "type": "array",
160
167
  "description": "What the planner could not read, so the plan says nothing about it.",
@@ -99,6 +99,24 @@ describe("a dispatched release (#4656)", () => {
99
99
  ]);
100
100
  });
101
101
 
102
+ test("under release.version the publish job stamps the label before the images and the build, and the cut stamps on its own (#4840)", () => {
103
+ const plain = parseYAML(dispatch("github", { groups: SECURE, images: true })) as GhDoc;
104
+ const doc = parseYAML(dispatch("github", { groups: SECURE, images: true, version: true })) as GhDoc;
105
+ const publish = runs(plain.jobs.publish!);
106
+ const at = publish.indexOf(`npx chant release images "$CHANT_RELEASE_LABEL" -o ${RELEASE_DIGESTS_FILE}`);
107
+ expect(runs(doc.jobs.publish!)).toEqual([...publish.slice(0, at), 'npx chant release stamp "$CHANT_RELEASE_LABEL"', ...publish.slice(at)]);
108
+ expect(runs(doc.jobs.cut!)).toEqual(runs(plain.jobs.cut!));
109
+ const gl = parseYAML(dispatch("gitlab", { images: true, version: true })) as Record<string, { script: string[] }>;
110
+ const script = gl["chant-release-publish"]!.script;
111
+ expect(script.indexOf('npx chant release stamp "$CHANT_RELEASE_LABEL"')).toBe(script.findIndex((l) => l.includes("release images")) - 1);
112
+ for (const forge of FORGES) {
113
+ const tagged = renderReleaseWorkflow({ forge, groups: new Set(), version: true });
114
+ const stamp = tagged.indexOf("release stamp ");
115
+ expect(stamp, forge).toBeGreaterThan(0);
116
+ expect(stamp, forge).toBeLessThan(tagged.indexOf("npm run build"));
117
+ }
118
+ });
119
+
102
120
  test("gitlab: four jobs chained by needs in the default stage, started with CHANT_RELEASE_LABEL, the commit handed on as a dotenv, pushes with CHANT_RELEASE_TOKEN", () => {
103
121
  const doc = parseYAML(dispatch("gitlab", { groups: SECURE, images: true })) as Record<string, { rules: Array<{ if: string }>; needs?: string[]; script: string[]; stage?: string; artifacts?: unknown; id_tokens?: unknown }>;
104
122
  expect(Object.keys(doc)).toEqual(["chant-release-gate", "chant-release-cut", "chant-release-publish", "chant-release-after"]);
@@ -109,6 +109,13 @@ export interface ReleaseWorkflowInput {
109
109
  imageArchives?: string[];
110
110
  /** `release.lane` (#4692): the gate's green lane. */
111
111
  lane?: string;
112
+ /**
113
+ * The config declares `release.version` (#4840): the publish job runs
114
+ * `chant release stamp <label>` before the images and the build, so what
115
+ * it builds and publishes carries the label as its version. The cut
116
+ * stamps on its own.
117
+ */
118
+ version?: boolean;
112
119
  /**
113
120
  * `release.publish` (#4767). On GitHub, a `forge: "github"` target with no
114
121
  * `tokenEnv` reads `GITHUB_TOKEN`, so the publish job sets it to the job's
@@ -141,6 +148,7 @@ export function renderReleaseWorkflow(input: ReleaseWorkflowInput): string {
141
148
  const flags = publishFlags(input.groups).join(" ");
142
149
  const after = p.after ?? [];
143
150
  const images = input.images === true;
151
+ const version = input.version === true;
144
152
  const extra = jobExtras(p, input.forge);
145
153
  // #4767: Forgejo's job token is not a GitHub token, and GitLab has no such expression.
146
154
  const forgeToken =
@@ -149,7 +157,7 @@ export function renderReleaseWorkflow(input: ReleaseWorkflowInput): string {
149
157
  : [];
150
158
  if (p.trigger === "dispatch") {
151
159
  const archives = images ? (input.imageArchives ?? []).map((a) => (root ? `${root}/${a.replace(/^\.\//, "")}` : a.replace(/^\.\//, ""))) : [];
152
- const o = { chant, install, build, root, verify, flags, after, images, archives, forge: input.forge, extra, forgeToken, gate: p.gate ?? "last-green", ...(input.lane ? { lane: input.lane } : {}) };
160
+ const o = { chant, install, build, root, verify, flags, after, images, version, archives, forge: input.forge, extra, forgeToken, gate: p.gate ?? "last-green", ...(input.lane ? { lane: input.lane } : {}) };
153
161
  return input.forge === "gitlab" ? renderGitlabDispatch(o) : renderGithubDispatch(o);
154
162
  }
155
163
  // #4657: the images are built from the release, so chant/lifecycle is fetched before them and the build after.
@@ -169,6 +177,7 @@ export function renderReleaseWorkflow(input: ReleaseWorkflowInput): string {
169
177
  ...(root ? [` - cd ${root}`] : []),
170
178
  ` - ${install}`,
171
179
  ...extra.gitlabScript.map((l) => ` - ${l}`),
180
+ ...(version ? [` - ${chant} release stamp ${label}`] : []),
172
181
  ...(images ? [...fetches, ...imageLines(label, `export CHANT_RELEASE_DIGESTS="$PWD/${RELEASE_DIGESTS_FILE}"`).map((l) => ` - ${l}`)] : []),
173
182
  ...(build ? [` - ${build}`] : []),
174
183
  ...(images ? [] : fetches),
@@ -211,6 +220,7 @@ export function renderReleaseWorkflow(input: ReleaseWorkflowInput): string {
211
220
  ...githubSetup(),
212
221
  ` - run: ${install}`,
213
222
  ...extra.githubSteps,
223
+ ...(version ? [` - run: ${chant} release stamp ${label}`] : []),
214
224
  ...(images ? [...fetches, ...imageLines(label, `echo "CHANT_RELEASE_DIGESTS=$PWD/${RELEASE_DIGESTS_FILE}" >> "$GITHUB_ENV"`).map((l) => ` - run: ${l}`)] : []),
215
225
  ...(build ? [` - run: ${build}`] : []),
216
226
  ...(images ? [] : fetches),
@@ -303,6 +313,8 @@ interface DispatchInput {
303
313
  flags: string;
304
314
  after: string[];
305
315
  images: boolean;
316
+ /** `release.version` (#4840): the publish job stamps the label before the images and the build. */
317
+ version: boolean;
306
318
  /** The image archives the cut hands to the publish job, from the repository root. Empty: the publish job builds them again. */
307
319
  archives: string[];
308
320
  forge: ReleaseWorkflowForge;
@@ -330,6 +342,11 @@ function imagesLine(o: DispatchInput): string {
330
342
  return `${o.chant} release images "$CHANT_RELEASE_LABEL"${o.archives.length > 0 ? " --no-build" : ""} -o ${RELEASE_DIGESTS_FILE}`;
331
343
  }
332
344
 
345
+ /** The publish job's `release stamp` line (#4840). */
346
+ function stampLine(o: DispatchInput): string {
347
+ return `${o.chant} release stamp "$CHANT_RELEASE_LABEL"`;
348
+ }
349
+
333
350
  /** The node one-liner that prints a JSON document's field from stdin, or from the file its argument names. */
334
351
  const field = (path: string): string =>
335
352
  `node -e 'const f=process.argv[1];const t=f?require("fs").readFileSync(f,"utf8"):require("fs").readFileSync(0,"utf8");const d=JSON.parse(t);process.stdout.write(String(${path}??""))'`;
@@ -436,6 +453,7 @@ function renderGithubDispatch(o: DispatchInput): string {
436
453
  ...(o.archives.length > 0
437
454
  ? [` - uses: ${usesRef(o.forge === "forgejo" ? ACTION_PINS.downloadArtifact3 : ACTION_PINS.downloadArtifact4)}`, " with:", ` name: ${RELEASE_IMAGES_ARTIFACT}`, ` path: ${commonDir(o.archives)}`]
438
455
  : []),
456
+ ...(o.version ? [` - run: ${stampLine(o)}`] : []),
439
457
  ...(o.images ? [` - run: ${imagesLine(o)}`, ` - run: echo "CHANT_RELEASE_DIGESTS=$PWD/${RELEASE_DIGESTS_FILE}" >> "$GITHUB_ENV"`] : []),
440
458
  ...(o.build ? [` - run: ${o.build}`] : []),
441
459
  ...(o.verify ? [` - run: ${o.chant} release verify "$CHANT_RELEASE_LABEL"`] : []),
@@ -490,6 +508,7 @@ function renderGitlabDispatch(o: DispatchInput): string {
490
508
  ...o.extra.gitlabScript,
491
509
  ...fetches,
492
510
  ...auth,
511
+ ...(o.version ? [stampLine(o)] : []),
493
512
  ...(o.images ? [imagesLine(o), `export CHANT_RELEASE_DIGESTS="$PWD/${RELEASE_DIGESTS_FILE}"`] : []),
494
513
  ...(o.build ? [o.build] : []),
495
514
  ...(o.verify ? [`${o.chant} release verify "$CHANT_RELEASE_LABEL"`] : []),
@@ -554,6 +573,7 @@ export async function runReleaseWorkflow(ctx: import("../cli/registry").CommandC
554
573
  ...(release?.workflow ? { pipeline: release.workflow } : {}),
555
574
  ...((release?.images?.length ?? 0) > 0 ? { images: true, imageArchives: resolveReleaseImages(release!.images!).map((i) => i.archive) } : {}),
556
575
  ...(release?.lane ? { lane: release.lane } : {}),
576
+ ...(release?.version ? { version: true } : {}),
557
577
  ...(release?.publish ? { publish: release.publish } : {}),
558
578
  ...(args.ciInstall ? { install: args.ciInstall } : {}),
559
579
  ...(args.buildCommand ? { build: args.buildCommand } : {}),