@intentius/chant 0.124.69 → 0.124.71

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 (170) hide show
  1. package/dist/ci-agent.d.ts +12 -1
  2. package/dist/ci-agent.d.ts.map +1 -1
  3. package/dist/ci-agent.js +13 -8
  4. package/dist/ci-commit.d.ts +297 -0
  5. package/dist/ci-commit.d.ts.map +1 -0
  6. package/dist/ci-commit.js +696 -0
  7. package/dist/ci-product-words.d.ts +6 -1
  8. package/dist/ci-product-words.d.ts.map +1 -1
  9. package/dist/ci-product-words.js +3 -1
  10. package/dist/cli/handlers/approve.d.ts.map +1 -1
  11. package/dist/cli/handlers/approve.js +7 -2
  12. package/dist/cli/handlers/commit.d.ts +26 -0
  13. package/dist/cli/handlers/commit.d.ts.map +1 -0
  14. package/dist/cli/handlers/commit.js +142 -0
  15. package/dist/cli/handlers/pr.d.ts +6 -0
  16. package/dist/cli/handlers/pr.d.ts.map +1 -1
  17. package/dist/cli/handlers/pr.js +16 -7
  18. package/dist/cli/handlers/release.d.ts +9 -0
  19. package/dist/cli/handlers/release.d.ts.map +1 -1
  20. package/dist/cli/handlers/release.js +114 -5
  21. package/dist/cli/main.d.ts.map +1 -1
  22. package/dist/cli/main.js +23 -0
  23. package/dist/cli/parse-args.d.ts.map +1 -1
  24. package/dist/cli/parse-args.js +15 -0
  25. package/dist/cli/registry.d.ts +4 -0
  26. package/dist/cli/registry.d.ts.map +1 -1
  27. package/dist/components/product-pipeline.d.ts +33 -0
  28. package/dist/components/product-pipeline.d.ts.map +1 -1
  29. package/dist/components/product-pipeline.js +34 -1
  30. package/dist/components/release-compile.d.ts +2 -0
  31. package/dist/components/release-compile.d.ts.map +1 -1
  32. package/dist/components/release-compile.js +8 -4
  33. package/dist/config.d.ts +46 -0
  34. package/dist/config.d.ts.map +1 -1
  35. package/dist/config.js +9 -0
  36. package/dist/lexicon.d.ts +37 -0
  37. package/dist/lexicon.d.ts.map +1 -1
  38. package/dist/lexicon.js +28 -0
  39. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +4 -0
  40. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
  41. package/dist/lifecycle/__fixtures__/publish-fakes.js +6 -2
  42. package/dist/lifecycle/gated-request.d.ts +3 -1
  43. package/dist/lifecycle/gated-request.d.ts.map +1 -1
  44. package/dist/lifecycle/gated-request.js +5 -2
  45. package/dist/lifecycle/git.d.ts.map +1 -1
  46. package/dist/lifecycle/git.js +57 -0
  47. package/dist/lifecycle/publish-declaration.d.ts +16 -0
  48. package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
  49. package/dist/lifecycle/publish-declaration.js +35 -3
  50. package/dist/lifecycle/publish-forge.d.ts +12 -0
  51. package/dist/lifecycle/publish-forge.d.ts.map +1 -1
  52. package/dist/lifecycle/publish-forge.js +103 -19
  53. package/dist/lifecycle/publish-npm.d.ts +15 -0
  54. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  55. package/dist/lifecycle/publish-npm.js +28 -1
  56. package/dist/lifecycle/publish-oci.d.ts +2 -0
  57. package/dist/lifecycle/publish-oci.d.ts.map +1 -1
  58. package/dist/lifecycle/publish-oci.js +10 -0
  59. package/dist/lifecycle/release-cut.d.ts +7 -1
  60. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  61. package/dist/lifecycle/release-cut.js +8 -1
  62. package/dist/lifecycle/release-images.d.ts +87 -0
  63. package/dist/lifecycle/release-images.d.ts.map +1 -0
  64. package/dist/lifecycle/release-images.js +139 -0
  65. package/dist/lifecycle/release-publish.d.ts +2 -0
  66. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  67. package/dist/op/activities/activity-contracts.d.ts +4 -4
  68. package/dist/op/activities/review-agent.d.ts.map +1 -1
  69. package/dist/op/activities/review-agent.js +4 -2
  70. package/dist/op/gate.d.ts +5 -1
  71. package/dist/op/gate.d.ts.map +1 -1
  72. package/dist/op/gate.js +7 -2
  73. package/dist/op/op-waves-notify.d.ts +1 -1
  74. package/dist/op/op-waves-notify.d.ts.map +1 -1
  75. package/dist/op/op-waves-notify.js +2 -1
  76. package/dist/op/op-waves-run.d.ts.map +1 -1
  77. package/dist/op/op-waves-run.js +12 -8
  78. package/dist/op/op-waves.d.ts +9 -0
  79. package/dist/op/op-waves.d.ts.map +1 -1
  80. package/dist/op/op-waves.js +11 -0
  81. package/dist/pr-forge-base.d.ts +18 -0
  82. package/dist/pr-forge-base.d.ts.map +1 -0
  83. package/dist/pr-forge-base.js +29 -0
  84. package/dist/release-floors.d.ts +1 -1
  85. package/dist/release-floors.js +1 -1
  86. package/dist/wave-runtime.mjs +305 -305
  87. package/dist/workspace/ci-green-cli.d.ts +7 -3
  88. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  89. package/dist/workspace/ci-green-cli.js +29 -8
  90. package/dist/workspace/ci-green-forge.d.ts +29 -0
  91. package/dist/workspace/ci-green-forge.d.ts.map +1 -1
  92. package/dist/workspace/ci-green-forge.js +50 -0
  93. package/dist/workspace/ci-green-workflow.d.ts +9 -1
  94. package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
  95. package/dist/workspace/ci-green-workflow.js +15 -3
  96. package/dist/workspace/ci-green.d.ts +35 -1
  97. package/dist/workspace/ci-green.d.ts.map +1 -1
  98. package/dist/workspace/ci-green.js +122 -4
  99. package/dist/workspace/declaration.d.ts +14 -2
  100. package/dist/workspace/declaration.d.ts.map +1 -1
  101. package/dist/workspace/declaration.js +14 -1
  102. package/dist/workspace/declaration.schema.json +17 -2
  103. package/dist/workspace/release-workflow.d.ts +23 -0
  104. package/dist/workspace/release-workflow.d.ts.map +1 -1
  105. package/dist/workspace/release-workflow.js +203 -12
  106. package/package.json +1 -1
  107. package/src/ci-agent.ts +13 -8
  108. package/src/ci-commit.test.ts +415 -0
  109. package/src/ci-commit.ts +857 -0
  110. package/src/ci-product-words.ts +6 -2
  111. package/src/cli/handlers/approve.ts +6 -2
  112. package/src/cli/handlers/commit.ts +152 -0
  113. package/src/cli/handlers/operator.test.ts +2 -0
  114. package/src/cli/handlers/pr-wave-approve-lines.test.ts +32 -0
  115. package/src/cli/handlers/pr.ts +17 -7
  116. package/src/cli/handlers/release.ts +110 -5
  117. package/src/cli/main.ts +23 -0
  118. package/src/cli/parse-args.ts +11 -0
  119. package/src/cli/registry.ts +4 -0
  120. package/src/components/product-pipeline.test.ts +28 -1
  121. package/src/components/product-pipeline.ts +54 -1
  122. package/src/components/release-compile.ts +9 -3
  123. package/src/config.ts +24 -0
  124. package/src/lexicon.ts +56 -0
  125. package/src/lifecycle/__fixtures__/publish-fakes.ts +11 -5
  126. package/src/lifecycle/gated-request-spend.test.ts +115 -0
  127. package/src/lifecycle/gated-request.ts +5 -2
  128. package/src/lifecycle/git.ts +53 -0
  129. package/src/lifecycle/ledger-two-clones.test.ts +132 -0
  130. package/src/lifecycle/publish-declaration.ts +35 -3
  131. package/src/lifecycle/publish-forge-notes.test.ts +193 -0
  132. package/src/lifecycle/publish-forge.ts +101 -22
  133. package/src/lifecycle/publish-npm.ts +31 -2
  134. package/src/lifecycle/publish-oci.ts +10 -0
  135. package/src/lifecycle/publish-targets.test.ts +2 -1
  136. package/src/lifecycle/release-cut.ts +17 -1
  137. package/src/lifecycle/release-images.test.ts +242 -0
  138. package/src/lifecycle/release-images.ts +175 -0
  139. package/src/lifecycle/release-publish.ts +2 -0
  140. package/src/op/activities/review-agent.test.ts +20 -1
  141. package/src/op/activities/review-agent.ts +5 -2
  142. package/src/op/gate.ts +7 -2
  143. package/src/op/op-waves-approve-target.test.ts +108 -0
  144. package/src/op/op-waves-notify.ts +2 -2
  145. package/src/op/op-waves-run.ts +12 -7
  146. package/src/op/op-waves.ts +12 -0
  147. package/src/pr-forge-base.test.ts +37 -0
  148. package/src/pr-forge-base.ts +36 -0
  149. package/src/release-floors.ts +1 -1
  150. package/src/workspace/__fixtures__/release-workflow/forgejo-plain-member.yml +26 -0
  151. package/src/workspace/__fixtures__/release-workflow/forgejo-plain.yml +23 -0
  152. package/src/workspace/__fixtures__/release-workflow/forgejo-secure-member.yml +27 -0
  153. package/src/workspace/__fixtures__/release-workflow/forgejo-secure.yml +24 -0
  154. package/src/workspace/__fixtures__/release-workflow/github-plain-member.yml +26 -0
  155. package/src/workspace/__fixtures__/release-workflow/github-plain.yml +23 -0
  156. package/src/workspace/__fixtures__/release-workflow/github-secure-member.yml +27 -0
  157. package/src/workspace/__fixtures__/release-workflow/github-secure.yml +24 -0
  158. package/src/workspace/__fixtures__/release-workflow/gitlab-plain-member.yml +13 -0
  159. package/src/workspace/__fixtures__/release-workflow/gitlab-plain.yml +12 -0
  160. package/src/workspace/__fixtures__/release-workflow/gitlab-secure-member.yml +14 -0
  161. package/src/workspace/__fixtures__/release-workflow/gitlab-secure.yml +13 -0
  162. package/src/workspace/ci-green-cli.ts +27 -8
  163. package/src/workspace/ci-green-forge.ts +70 -0
  164. package/src/workspace/ci-green-workflow.ts +15 -3
  165. package/src/workspace/ci-green.ts +130 -5
  166. package/src/workspace/ci-verdict-retries.test.ts +376 -0
  167. package/src/workspace/declaration.schema.json +17 -2
  168. package/src/workspace/declaration.ts +28 -4
  169. package/src/workspace/release-workflow.test.ts +151 -0
  170. package/src/workspace/release-workflow.ts +270 -12
@@ -34,9 +34,9 @@ export const CI_PRODUCT_STAGES: readonly CiProductStage[] = ["plan", "apply", "r
34
34
  * answers it. `action` (#4653) asks for a day-2 action on one member, which
35
35
  * runs under a gated request.
36
36
  */
37
- export type CiProductCommand = "plan" | "apply" | "lock" | "unlock" | "agent" | "action";
37
+ export type CiProductCommand = "plan" | "apply" | "lock" | "unlock" | "agent" | "action" | "commit";
38
38
 
39
- export const CI_PRODUCT_COMMANDS: readonly CiProductCommand[] = ["plan", "apply", "lock", "unlock", "agent", "action"];
39
+ export const CI_PRODUCT_COMMANDS: readonly CiProductCommand[] = ["plan", "apply", "lock", "unlock", "agent", "action", "commit"];
40
40
 
41
41
  /**
42
42
  * What an approval of a product's waves binds to (ruling B, 2026-10-27).
@@ -464,6 +464,8 @@ export type ParsedProductComment =
464
464
  * The engine's lexicon checks the action against the member's plan.
465
465
  */
466
466
  | { kind: "action"; member: string; address: string }
467
+ /** A commit job's command (#4722), by the word typed: `/terragucci fmt`. Several words may each map onto `commit`. */
468
+ | { kind: "commit"; word: string }
467
469
  | { kind: "refused"; reason: string };
468
470
 
469
471
  /** A member as a comment may name it: path segments, no leading dash, no shell or glob syntax. */
@@ -539,6 +541,8 @@ export function parseProductComment(words: CiProductWords, body: unknown, env: R
539
541
  case "lock":
540
542
  case "unlock":
541
543
  return parts.length === 2 ? { kind: command } : { kind: "refused", reason: `${line} takes nothing after it` };
544
+ case "commit":
545
+ return parts.length === 2 ? { kind: "commit", word: typed } : { kind: "refused", reason: `${line} takes nothing after it` };
542
546
  case "agent": {
543
547
  const ask = text.slice(`${prefix} ${typed}`.length).trim();
544
548
  if (ask === "") return { kind: "refused", reason: `${line} needs an ask after it, on the same line` };
@@ -24,7 +24,7 @@ import { approverOf, humanQuorumSince, tallyGateApprovals } from "../../op/gate"
24
24
  import { quorumRuleLine, quorumRules, trustQuorumJudge, UNPROVEN_JUDGE, type GateQuorumJudge } from "../../op/gate-quorum";
25
25
  import { FAN_OUT_GATE_OP, OVERRIDE_GATE_OP, RELEASE_GATE_OP, WORKSPACE_EXIT_GATE_OP, WORKSPACE_PROMOTE_GATE_OP, WORKSPACE_UPGRADE_GATE_OP } from "../../op/gate-name";
26
26
  import { PR_GATE_OP } from "../../pr-loop";
27
- import { pushLifecycleReport, requireLifecycleLedger } from "../../lifecycle/git";
27
+ import { LifecyclePushLostError, pushLifecycleRebasing, requireLifecycleLedger } from "../../lifecycle/git";
28
28
  import { LIFECYCLE_LOCAL_NOTE, isLifecycleLocalNote } from "../../lifecycle/local-note";
29
29
  import { ledgerRecordingOff, NO_RECORD_ENV } from "../../lifecycle/no-record";
30
30
  import { checkGateSignature, gateSealPayload, gateSealVersion, WEBAUTHN_SEAL_KIND, type SealedGateApproval } from "../../lifecycle/gate-seal";
@@ -74,7 +74,11 @@ const LIFECYCLE_BRANCH = "chant/lifecycle";
74
74
  * elsewhere to tell, so that case is a quiet suffix and no warning (#3677).
75
75
  */
76
76
  async function reportedPush(consequence: string): Promise<{ pushed: boolean; suffix: string }> {
77
- const { pushed, pushWarning } = await pushLifecycleReport();
77
+ // #4637: a push another writer beat is replayed onto the remote's tip and tried again; an approval line appends.
78
+ const { pushed, pushWarning } = await pushLifecycleRebasing().catch((err: unknown) => {
79
+ if (err instanceof LifecyclePushLostError) return { pushed: false, pushWarning: err.message };
80
+ throw err;
81
+ });
78
82
  if (pushed) return { pushed, suffix: "" };
79
83
  if (isLifecycleLocalNote(pushWarning)) return { pushed, suffix: ` (${LIFECYCLE_LOCAL_NOTE})` };
80
84
  console.error(formatWarning({
@@ -0,0 +1,152 @@
1
+ /**
2
+ * `chant commit prepare|run|land` (#4722): the three steps of the commit jobs
3
+ * the Op generator writes for a scheduled Op spec's `commit`
4
+ * (../../ci-commit.ts says what each does and which token each holds).
5
+ *
6
+ * ```
7
+ * chant commit prepare --forge <kind> [--output <dir>] the commit job, read token: decide
8
+ * chant commit run --forge <kind> [--output <dir>] the commit job, no forge token: run the command
9
+ * chant commit land --forge <kind> [--output <dir>] the push job, push token: commit, push, reply, record
10
+ * ```
11
+ *
12
+ * The settings come from the job's `CHANT_COMMIT_*` variables, which the
13
+ * generator wrote into the workflow file of the base branch.
14
+ */
15
+
16
+ import { execFileSync } from "node:child_process";
17
+ import { readFileSync } from "node:fs";
18
+ import { tmpdir } from "node:os";
19
+ import { join, resolve } from "node:path";
20
+ import { AgentError, type AgentGit } from "../../ci-agent";
21
+ import {
22
+ COMMIT_DIR,
23
+ commitSettingsFromEnv,
24
+ landCommitChange,
25
+ prepareCommitRun,
26
+ runCommit,
27
+ runCommitArgv,
28
+ type HeadApproval,
29
+ } from "../../ci-commit";
30
+ import { activeProductWords, type CiProductWords } from "../../ci-product-words";
31
+ import { CHANT_EXIT } from "../../exit-codes";
32
+ import { appendRunRecord, readRunLedger } from "../../lifecycle/run-ledger";
33
+ import { listFilesInDir, pushLifecycleRebasing, readBlobFromPath, type LedgerLocation } from "../../lifecycle/git";
34
+ import { parseGateLedger } from "../../lifecycle/gate-ledger";
35
+ import { resolveCiRun } from "../../lifecycle/release-ledger";
36
+ import { FORGE_KINDS, forgeFromEnv, type ForgeKind, type PrForge } from "../../pr-forge";
37
+ import { pullRequestBaseFromEnv } from "../../pr-forge-base";
38
+ import { formatError, formatInfo } from "../format";
39
+ import type { CommandContext } from "../registry";
40
+
41
+ const USAGE = "chant commit prepare|run|land --forge github|gitlab|forgejo [--output <dir>]";
42
+
43
+ function fail(message: string): number {
44
+ console.error(formatError({ message, hint: USAGE }));
45
+ return CHANT_EXIT.failed;
46
+ }
47
+
48
+ /** git with hooks and fsmonitor off: nothing here runs code from the repository. */
49
+ const git: AgentGit = (args, opts = {}) =>
50
+ execFileSync("git", ["-c", "core.hooksPath=/dev/null", "-c", "core.fsmonitor=false", ...args], {
51
+ cwd: opts.cwd,
52
+ input: opts.input,
53
+ encoding: "utf8",
54
+ stdio: ["pipe", "pipe", "pipe"],
55
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
56
+ maxBuffer: 64 << 20,
57
+ });
58
+
59
+ function eventOf(): unknown {
60
+ const file = process.env.GITHUB_EVENT_PATH;
61
+ if (!file) return undefined;
62
+ try {
63
+ return JSON.parse(readFileSync(file, "utf8"));
64
+ } catch {
65
+ return undefined;
66
+ }
67
+ }
68
+
69
+ function workDir(name: string): string {
70
+ return join(process.env.RUNNER_TEMP || process.env.TMPDIR || tmpdir(), name);
71
+ }
72
+
73
+ /**
74
+ * Who approved the plan of pull request `pr` at `sha`, read from the gate
75
+ * ledger: a resolution of the pull request's gates (`pr-<n>`, `pr-<n>-<member>`)
76
+ * or the waves' op, made for that commit. Undefined when there is none.
77
+ */
78
+ export function ledgerHeadApproval(words: CiProductWords, location?: LedgerLocation): HeadApproval {
79
+ return async (pr, sha) => {
80
+ const own = new RegExp(`^pr-${pr}(-[a-z0-9][a-z0-9-]*)?\\.jsonl$`);
81
+ const files = (await listFilesInDir("_gates", location)).filter((f) => own.test(f) || (words.op !== undefined && f === `${words.op}.jsonl`));
82
+ for (const f of files) {
83
+ const text = await readBlobFromPath("_gates", f, location);
84
+ if (!text) continue;
85
+ const hit = parseGateLedger(text).resolutions.find((r) => r.gitSha === sha);
86
+ if (hit) return hit.resolvedBy;
87
+ }
88
+ return undefined;
89
+ };
90
+ }
91
+
92
+ export async function runCommitCommandLine(ctx: CommandContext): Promise<number> {
93
+ const action = ctx.args.path;
94
+ if (action !== "prepare" && action !== "run" && action !== "land") return fail(action ? `commit ${action} is not one of prepare, run or land` : "commit needs an action: prepare, run or land");
95
+ const kind = ctx.args.forge;
96
+ if (!kind || !(FORGE_KINDS as readonly string[]).includes(kind)) return fail(`--forge is one of ${FORGE_KINDS.join(", ")}`);
97
+ const words = activeProductWords();
98
+ const dir = resolve(ctx.args.output ?? COMMIT_DIR);
99
+ let settings;
100
+ try {
101
+ settings = commitSettingsFromEnv(process.env, words.product);
102
+ } catch (e) {
103
+ return fail((e as Error).message);
104
+ }
105
+ const readRuns = async () => (await readRunLedger(settings.env, settings.name)).records;
106
+ const forge = (): PrForge => forgeFromEnv(kind as ForgeKind);
107
+ const approval = ledgerHeadApproval(words);
108
+
109
+ try {
110
+ if (action === "prepare") {
111
+ const base = kind !== "gitlab" ? pullRequestBaseFromEnv(kind as ForgeKind) : undefined;
112
+ const d = await prepareCommitRun({ settings, words, dir, env: process.env, event: eventOf(), ...(kind !== "gitlab" ? { forge: forge() } : {}), ...(base ? { pullRequestBase: base } : {}), readRuns, approval, git, now: new Date() });
113
+ console.error(formatInfo(d.go ? `${settings.name}: runs on ${d.sha?.slice(0, 12)} for #${d.pr}` : `${settings.name}: does not run: ${d.reason}`));
114
+ return CHANT_EXIT.done;
115
+ }
116
+ if (action === "run") {
117
+ const r = await runCommit({ settings, dir, checkout: process.cwd(), workDir: workDir("chant-commit-work"), env: process.env, git, runCommand: runCommitArgv });
118
+ console.error(formatInfo(`${settings.name}: exited ${r.rc}${r.changed ? ", with a change" : ", changing nothing"}`));
119
+ // The push job says why on the pull request; this job stays green so it runs.
120
+ return CHANT_EXIT.done;
121
+ }
122
+ const ci = resolveCiRun(process.env);
123
+ const landBase = pullRequestBaseFromEnv(kind as ForgeKind);
124
+ const out = await landCommitChange({
125
+ ...(landBase ? { pullRequestBase: landBase } : {}),
126
+ settings,
127
+ words,
128
+ dir,
129
+ workDir: workDir("chant-commit-land"),
130
+ env: process.env,
131
+ event: eventOf(),
132
+ forge: forge(),
133
+ git,
134
+ push: ({ cwd, ref }) => {
135
+ git(["push", "-q", "origin", `HEAD:${ref}`], { cwd });
136
+ },
137
+ readRuns,
138
+ approval,
139
+ record: async (input) => {
140
+ await appendRunRecord(input);
141
+ await pushLifecycleRebasing();
142
+ },
143
+ now: () => new Date(),
144
+ ...(ci ? { runOrigin: ci.runOrigin } : {}),
145
+ });
146
+ console.error(formatInfo(`${settings.name}: ${out.result}: ${out.reason}`));
147
+ return out.code;
148
+ } catch (e) {
149
+ if (e instanceof AgentError) return fail(e.message);
150
+ return fail(`commit ${action}: ${(e as Error).message}`);
151
+ }
152
+ }
@@ -64,6 +64,8 @@ vi.mock("../../lifecycle/git", async () => {
64
64
  return {
65
65
  ...actual,
66
66
  pushLifecycleReport: (...args: unknown[]) => pushLifecycleMock(...args),
67
+ // #4637: chant approve pushes through the rebasing push.
68
+ pushLifecycleRebasing: (...args: unknown[]) => pushLifecycleMock(...args),
67
69
  // Mocked, not merely defaulted: the real one shells to `git fetch`, and
68
70
  // these tests run in the chant checkout itself (#2303).
69
71
  requireLifecycleLedger: (...args: unknown[]) => requireLifecycleLedgerMock(...args),
@@ -0,0 +1,32 @@
1
+ /**
2
+ * #4574: pr-apply's lines for a waiting component wave or round name one
3
+ * approve line per component under a product's words, as the note does
4
+ * (#4601). chant's own line is what it was.
5
+ */
6
+ import { afterEach, describe, expect, test } from "vitest";
7
+ import { assertProductWords, setActiveProductWords } from "../../ci-product-words";
8
+ import { waveApproveLines } from "./pr";
9
+
10
+ const digest = `sha256:${"d".repeat(64)}`;
11
+
12
+ afterEach(() => {
13
+ setActiveProductWords(undefined);
14
+ });
15
+
16
+ describe("waveApproveLines (#4574)", () => {
17
+ test("chant's words: one line, no target", () => {
18
+ expect(waveApproveLines("chant-pr", "dev", { gate: "wave-1", digest, components: ["a", "b"] })).toBe(`chant approve chant-pr wave-1 --plan ${digest} --approver <you> --sign`);
19
+ });
20
+
21
+ test("a product's {target}: one line per component, else the environment", () => {
22
+ setActiveProductWords(assertProductWords({ product: "yodel", approve: "yodel approve {target} --plan {digest}" }));
23
+ expect(waveApproveLines("op", "dev", { gate: "wave-1", digest, components: ["app"] })).toBe(`yodel approve app --plan ${digest}`);
24
+ expect(waveApproveLines("op", "dev", { gate: "wave-1", digest, components: ["a", "b"] })).toBe(`yodel approve a --plan ${digest}; yodel approve b --plan ${digest}`);
25
+ expect(waveApproveLines("op", "dev", { gate: "wave-1", digest, components: [] })).toBe(`yodel approve dev --plan ${digest}`);
26
+ });
27
+
28
+ test("a product's template with no {target}: one line", () => {
29
+ setActiveProductWords(assertProductWords({ product: "plywood", approve: "plywood approve {gate} --plan {digest} {sign}" }));
30
+ expect(waveApproveLines("op", "dev", { gate: "wave-1", digest, components: ["a", "b"] })).toBe(`plywood approve wave-1 --plan ${digest} --sign`);
31
+ });
32
+ });
@@ -1340,7 +1340,7 @@ async function prApply(ctx: CommandContext, stage: StageEvents, beforeMerge?: Pr
1340
1340
  members: applied.members,
1341
1341
  ...(resumed ? { resumed: resumed.completed } : {}),
1342
1342
  ...(applied.rounds ? { rounds: applied.rounds } : {}),
1343
- ...(applied.held ? { message: applied.held } : applied.leaseFailed ? { message: applied.leaseFailed } : applied.status === "waiting" ? { message: waitingMessage(op, applied.rounds) } : {}),
1343
+ ...(applied.held ? { message: applied.held } : applied.leaseFailed ? { message: applied.leaseFailed } : applied.status === "waiting" ? { message: waitingMessage(op, p.env, applied.rounds) } : {}),
1344
1344
  });
1345
1345
  // A component that stopped at a gate of its own leaves the apply waiting on
1346
1346
  // a person. A step that refused its plan because the target moved since
@@ -1734,6 +1734,8 @@ async function decideApplyGate(
1734
1734
  console.error(formatInfo(`the merged changes' approvals do not cover the plan at ${green.commit.slice(0, 12)}: ${uncovered.join("; ")}`));
1735
1735
  }
1736
1736
  const digest = set.doc.digest;
1737
+ // #4574: the members fill a product's {target}, one line each, as the note names them (#4601).
1738
+ const approve = prApproveCommands({ op, gate: p.gate, digest, env: p.env, ...(p.member ? { member: p.member } : {}), members: set.members }).join("; ");
1737
1739
  const check = await emitGateStep(
1738
1740
  events?.emit,
1739
1741
  { op, gate: p.gate },
@@ -1742,7 +1744,7 @@ async function decideApplyGate(
1742
1744
  const a = approvalOf(unapproved);
1743
1745
  return a.status === "changed"
1744
1746
  ? describePlanChanged({ op, gate: p.gate, digest, approval: a })
1745
- : `No approval stands for this plan. Approve it: ${prApproveCommand({ op, gate: p.gate, digest })}`;
1747
+ : `No approval stands for this plan. Approve it: ${approve}`;
1746
1748
  },
1747
1749
  );
1748
1750
  const approval = approvalOf(check);
@@ -1753,7 +1755,7 @@ async function decideApplyGate(
1753
1755
  approval,
1754
1756
  satisfied: false,
1755
1757
  refusal: "not-approved",
1756
- message: `No approval stands for this plan, so nothing was applied.${why} Approve it: ${prApproveCommand({ op, gate: p.gate, digest })}; then run the apply again.`,
1758
+ message: `No approval stands for this plan, so nothing was applied.${why} Approve it: ${approve}; then run the apply again.`,
1757
1759
  };
1758
1760
  }
1759
1761
 
@@ -1890,14 +1892,20 @@ function reviewCheck(args: CommandContext["args"], p: Prepared, pr: number, auth
1890
1892
  };
1891
1893
  }
1892
1894
 
1895
+ /** A waiting wave's or round's approve lines (#4574): one per component when the product's template names `{target}`, as the note names them (#4601). */
1896
+ export function waveApproveLines(op: string, env: string, w: { gate: string; digest: string; components: readonly string[] }): string {
1897
+ const targets = activeProductWords().approve.includes("{target}") ? (w.components.length > 0 ? w.components : [env]) : [undefined];
1898
+ return targets.map((target) => prApproveCommand({ op, gate: w.gate, digest: w.digest, ...(target !== undefined ? { target } : {}) })).join("; ");
1899
+ }
1900
+
1893
1901
  /** What a `waiting` apply prints (#3999): the round's gate and digest to approve, and how to carry on. */
1894
- function waitingMessage(op: string, rounds: PrRound[] | undefined): string {
1902
+ function waitingMessage(op: string, env: string, rounds: PrRound[] | undefined): string {
1895
1903
  const last = rounds?.at(-1);
1896
1904
  if (!last) return "Some members were held back after an upstream applied.";
1897
1905
  return (
1898
1906
  `${last.components.join(", ")} ${last.components.length === 1 ? "was" : "were"} planned again after an upstream applied, ` +
1899
1907
  `and no approval stands for that plan (${last.digest}), so ${last.components.length === 1 ? "it" : "they"} did not apply. ` +
1900
- `Approve it: ${prApproveCommand({ op, gate: last.gate, digest: last.digest })}; then run the apply again with the same --resume record.`
1908
+ `Approve it: ${waveApproveLines(op, env, last)}; then run the apply again with the same --resume record.`
1901
1909
  );
1902
1910
  }
1903
1911
 
@@ -2355,7 +2363,8 @@ async function prApplyWaves(
2355
2363
  setWave(entry);
2356
2364
  // #4003: the wave's new plan beside the report, for whoever approves its gate.
2357
2365
  if (ran.changeSet) writeWaveChangeSet(ctx, k, ran.changeSet, upload);
2358
- const approveLine = prApproveCommand({ op, gate: entry.gate, digest: entry.digest });
2366
+ // #4574: the wave's components fill a product's {target}, as the note names them (#4601).
2367
+ const approveLine = waveApproveLines(op, p.env, entry);
2359
2368
  const message =
2360
2369
  ran.exitCode === CHANT_EXIT.moved
2361
2370
  ? `Wave ${k}'s plan changed after its approval, so nothing in it was applied.${entry.approved ? ` approved: ${entry.approved}; planned now: ${entry.digest}.` : ""} Read the new plan, and if it is right, approve it: ${approveLine}; then run the wave's apply again.`
@@ -2737,8 +2746,9 @@ async function runComponentWave(
2737
2746
  // A wave that waits at its own gate is the stream's gate step there, as before op waves (#4003).
2738
2747
  if (d && !byPullRequest && (exitCode === CHANT_EXIT.waiting || exitCode === CHANT_EXIT.moved)) {
2739
2748
  const waiting = { satisfied: false, pending: { op: at.op }, ...(d.mismatch ? { mismatch: d.mismatch } : {}) } as unknown as GateCheck;
2749
+ const approve = waveApproveLines(at.op, p.env, { gate: d.gate, digest: d.digest, components: at.runs });
2740
2750
  await emitGateStep(at.events?.emit, { op: at.op, gate: d.gate }, async () => waiting, () =>
2741
- d.mismatch ? `wave ${at.k}'s plan changed after its approval. Approve the plan now: ${prApproveCommand({ op: at.op, gate: d.gate, digest: d.digest })}` : `wave ${at.k}'s plan is not the one the pull request approved. Approve it: ${prApproveCommand({ op: at.op, gate: d.gate, digest: d.digest })}`,
2751
+ d.mismatch ? `wave ${at.k}'s plan changed after its approval. Approve the plan now: ${approve}` : `wave ${at.k}'s plan is not the one the pull request approved. Approve it: ${approve}`,
2742
2752
  );
2743
2753
  }
2744
2754
  const read = readWaveOutputs(at.outputsFile);
@@ -43,13 +43,14 @@
43
43
 
44
44
  import { execFileSync } from "node:child_process";
45
45
  import { existsSync } from "node:fs";
46
- import { resolve } from "node:path";
46
+ import { tmpdir } from "node:os";
47
+ import { join, relative, resolve } from "node:path";
47
48
  import { formatBold, formatError, formatSuccess, formatWarning } from "../format";
48
49
  import { parseParamFlags } from "../build-params-cli";
49
50
  import type { CommandContext } from "../registry";
50
51
 
51
52
  const USAGE =
52
- "chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
53
+ "chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release images <label|digest> [-o <file>] [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
53
54
 
54
55
  /** The build inputs `release cut` and `release compile` share. */
55
56
  function compileInputs(
@@ -113,6 +114,74 @@ async function laneOf(ctx: CommandContext, cwd: string): Promise<string | undefi
113
114
  }
114
115
  }
115
116
 
117
+ /** The member's `release.images` (#4657), or none when the config declares none. */
118
+ async function releaseImagesOf(cwd: string): Promise<Array<{ name: string; build: string; archive: string }>> {
119
+ const { loadChantConfig } = await import("../../config");
120
+ return (await loadChantConfig(cwd)).config.release?.images ?? [];
121
+ }
122
+
123
+ /** A commit's time in seconds, the `SOURCE_DATE_EPOCH` a release's image builds run with (#4657). */
124
+ function commitTime(cwd: string, commit: string): number {
125
+ return Number(execFileSync("git", ["show", "-s", "--format=%ct", commit], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim());
126
+ }
127
+
128
+ /**
129
+ * `release images <label|digest> [-o <file>] [--json]` (#4657): build the
130
+ * images the release recorded again, from the release's commit checked out
131
+ * here, refuse an archive whose digest is not the recorded one, and write the
132
+ * recorded digests to the file the package build reads through
133
+ * `CHANT_RELEASE_DIGESTS` (default `.chant/release-digests.json`). The
134
+ * publish job runs it before the build that packs the package.
135
+ */
136
+ export async function runReleaseImages(ctx: CommandContext): Promise<number> {
137
+ const { args } = ctx;
138
+ const ref = args.extraPositional;
139
+ const fail = (code: string, message: string, fix?: string): number => {
140
+ if (args.json) console.log(JSON.stringify({ ref: ref ?? null, error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
141
+ else console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
142
+ return 1;
143
+ };
144
+ if (!ref) return fail("release-not-named", "release images needs a release, by label or digest", USAGE);
145
+ const cwd = resolve(".");
146
+ const { resolveRelease } = await import("../../lifecycle/release-store");
147
+ const { buildReleaseImages, releaseImageDigests, writeReleaseDigests, ReleaseImageError, RELEASE_DIGESTS_ENV } = await import("../../lifecycle/release-images");
148
+ const { ociArchiveDigest } = await import("../../lifecycle/publish-oci");
149
+ const { getHeadCommit } = await import("../../lifecycle/git");
150
+ const found = await resolveRelease(ref, { cwd });
151
+ if (!found) return fail("release-not-found", `no release is labelled or digested "${ref}" in this member`, "Fetch chant/lifecycle (git fetch origin chant/lifecycle:chant/lifecycle), then list them with: chant release list");
152
+ const { release, label } = found;
153
+ const head = await getHeadCommit({ cwd });
154
+ if (head !== release.commit) return fail("release-images-wrong-commit", `the release was cut from ${release.commit.slice(0, 12)}, and this checkout is at ${head.slice(0, 12)}, so its images would not be the release's`, `Check out the release's commit: git checkout ${release.commit}`);
155
+ const declared = await releaseImagesOf(cwd);
156
+ const recorded = releaseImageDigests(release, declared.map((d) => d.name));
157
+ const missing = declared.filter((d) => recorded[d.name] === undefined).map((d) => d.name);
158
+ if (missing.length > 0) return fail("release-image-not-recorded", `release.images names ${missing.join(", ")}, which release ${release.releaseDigest} does not record`, "Cut a new release, so its cut builds every image the config declares.");
159
+ let built: import("../../lifecycle/release-store").ReleaseArtifact[];
160
+ try {
161
+ built = buildReleaseImages({ images: declared, cwd, sourceDateEpoch: commitTime(cwd, release.commit), label, archiveDigest: ociArchiveDigest });
162
+ } catch (err) {
163
+ if (err instanceof ReleaseImageError) return fail(err.code, err.message, err.fix);
164
+ throw err;
165
+ }
166
+ const differ = built.filter((a) => recorded[a.component] !== a.digest);
167
+ if (differ.length > 0) {
168
+ return fail(
169
+ "release-image-digest-mismatch",
170
+ differ.map((a) => `image "${a.component}" built to ${a.digest}, and the release records ${recorded[a.component]}`).join("; "),
171
+ "An image build must write the same archive from the same commit: set SOURCE_DATE_EPOCH-aware timestamps (rewrite-timestamp=true), and remove logs and caches from its layers.",
172
+ );
173
+ }
174
+ const file = resolve(cwd, args.output ?? ".chant/release-digests.json");
175
+ writeReleaseDigests(file, recorded);
176
+ if (args.json) console.log(JSON.stringify({ releaseDigest: release.releaseDigest, label, digests: recorded, file }, null, 2));
177
+ else {
178
+ for (const [name, digest] of Object.entries(recorded)) console.error(` ${name} ${digest}`);
179
+ console.error(formatSuccess(`Built ${built.length} image(s) to the digests release ${label ?? release.releaseDigest} records, and wrote them to ${relative(cwd, file) || file}`));
180
+ console.log(`${RELEASE_DIGESTS_ENV}=${file}`);
181
+ }
182
+ return 0;
183
+ }
184
+
116
185
  function describeActorSource(source: import("../../lifecycle/release-workstation").ActorSource): string {
117
186
  switch (source) {
118
187
  case "flag":
@@ -265,7 +334,25 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
265
334
  // --at: the cut reads, compiles and builds the commit's tree, not the checkout's.
266
335
  if (args.at !== undefined && top && commit) checkout = at.checkoutCommit(top, cwd, commit);
267
336
  const cutCwd = checkout?.memberDir ?? cwd;
268
- const compiler = spawnTargetCompiler(compileInputs(ctx, params, cutCwd, label));
337
+ // #4657: the images release.images declares are built first, and their digests handed to the build command.
338
+ const declaredImages = await releaseImagesOf(cutCwd);
339
+ const digestsFile = declaredImages.length > 0 ? join(tmpdir(), `chant-release-digests-${process.pid}.json`) : undefined;
340
+ const compiler = spawnTargetCompiler({ ...compileInputs(ctx, params, cutCwd, label), ...(digestsFile ? { releaseDigests: digestsFile } : {}) });
341
+ const buildImages = digestsFile
342
+ ? async (at: string) => {
343
+ const { buildReleaseImages, writeReleaseDigests, ReleaseImageError } = await import("../../lifecycle/release-images");
344
+ const { ociArchiveDigest } = await import("../../lifecycle/publish-oci");
345
+ try {
346
+ const built = buildReleaseImages({ images: declaredImages, cwd: cutCwd, sourceDateEpoch: commitTime(cutCwd, at), label, archiveDigest: ociArchiveDigest });
347
+ writeReleaseDigests(digestsFile, Object.fromEntries(built.map((a) => [a.component, a.digest])));
348
+ return built;
349
+ } catch (err) {
350
+ const code = err instanceof ReleaseImageError ? err.code : (err as { code?: unknown }).code;
351
+ const fix = err instanceof ReleaseImageError ? err.fix : undefined;
352
+ throw new ReleaseCutError(code === "release-image-name-taken" ? "release-image-name-taken" : "release-image-build-failed", `no release was cut: ${(err as Error).message}`, fix);
353
+ }
354
+ }
355
+ : undefined;
269
356
  // #4692: the lane is the commit's own config's under --at.
270
357
  const lane = await laneOf(ctx, cutCwd);
271
358
  const request = {
@@ -279,6 +366,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
279
366
  ...(lane !== undefined ? { lane } : {}),
280
367
  ...(args.overrideGreen ? { overrideGreen: true } : {}),
281
368
  ...(Object.keys(images).length > 0 ? { images } : {}),
369
+ ...(buildImages ? { buildImages } : {}),
282
370
  };
283
371
 
284
372
  if (dryRun) {
@@ -565,6 +653,7 @@ export async function runReleasePublish(ctx: CommandContext): Promise<number> {
565
653
  /** One item a target publishes, for a line: what, where, and the SBOM or attachment it is (#4049). */
566
654
  function describeItem(i: import("../../lifecycle/release-publish").PublishItem): string {
567
655
  const what = i.attachment === "sbom" ? `${i.name} (SBOM)` : i.attachment === "provenance" ? `${i.name} (provenance)` : i.name;
656
+ if (i.notes !== undefined) return `${i.name} to ${i.destination}:\n${i.notes.trimEnd().split("\n").map((l) => ` ${l}`.trimEnd()).join("\n")}`;
568
657
  return `${what} to ${i.destination}${i.sbom ? `, carrying ${i.sbom}` : ""}`;
569
658
  }
570
659
 
@@ -588,7 +677,13 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
588
677
  else console.error(formatError({ message: `${result.error.message} [${result.error.code}]`, ...(result.error.fix ? { hint: result.error.fix } : {}) }));
589
678
  return 1;
590
679
  }
591
- const code = verificationCode(result);
680
+ let code: string | null = verificationCode(result);
681
+ // #4657: a package built here that pins an image digest the release does not record fails the check.
682
+ const pins = code ? null : await unknownPackagePins(resolve("."), result.releaseDigest);
683
+ if (pins) {
684
+ code = "release-pin-unknown";
685
+ result.reason = pins;
686
+ }
592
687
  if (args.json) {
593
688
  console.log(JSON.stringify({ ...result, ...(code ? { error: { code, message: result.reason } } : {}) }, null, 2));
594
689
  return code ? 1 : 0;
@@ -601,7 +696,7 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
601
696
  console.error(
602
697
  formatError({
603
698
  message: `${name} does not verify: ${result.reason} [${code}]`,
604
- hint: code === "release-digest-mismatch" ? "Do not publish or deploy it; cut the release again." : `Cut it again signed with a key ${result.signers.path} lists: chant release cut ${result.label ?? "<label>"} --sign --yes`,
699
+ hint: code === "release-digest-mismatch" ? "Do not publish or deploy it; cut the release again." : code === "release-pin-unknown" ? "Build the package from the digests the release records: chant release images <label>, then the build with CHANT_RELEASE_DIGESTS set." : `Cut it again signed with a key ${result.signers.path} lists: chant release cut ${result.label ?? "<label>"} --sign --yes`,
605
700
  }),
606
701
  );
607
702
  return 1;
@@ -610,6 +705,16 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
610
705
  return 0;
611
706
  }
612
707
 
708
+ /** The first package built here that pins an image digest release `digest` does not record (#4657), said in a sentence, or null. */
709
+ async function unknownPackagePins(cwd: string, digest: string): Promise<string | null> {
710
+ const { loadChantConfig } = await import("../../config");
711
+ const { readRelease } = await import("../../lifecycle/release-store");
712
+ const { packagePinProblem } = await import("../../lifecycle/release-images");
713
+ const targets = (await loadChantConfig(cwd).catch(() => null))?.config.release?.publish ?? [];
714
+ const release = await readRelease(digest, { cwd });
715
+ return release ? packagePinProblem(cwd, release, targets) : null;
716
+ }
717
+
613
718
  /**
614
719
  * `release candidates [--env <env>] [--forge-issues] [--json]` (#4168 4.2):
615
720
  * the green commits of trunk a release can be cut from, newest first, each
package/src/cli/main.ts CHANGED
@@ -303,6 +303,12 @@ CI:
303
303
  (GITHUB_SHA, else HEAD), judged from its check runs
304
304
  as the tick judges; 1 when one failed; 3 while one is
305
305
  pending, unless --wait reads again until none is.
306
+ ci verdict --wait [--retries <n>] [--timeout-minutes <n>]
307
+ Waiting, it looks past forge errors (5xx, no answer)
308
+ a few times, re-runs a failed job's workflow run up
309
+ to --retries times (else ci.green.mergeQueue.retries,
310
+ 0) and fails when it fails again, and gives up after
311
+ --timeout-minutes.
306
312
  ci list [--json] [--limit <n>] [--since <rev>] [--forge github] [--source checks|runs]
307
313
  The first-parent commits of ci.green's branch within
308
314
  its window, newest first, each green, revoked or
@@ -520,6 +526,11 @@ Releases:
520
526
  release verify <label|digest> [--json]
521
527
  Check, offline, that the release was signed by a key
522
528
  .chant/allowed_signers lists at the release's commit.
529
+ release images <label|digest> [-o <file>] [--json]
530
+ Build the images release.images declares again from
531
+ the release's commit, refuse one whose digest is not
532
+ the recorded one, and write the recorded digests to
533
+ the file CHANT_RELEASE_DIGESTS names for the build.
523
534
  release workflow [--forge github|gitlab|forgejo] [--install <command>]
524
535
  [--build <command>] [--chant <command>] [--output <file>]
525
536
  Write the publish workflow, run on a release/** tag.
@@ -1302,6 +1313,13 @@ Component release ledger + status:
1302
1313
  runs the model command with no forge token, land
1303
1314
  pushes the change, opens or updates the pull
1304
1315
  request and records the run (--forge <kind>)
1316
+ commit prepare|run|land The commit jobs (#4722) the Op generator writes for
1317
+ a spec's commit: prepare decides from the comment or
1318
+ the failed check, the ledger's run count and the
1319
+ head's approvals, run runs the product's command
1320
+ with no forge token, land pushes the change to the
1321
+ pull request's branch and records the run
1322
+ (--forge <kind>)
1305
1323
  components pr-env An environment per open pull request (#4298): up
1306
1324
  --base <ref> --pr <n> applies the change to pr-<n>,
1307
1325
  derived from ci.prEnvironment.template, once an
@@ -1870,6 +1888,8 @@ export const commandRegistry: CommandDef[] = [
1870
1888
  { name: "release publish", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleasePublish(ctx) },
1871
1889
  // #4049: check a release's signature offline.
1872
1890
  { name: "release verify", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseVerify(ctx) },
1891
+ // #4657: build a release's images again in its publish job, checked against the digests it records.
1892
+ { name: "release images", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseImages(ctx) },
1873
1893
  { name: "release workflow", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/release-workflow")).runReleaseWorkflow(ctx) },
1874
1894
  // #4168 4.3: mode (b), chosen changes composed onto a base on chant/compose/<name>.
1875
1895
  { name: "release compose", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseCompose(ctx) },
@@ -2033,6 +2053,9 @@ export const commandRegistry: CommandDef[] = [
2033
2053
  { name: "agent prepare", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
2034
2054
  { name: "agent run", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
2035
2055
  { name: "agent land", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
2056
+ { name: "commit prepare", handler: async (ctx) => (await import("./handlers/commit")).runCommitCommandLine(ctx) },
2057
+ { name: "commit run", handler: async (ctx) => (await import("./handlers/commit")).runCommitCommandLine(ctx) },
2058
+ { name: "commit land", handler: async (ctx) => (await import("./handlers/commit")).runCommitCommandLine(ctx) },
2036
2059
  { name: "components pr-env", requiresPlugins: true, handler: async (ctx) => (await import("./handlers/pr-env")).runComponentsPrEnv(ctx) },
2037
2060
  { name: "components status", requiresPlugins: true, handler: runComponentsStatus },
2038
2061
  { name: "components release", handler: runComponentsReleaseRecord },
@@ -1225,6 +1225,17 @@ export function parseArgs(args: string[]): ParsedArgs {
1225
1225
  } else if (arg === "--wait") {
1226
1226
  // `chant ci verdict --wait` (#4644): read the check runs again until no required phase is pending.
1227
1227
  result.ciWait = true;
1228
+ } else if (arg === "--retries") {
1229
+ // `chant ci verdict --wait --retries <n>` (#4729): re-run a failed workflow run's failed jobs up to n times; overrides ci.green.mergeQueue.retries.
1230
+ const raw = args[++i];
1231
+ if (raw === undefined || !/^\d+$/.test(raw)) throw new Error(`--retries needs a whole number of re-runs: --retries <n>, got ${JSON.stringify(raw ?? "")}`);
1232
+ result.ciRetries = Number(raw);
1233
+ } else if (arg === "--timeout-minutes") {
1234
+ // `chant ci verdict --wait --timeout-minutes <n>` (#4729): give up with a message after n minutes, before the job's own timeout.
1235
+ const raw = args[++i];
1236
+ const n = raw === undefined ? NaN : Number(raw);
1237
+ if (raw === undefined || raw.trim() === "" || !Number.isFinite(n) || n <= 0) throw new Error(`--timeout-minutes needs a number of minutes above 0: --timeout-minutes <n>, got ${JSON.stringify(raw ?? "")}`);
1238
+ result.ciTimeoutMinutes = n;
1228
1239
  } else if (arg === "--lane") {
1229
1240
  // `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662): a green lane's tags and phases.
1230
1241
  // `chant release cut|candidates --lane <name>` (#4692): a cut from that lane's green tag.
@@ -933,6 +933,10 @@ export interface ParsedArgs {
933
933
  since?: string;
934
934
  /** `chant ci verdict --wait` (#4644) — read again until no required phase is pending. */
935
935
  ciWait?: boolean;
936
+ /** `chant ci verdict --wait --retries <n>` (#4729) — re-run a failed workflow run's failed jobs up to n times before failing; overrides `ci.green.mergeQueue.retries`. */
937
+ ciRetries?: number;
938
+ /** `chant ci verdict --wait --timeout-minutes <n>` (#4729) — give up after n minutes, with a message, before the job's own timeout. */
939
+ ciTimeoutMinutes?: number;
936
940
  /** `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662) — a ci.green lane. `chant release cut --lane <name>` and `chant release candidates --lane <name>` (#4692) — check that lane's green tags. */
937
941
  lane?: string;
938
942
  /** `chant ci base --phase <name>` (#4643) — the ci.green phase whose base to find. `chant ci quarantine filter --phase <name>` (#4677) — the phase whose runner takes the filter. */
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import { componentWaveOutputsFile, componentWaveSteps, componentWavesSpec, productDriftAgent, productPipelineJobs, productWavesSpec } from "./product-pipeline";
2
+ import { componentWaveOutputsFile, componentWaveSteps, componentWavesSpec, productCheckCommit, productDriftAgent, productPipelineJobs, productWavesSpec } from "./product-pipeline";
3
3
  import { prApplyComment, prLoopSetup, PR_LOOP_IMAGE, PR_LOOP_SETUP, withProductBin } from "./pr-pipeline";
4
4
  import { PLYWOOD, TERRAGUCCI } from "../__fixtures__/product-words";
5
5
  import type { OpWavesSpec } from "../op/op-waves";
@@ -198,3 +198,30 @@ describe("the note job's read of the control repo (#4619)", () => {
198
198
  });
199
199
  });
200
200
 
201
+
202
+ describe("the commit jobs (#4722)", () => {
203
+ const words = { ...PLYWOOD, commands: { ...PLYWOOD.commands, fmt: "commit" as const } };
204
+
205
+ test("return each comment commit job's Op spec, with the settings checked", () => {
206
+ const pw = productPipelineJobs("github", "production", { words: only(words, "plan", "commit"), commits: [{ word: "fmt", command: ["tofu", "fmt"], allowed: ["infra/"], tokenEnv: "PUSH_TOKEN", runner: "small" }] });
207
+ expect(pw.comments.commit).toBe("/plywood fmt");
208
+ expect(pw.commits).toEqual([
209
+ {
210
+ comment: "/plywood fmt",
211
+ name: "plywood-fmt",
212
+ spec: { name: "plywood-fmt", trigger: { kind: "pull_request" }, commit: { on: "comment", comment: "/plywood fmt", command: ["tofu", "fmt"], allowed: ["infra/"], tokenEnv: "PUSH_TOKEN" }, runner: "small" },
213
+ },
214
+ ]);
215
+ expect(() => productPipelineJobs("github", "production", { words: only(words, "plan", "commit"), commits: [{ word: "fmt", command: ["tofu", "fmt"], allowed: [] }] })).toThrow(/allowed/);
216
+ expect(() => productPipelineJobs("github", "production", { words: only(words, "plan", "commit"), commits: [{ word: "lint", command: ["tofu", "fmt"], allowed: ["infra/"] }] })).toThrow(/not a command the words map onto commit/);
217
+ });
218
+
219
+ test("words that name a commit command with no commit job are refused", () => {
220
+ expect(() => productPipelineJobs("github", "production", { words: only(words, "plan", "commit") })).toThrow(/needs a commit job/);
221
+ });
222
+
223
+ test("a check's commit rides on the check's own spec", () => {
224
+ expect(productCheckCommit(words, "fmt-check", { command: ["tofu", "fmt"], allowed: ["infra/"], findings: [3] })).toEqual({ on: "check", command: ["tofu", "fmt"], allowed: ["infra/"], findings: [3] });
225
+ expect(() => productCheckCommit(words, "fmt-check", { command: [], allowed: ["infra/"] })).toThrow(/argv/);
226
+ });
227
+ });