@intentius/chant 0.124.77 → 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 (228) hide show
  1. package/dist/__fixtures__/notify-messages/events.d.ts +9 -0
  2. package/dist/__fixtures__/notify-messages/events.d.ts.map +1 -0
  3. package/dist/__fixtures__/notify-messages/events.js +21 -0
  4. package/dist/__fixtures__/product-words.d.ts +14 -0
  5. package/dist/__fixtures__/product-words.d.ts.map +1 -1
  6. package/dist/__fixtures__/product-words.js +11 -0
  7. package/dist/__fixtures__/terragucci-notify.d.ts +66 -0
  8. package/dist/__fixtures__/terragucci-notify.d.ts.map +1 -0
  9. package/dist/__fixtures__/terragucci-notify.js +133 -0
  10. package/dist/action-pins.d.ts +8 -0
  11. package/dist/action-pins.d.ts.map +1 -1
  12. package/dist/action-pins.js +8 -0
  13. package/dist/agent-guard.d.ts.map +1 -1
  14. package/dist/agent-guard.js +1 -2
  15. package/dist/change-set.d.ts +10 -1
  16. package/dist/change-set.d.ts.map +1 -1
  17. package/dist/change-set.js +4 -1
  18. package/dist/ci-agent.d.ts +16 -2
  19. package/dist/ci-agent.d.ts.map +1 -1
  20. package/dist/ci-agent.js +6 -1
  21. package/dist/ci-commit.d.ts +66 -2
  22. package/dist/ci-commit.d.ts.map +1 -1
  23. package/dist/ci-commit.js +147 -19
  24. package/dist/ci-own-jobs.d.ts.map +1 -1
  25. package/dist/ci-own-jobs.js +1 -2
  26. package/dist/ci-product-words.d.ts +18 -4
  27. package/dist/ci-product-words.d.ts.map +1 -1
  28. package/dist/ci-product-words.js +26 -6
  29. package/dist/ci-product.d.ts +7 -3
  30. package/dist/ci-product.d.ts.map +1 -1
  31. package/dist/ci-product.js +8 -5
  32. package/dist/cli/handlers/release.d.ts +8 -0
  33. package/dist/cli/handlers/release.d.ts.map +1 -1
  34. package/dist/cli/handlers/release.js +68 -6
  35. package/dist/cli/handlers/run-wave.js +1 -0
  36. package/dist/cli/main.d.ts.map +1 -1
  37. package/dist/cli/main.js +7 -0
  38. package/dist/cli/mcp/product-tools.d.ts +6 -0
  39. package/dist/cli/mcp/product-tools.d.ts.map +1 -1
  40. package/dist/cli/mcp/product-tools.js +7 -0
  41. package/dist/cli/mcp/read-only.d.ts +12 -0
  42. package/dist/cli/mcp/read-only.d.ts.map +1 -1
  43. package/dist/cli/mcp/read-only.js +16 -0
  44. package/dist/cli/mcp/server.d.ts +11 -0
  45. package/dist/cli/mcp/server.d.ts.map +1 -1
  46. package/dist/cli/mcp/server.js +26 -5
  47. package/dist/cli/mcp/types.d.ts +5 -1
  48. package/dist/cli/mcp/types.d.ts.map +1 -1
  49. package/dist/components/capability.d.ts +42 -0
  50. package/dist/components/capability.d.ts.map +1 -1
  51. package/dist/components/group-digest.d.ts +17 -0
  52. package/dist/components/group-digest.d.ts.map +1 -0
  53. package/dist/components/group-digest.js +18 -0
  54. package/dist/components/groups.d.ts +2 -11
  55. package/dist/components/groups.d.ts.map +1 -1
  56. package/dist/components/groups.js +2 -12
  57. package/dist/components/index.d.ts +1 -1
  58. package/dist/components/index.d.ts.map +1 -1
  59. package/dist/components/pr-env-components.d.ts.map +1 -1
  60. package/dist/components/pr-env-components.js +1 -2
  61. package/dist/config.d.ts +28 -8
  62. package/dist/config.d.ts.map +1 -1
  63. package/dist/config.js +21 -1
  64. package/dist/lexicon.d.ts +8 -0
  65. package/dist/lexicon.d.ts.map +1 -1
  66. package/dist/lexicon.js +8 -0
  67. package/dist/lifecycle/release-cut.d.ts +7 -1
  68. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  69. package/dist/lifecycle/release-cut.js +1 -0
  70. package/dist/lifecycle/release-images.d.ts +86 -3
  71. package/dist/lifecycle/release-images.d.ts.map +1 -1
  72. package/dist/lifecycle/release-images.js +131 -6
  73. package/dist/lifecycle/release-publish.d.ts +8 -1
  74. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  75. package/dist/lifecycle/release-publish.js +30 -3
  76. package/dist/lifecycle/release-version.d.ts +86 -0
  77. package/dist/lifecycle/release-version.d.ts.map +1 -0
  78. package/dist/lifecycle/release-version.js +209 -0
  79. package/dist/mcp/types.d.ts +26 -0
  80. package/dist/mcp/types.d.ts.map +1 -1
  81. package/dist/notify-product.d.ts +11 -2
  82. package/dist/notify-product.d.ts.map +1 -1
  83. package/dist/notify-product.js +15 -4
  84. package/dist/notify-relay.d.ts.map +1 -1
  85. package/dist/notify-relay.js +1 -2
  86. package/dist/notify.d.ts +36 -4
  87. package/dist/notify.d.ts.map +1 -1
  88. package/dist/notify.js +31 -21
  89. package/dist/notify.schema.json +1 -0
  90. package/dist/op/activities/review-product.d.ts +111 -0
  91. package/dist/op/activities/review-product.d.ts.map +1 -0
  92. package/dist/op/activities/review-product.js +115 -0
  93. package/dist/op/gate.d.ts +17 -0
  94. package/dist/op/gate.d.ts.map +1 -1
  95. package/dist/op/gate.js +36 -0
  96. package/dist/op/index.d.ts +8 -6
  97. package/dist/op/index.d.ts.map +1 -1
  98. package/dist/op/index.js +5 -4
  99. package/dist/op/op-waves-after-plan.d.ts +76 -1
  100. package/dist/op/op-waves-after-plan.d.ts.map +1 -1
  101. package/dist/op/op-waves-after-plan.js +142 -3
  102. package/dist/op/op-waves-capability-spec.js +1 -2
  103. package/dist/op/op-waves-capability.d.ts +89 -2
  104. package/dist/op/op-waves-capability.d.ts.map +1 -1
  105. package/dist/op/op-waves-capability.js +215 -7
  106. package/dist/op/op-waves-run-hooks.d.ts +104 -0
  107. package/dist/op/op-waves-run-hooks.d.ts.map +1 -0
  108. package/dist/op/op-waves-run-hooks.js +146 -0
  109. package/dist/op/op-waves-run.d.ts +21 -0
  110. package/dist/op/op-waves-run.d.ts.map +1 -1
  111. package/dist/op/op-waves-run.js +233 -13
  112. package/dist/op/op-waves.d.ts +11 -1
  113. package/dist/op/op-waves.d.ts.map +1 -1
  114. package/dist/op/op-waves.js +7 -1
  115. package/dist/op/runtime.d.ts +2 -0
  116. package/dist/op/runtime.d.ts.map +1 -1
  117. package/dist/policy-engine.d.ts.map +1 -1
  118. package/dist/policy-engine.js +1 -2
  119. package/dist/pr-forge-reads.d.ts +124 -0
  120. package/dist/pr-forge-reads.d.ts.map +1 -0
  121. package/dist/pr-forge-reads.js +322 -0
  122. package/dist/pr-forge.d.ts +14 -0
  123. package/dist/pr-forge.d.ts.map +1 -1
  124. package/dist/pr-forge.js +21 -13
  125. package/dist/pr-plan-note.d.ts +293 -0
  126. package/dist/pr-plan-note.d.ts.map +1 -0
  127. package/dist/pr-plan-note.js +361 -0
  128. package/dist/release-floors.d.ts +13 -1
  129. package/dist/release-floors.d.ts.map +1 -1
  130. package/dist/release-floors.js +13 -1
  131. package/dist/state-export.d.ts.map +1 -1
  132. package/dist/state-export.js +1 -2
  133. package/dist/state-migration.d.ts.map +1 -1
  134. package/dist/state-migration.js +1 -2
  135. package/dist/state-unlock.d.ts.map +1 -1
  136. package/dist/state-unlock.js +1 -2
  137. package/dist/wave-runtime.mjs +314 -314
  138. package/dist/workspace/change-set.schema.json +7 -0
  139. package/dist/workspace/release-workflow.d.ts +7 -0
  140. package/dist/workspace/release-workflow.d.ts.map +1 -1
  141. package/dist/workspace/release-workflow.js +13 -2
  142. package/package.json +1 -1
  143. package/src/__fixtures__/notify-messages/events.ts +23 -0
  144. package/src/__fixtures__/notify-messages/messages.json +50 -0
  145. package/src/__fixtures__/pr-loop/terragucci-plan.note.golden.md +53 -0
  146. package/src/__fixtures__/pr-loop/terragucci-plan.note.json +83 -0
  147. package/src/__fixtures__/product-words.ts +12 -0
  148. package/src/__fixtures__/review-agent/terragucci-review.json +94 -0
  149. package/src/__fixtures__/terragucci-notify.ts +170 -0
  150. package/src/action-pins.test.ts +11 -1
  151. package/src/action-pins.ts +9 -0
  152. package/src/agent-guard.test.ts +1 -2
  153. package/src/agent-guard.ts +1 -2
  154. package/src/change-set.test.ts +20 -0
  155. package/src/change-set.ts +11 -1
  156. package/src/ci-agent.test.ts +9 -0
  157. package/src/ci-agent.ts +15 -2
  158. package/src/ci-commit.test.ts +162 -0
  159. package/src/ci-commit.ts +167 -21
  160. package/src/ci-own-jobs.test.ts +1 -2
  161. package/src/ci-own-jobs.ts +1 -2
  162. package/src/ci-product-words.ts +35 -7
  163. package/src/ci-product.ts +9 -6
  164. package/src/cli/handlers/build-pr-loop-control.test.ts +1 -2
  165. package/src/cli/handlers/build-run-group.test.ts +1 -2
  166. package/src/cli/handlers/release.ts +60 -7
  167. package/src/cli/handlers/run-wave.ts +1 -0
  168. package/src/cli/main.ts +7 -0
  169. package/src/cli/mcp/product-tools.test.ts +50 -0
  170. package/src/cli/mcp/product-tools.ts +8 -0
  171. package/src/cli/mcp/read-only.ts +19 -0
  172. package/src/cli/mcp/server.test.ts +30 -0
  173. package/src/cli/mcp/server.ts +28 -5
  174. package/src/cli/mcp/types.ts +6 -1
  175. package/src/components/capability.ts +41 -0
  176. package/src/components/group-digest.ts +20 -0
  177. package/src/components/groups.ts +3 -13
  178. package/src/components/index.ts +2 -0
  179. package/src/components/pr-env-components.test.ts +1 -2
  180. package/src/components/pr-env-components.ts +1 -2
  181. package/src/config.ts +38 -3
  182. package/src/gate-policy-bundle.test.ts +1 -1
  183. package/src/lexicon.ts +9 -0
  184. package/src/lifecycle/release-cut.ts +11 -0
  185. package/src/lifecycle/release-images-dockerfile.test.ts +229 -0
  186. package/src/lifecycle/release-images.ts +171 -8
  187. package/src/lifecycle/release-publish.ts +34 -3
  188. package/src/lifecycle/release-version.test.ts +155 -0
  189. package/src/lifecycle/release-version.ts +227 -0
  190. package/src/mcp/types.ts +27 -0
  191. package/src/notify-message-words.test.ts +185 -0
  192. package/src/notify-product.ts +16 -4
  193. package/src/notify-relay.ts +1 -2
  194. package/src/notify.schema.json +1 -0
  195. package/src/notify.ts +59 -19
  196. package/src/op/activities/review-product.test.ts +116 -0
  197. package/src/op/activities/review-product.ts +199 -0
  198. package/src/op/gate.ts +46 -0
  199. package/src/op/index.ts +10 -4
  200. package/src/op/op-waves-after-plan-wave.test.ts +226 -0
  201. package/src/op/op-waves-after-plan.ts +170 -5
  202. package/src/op/op-waves-capability-spec.ts +1 -1
  203. package/src/op/op-waves-capability.test.ts +6 -0
  204. package/src/op/op-waves-capability.ts +243 -10
  205. package/src/op/op-waves-run-hooks.test.ts +184 -0
  206. package/src/op/op-waves-run-hooks.ts +195 -0
  207. package/src/op/op-waves-run.ts +240 -16
  208. package/src/op/op-waves-step-wave.test.ts +277 -0
  209. package/src/op/op-waves.ts +15 -2
  210. package/src/op/runtime.ts +2 -0
  211. package/src/op/schedule-overdue.test.ts +26 -0
  212. package/src/policy-engine.test.ts +1 -2
  213. package/src/policy-engine.ts +1 -2
  214. package/src/pr-forge-reads.test.ts +285 -0
  215. package/src/pr-forge-reads.ts +424 -0
  216. package/src/pr-forge.ts +30 -16
  217. package/src/pr-plan-note.test.ts +105 -0
  218. package/src/pr-plan-note.ts +520 -0
  219. package/src/release-floors.ts +19 -1
  220. package/src/state-export.test.ts +1 -2
  221. package/src/state-export.ts +1 -2
  222. package/src/state-migration.test.ts +1 -2
  223. package/src/state-migration.ts +1 -2
  224. package/src/state-unlock.test.ts +1 -2
  225. package/src/state-unlock.ts +1 -2
  226. package/src/workspace/change-set.schema.json +7 -0
  227. package/src/workspace/release-workflow.test.ts +18 -0
  228. package/src/workspace/release-workflow.ts +23 -2
@@ -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). */
@@ -129,6 +129,32 @@ describe("scheduledRuns", () => {
129
129
  expect(await forge.scheduledRuns!({ op: "drift", workflow: "ops.gitlab-ci.yml" })).toEqual({ last: "2026-10-01T06:00:00Z" });
130
130
  expect(await forge.scheduledRuns!({ op: "nobody", workflow: "ops.gitlab-ci.yml" })).toEqual({ noSchedule: true });
131
131
  });
132
+
133
+ test("gitlab: the schedules a scheduleRule picks, a schedule without the variable among them (#4813)", async () => {
134
+ const schedules: Record<number, unknown> = {
135
+ 1: { id: 1, variables: [{ key: "TERRAGUCCI_SCHEDULE", value: "comments" }], last_pipeline: { id: 900 } },
136
+ 2: { id: 2, variables: [], last_pipeline: { id: 901 } },
137
+ 3: { id: 3, variables: [{ key: "TERRAGUCCI_SCHEDULE", value: "nightly" }], last_pipeline: { id: 902 } },
138
+ };
139
+ const created: Record<number, string> = { 900: "2026-10-09T00:00:00Z", 901: "2026-10-05T06:00:00Z", 902: "2026-10-07T06:00:00Z" };
140
+ const project = (ids: number[]) =>
141
+ fakeFetch((_m, u) => {
142
+ const p = u.pathname.replace("/api/v4/projects/42", "");
143
+ if (p === "/pipeline_schedules") return ids.map((id) => ({ id }));
144
+ const s = /^\/pipeline_schedules\/(\d+)$/.exec(p);
145
+ if (s) return schedules[Number(s[1])];
146
+ const pl = /^\/pipelines\/(\d+)$/.exec(p);
147
+ return pl ? { id: Number(pl[1]), created_at: created[Number(pl[1])] } : undefined;
148
+ });
149
+ const drift = { op: "tf-drift", workflow: ".gitlab-ci.yml", schedule: { variable: "TERRAGUCCI_SCHEDULE", not: ["comments", "resume", "rollouts", "ephemeral"] } };
150
+ const forge = (ids: number[]) => gitlabForge({ apiBase: "https://gitlab.com/api/v4", project: "42", token: "t", fetch: project(ids) });
151
+ expect(await forge([1, 2, 3]).scheduledRuns!(drift)).toEqual({ last: "2026-10-07T06:00:00Z" });
152
+ expect(await forge([1]).scheduledRuns!(drift)).toEqual({ noSchedule: true });
153
+ // Without a selector, none of these sets CHANT_SCHEDULED_OP.
154
+ expect(await forge([1, 2, 3]).scheduledRuns!({ op: "tf-drift", workflow: ".gitlab-ci.yml" })).toEqual({ noSchedule: true });
155
+ // A value picks the schedules that set the variable to it, and `not` still applies.
156
+ expect(await forge([1, 2, 3]).scheduledRuns!({ ...drift, schedule: { variable: "TERRAGUCCI_SCHEDULE", value: "comments" } })).toEqual({ last: "2026-10-09T00:00:00Z" });
157
+ });
132
158
  });
133
159
 
134
160
  describe("checkOverdueOps", () => {
@@ -17,7 +17,6 @@ import {
17
17
  policyEngineRelease,
18
18
  tarEntry,
19
19
  } from "./policy-engine";
20
- import { NEXT_RELEASE } from "./release-floors";
21
20
 
22
21
  const scratch: string[] = [];
23
22
  afterAll(() => {
@@ -69,7 +68,7 @@ describe("the pins (#4774)", () => {
69
68
  }
70
69
  }
71
70
  expect(Object.keys(POLICY_ENGINE_SHA256)).toHaveLength(POLICY_ENGINE_PLATFORMS.length * 2);
72
- expect(POLICY_ENGINE_INSTALL_FLOOR).toBe(NEXT_RELEASE);
71
+ expect(POLICY_ENGINE_INSTALL_FLOOR).toBe("0.124.77");
73
72
  });
74
73
 
75
74
  test("the release files are the ones each project publishes", () => {
@@ -25,10 +25,9 @@ import { chmodSync, existsSync, mkdirSync, renameSync, writeFileSync } from "nod
25
25
  import { tmpdir } from "node:os";
26
26
  import { join } from "node:path";
27
27
  import { gunzipSync } from "node:zlib";
28
- import { NEXT_RELEASE } from "./release-floors";
29
28
 
30
29
  /** The first chant with `ci.policy.install` and `@intentius/chant/policy-engine` (#4774). Products feature-detect on it. */
31
- export const POLICY_ENGINE_INSTALL_FLOOR = NEXT_RELEASE;
30
+ export const POLICY_ENGINE_INSTALL_FLOOR = "0.124.77";
32
31
 
33
32
  export type PolicyEngineName = "conftest" | "opa";
34
33