@intentius/chant 0.124.89 → 0.124.91

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 (185) hide show
  1. package/dist/actor.d.ts +5 -3
  2. package/dist/actor.d.ts.map +1 -1
  3. package/dist/actor.js +7 -5
  4. package/dist/audit/core.d.ts.map +1 -1
  5. package/dist/audit/core.js +11 -1
  6. package/dist/ci-comment-commands.d.ts +18 -2
  7. package/dist/ci-comment-commands.d.ts.map +1 -1
  8. package/dist/ci-comment-commands.js +30 -2
  9. package/dist/ci-job-guard.d.ts +42 -45
  10. package/dist/ci-job-guard.d.ts.map +1 -1
  11. package/dist/ci-job-guard.js +206 -3
  12. package/dist/ci-note-commands.d.ts +41 -1
  13. package/dist/ci-note-commands.d.ts.map +1 -1
  14. package/dist/ci-note-commands.js +64 -5
  15. package/dist/ci-product.d.ts +50 -1
  16. package/dist/ci-product.d.ts.map +1 -1
  17. package/dist/ci-product.js +52 -6
  18. package/dist/cli/handlers/pr-comment.d.ts +13 -1
  19. package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
  20. package/dist/cli/handlers/pr-comment.js +90 -1
  21. package/dist/cli/handlers/pr-notes.d.ts.map +1 -1
  22. package/dist/cli/handlers/pr-notes.js +23 -1
  23. package/dist/cli/handlers/pr.d.ts +2 -2
  24. package/dist/cli/handlers/pr.d.ts.map +1 -1
  25. package/dist/cli/handlers/pr.js +41 -20
  26. package/dist/cli/handlers/run-wave.d.ts.map +1 -1
  27. package/dist/cli/handlers/run-wave.js +154 -4
  28. package/dist/cli/main.d.ts.map +1 -1
  29. package/dist/cli/main.js +17 -0
  30. package/dist/cli/parse-args.d.ts.map +1 -1
  31. package/dist/cli/parse-args.js +28 -0
  32. package/dist/cli/registry.d.ts +12 -1
  33. package/dist/cli/registry.d.ts.map +1 -1
  34. package/dist/components/pr-checks.d.ts +39 -1
  35. package/dist/components/pr-checks.d.ts.map +1 -1
  36. package/dist/components/pr-checks.js +45 -2
  37. package/dist/components/pr-pipeline.d.ts +11 -3
  38. package/dist/components/pr-pipeline.d.ts.map +1 -1
  39. package/dist/components/pr-pipeline.js +20 -7
  40. package/dist/components/product-pipeline.d.ts +54 -2
  41. package/dist/components/product-pipeline.d.ts.map +1 -1
  42. package/dist/components/product-pipeline.js +63 -6
  43. package/dist/components/product-plan.d.ts +92 -2
  44. package/dist/components/product-plan.d.ts.map +1 -1
  45. package/dist/components/product-plan.js +172 -22
  46. package/dist/floor-table.data.d.ts.map +1 -1
  47. package/dist/floor-table.data.js +37 -23
  48. package/dist/lexicon-module.d.ts +2 -0
  49. package/dist/lexicon-module.d.ts.map +1 -1
  50. package/dist/lexicon-module.js +6 -2
  51. package/dist/lexicon.d.ts +82 -4
  52. package/dist/lexicon.d.ts.map +1 -1
  53. package/dist/lifecycle/gate-applied.d.ts +9 -0
  54. package/dist/lifecycle/gate-applied.d.ts.map +1 -1
  55. package/dist/op/apply-status.d.ts +84 -0
  56. package/dist/op/apply-status.d.ts.map +1 -0
  57. package/dist/op/apply-status.js +106 -0
  58. package/dist/op/before-merge-decide.d.ts +102 -0
  59. package/dist/op/before-merge-decide.d.ts.map +1 -0
  60. package/dist/op/before-merge-decide.js +142 -0
  61. package/dist/op/before-merge-done.d.ts +56 -0
  62. package/dist/op/before-merge-done.d.ts.map +1 -0
  63. package/dist/op/before-merge-done.js +69 -0
  64. package/dist/op/before-merge-store.d.ts +20 -0
  65. package/dist/op/before-merge-store.d.ts.map +1 -0
  66. package/dist/op/before-merge-store.js +48 -0
  67. package/dist/op/before-merge.d.ts +150 -0
  68. package/dist/op/before-merge.d.ts.map +1 -0
  69. package/dist/op/before-merge.js +207 -0
  70. package/dist/op/follow-on-run.d.ts +117 -0
  71. package/dist/op/follow-on-run.d.ts.map +1 -0
  72. package/dist/op/follow-on-run.js +154 -0
  73. package/dist/op/follow-on-store.d.ts +17 -0
  74. package/dist/op/follow-on-store.d.ts.map +1 -0
  75. package/dist/op/follow-on-store.js +54 -0
  76. package/dist/op/gate.d.ts +6 -0
  77. package/dist/op/gate.d.ts.map +1 -1
  78. package/dist/op/gate.js +10 -1
  79. package/dist/op/index.d.ts +3 -1
  80. package/dist/op/index.d.ts.map +1 -1
  81. package/dist/op/index.js +1 -0
  82. package/dist/op/op-waves-after-plan.d.ts +13 -0
  83. package/dist/op/op-waves-after-plan.d.ts.map +1 -1
  84. package/dist/op/op-waves-evidence-jobs.d.ts +4 -1
  85. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
  86. package/dist/op/op-waves-evidence-jobs.js +10 -2
  87. package/dist/op/op-waves-follow-on.d.ts +162 -0
  88. package/dist/op/op-waves-follow-on.d.ts.map +1 -0
  89. package/dist/op/op-waves-follow-on.js +355 -0
  90. package/dist/op/op-waves-run.d.ts +146 -6
  91. package/dist/op/op-waves-run.d.ts.map +1 -1
  92. package/dist/op/op-waves-run.js +871 -99
  93. package/dist/op/op-waves-split.d.ts +122 -0
  94. package/dist/op/op-waves-split.d.ts.map +1 -0
  95. package/dist/op/op-waves-split.js +166 -0
  96. package/dist/op/op-waves.d.ts +20 -0
  97. package/dist/op/op-waves.d.ts.map +1 -1
  98. package/dist/op/op-waves.js +15 -1
  99. package/dist/op/schedule-overdue.d.ts +15 -1
  100. package/dist/op/schedule-overdue.d.ts.map +1 -1
  101. package/dist/op/schedule-overdue.js +18 -2
  102. package/dist/op/stage-hooks.d.ts +36 -1
  103. package/dist/op/stage-hooks.d.ts.map +1 -1
  104. package/dist/op/stage-hooks.js +17 -3
  105. package/dist/op/wave-stop.d.ts +4 -1
  106. package/dist/op/wave-stop.d.ts.map +1 -1
  107. package/dist/op/wave-stop.js +4 -2
  108. package/dist/planned-files.d.ts +16 -8
  109. package/dist/planned-files.d.ts.map +1 -1
  110. package/dist/planned-files.js +12 -8
  111. package/dist/pr-post.d.ts +6 -0
  112. package/dist/pr-post.d.ts.map +1 -1
  113. package/dist/pr-post.js +7 -5
  114. package/dist/release-floors.d.ts +9 -1
  115. package/dist/release-floors.d.ts.map +1 -1
  116. package/dist/release-floors.js +27 -19
  117. package/dist/wave-blocked.d.ts +7 -1
  118. package/dist/wave-blocked.d.ts.map +1 -1
  119. package/dist/wave-blocked.js +7 -2
  120. package/dist/wave-runtime.mjs +364 -351
  121. package/package.json +1 -1
  122. package/src/actor.test.ts +14 -1
  123. package/src/actor.ts +8 -6
  124. package/src/audit/core.ts +13 -1
  125. package/src/audit/first-load.test.ts +101 -0
  126. package/src/ci-comment-commands.test.ts +63 -0
  127. package/src/ci-comment-commands.ts +43 -4
  128. package/src/ci-image.test.ts +1 -2
  129. package/src/ci-job-guard.before-merge.test.ts +148 -0
  130. package/src/ci-job-guard.follow-on-record.test.ts +137 -0
  131. package/src/ci-job-guard.follow-on.test.ts +144 -0
  132. package/src/ci-job-guard.ts +221 -3
  133. package/src/ci-note-commands.test.ts +76 -1
  134. package/src/ci-note-commands.ts +96 -7
  135. package/src/ci-product.ts +65 -6
  136. package/src/cli/handlers/pr-comment.ts +85 -2
  137. package/src/cli/handlers/pr-notes.ts +30 -6
  138. package/src/cli/handlers/pr.ts +34 -17
  139. package/src/cli/handlers/run-wave.ts +144 -4
  140. package/src/cli/main.ts +17 -0
  141. package/src/cli/parse-args.ts +20 -0
  142. package/src/cli/registry.ts +12 -1
  143. package/src/components/pr-checks.ts +66 -2
  144. package/src/components/pr-pipeline.ts +21 -9
  145. package/src/components/product-pipeline.apply-status.test.ts +50 -0
  146. package/src/components/product-pipeline.ts +117 -9
  147. package/src/components/product-plan-names.test.ts +135 -0
  148. package/src/components/product-plan.test.ts +23 -5
  149. package/src/components/product-plan.ts +248 -25
  150. package/src/floor-table.data.ts +37 -23
  151. package/src/lexicon-module.ts +6 -2
  152. package/src/lexicon.ts +78 -1
  153. package/src/lifecycle/gate-applied.ts +7 -0
  154. package/src/op/apply-status.test.ts +83 -0
  155. package/src/op/apply-status.ts +132 -0
  156. package/src/op/before-merge-decide.ts +190 -0
  157. package/src/op/before-merge-done.ts +99 -0
  158. package/src/op/before-merge-store.ts +44 -0
  159. package/src/op/before-merge.test.ts +201 -0
  160. package/src/op/before-merge.ts +266 -0
  161. package/src/op/follow-on-run.ts +206 -0
  162. package/src/op/follow-on-store.ts +54 -0
  163. package/src/op/gate.ts +16 -1
  164. package/src/op/index.ts +5 -0
  165. package/src/op/op-waves-after-plan.ts +13 -0
  166. package/src/op/op-waves-evidence-jobs.ts +11 -3
  167. package/src/op/op-waves-follow-on-record.test.ts +152 -0
  168. package/src/op/op-waves-follow-on.test.ts +247 -0
  169. package/src/op/op-waves-follow-on.ts +385 -0
  170. package/src/op/op-waves-render-spec.test.ts +1 -2
  171. package/src/op/op-waves-run.ts +971 -93
  172. package/src/op/op-waves-split-product.test.ts +288 -0
  173. package/src/op/op-waves-split-step.test.ts +298 -0
  174. package/src/op/op-waves-split.test.ts +196 -0
  175. package/src/op/op-waves-split.ts +189 -0
  176. package/src/op/op-waves.ts +28 -3
  177. package/src/op/schedule-overdue.test.ts +29 -1
  178. package/src/op/schedule-overdue.ts +27 -3
  179. package/src/op/stage-hooks.ts +52 -4
  180. package/src/op/wave-stop.ts +5 -3
  181. package/src/planned-files.test.ts +33 -0
  182. package/src/planned-files.ts +26 -10
  183. package/src/pr-post.ts +13 -5
  184. package/src/release-floors.ts +31 -19
  185. package/src/wave-blocked.ts +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.124.89",
3
+ "version": "0.124.91",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
package/src/actor.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** #4911: one actor fallback for the lexicons' gated requests and the products' requesters. */
2
2
  import { execFileSync } from "node:child_process";
3
- import { mkdtempSync, readdirSync, readFileSync, statSync } from "node:fs";
3
+ import { mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { join, relative } from "node:path";
6
6
  import { beforeAll, describe, expect, test } from "vitest";
@@ -45,6 +45,19 @@ describe("actorOf", () => {
45
45
  expect(actorOrder({ triggering: true, repo })).toEqual(["GITHUB_TRIGGERING_ACTOR", "GITHUB_ACTOR", "GITLAB_USER_LOGIN", "git:user.name", "USER", "USERNAME"]);
46
46
  });
47
47
 
48
+ /** #5005: git reads the config the given env names, not the process's. */
49
+ test("git config runs with the env it is given", () => {
50
+ const home = mkdtempSync(join(tmpdir(), "chant-actor-home-"));
51
+ const bare = mkdtempSync(join(tmpdir(), "chant-actor-bare-"));
52
+ execFileSync("git", ["init", "-q", bare]);
53
+ const global = join(home, "gitconfig");
54
+ writeFileSync(global, "[user]\n\tname = Job Identity\n");
55
+ const base = { PATH: process.env.PATH, HOME: home, GIT_CONFIG_NOSYSTEM: "1", USER: "me" };
56
+ expect(actorOf({ env: { ...base, GIT_CONFIG_GLOBAL: global }, repo: bare })).toBe("Job Identity");
57
+ expect(actorOf({ env: { ...base, GIT_CONFIG_GLOBAL: join(home, "none") }, repo: bare })).toBe("me");
58
+ expect(actorOf({ env: { ...base, GIT_CONFIG_GLOBAL: global }, repo })).toBe("Ada Person");
59
+ });
60
+
48
61
  test("the forge and the login can be left out, and the fallback named", () => {
49
62
  expect(actorOf({ env: { GITHUB_ACTOR: "octo", USER: "me" }, forge: false, repo })).toBe("Ada Person");
50
63
  expect(actorOf({ env: { USER: "me" }, triggering: true, login: false, fallback: "" })).toBe("");
package/src/actor.ts CHANGED
@@ -30,7 +30,7 @@ export function actorFromEnv(env: Record<string, string | undefined> = process.e
30
30
 
31
31
  /** Which of the places {@link actorOf} reads, and the answer when none is set. */
32
32
  export interface ActorOptions {
33
- /** The variables. Default `process.env`. */
33
+ /** The variables, and the environment the `git config` for `repo` runs with (#5005). Default `process.env`. */
34
34
  env?: Record<string, string | undefined>;
35
35
  /** Read `GITHUB_TRIGGERING_ACTOR` first: who re-ran the job, ahead of who started the run. Default false. */
36
36
  triggering?: boolean;
@@ -56,8 +56,8 @@ export function actorOrder(options: Omit<ActorOptions, "env" | "fallback"> = {})
56
56
  ];
57
57
  }
58
58
 
59
- function gitConfig(repo: string, key: string): string | undefined {
60
- const r = spawnSync("git", ["-C", repo, "config", key], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] });
59
+ function gitConfig(repo: string, key: string, env: Record<string, string | undefined>): string | undefined {
60
+ const r = spawnSync("git", ["-C", repo, "config", key], { encoding: "utf-8", env, stdio: ["ignore", "pipe", "ignore"] });
61
61
  return r.status === 0 ? r.stdout.trim() : undefined;
62
62
  }
63
63
 
@@ -65,15 +65,17 @@ function gitConfig(repo: string, key: string): string | undefined {
65
65
  * The first place of {@link actorOrder} set to something other than blanks,
66
66
  * else `fallback` (#4966). With no options it answers as
67
67
  * {@link actorFromEnv}. A git config key is read only when every place
68
- * before it is empty, so a job with a forge actor runs no git.
68
+ * before it is empty, so a job with a forge actor runs no git. git runs
69
+ * with `env`, so a job's `GIT_CONFIG_GLOBAL` or `HOME` picks the config it
70
+ * reads, not the process's (#5005).
69
71
  */
70
72
  export function actorOf(options: ActorOptions = {}): string {
71
73
  const env = options.env ?? process.env;
72
74
  for (const place of actorOrder(options)) {
73
- const v = (place.startsWith("git:") ? gitConfig(options.repo!, place.slice(4)) : env[place])?.trim();
75
+ const v = (place.startsWith("git:") ? gitConfig(options.repo!, place.slice(4), env) : env[place])?.trim();
74
76
  if (v) return v;
75
77
  }
76
78
  return options.fallback ?? "unknown";
77
79
  }
78
80
 
79
- export { ACTOR_ORDER_FLOOR } from "./release-floors";
81
+ export { ACTOR_GIT_ENV_FLOOR, ACTOR_ORDER_FLOOR } from "./release-floors";
package/src/audit/core.ts CHANGED
@@ -27,7 +27,7 @@ import { applyInlineSuppressions, type SuppressionMetaFinding } from "../lint/su
27
27
  import type { SerializerResult } from "../serializer";
28
28
  import type { AuditEntitiesInput, LexiconPlugin } from "../lexicon";
29
29
  import type { Declarable } from "../declarable";
30
- import { lexiconModulePath, lexiconPackagesToInstall, lexiconSourceLabel } from "../lexicon-module";
30
+ import { isPackageNotFound, lexiconModulePath, lexiconPackagesToInstall, lexiconSourceLabel } from "../lexicon-module";
31
31
 
32
32
  /**
33
33
  * The lexicon whose post-synth checks run against an audited file. Any lexicon
@@ -166,6 +166,18 @@ async function load(names: string[]): Promise<LexiconPlugin[]> {
166
166
  `Could not load the lexicon module ${paths.join(", ")} needed to audit ${names.join("/")} workflows.\n(${detail})`,
167
167
  );
168
168
  }
169
+ // chant#4881 — only a package that can't be resolved is missing. Any other
170
+ // failure (a module the package imports, its `init()`, a cross-lexicon
171
+ // conflict) is reported as itself, so nobody is told to install a package
172
+ // they have.
173
+ if (paths.length === 0 && !pkgs.some((pkg) => isPackageNotFound(err, pkg))) {
174
+ const generated = /[\\/]generated[\\/]index\b/.test(detail)
175
+ ? " Its src/generated/ code is missing; in a source checkout, run the lexicon's `npm run generate`."
176
+ : "";
177
+ throw new Error(
178
+ `The lexicon package ${pkgs.join(", ")} needed to audit ${names.join("/")} workflows is installed but failed to load: ${detail}${generated}`,
179
+ );
180
+ }
169
181
  const fromPath = paths.length > 0 ? ` The lexicon module ${paths.join(", ")} is declared by path and has nothing to install.` : "";
170
182
  throw new MissingLexiconError(
171
183
  `Missing lexicon package needed to audit ${names.join("/")} workflows. Install it with: npm i ${pkgs.join(" ")}${fromPath}\n(${detail})`,
@@ -0,0 +1,101 @@
1
+ /**
2
+ * chant#4881 — the first `auditFiles` call for a lexicon, in a fresh module
3
+ * graph, either gets findings or reports why it can't. `MissingLexiconError`
4
+ * is kept for a package that can't be resolved. A package that resolves but
5
+ * fails to load (here, one whose barrel re-exports a `generated/` module that
6
+ * was never generated, as a source checkout's lexicons do before
7
+ * `npm run generate`) is reported as that failure, not as missing.
8
+ *
9
+ * Each test re-imports `./core` after `vi.resetModules()`, so no earlier load
10
+ * of the same lexicon can warm it.
11
+ */
12
+ import { describe, test, expect, beforeAll, afterAll, beforeEach, vi } from "vitest";
13
+ import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
14
+ import { tmpdir } from "node:os";
15
+ import { join } from "node:path";
16
+ import type { AuditInput } from "./core";
17
+
18
+ const GOOD = "zz4881good";
19
+ const BROKEN = "zz4881broken";
20
+ let project: string;
21
+
22
+ const plugin = (name: string) => `export const ${name}Plugin = {
23
+ name: "${name}",
24
+ serializer: { name: "${name}", serialize: () => "" },
25
+ generate: async () => {},
26
+ validate: async () => {},
27
+ coverage: async () => {},
28
+ package: async () => {},
29
+ postSynthChecks: () => [{
30
+ id: "ZZ4881",
31
+ description: "flags every audited file",
32
+ check: (ctx) => [...ctx.outputs.keys()].map((key) => ({ checkId: "ZZ4881", severity: "error", message: "flagged " + key })),
33
+ }],
34
+ };
35
+ `;
36
+
37
+ async function writeLexicon(name: string, index: string): Promise<void> {
38
+ const dir = join(project, "node_modules", "@intentius", `chant-lexicon-${name}`);
39
+ await mkdir(dir, { recursive: true });
40
+ await writeFile(
41
+ join(dir, "package.json"),
42
+ JSON.stringify({ name: `@intentius/chant-lexicon-${name}`, version: "0.0.1", type: "module", exports: { ".": { default: "./index.js" } } }),
43
+ );
44
+ await writeFile(join(dir, "index.js"), index);
45
+ }
46
+
47
+ beforeAll(async () => {
48
+ project = await mkdtemp(join(tmpdir(), "chant-4881-"));
49
+ await writeFile(join(project, "package.json"), JSON.stringify({ name: "chant-4881-project", private: true }));
50
+ await writeLexicon(GOOD, plugin(GOOD));
51
+ await writeLexicon(BROKEN, `${plugin(BROKEN)}export * from "./generated/index.js";\n`);
52
+ });
53
+
54
+ afterAll(async () => {
55
+ await rm(project, { recursive: true, force: true });
56
+ });
57
+
58
+ beforeEach(() => {
59
+ vi.resetModules();
60
+ });
61
+
62
+ /** One `auditFiles` call from a fresh module graph, run from the fixture project. */
63
+ async function auditOnce(lexicon: string): Promise<{ result?: unknown; error?: unknown; MissingLexiconError: Function }> {
64
+ const core = await import("./core");
65
+ const input: AuditInput = { path: "ci.yml", content: "name: ci\n", lexicon };
66
+ const cwd = process.cwd();
67
+ process.chdir(project);
68
+ try {
69
+ return { result: await core.auditFiles([input]), MissingLexiconError: core.MissingLexiconError };
70
+ } catch (error) {
71
+ return { error, MissingLexiconError: core.MissingLexiconError };
72
+ } finally {
73
+ process.chdir(cwd);
74
+ }
75
+ }
76
+
77
+ describe("the first load of a lexicon (#4881)", () => {
78
+ test("an installed lexicon gets findings on the first call", async () => {
79
+ const { result, error } = await auditOnce(GOOD);
80
+ expect(error).toBeUndefined();
81
+ expect(result).toEqual([expect.objectContaining({ checkId: "ZZ4881", file: "ci.yml", lexicon: GOOD })]);
82
+ });
83
+
84
+ test("an uninstalled lexicon gets MissingLexiconError", async () => {
85
+ const { error, MissingLexiconError } = await auditOnce("zz4881absent");
86
+ expect(error).toBeInstanceOf(MissingLexiconError);
87
+ expect((error as Error).message).toContain("npm i @intentius/chant-lexicon-zz4881absent");
88
+ });
89
+
90
+ test("an installed lexicon that fails to load reports the failure, not a missing package", async () => {
91
+ const { error, MissingLexiconError } = await auditOnce(BROKEN);
92
+ expect(error).toBeInstanceOf(Error);
93
+ expect(error).not.toBeInstanceOf(MissingLexiconError);
94
+ const message = (error as Error).message;
95
+ expect(message).toContain(`@intentius/chant-lexicon-${BROKEN}`);
96
+ expect(message).toContain("is installed but failed to load");
97
+ expect(message).toMatch(/generated[\\/]index/);
98
+ expect(message).toContain("npm run generate");
99
+ expect(message).not.toContain("npm i ");
100
+ });
101
+ });
@@ -374,3 +374,66 @@ describe("a wave stop on a re-run, and a re-plan comment with flags (#4979)", ()
374
374
  expect(() => commentJobsFromEnv('{"waves":{"op":"tf-apply","count":0}}')).toThrow(/waves is \{ op, count \}/);
375
375
  });
376
376
  });
377
+
378
+ describe("the comment job's apply before merge on the waves (#4984)", () => {
379
+ const bm = { workflow: "tf-apply.yml", plan: ["terragucci/plan"], pipelineFiles: [".github/workflows/"] };
380
+ const jobs: CommentJobs = { applyOnMerge: true, waves: { op: "tf-apply", count: 2 }, wavesBeforeMerge: bm };
381
+
382
+ test("an open pull request's apply is decided, and the waves workflow dispatched on the default branch with the decided head", async () => {
383
+ const { spawnSync } = await import("node:child_process");
384
+ const { mkdtempSync, writeFileSync } = await import("node:fs");
385
+ const { tmpdir } = await import("node:os");
386
+ const { join } = await import("node:path");
387
+ const { beforeMergeDigest } = await import("./op/before-merge");
388
+ const dir = mkdtempSync(join(tmpdir(), "chant-cc-bm-"));
389
+ const git = (...args: string[]) => {
390
+ const r = spawnSync("git", args, { cwd: dir, encoding: "utf-8", env: { ...process.env, GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "t@t", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "t@t" } });
391
+ if (r.status !== 0) throw new Error(r.stderr);
392
+ return r.stdout.trim();
393
+ };
394
+ git("init", "-q", "-b", "main");
395
+ writeFileSync(join(dir, "main.tf"), "1");
396
+ git("add", ".");
397
+ git("commit", "-q", "-m", "base");
398
+ const baseSha = git("rev-parse", "HEAD");
399
+ git("checkout", "-q", "-b", "feature");
400
+ writeFileSync(join(dir, "main.tf"), "2");
401
+ git("commit", "-q", "-am", "head");
402
+ const head = git("rev-parse", "HEAD");
403
+ git("update-ref", "refs/pull/12/head", head);
404
+ git("checkout", "-q", "main");
405
+ git("remote", "add", "origin", dir);
406
+ const s = setup({ pr: { state: "open", headSha: head, mergeCommit: undefined } }, jobs, "/terragucci apply wave-1");
407
+ const sent: Array<[string, string, Record<string, string> | undefined]> = [];
408
+ const stops: Array<[string, number | null]> = [];
409
+ const at = "2026-11-10T12:00:00.000Z";
410
+ const got = await answerProductComment({
411
+ ...s.opts,
412
+ runs: { rerunFailed: async () => ({}), dispatch: async (wf, ref, inputs) => (sent.push([wf, ref, inputs]), {}) },
413
+ beforeMerge: {
414
+ requires: async () => null,
415
+ statuses: async () => [{ context: "terragucci/plan", state: "success" }],
416
+ git: (argv, o) => {
417
+ const r = spawnSync(argv[0]!, argv.slice(1), { encoding: "utf8", ...(o.cwd ? { cwd: o.cwd } : {}) });
418
+ return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
419
+ },
420
+ cwd: dir,
421
+ record: async (d) => ({ ...d, digest: beforeMergeDigest("tf-apply", d) }),
422
+ stop: async (h, through) => void stops.push([h, through]),
423
+ now: () => at,
424
+ },
425
+ });
426
+ const digest = beforeMergeDigest("tf-apply", { pr: 12, head, base: baseSha, through: 1, at, by: "alice" });
427
+ expect(sent).toEqual([["tf-apply.yml", "main", { pr: "12", head, digest }]]);
428
+ expect(stops).toEqual([[head, 1]]);
429
+ expect(got).toMatchObject({ command: "apply", ran: true, replied: true });
430
+ expect(s.posted).toEqual([`terragucci: started the waves of tf-apply on pull request 12's head ${head.slice(0, 8)} through wave 1 for alice; each wave's gate decides, and the run says when the head applied`]);
431
+ });
432
+
433
+ test("CHANT_COMMENT_JOBS carries the waves before merge, each field checked", () => {
434
+ expect(commentJobsFromEnv(JSON.stringify(jobs))).toEqual(jobs);
435
+ expect(() => commentJobsFromEnv(JSON.stringify({ wavesBeforeMerge: bm }))).toThrow("wavesBeforeMerge needs waves");
436
+ expect(() => commentJobsFromEnv(JSON.stringify({ ...jobs, wavesBeforeMerge: { ...bm, workflow: "../x" } }))).toThrow("workflow is a workflow file name");
437
+ expect(() => commentJobsFromEnv(JSON.stringify({ ...jobs, wavesBeforeMerge: { ...bm, requires: ["green"] } }))).toThrow("requires is a list of approved, mergeable, undiverged, checks");
438
+ });
439
+ });
@@ -32,6 +32,10 @@
32
32
  * the reply says so.
33
33
  * - with `noPlanFlags` (#4979), a plan comment with flags the product
34
34
  * plan's re-plan cannot take, with the reason.
35
+ * - with `wavesBeforeMerge` (#4984), `/<product> apply [wave-<n>]` on an
36
+ * open pull request: the decision before merge
37
+ * (./op/before-merge-decide.ts) records the head on `chant/lifecycle`
38
+ * and dispatches the waves workflow on the default branch for it.
35
39
  *
36
40
  * Who asked comes first. On GitHub the commenter's permission is read from
37
41
  * the forge; Forgejo answers 403 when a job's token asks for another user's
@@ -51,6 +55,7 @@ import { retryApply, type ApplyRerun, type ApplyRetried, type ChantNoteJobs, typ
51
55
  import { parseProductComment, type CiProductWords, type ParsedProductComment } from "./ci-product-words";
52
56
  import { ForgeApiError, type ForgeFetch, type PrForge } from "./pr-forge";
53
57
  import type { ForgeReads, PullRequestDetail } from "./pr-forge-reads";
58
+ import type { DecideBeforeMergeInput, WavesBeforeMergeJobs } from "./op/before-merge-decide";
54
59
 
55
60
  /** The comment job's name in a generated workflow (#4946). */
56
61
  export const PR_COMMENT_JOB = "comment";
@@ -90,8 +95,18 @@ export interface CommentJobs extends Omit<ChantNoteJobs, "members"> {
90
95
  * clears it.
91
96
  */
92
97
  waves?: { op: string; count: number };
98
+ /**
99
+ * The waves before merge (#4984), with `waves`: `/<product> apply
100
+ * [wave-<n>]` on an open pull request is this job's. It decides
101
+ * (./op/before-merge-decide.ts), records the decided head on
102
+ * `chant/lifecycle`, and dispatches the waves workflow for it.
103
+ */
104
+ wavesBeforeMerge?: WavesBeforeMergeJobs;
93
105
  }
94
106
 
107
+ /** What the decision before merge reads and writes with (#4984), the comment job's handler's. */
108
+ export type CommentBeforeMerge = Pick<DecideBeforeMergeInput, "requires" | "statuses" | "git" | "cwd" | "lock" | "record" | "stop" | "now">;
109
+
95
110
  /** Writes a wave stop for op `op` at `sha` on `chant/lifecycle`, or clears it (#4979). */
96
111
  export type CommentWaveStops = (op: string, sha: string, stop: { through: number; at: string; by?: string; pr?: number } | null) => Promise<void>;
97
112
 
@@ -106,8 +121,8 @@ export const RERUN_APPLY_JOBS = /^(?:wave-([1-9][0-9]*)-[a-z0-9][a-z0-9_-]*|(?:[
106
121
  export interface CommentRuns {
107
122
  /** GitHub: `POST /repos/{repo}/actions/runs/{run}/rerun-failed-jobs`. */
108
123
  rerunFailed(run: number): Promise<StartedRun>;
109
- /** Forgejo: `POST /repos/{repo}/actions/workflows/{workflow}/dispatches` on `ref`. */
110
- dispatch(workflow: string, ref: string): Promise<StartedRun>;
124
+ /** Forgejo (and before merge, #4984, both): `POST /repos/{repo}/actions/workflows/{workflow}/dispatches` on `ref`, with `inputs`. */
125
+ dispatch(workflow: string, ref: string, inputs?: Record<string, string>): Promise<StartedRun>;
111
126
  }
112
127
 
113
128
  /** The writes for a GitHub or Forgejo API root, repository and token. */
@@ -123,7 +138,7 @@ export function commentRuns(opts: { apiBase: string; repo: string; token: string
123
138
  };
124
139
  return {
125
140
  rerunFailed: (run) => post(`/actions/runs/${run}/rerun-failed-jobs`, {}),
126
- dispatch: (workflow, ref) => post(`/actions/workflows/${encodeURIComponent(workflow)}/dispatches`, { ref }),
141
+ dispatch: (workflow, ref, inputs) => post(`/actions/workflows/${encodeURIComponent(workflow)}/dispatches`, { ref, ...(inputs ? { inputs } : {}) }),
127
142
  };
128
143
  }
129
144
 
@@ -150,6 +165,8 @@ export interface AnswerCommentOptions {
150
165
  stops?: CommentWaveStops;
151
166
  /** The time a stop is written at. Default now. */
152
167
  now?: () => string;
168
+ /** With `jobs.wavesBeforeMerge` (#4984): what the decision reads and writes with. Absent: an open pull request's apply is refused, as before. */
169
+ beforeMerge?: CommentBeforeMerge;
153
170
  }
154
171
 
155
172
  /** What the comment job did. */
@@ -281,7 +298,7 @@ export async function answerProductComment(o: AnswerCommentOptions): Promise<Com
281
298
  }
282
299
 
283
300
  // An apply: the apply before merge answers an open pull request; this job a merged one, with applyOnMerge.
284
- if (!o.jobs.applyBeforeMerge && !o.jobs.applyOnMerge) return reply(notRunReply(o.words, "apply", o.forge));
301
+ if (!o.jobs.applyBeforeMerge && !o.jobs.applyOnMerge && !o.jobs.wavesBeforeMerge) return reply(notRunReply(o.words, "apply", o.forge));
285
302
  let pr: PullRequestDetail | undefined;
286
303
  try {
287
304
  pr = await o.reads.pullRequest(n);
@@ -293,6 +310,28 @@ export async function answerProductComment(o: AnswerCommentOptions): Promise<Com
293
310
  const verb = o.words.verbs.apply;
294
311
  if (pr.state === "open") {
295
312
  if (o.jobs.applyBeforeMerge) return silent("the apply before merge answers this comment", command);
313
+ // #4984: the waves before merge: decide, record the head and dispatch the waves workflow for it.
314
+ const bm = o.jobs.wavesBeforeMerge;
315
+ if (bm && o.jobs.waves && o.beforeMerge) {
316
+ const workflow = bm.workflow;
317
+ if (!workflow) return broke("the waves before merge name no workflow to dispatch", command);
318
+ const { decideWavesBeforeMerge } = await import("./op/before-merge-decide");
319
+ const done = await decideWavesBeforeMerge({
320
+ ...o.beforeMerge,
321
+ forge: o.forge,
322
+ pr,
323
+ user,
324
+ base: o.base,
325
+ ...(parsed.wave !== undefined ? { wave: parsed.wave } : {}),
326
+ op: o.jobs.waves.op,
327
+ count: o.jobs.waves.count,
328
+ jobs: bm,
329
+ words: o.words,
330
+ start: (r) => o.runs.dispatch(workflow, o.base, { pr: String(r.pr), head: r.head, digest: r.digest }),
331
+ });
332
+ if (done.kind === "fail") return broke(done.reason, command);
333
+ return reply(done.text, done.kind === "ran", done.kind === "ran" ? done.url : undefined);
334
+ }
296
335
  return reply(`${at} is not merged: \`/${o.words.product} ${typedApply(o.words)}\` runs the ${verb[0]} of a merged ${t.request} again, from the default branch, and never ${verb[0]}s a ${t.request}'s branch`);
297
336
  }
298
337
  if (pr.state === "closed") return reply(`${at} was closed without merging, so there is nothing of it to ${verb[0]}`);
@@ -28,7 +28,6 @@ import {
28
28
  unzipEntry,
29
29
  type CiTool,
30
30
  } from "./ci-image";
31
- import { NEXT_RELEASE } from "./release-floors";
32
31
 
33
32
  const tmp = (): string => mkdtempSync(join(tmpdir(), "ci-image-"));
34
33
  const sha = (b: Uint8Array): string => createHash("sha256").update(b).digest("hex");
@@ -209,7 +208,7 @@ describe("ciToolRelease", () => {
209
208
  expect(CI_IMAGE_FLOOR).toBe("0.124.86");
210
209
  expect(CI_IMAGE_NON_ROOT_FLOOR).toBe("0.124.88");
211
210
  expect(CI_IMAGE_DOCKER_STAGES_FLOOR).toBe("0.124.88");
212
- expect(CI_TOOL_NODE_DOWNLOAD_FLOOR).toBe(NEXT_RELEASE);
211
+ expect(CI_TOOL_NODE_DOWNLOAD_FLOOR).toBe("0.124.89");
213
212
  });
214
213
  });
215
214
 
@@ -0,0 +1,148 @@
1
+ /**
2
+ * The guard before merge (#4984): a waves run started for an open pull
3
+ * request's head is admitted only as the decision recorded for that head on
4
+ * `chant/lifecycle`, and every other run that names a head is refused. The
5
+ * `node -e` program reads the decision from a real repository and agrees
6
+ * with checkJob.
7
+ */
8
+
9
+ import { spawnSync } from "node:child_process";
10
+ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { join } from "node:path";
13
+ import { beforeAll, describe, expect, test } from "vitest";
14
+ import { checkJob, describeJobGuard, JOB_GUARD_ENV, JOB_GUARD_JS, jobGuardSpec, jobSeen, type JobGuardSpec } from "./ci-job-guard";
15
+ import { CHANT_EXIT } from "./exit-codes";
16
+ import { beforeMergeDigest, beforeMergePath, renderBeforeMerge, type BeforeMergeRecord } from "./op/before-merge";
17
+
18
+ const HEAD = "a".repeat(40);
19
+ const OTHER = "b".repeat(40);
20
+ const BASE = "c".repeat(40);
21
+ const decision = { pr: 7, head: HEAD, base: BASE, at: "2026-11-10T12:00:00.000Z", by: "alice" };
22
+ const record: BeforeMergeRecord = { ...decision, digest: beforeMergeDigest("deploy", decision) };
23
+
24
+ const gh: JobGuardSpec = { forge: "github", job: "wave 1 (prod) of deploy", branches: ["main"], beforeMerge: { op: "deploy" } };
25
+ const gl: JobGuardSpec = { forge: "gitlab", job: "wave 1 (prod) of deploy", branches: ["main"], beforeMerge: { op: "deploy" } };
26
+ const run = { pr: "7", head: HEAD, digest: record.digest };
27
+
28
+ describe("checkJob before merge", () => {
29
+ test("the decided head, on the default branch, runs", () => {
30
+ const r = checkJob(gh, { ref: "refs/heads/main", beforeMerge: run, beforeMergeRecord: record });
31
+ expect(r.problems).toEqual([]);
32
+ expect(r.checked).toEqual(["ref refs/heads/main", `before merge: pull request 7's decided head ${HEAD.slice(0, 12)}`]);
33
+ });
34
+
35
+ test("a push run names no head and is checked as before", () => {
36
+ expect(checkJob(gh, { ref: "refs/heads/main" }).checked).toEqual(["ref refs/heads/main"]);
37
+ });
38
+
39
+ test("a head no decision names is refused", () => {
40
+ const r = checkJob(gh, { ref: "refs/heads/main", beforeMerge: { ...run, head: OTHER }, beforeMergeRecord: null });
41
+ expect(r.problems).toEqual([`before merge: no decision on chant/lifecycle names head ${OTHER.slice(0, 12)} of deploy, so this run applies nothing`]);
42
+ });
43
+
44
+ test("another pull request's run, another digest, and a decision edited by hand are refused", () => {
45
+ expect(checkJob(gh, { ref: "refs/heads/main", beforeMerge: { ...run, pr: "8" }, beforeMergeRecord: record }).problems).toEqual([`before merge: the decision for head ${HEAD.slice(0, 12)} is pull request 7's, not 8's`]);
46
+ const other = `sha256:${"0".repeat(64)}`;
47
+ expect(checkJob(gh, { ref: "refs/heads/main", beforeMerge: { ...run, digest: other }, beforeMergeRecord: record }).problems).toEqual([`before merge: the run carries digest ${other}, and the decision for head ${HEAD.slice(0, 12)} has ${record.digest}`]);
48
+ expect(checkJob(gh, { ref: "refs/heads/main", beforeMerge: run, beforeMergeRecord: { ...record, through: 1 } }).problems).toEqual([`before merge: the decision for head ${HEAD.slice(0, 12)} was changed after it was made: its fields give another digest`]);
49
+ });
50
+
51
+ test("a decided head started on another ref is refused for the ref", () => {
52
+ const r = checkJob(gh, { ref: "refs/heads/feature", beforeMerge: run, beforeMergeRecord: record });
53
+ expect(r.problems).toEqual(["ref: expected refs/heads/main, found refs/heads/feature"]);
54
+ const l = checkJob(gl, { ref: "feature", refProtected: "false", forgeEnvironment: null, beforeMerge: run, beforeMergeRecord: record });
55
+ expect(l.problems).toEqual(["ref: expected main, found feature", "ref: expected a protected ref (CI_COMMIT_REF_PROTECTED true), found false"]);
56
+ });
57
+
58
+ test("a job without the before-merge mode refuses any run that names a head", () => {
59
+ const spec: JobGuardSpec = { forge: "github", job: "w", branches: ["main"] };
60
+ expect(checkJob(spec, { ref: "refs/heads/main", beforeMerge: run }).problems).toEqual([`before merge: the run names pull request 7's head ${HEAD}, and this job applies only the pushes to its branches`]);
61
+ });
62
+
63
+ test("variables that are not a decision's, and a ledger that cannot be read", () => {
64
+ expect(checkJob(gh, { ref: "refs/heads/main", beforeMerge: { head: "main" } }).problems).toEqual([
65
+ "before merge: the run's pull request none is not a number",
66
+ 'before merge: the run\'s head "main" is not a commit sha',
67
+ "before merge: the run's digest none is not a sha256 digest",
68
+ ]);
69
+ expect(checkJob(gh, { ref: "refs/heads/main", beforeMerge: run, beforeMergeError: "no token" }).problems).toEqual(["before merge: the decisions on chant/lifecycle could not be read: no token"]);
70
+ });
71
+
72
+ test("jobGuardSpec carries the mode", () => {
73
+ expect(jobGuardSpec({ forge: "forgejo", job: "w", branches: ["main"], beforeMerge: { op: "deploy" } }).beforeMerge).toEqual({ op: "deploy" });
74
+ });
75
+
76
+ test("jobSeen reads the decision for the run's head only with the mode", async () => {
77
+ const env = { GITHUB_REF: "refs/heads/main", CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: record.digest };
78
+ const read: string[] = [];
79
+ const reader = (_f: string, _e: NodeJS.ProcessEnv, path: string) => {
80
+ read.push(path);
81
+ return renderBeforeMerge({ version: 1, heads: { [HEAD]: record } });
82
+ };
83
+ const seen = await jobSeen(gh, env, fetch, reader);
84
+ expect(read).toEqual([beforeMergePath("deploy")]);
85
+ expect(seen.beforeMergeRecord).toEqual(record);
86
+ const plain = await jobSeen({ forge: "github", job: "w", branches: ["main"] }, env, fetch, reader);
87
+ expect(plain.beforeMergeRecord).toBeUndefined();
88
+ expect(read).toHaveLength(1);
89
+ });
90
+ });
91
+
92
+ describe("the node -e program reads the decision from chant/lifecycle", () => {
93
+ let server = "";
94
+ beforeAll(() => {
95
+ // A bare repository standing in for the forge, with the decisions file on chant/lifecycle.
96
+ server = mkdtempSync(join(tmpdir(), "chant-guard-forge-"));
97
+ const work = mkdtempSync(join(tmpdir(), "chant-guard-work-"));
98
+ const git = (cwd: string, ...args: string[]) => {
99
+ const r = spawnSync("git", args, { cwd, encoding: "utf-8", env: { ...process.env, GIT_AUTHOR_NAME: "t", GIT_AUTHOR_EMAIL: "t@t", GIT_COMMITTER_NAME: "t", GIT_COMMITTER_EMAIL: "t@t" } });
100
+ if (r.status !== 0) throw new Error(r.stderr);
101
+ };
102
+ mkdirSync(join(server, "acme"), { recursive: true });
103
+ git(join(server, "acme"), "init", "-q", "--bare", "infra.git");
104
+ git(work, "init", "-q", "-b", "chant/lifecycle");
105
+ mkdirSync(join(work, "_waves"));
106
+ writeFileSync(join(work, beforeMergePath("deploy")), renderBeforeMerge({ version: 1, heads: { [HEAD]: record } }));
107
+ git(work, "add", ".");
108
+ git(work, "commit", "-q", "-m", "decide");
109
+ git(work, "push", "-q", join(server, "acme", "infra.git"), "chant/lifecycle");
110
+ });
111
+
112
+ const run = (spec: JobGuardSpec, env: Record<string, string>) =>
113
+ spawnSync(process.execPath, ["-e", JOB_GUARD_JS], { env: { PATH: process.env.PATH ?? "", HOME: process.env.HOME ?? "", [JOB_GUARD_ENV]: JSON.stringify(spec), ...env }, encoding: "utf-8" });
114
+ const forgeEnv = (spec: JobGuardSpec): Record<string, string> =>
115
+ spec.forge === "gitlab"
116
+ ? { CI_SERVER_URL: `file://${server}`, CI_PROJECT_PATH: "acme/infra", CI_JOB_TOKEN: "t", CI_COMMIT_REF_NAME: "main", CI_COMMIT_REF_PROTECTED: "true" }
117
+ : { GITHUB_SERVER_URL: `file://${server}`, GITHUB_REPOSITORY: "acme/infra", GITHUB_TOKEN: "t", GITHUB_REF: "refs/heads/main" };
118
+
119
+ const cases: Array<[string, JobGuardSpec, Record<string, string>]> = [
120
+ ["GitHub: the decided head", gh, { CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: record.digest }],
121
+ ["GitLab: the decided head", gl, { CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: record.digest }],
122
+ ["Forgejo: a head nothing decided", { ...gh, forge: "forgejo" }, { CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: OTHER, CHANT_BEFORE_MERGE_DIGEST: record.digest }],
123
+ ["GitHub: another pull request's number", gh, { CHANT_BEFORE_MERGE_PR: "9", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: record.digest }],
124
+ ["GitHub: the decided head dispatched on another branch", gh, { GITHUB_REF: "refs/heads/feature", CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: record.digest }],
125
+ ["GitLab: a head that is not a sha", gl, { CHANT_BEFORE_MERGE_HEAD: "refs/heads/feature" }],
126
+ ["GitHub: no mode, and a run that names a head", { forge: "github", job: "w", branches: ["main"] }, { CHANT_BEFORE_MERGE_HEAD: HEAD }],
127
+ ];
128
+
129
+ for (const [name, spec, extra] of cases) {
130
+ test(name, async () => {
131
+ const env = { ...forgeEnv(spec), ...extra };
132
+ const r = run(spec, env);
133
+ const want = describeJobGuard(spec, checkJob(spec, await jobSeen(spec, { ...process.env, ...env }, (() => Promise.reject(new Error("no fetch"))) as unknown as typeof fetch)));
134
+ expect(r.status).toBe(want.ok ? 0 : CHANT_EXIT.misplaced);
135
+ expect(r.stdout.trim().split("\n").filter(Boolean)).toEqual(want.out);
136
+ expect(r.stderr.trim().split("\n").filter(Boolean)).toEqual(want.err);
137
+ });
138
+ }
139
+
140
+ test("the decided head is admitted, and any other ref refused", async () => {
141
+ expect(run(gh, { ...forgeEnv(gh), CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: record.digest }).status).toBe(0);
142
+ for (const head of [OTHER, BASE]) {
143
+ const r = run(gh, { ...forgeEnv(gh), CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: head, CHANT_BEFORE_MERGE_DIGEST: record.digest });
144
+ expect(r.status).toBe(CHANT_EXIT.misplaced);
145
+ expect(r.stderr).toContain(`no decision on chant/lifecycle names head ${head.slice(0, 12)}`);
146
+ }
147
+ });
148
+ });