@intentius/chant 0.124.75 → 0.124.77

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 (147) hide show
  1. package/dist/__fixtures__/agent-guard/plywood.d.ts +8 -0
  2. package/dist/__fixtures__/agent-guard/plywood.d.ts.map +1 -0
  3. package/dist/__fixtures__/agent-guard/plywood.js +19 -0
  4. package/dist/__fixtures__/agent-guard/terragucci.d.ts +8 -0
  5. package/dist/__fixtures__/agent-guard/terragucci.d.ts.map +1 -0
  6. package/dist/__fixtures__/agent-guard/terragucci.js +30 -0
  7. package/dist/__fixtures__/gated-ledger.d.ts +10 -0
  8. package/dist/__fixtures__/gated-ledger.d.ts.map +1 -0
  9. package/dist/__fixtures__/gated-ledger.js +51 -0
  10. package/dist/agent-guard.d.ts +143 -0
  11. package/dist/agent-guard.d.ts.map +1 -0
  12. package/dist/agent-guard.js +456 -0
  13. package/dist/ci-commit.d.ts +54 -3
  14. package/dist/ci-commit.d.ts.map +1 -1
  15. package/dist/ci-commit.js +69 -7
  16. package/dist/ci-own-jobs.d.ts +81 -0
  17. package/dist/ci-own-jobs.d.ts.map +1 -0
  18. package/dist/ci-own-jobs.js +234 -0
  19. package/dist/ci-product.d.ts +39 -0
  20. package/dist/ci-product.d.ts.map +1 -1
  21. package/dist/ci-product.js +40 -0
  22. package/dist/cli/handlers/approve.d.ts +5 -1
  23. package/dist/cli/handlers/approve.d.ts.map +1 -1
  24. package/dist/cli/handlers/approve.js +17 -11
  25. package/dist/cli/handlers/build.d.ts +1 -1
  26. package/dist/cli/handlers/build.d.ts.map +1 -1
  27. package/dist/cli/handlers/build.js +88 -2
  28. package/dist/cli/handlers/commit.d.ts.map +1 -1
  29. package/dist/cli/handlers/commit.js +3 -1
  30. package/dist/cli/handlers/notify-relay.d.ts +18 -1
  31. package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
  32. package/dist/cli/handlers/notify-relay.js +90 -14
  33. package/dist/cli/handlers/pr.d.ts.map +1 -1
  34. package/dist/cli/handlers/pr.js +3 -1
  35. package/dist/cli/handlers/release.d.ts +9 -1
  36. package/dist/cli/handlers/release.d.ts.map +1 -1
  37. package/dist/cli/handlers/release.js +34 -6
  38. package/dist/cli/handlers/run-generate.d.ts.map +1 -1
  39. package/dist/cli/handlers/run-generate.js +2 -1
  40. package/dist/cli/main.d.ts.map +1 -1
  41. package/dist/cli/main.js +21 -1
  42. package/dist/cli/parse-args.d.ts.map +1 -1
  43. package/dist/cli/parse-args.js +60 -4
  44. package/dist/cli/registry.d.ts +16 -0
  45. package/dist/cli/registry.d.ts.map +1 -1
  46. package/dist/components/pr-env-components.d.ts +65 -0
  47. package/dist/components/pr-env-components.d.ts.map +1 -0
  48. package/dist/components/pr-env-components.js +163 -0
  49. package/dist/components/pr-policy.d.ts +15 -0
  50. package/dist/components/pr-policy.d.ts.map +1 -1
  51. package/dist/components/pr-policy.js +24 -1
  52. package/dist/components/release-compile.d.ts +15 -3
  53. package/dist/components/release-compile.d.ts.map +1 -1
  54. package/dist/components/release-compile.js +66 -15
  55. package/dist/gate-policy.d.ts +14 -1
  56. package/dist/gate-policy.d.ts.map +1 -1
  57. package/dist/gate-policy.js +16 -6
  58. package/dist/lexicon.d.ts +17 -1
  59. package/dist/lexicon.d.ts.map +1 -1
  60. package/dist/lexicon.js +1 -0
  61. package/dist/lifecycle/gated-op.d.ts +95 -0
  62. package/dist/lifecycle/gated-op.d.ts.map +1 -0
  63. package/dist/lifecycle/gated-op.js +96 -0
  64. package/dist/lifecycle/git.d.ts.map +1 -1
  65. package/dist/lifecycle/git.js +83 -2
  66. package/dist/notify-relay-repo.d.ts +131 -0
  67. package/dist/notify-relay-repo.d.ts.map +1 -0
  68. package/dist/notify-relay-repo.js +202 -0
  69. package/dist/notify-relay.d.ts +25 -1
  70. package/dist/notify-relay.d.ts.map +1 -1
  71. package/dist/notify-relay.js +28 -2
  72. package/dist/op/op-waves-capability.js +2 -2
  73. package/dist/policy-engine.d.ts +95 -0
  74. package/dist/policy-engine.d.ts.map +1 -0
  75. package/dist/policy-engine.js +158 -0
  76. package/dist/release-floors.d.ts +1 -1
  77. package/dist/release-floors.js +1 -1
  78. package/dist/state-export.d.ts +126 -0
  79. package/dist/state-export.d.ts.map +1 -0
  80. package/dist/state-export.js +157 -0
  81. package/dist/state-migration.d.ts +148 -0
  82. package/dist/state-migration.d.ts.map +1 -0
  83. package/dist/state-migration.js +147 -0
  84. package/dist/state-unlock.d.ts +167 -0
  85. package/dist/state-unlock.d.ts.map +1 -0
  86. package/dist/state-unlock.js +197 -0
  87. package/dist/wave-runtime.mjs +329 -329
  88. package/dist/workspace/declaration.schema.json +1 -1
  89. package/dist/workspace/release-workflow.d.ts +10 -0
  90. package/dist/workspace/release-workflow.d.ts.map +1 -1
  91. package/dist/workspace/release-workflow.js +8 -3
  92. package/package.json +1 -1
  93. package/src/__fixtures__/agent-guard/plywood.ts +27 -0
  94. package/src/__fixtures__/agent-guard/terragucci.ts +39 -0
  95. package/src/__fixtures__/gated-ledger.ts +58 -0
  96. package/src/agent-guard.test.ts +320 -0
  97. package/src/agent-guard.ts +548 -0
  98. package/src/ci-commit.test.ts +50 -2
  99. package/src/ci-commit.ts +93 -9
  100. package/src/ci-own-jobs.test.ts +109 -0
  101. package/src/ci-own-jobs.ts +253 -0
  102. package/src/ci-product.ts +81 -0
  103. package/src/cli/handlers/approve-cwd.test.ts +112 -0
  104. package/src/cli/handlers/approve.ts +22 -11
  105. package/src/cli/handlers/build-own-jobs.test.ts +80 -0
  106. package/src/cli/handlers/build-pr-loop-control.test.ts +88 -0
  107. package/src/cli/handlers/build-run-group.test.ts +60 -0
  108. package/src/cli/handlers/build.ts +83 -3
  109. package/src/cli/handlers/commit.ts +3 -0
  110. package/src/cli/handlers/notify-relay.ts +99 -17
  111. package/src/cli/handlers/pr.ts +3 -1
  112. package/src/cli/handlers/release-cut-archives.test.ts +21 -0
  113. package/src/cli/handlers/release.ts +31 -6
  114. package/src/cli/handlers/run-generate.ts +2 -1
  115. package/src/cli/main.ts +21 -1
  116. package/src/cli/parse-args.ts +45 -3
  117. package/src/cli/registry.ts +16 -0
  118. package/src/components/pr-env-components.test.ts +138 -0
  119. package/src/components/pr-env-components.ts +214 -0
  120. package/src/components/pr-policy.test.ts +41 -1
  121. package/src/components/pr-policy.ts +25 -1
  122. package/src/components/release-compile.test.ts +47 -0
  123. package/src/components/release-compile.ts +70 -13
  124. package/src/gate-policy-bundle.test.ts +14 -0
  125. package/src/gate-policy.test.ts +7 -0
  126. package/src/gate-policy.ts +22 -7
  127. package/src/lexicon.ts +18 -1
  128. package/src/lifecycle/gated-op.ts +158 -0
  129. package/src/lifecycle/git.test.ts +92 -0
  130. package/src/lifecycle/git.ts +71 -2
  131. package/src/notify-relay-repo.test.ts +284 -0
  132. package/src/notify-relay-repo.ts +234 -0
  133. package/src/notify-relay.test.ts +12 -0
  134. package/src/notify-relay.ts +30 -3
  135. package/src/op/op-waves-capability.ts +2 -2
  136. package/src/policy-engine.test.ts +163 -0
  137. package/src/policy-engine.ts +201 -0
  138. package/src/release-floors.ts +1 -1
  139. package/src/state-export.test.ts +125 -0
  140. package/src/state-export.ts +228 -0
  141. package/src/state-migration.test.ts +134 -0
  142. package/src/state-migration.ts +237 -0
  143. package/src/state-unlock.test.ts +166 -0
  144. package/src/state-unlock.ts +294 -0
  145. package/src/workspace/declaration.schema.json +1 -1
  146. package/src/workspace/release-workflow.test.ts +34 -0
  147. package/src/workspace/release-workflow.ts +17 -3
@@ -1 +1 @@
1
- {"version":3,"file":"approve.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/approve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EACuE,KAAK,UAAU,EAC5F,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEuC,KAAK,mBAAmB,EAAE,KAAK,oBAAoB,EAChG,MAAM,wBAAwB,CAA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ED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAGlI;AA0gBD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,oBAAoB,EAAE,EAC7B,QAAQ,EAAE,iBAAiB,GAAG,SAAS,EACvC,OAAO,GAAE,SAAS,iBAAiB,EAA+B,EAClE,KAAK,GAAE,eAAgC,GACtC,MAAM,EAAE,CAuCV"}
@@ -57,9 +57,10 @@ const LIFECYCLE_BRANCH = "chant/lifecycle";
57
57
  * failure; the exit code is unchanged. With no remote at all there is nobody
58
58
  * elsewhere to tell, so that case is a quiet suffix and no warning (#3677).
59
59
  */
60
- async function reportedPush(consequence) {
60
+ async function reportedPush(consequence, cwd) {
61
61
  // #4637: a push another writer beat is replayed onto the remote's tip and tried again; an approval line appends.
62
- const { pushed, pushWarning } = await pushLifecycleRebasing().catch((err) => {
62
+ // #4760: and the push is of the repository at `cwd`, not whatever one the process runs in.
63
+ const { pushed, pushWarning } = await pushLifecycleRebasing(...(cwd !== undefined ? [{ cwd }] : [])).catch((err) => {
63
64
  if (err instanceof LifecyclePushLostError)
64
65
  return { pushed: false, pushWarning: err.message };
65
66
  throw err;
@@ -304,7 +305,13 @@ async function approveGate(opName, gate, opts, statementOnly) {
304
305
  }));
305
306
  return { ok: false };
306
307
  }
307
- const { ops } = await discoverOps();
308
+ // #4760: every ledger read, append and push below acts on the repository at
309
+ // `opts.cwd`, the one the scope and signing key come from, and never on
310
+ // process.cwd() when a caller names another. With no `opts.cwd` the calls
311
+ // are made exactly as before, with no location, so they default as they did.
312
+ const cwd = opts.cwd ?? process.cwd();
313
+ const at = opts.cwd !== undefined ? [{ cwd: opts.cwd }] : [];
314
+ const { ops } = await discoverOps(...at);
308
315
  // `fan-out` is the op name every `chant components fan-out` gate is recorded
309
316
  // under (../handlers/fan-out.ts). It is a command rather than a declaration,
310
317
  // so there is no `*.op.ts` to find and nothing is wrong when none is there.
@@ -321,7 +328,7 @@ async function approveGate(opName, gate, opts, statementOnly) {
321
328
  // single commit holding only this resolution — the pending fact it is
322
329
  // answering is discarded rather than appended to.
323
330
  try {
324
- await requireLifecycleLedger();
331
+ await requireLifecycleLedger(...at);
325
332
  }
326
333
  catch (err) {
327
334
  console.error(formatError({
@@ -334,7 +341,7 @@ async function approveGate(opName, gate, opts, statementOnly) {
334
341
  // the new gate has no standing fact of its own. Once it has one, approve
335
342
  // the gate the runs now stop at.
336
343
  if (successor) {
337
- const theirs = latestPendingGate((await readGateLedger(successor.op)).pending, successor.gate);
344
+ const theirs = latestPendingGate((await readGateLedger(successor.op, ...at)).pending, successor.gate);
338
345
  if (theirs && !isPendingGateExpired(theirs, new Date().toISOString())) {
339
346
  console.error(formatError({
340
347
  message: `Gate "${gate}" on "${opName}" is now gate "${successor.gate}" on "${successor.op}", which lists it as an alias, ` +
@@ -368,7 +375,7 @@ async function approveGate(opName, gate, opts, statementOnly) {
368
375
  // recorded in, and an approval answers one environment. `--env` picks it;
369
376
  // without it, the newest standing fact decides, and the success line below
370
377
  // names the environment it chose.
371
- const ledgerBefore = await readGateLedger(opName);
378
+ const ledgerBefore = await readGateLedger(opName, ...at);
372
379
  const pendingFor = (all) => {
373
380
  const bound = all.some((p) => p.gate === gate && p.environment !== undefined);
374
381
  return bound && opts.environment !== undefined ? all.filter((p) => p.environment === opts.environment) : all;
@@ -417,7 +424,7 @@ async function approveGate(opName, gate, opts, statementOnly) {
417
424
  // commit is superseded. Its promote refuses the release, so an approval of
418
425
  // it would count for nothing; refuse it here, whatever plan is named.
419
426
  if (standing?.releaseDigest !== undefined) {
420
- const refused = await refuseRevokedRelease(opName, gate, standing.releaseDigest, opts.cwd ?? process.cwd());
427
+ const refused = await refuseRevokedRelease(opName, gate, standing.releaseDigest, cwd);
421
428
  if (refused)
422
429
  return { ok: false };
423
430
  }
@@ -428,7 +435,7 @@ async function approveGate(opName, gate, opts, statementOnly) {
428
435
  // resolved over the same one has no second party in it. Refused by default,
429
436
  // the way #2300 refuses a plan nobody approved.
430
437
  const origin = opts.origin ?? currentGateOrigin();
431
- const ledger = await readGateLedger(opName);
438
+ const ledger = await readGateLedger(opName, ...at);
432
439
  const standingForOrigin = latestPendingGate(pendingFor(ledger.pending), gate);
433
440
  // chant#3485: a gate that is never resolved over MCP or ACP says so on its
434
441
  // own record, or on its Op's config. No flag overrides this one.
@@ -484,7 +491,6 @@ async function approveGate(opName, gate, opts, statementOnly) {
484
491
  // #3163, ws-080: the declaration at base may require a checkable approver
485
492
  // (identity.attribution "identified") and a signed approval for this gate
486
493
  // (identity.gates). Both are judged before anything is written.
487
- const cwd = opts.cwd ?? process.cwd();
488
494
  const identity = await import("../../workspace/identity.js");
489
495
  const { scopeSource } = await import("../../workspace/write-scope.js");
490
496
  const scope = scopeSource(cwd);
@@ -687,9 +693,9 @@ async function approveGate(opName, gate, opts, statementOnly) {
687
693
  ...(standing?.runId ? { runId: standing.runId } : {}),
688
694
  origin,
689
695
  ...(refusal && opts.allowSameOrigin ? { sameOriginOverride: true } : {}),
690
- });
696
+ }, ...at);
691
697
  const push = await reportedPush(`The resolution is recorded locally on ${LIFECYCLE_BRANCH}. Until it reaches the remote, ` +
692
- `a run in another checkout will not see it.`);
698
+ `a run in another checkout will not see it.`, opts.cwd);
693
699
  console.error(formatSuccess(`Gate "${gate}" on "${opName}" resolved by ${record.resolvedBy}` +
694
700
  (record.relayedBy ? `, relayed by ${record.relayedBy},` : "") +
695
701
  ` at ${record.timestamp}` +
@@ -5,6 +5,6 @@ import type { CommandContext } from "../registry.js";
5
5
  * they do. Each value is refused by name, as `pr-apply` and `pr-post` refuse
6
6
  * it, so a build never writes a job that fails on its own line.
7
7
  */
8
- export declare function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents">): string | undefined;
8
+ export declare function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents"> & Partial<Pick<CommandContext["args"], "controlRepo" | "controlSettings">>): string | undefined;
9
9
  export declare function runBuild(ctx: CommandContext): Promise<number>;
10
10
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqGlD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,kBAAkB,GAAG,OAAO,GAAG,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,GAAG,kBAAkB,CAAC,GAAG,MAAM,GAAG,SAAS,CA6BvO;AAuOD,wBAAsB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJnE"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqGlD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,kBAAkB,GAAG,OAAO,GAAG,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,GAAG,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAgClT;AAoTD,wBAAsB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJnE"}
@@ -109,6 +109,8 @@ function prLoopOption(args, reportUrl, requireReview = false, requireRunnerStart
109
109
  */
110
110
  export function prLoopFlagsProblem(args) {
111
111
  const given = [
112
+ ...(args.controlRepo !== undefined ? ["--control"] : []),
113
+ ...(args.controlSettings !== undefined ? ["--control-setting"] : []),
112
114
  ...(args.merge !== undefined ? ["--merge"] : []),
113
115
  ...(args.mergeTokenEnv !== undefined ? ["--merge-token-env"] : []),
114
116
  ...(args.mergeMethod !== undefined ? ["--merge-method"] : []),
@@ -141,6 +143,8 @@ export function prLoopFlagsProblem(args) {
141
143
  if (args.mergeMethod !== undefined && !PR_MERGE_METHODS.includes(args.mergeMethod))
142
144
  return `--merge-method takes ${PR_MERGE_METHODS.join(", ")}, not ${args.mergeMethod}`;
143
145
  }
146
+ if (args.controlSettings !== undefined && args.controlRepo === undefined)
147
+ return "--control-setting sets the control repo's settings, so it needs --control <repo>";
144
148
  const respond = args.respond ? parseRespondList(args.respond) : {};
145
149
  if ("error" in respond)
146
150
  return respond.error;
@@ -151,6 +155,66 @@ export function prLoopFlagsProblem(args) {
151
155
  return "--decide-backend and --decide-model name the description check's service, so they go with --respond description=check";
152
156
  return undefined;
153
157
  }
158
+ /**
159
+ * `--own-jobs <file>` and `--keep-own-jobs` (#4769): `yaml` with the jobs of
160
+ * `file` after chant's, then the jobs of the file at `target` that the new
161
+ * one lacks and that run neither chant nor the product's bin. A
162
+ * collision, a GitLab keyword, a file that is not a map of jobs, or a forge
163
+ * with no jobs file is refused.
164
+ */
165
+ async function withOwnJobs(yaml, lexicon, file, keep, target) {
166
+ const ownJobs = await import("../../ci-own-jobs.js");
167
+ if (!ownJobs.OWN_JOBS_FORGES.includes(lexicon))
168
+ return { error: `--own-jobs and --keep-own-jobs take a ${ownJobs.OWN_JOBS_FORGES.join(", ")} pipeline, not ${lexicon}` };
169
+ const forge = lexicon;
170
+ if (keep && !target)
171
+ return { error: "--keep-own-jobs keeps the jobs of the file the build writes over, so it needs --output <file>" };
172
+ let out = yaml;
173
+ try {
174
+ if (file !== undefined)
175
+ out = ownJobs.mergeOwnJobs(out, forge, ownJobs.readOwnJobsFile(resolve(file), file), { where: file });
176
+ }
177
+ catch (err) {
178
+ return { error: err instanceof Error ? err.message : String(err) };
179
+ }
180
+ if (keep && target) {
181
+ const { existsSync, readFileSync } = await import("node:fs");
182
+ const previous = existsSync(target) ? readFileSync(target, "utf-8") : undefined;
183
+ const words = activeProductWords();
184
+ const kept = ownJobs.keepOwnJobs(previous, out, forge, { bins: words.bin ? [words.bin] : [] });
185
+ out = kept.text;
186
+ }
187
+ return { yaml: out };
188
+ }
189
+ /**
190
+ * The pull request loop's `control` from `--control <repo>` and each
191
+ * `--control-setting <key>=<value>` (#4772), checked as an op waves spec's
192
+ * `control` is: `op` and `member` are needed, since a build has no
193
+ * repository name to default the member to, and the read secret is never
194
+ * the dispatch token's. The generated note job then reads the control
195
+ * repo's records with the read secret (`controlNoteCheckout`), and an apply
196
+ * on merge sends its dispatch.
197
+ */
198
+ async function buildControl(repo, settings) {
199
+ const { controlSettingsProblems, resolveControlTarget, CONTROL_NAME } = await import("../../control/dispatch.js");
200
+ const { sentCheck, markSent, ...rest } = settings;
201
+ const input = { repo, ...rest };
202
+ const problems = controlSettingsProblems(input, "control");
203
+ if (!(typeof input.member === "string" && CONTROL_NAME.test(input.member)))
204
+ problems.push("control.member must name this repo in the control repo's workspace");
205
+ for (const [key, line] of [["sentCheck", sentCheck], ["markSent", markSent]]) {
206
+ if (line !== undefined && line.includes("\n"))
207
+ problems.push(`control.${key} must be one shell line`);
208
+ }
209
+ if (problems.length > 0)
210
+ return { error: `--control: ${problems.join("; ")} (set each with --control-setting <key>=<value>)` };
211
+ try {
212
+ return { control: { target: resolveControlTarget(input, input.member), ...(sentCheck ? { sentCheck } : {}), ...(markSent ? { markSent } : {}) } };
213
+ }
214
+ catch (err) {
215
+ return { error: err instanceof Error ? err.message : String(err) };
216
+ }
217
+ }
154
218
  /**
155
219
  * `chant build --components --generate <lexicon>` — generate mode (#563,
156
220
  * epic #551 Phase 3). Discovers `Component` declarations under `args.path`
@@ -300,6 +364,16 @@ async function runGenerateComponents(ctx) {
300
364
  if (found && args.prLoop) {
301
365
  lockGrain = (await import("../../workspace/ci-lock-grain.js")).ciLockGrainAt(resolve(args.path), undefined, plan?.member.name) === "repo" ? "repo" : undefined;
302
366
  }
367
+ // #4772: --control names the control repo; the note job reads its records, and an apply on merge tells it.
368
+ let control;
369
+ if (args.prLoop && args.controlRepo !== undefined) {
370
+ const resolved = await buildControl(args.controlRepo, args.controlSettings ?? {});
371
+ if ("error" in resolved) {
372
+ console.error(formatError({ message: resolved.error }));
373
+ return 1;
374
+ }
375
+ control = resolved.control;
376
+ }
303
377
  // Which lexicons support generate mode is a property of the loaded lexicon
304
378
  // plugins (those implementing `generateComponentPipeline`, #688), not a
305
379
  // hard-coded core list — `generateComponentsPipeline` returns a descriptive
@@ -318,16 +392,28 @@ async function runGenerateComponents(ctx) {
318
392
  : {}),
319
393
  // #3183: a plan job per pull request and an apply job per merge.
320
394
  // #4292: on the branch ci.branches routes the member to, when it routes it.
321
- ...(args.prLoop ? { prLoop: { ...prLoopOption(args, reportUrl, reviewRules, isolatedRunners), ...(plan?.branch ? { branch: plan.branch } : {}), ...(identity ? { identity } : {}), ...(prEnvIdentity ? { prEnvIdentity } : {}), ...(locks ? { locks } : {}), ...(engineSetup.length > 0 ? { engineSetup } : {}), ...(lockGrain ? { lockGrain } : {}) } } : {}),
395
+ ...(args.prLoop ? { prLoop: { ...prLoopOption(args, reportUrl, reviewRules, isolatedRunners), ...(plan?.branch ? { branch: plan.branch } : {}), ...(identity ? { identity } : {}), ...(prEnvIdentity ? { prEnvIdentity } : {}), ...(locks ? { locks } : {}), ...(engineSetup.length > 0 ? { engineSetup } : {}), ...(lockGrain ? { lockGrain } : {}), ...(control ? { control } : {}) } } : {}),
322
396
  // #4002: the job image and the lines that install what it lacks, chant itself included.
323
397
  ...(args.image ? { image: args.image } : {}),
324
398
  ...(args.beforeScript?.length ? { beforeScript: args.beforeScript } : {}),
399
+ // #4771: a workflow-level run group, which Forgejo's generator writes.
400
+ ...(args.runGroup ? { runGroup: args.runGroup } : {}),
325
401
  }, args.sandbox, paramsResolution.provenance);
326
402
  if (!result.success) {
327
403
  console.error(formatError({ message: result.error ?? "Failed to generate CI pipeline from components" }));
328
404
  return 1;
329
405
  }
330
- const yaml = result.yaml ?? "";
406
+ let yaml = result.yaml ?? "";
407
+ // #4769: the repository's own jobs, from a file and from the file this build writes over.
408
+ if (args.ownJobs !== undefined || args.keepOwnJobs) {
409
+ const target = plan ? plan.target : args.output ? resolve(args.output) : undefined;
410
+ const own = await withOwnJobs(yaml, lexicon, args.ownJobs, args.keepOwnJobs === true, target);
411
+ if ("error" in own) {
412
+ console.error(formatError({ message: own.error }));
413
+ return 1;
414
+ }
415
+ yaml = own.yaml;
416
+ }
331
417
  if (args.format === "json") {
332
418
  console.log(JSON.stringify({
333
419
  stages: result.stages,
@@ -1 +1 @@
1
- {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAOL,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGjF,OAAO,EAA2D,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMnH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkClD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,YAAY,CAYjG;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8D/E"}
1
+ {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAQL,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGjF,OAAO,EAA2D,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMnH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAkClD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,YAAY,CAYjG;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAgE/E"}
@@ -17,7 +17,7 @@ import { readFileSync, writeFileSync } from "node:fs";
17
17
  import { tmpdir } from "node:os";
18
18
  import { join, resolve } from "node:path";
19
19
  import { AgentError } from "../../ci-agent.js";
20
- import { COMMIT_DIR, commitSettingsFromEnv, landCommitChange, prepareCommitRun, runCommit, runCommitArgv, COMMIT_PUSHED_FILE, } from "../../ci-commit.js";
20
+ import { COMMIT_DIR, commitSettingsFromEnv, landCommitChange, prepareCommitRun, runCommit, runCommitArgv, activeCommitRefusalReply, COMMIT_PUSHED_FILE, } from "../../ci-commit.js";
21
21
  import { activeProductWords } from "../../ci-product-words.js";
22
22
  import { CHANT_EXIT } from "../../exit-codes.js";
23
23
  import { appendRunRecord, readRunLedger } from "../../lifecycle/run-ledger.js";
@@ -130,6 +130,8 @@ export async function runCommitCommandLine(ctx) {
130
130
  },
131
131
  now: () => new Date(),
132
132
  ...(ci ? { runOrigin: ci.runOrigin } : {}),
133
+ // #4724: the product's bin sets its reply to a command that refused, as it sets its words.
134
+ ...(activeCommitRefusalReply() ? { refusalReply: activeCommitRefusalReply() } : {}),
133
135
  });
134
136
  // #4749: what was pushed, for the push job's `after` lines.
135
137
  if (out.result === "pushed" && out.commit)
@@ -8,8 +8,25 @@ export declare function relaySettingsFromEnv(env: NodeJS.ProcessEnv): {
8
8
  } | {
9
9
  error: string;
10
10
  };
11
+ /**
12
+ * Fetch the default branch, the one `origin/HEAD` names, so the signers are
13
+ * read at its current tip (#4759). A checkout with no `origin/HEAD` reads its
14
+ * local branch as before. A fetch that fails throws: signers read from a
15
+ * stale tip could still count one removed since.
16
+ */
17
+ export declare function fetchDefaultBranch(cwd: string): Promise<void>;
11
18
  /** The relay's reads and writes against the checkout at `cwd`. */
12
19
  export declare function checkoutRelayDeps(cwd: string, principal: string): RelayDeps;
20
+ /** The flags and variables that make the relay clone the repo itself (#4759). */
21
+ export interface RelayRepoOptions {
22
+ repo?: string;
23
+ tokenEnv?: string;
24
+ forge?: string;
25
+ host?: string;
26
+ port?: string;
27
+ }
13
28
  /** `chant notify relay`. Runs until the process is stopped. */
14
- export declare function runNotifyRelay(_ctx: CommandContext): Promise<number>;
29
+ export declare function runNotifyRelay(ctx: CommandContext): Promise<number>;
30
+ /** Read the settings, clone when asked, and serve. Runs until the process is stopped. */
31
+ export declare function serveNotifyRelay(o: RelayRepoOptions, env?: NodeJS.ProcessEnv): Promise<number>;
15
32
  //# sourceMappingURL=notify-relay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notify-relay.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/notify-relay.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAuE,KAAK,SAAS,EAAqB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhK,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;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AAO,CAAC,MAAM,CAAC,CASzE;AAED,yFAAyF;AACzF,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BjH"}
@@ -13,15 +13,31 @@
13
13
  * 127.0.0.1:8787). The relay refuses to start with neither chat secret, or
14
14
  * with no relay key, since it could then verify nothing.
15
15
  *
16
- * Each click fetches `chant/lifecycle`, reads the signers file at base, and
17
- * records through `recordGateApproval`, one click at a time, so two clicks
18
- * never race on the ledger. A gate that asks a decision point gets its
19
- * question answered through `answerPoint` instead (#4611).
16
+ * Each click fetches the default branch and `chant/lifecycle`, reads the
17
+ * signers file at the default branch's tip, and records through
18
+ * `recordGateApproval`, one click at a time, so two clicks never race on the
19
+ * ledger. A gate that asks a decision point gets its question answered
20
+ * through `answerPoint` instead (#4611).
21
+ *
22
+ * With `--repo <url>` the relay checks its token and clones the repo itself
23
+ * (#4759, ../../notify-relay-repo.ts):
24
+ *
25
+ * ```
26
+ * chant notify relay --repo https://github.com/acme/infra.git --token-env RELAY_TOKEN --host 0.0.0.0
27
+ * ```
28
+ *
29
+ * `--token-env` names the variable holding the approve-only token (default
30
+ * `CHANT_RELAY_TOKEN`), `--forge` the forge for a host other than github.com
31
+ * and gitlab.com, and `--host` and `--port` override `CHANT_RELAY_HOST` and
32
+ * `CHANT_RELAY_PORT`. `CHANT_RELAY_REPO` and `CHANT_RELAY_FORGE` stand in for
33
+ * the flags.
20
34
  */
35
+ import { execFile } from "node:child_process";
36
+ import { promisify } from "node:util";
21
37
  import { activeProductWords } from "../../ci-product-words.js";
22
38
  import { CHANT_EXIT } from "../../exit-codes.js";
23
39
  import { DEFAULT_RELAY_MAX_AGE_SECONDS } from "../../notify.js";
24
- import { DEFAULT_RELAY_HOST, DEFAULT_RELAY_PORT, RELAY_ENV, startRelayServer } from "../../notify-relay.js";
40
+ import { DEFAULT_RELAY_HOST, DEFAULT_RELAY_PORT, RELAY_ENV, RELAY_REPO_ENV, startRelayServer } from "../../notify-relay.js";
25
41
  import { formatError, formatInfo } from "../format.js";
26
42
  /** The relay's settings, read from `env`, or the first problem with them. */
27
43
  export function relaySettingsFromEnv(env) {
@@ -56,6 +72,32 @@ function serial() {
56
72
  return run;
57
73
  };
58
74
  }
75
+ const run = promisify(execFile);
76
+ /**
77
+ * Fetch the default branch, the one `origin/HEAD` names, so the signers are
78
+ * read at its current tip (#4759). A checkout with no `origin/HEAD` reads its
79
+ * local branch as before. A fetch that fails throws: signers read from a
80
+ * stale tip could still count one removed since.
81
+ */
82
+ export async function fetchDefaultBranch(cwd) {
83
+ let head;
84
+ try {
85
+ head = (await run("git", ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], { cwd })).stdout.trim();
86
+ }
87
+ catch {
88
+ return;
89
+ }
90
+ const branch = head.replace(/^refs\/remotes\/origin\//, "");
91
+ if (!branch || branch === head)
92
+ return;
93
+ try {
94
+ await run("git", ["fetch", "-q", "origin", `+refs/heads/${branch}:refs/remotes/origin/${branch}`], { cwd });
95
+ }
96
+ catch (e) {
97
+ const err = e;
98
+ throw new Error(`cannot fetch ${branch} to read the signers at its tip: ${(err.stderr ?? "").trim() || err.message}`);
99
+ }
100
+ }
59
101
  /** The relay's reads and writes against the checkout at `cwd`. */
60
102
  export function checkoutRelayDeps(cwd, principal) {
61
103
  const words = activeProductWords();
@@ -63,11 +105,12 @@ export function checkoutRelayDeps(cwd, principal) {
63
105
  return {
64
106
  principal,
65
107
  words,
66
- async signers() {
108
+ signers: () => one(async () => {
109
+ await fetchDefaultBranch(cwd);
67
110
  const { scopeSource } = await import("../../workspace/write-scope.js");
68
111
  const policy = scopeSource(cwd).policy;
69
112
  return { signers: policy.signers, path: policy.signersPath };
70
- },
113
+ }),
71
114
  pending: (digest) => one(async () => {
72
115
  const { fetchLifecycle } = await import("../../lifecycle/git.js");
73
116
  const { pendingGatesByPlan } = await import("../../lifecycle/gate-pending-by-plan.js");
@@ -134,15 +177,48 @@ export function checkoutRelayDeps(cwd, principal) {
134
177
  };
135
178
  }
136
179
  /** `chant notify relay`. Runs until the process is stopped. */
137
- export async function runNotifyRelay(_ctx) {
138
- const read = relaySettingsFromEnv(process.env);
139
- if ("error" in read) {
140
- console.error(formatError({ message: `chant notify relay did not start: ${read.error}` }));
180
+ export async function runNotifyRelay(ctx) {
181
+ const a = ctx.args;
182
+ return serveNotifyRelay({
183
+ ...(a.repoUrl ? { repo: a.repoUrl } : {}),
184
+ ...(a.tokenEnv ? { tokenEnv: a.tokenEnv } : {}),
185
+ ...(a.forge ? { forge: a.forge } : {}),
186
+ ...(a.host ? { host: a.host } : {}),
187
+ ...(a.port?.[0] ? { port: a.port[0] } : {}),
188
+ });
189
+ }
190
+ /** Read the settings, clone when asked, and serve. Runs until the process is stopped. */
191
+ export async function serveNotifyRelay(o, env = process.env) {
192
+ const fail = (why) => {
193
+ console.error(formatError({ message: `chant notify relay did not start: ${why}` }));
141
194
  return CHANT_EXIT.failed;
142
- }
195
+ };
196
+ const read = relaySettingsFromEnv({ ...env, ...(o.host ? { [RELAY_ENV.host]: o.host } : {}), ...(o.port ? { [RELAY_ENV.port]: o.port } : {}) });
197
+ if ("error" in read)
198
+ return fail(read.error);
143
199
  const words = activeProductWords();
144
- const principal = process.env[RELAY_ENV.principal]?.trim() || `${words.product}-relay`;
145
- const deps = checkoutRelayDeps(process.cwd(), principal);
200
+ const principal = env[RELAY_ENV.principal]?.trim() || `${words.product}-relay`;
201
+ if (/[\r\n]/.test(principal))
202
+ return fail(`${RELAY_ENV.principal} is one principal on one line`);
203
+ let cwd = process.cwd();
204
+ const repoUrl = o.repo ?? (env[RELAY_REPO_ENV.repo] || undefined);
205
+ if (repoUrl) {
206
+ const tokenEnv = o.tokenEnv ?? RELAY_REPO_ENV.token;
207
+ const { prepareRelayCheckout } = await import("../../notify-relay-repo.js");
208
+ const made = await prepareRelayCheckout({ url: repoUrl, token: env[tokenEnv]?.trim() ?? "", forge: o.forge ?? (env[RELAY_REPO_ENV.forge] || undefined), env });
209
+ if ("error" in made)
210
+ return fail(made.error.startsWith("the token is empty") ? `${tokenEnv} is empty: the relay pushes approvals with an approve-only token` : made.error);
211
+ // The token as a git header for this process's git calls only: the relay fetches and pushes chant/lifecycle with it.
212
+ Object.assign(process.env, made.gitEnv);
213
+ cwd = made.dir;
214
+ // chant approve writes and pushes the ledger of the process's directory.
215
+ process.chdir(cwd);
216
+ console.error(formatInfo(`cloned ${made.repo.path} (${made.repo.forge}, default branch ${made.branch}) into ${cwd}, pushing as ${made.user}`));
217
+ }
218
+ else if (o.tokenEnv || o.forge) {
219
+ return fail("--token-env and --forge go with --repo <url>");
220
+ }
221
+ const deps = checkoutRelayDeps(cwd, principal);
146
222
  const { url } = await startRelayServer(read.settings, deps, { host: read.host, port: read.port, log: (line) => console.error(formatInfo(line)) });
147
223
  console.error(formatInfo(`${words.product} notify relay listens at ${url} (POST /slack, POST /teams, GET /healthz), recording approvals relayed by ${principal}`));
148
224
  await new Promise(() => { });
@@ -1 +1 @@
1
- {"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/pr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAOH,OAAO,EAA+C,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAI7F,OAAO,EACL,UAAU,EAUV,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAA0C,KAAK,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAIxH,OAAO,EAYL,KAAK,aAAa,EAGlB,KAAK,cAAc,EAKpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAA+D,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAY3G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,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,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,MAAM,CAGpI;AA+oBD;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAMhF;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAMjF;AA6LD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsC9E"}
@@ -102,7 +102,7 @@ import { PLAN_FLAG_ARGS, PlanFlagRefusedError, TargetsRefusedError } from "../..
102
102
  import { prPlanTargets } from "../../components/pr-targets.js";
103
103
  import { PREVIEW_COMMENT_ENV } from "../../components/pr-pipeline.js";
104
104
  import { prLoopHooksAt, runPrHooks } from "../../components/pr-hooks.js";
105
- import { decidePrPolicyOverride, policyReviewOf, prLoopPolicyAt, prPolicyReport, runPrPolicy, spendPrPolicyOverride } from "../../components/pr-policy.js";
105
+ import { decidePrPolicyOverride, policyReviewOf, prLoopPolicyAt, preparePrPolicyEngine, prPolicyReport, runPrPolicy, spendPrPolicyOverride } from "../../components/pr-policy.js";
106
106
  import { lexiconNames } from "../../lexicon-module.js";
107
107
  /** Where the reports land unless `--output` says. */
108
108
  export const PR_REPORT_DIR = ".chant/pr";
@@ -729,6 +729,8 @@ function openUpload(events, stage, pr, p) {
729
729
  async function judgePolicy(p, at) {
730
730
  // The review is read only when a policy will run: a workspace with no policy makes no forge call for it.
731
731
  const review = p.policy.settings ? await policyReviewOf(p.forge, at.pr) : undefined;
732
+ // #4774: with ci.policy.install, the engine is fetched here, once, and only for a stage that runs the policy.
733
+ p.policy = await preparePrPolicyEngine(p.policy);
732
734
  const verdict = runPrPolicy(p.policy, { version: 1, stage: at.stage, op: at.op, gate: p.gate, env: p.env, pr: at.pr, base: p.base, head: p.head, changeSet: at.set.doc, ...(review ? { review } : {}) });
733
735
  if (!verdict)
734
736
  return { held: false };
@@ -52,6 +52,10 @@ export declare function nextCommands(req: {
52
52
  }): string[];
53
53
  /** The command line that ran, without `--json`, with `--yes` added: what a dry run says to run next. */
54
54
  export declare function sameWithYes(argv: readonly string[]): string;
55
+ /** Copy each `release.images` archive from the directory the cut built it in to the same path under `to`. */
56
+ export declare function copyImageArchives(images: ReadonlyArray<{
57
+ archive: string;
58
+ }>, from: string, to: string): void;
55
59
  /**
56
60
  * `release images <label|digest> [--no-build] [-o <file>] [--json]` (#4657): build the
57
61
  * images the release recorded again, from the release's commit checked out
@@ -118,7 +122,11 @@ export declare function runReleaseList(ctx: CommandContext): Promise<number>;
118
122
  * a release: its own deploy reads these files instead of building again.
119
123
  */
120
124
  export declare function runReleaseExport(ctx: CommandContext): Promise<number>;
121
- /** Internal: compile one environment, or build artifacts, in this process, and print the JSON the cut reads. */
125
+ /**
126
+ * Internal: compile one environment, or build artifacts, in this process, and
127
+ * write the JSON the cut reads to the file `CHANT_RELEASE_COMPILE_RESULT`
128
+ * names (#4764), or print it when that is unset.
129
+ */
122
130
  export declare function runReleaseCompile(ctx: CommandContext): Promise<number>;
123
131
  export declare function runReleaseUnknown(ctx: CommandContext): Promise<number>;
124
132
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/release.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyBlD,0HAA0H;AAC1H,wBAAgB,YAAY,CAAC,GAAG,EAAE;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uF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,OAAO,CAAC,MAAM,CAAC,CAmCzE;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAyC3E;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B5E;AAED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAG5E;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsD5E"}
@@ -41,9 +41,9 @@
41
41
  * names a `release` gate requires a signed cut by an actor in its class (#4031).
42
42
  */
43
43
  import { execFileSync } from "node:child_process";
44
- import { existsSync } from "node:fs";
44
+ import { cpSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
45
45
  import { tmpdir } from "node:os";
46
- import { join, relative, resolve } from "node:path";
46
+ import { dirname, join, relative, resolve } from "node:path";
47
47
  import { formatBold, formatError, formatSuccess, formatWarning } from "../format.js";
48
48
  import { parseParamFlags } from "../build-params-cli.js";
49
49
  const USAGE = "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> [--no-build] [-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]";
@@ -102,6 +102,17 @@ async function releaseImagesOf(cwd) {
102
102
  const { loadChantConfig } = await import("../../config.js");
103
103
  return (await loadChantConfig(cwd)).config.release?.images ?? [];
104
104
  }
105
+ /** Copy each `release.images` archive from the directory the cut built it in to the same path under `to`. */
106
+ export function copyImageArchives(images, from, to) {
107
+ for (const i of images) {
108
+ const src = resolve(from, i.archive);
109
+ if (!existsSync(src))
110
+ continue;
111
+ const dest = resolve(to, i.archive);
112
+ mkdirSync(dirname(dest), { recursive: true });
113
+ cpSync(src, dest, { recursive: true, force: true });
114
+ }
115
+ }
105
116
  /** A commit's time in seconds, the `SOURCE_DATE_EPOCH` a release's image builds run with (#4657). */
106
117
  function commitTime(cwd, commit) {
107
118
  return Number(execFileSync("git", ["show", "-s", "--format=%ct", commit], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim());
@@ -456,6 +467,11 @@ export async function runReleaseCut(ctx) {
456
467
  return 0;
457
468
  }
458
469
  const result = await cutRelease(request);
470
+ // #4657: under --at the images were built in the commit's own checkout, which is removed below; the archives the
471
+ // release records are put where release.images names them here, so the job's next step (the hand-off to the
472
+ // publish job) finds them.
473
+ if (checkout && declaredImages.length > 0)
474
+ copyImageArchives(declaredImages, cutCwd, cwd);
459
475
  const push = await pushLifecycleReport({ cwd }).catch(() => ({ pushed: false, pushWarning: undefined }));
460
476
  // The tag names the release's label, which a re-cut with no label reads from the earlier cut.
461
477
  let tagged = null;
@@ -889,7 +905,11 @@ export async function runReleaseExport(ctx) {
889
905
  }
890
906
  return 0;
891
907
  }
892
- /** Internal: compile one environment, or build artifacts, in this process, and print the JSON the cut reads. */
908
+ /**
909
+ * Internal: compile one environment, or build artifacts, in this process, and
910
+ * write the JSON the cut reads to the file `CHANT_RELEASE_COMPILE_RESULT`
911
+ * names (#4764), or print it when that is unset.
912
+ */
893
913
  export async function runReleaseCompile(ctx) {
894
914
  const { args } = ctx;
895
915
  const env = args.env;
@@ -897,17 +917,25 @@ export async function runReleaseCompile(ctx) {
897
917
  console.error(formatError({ message: "release compile needs --env <env>" }));
898
918
  return 1;
899
919
  }
900
- const { compileEnvironment, buildReleaseArtifacts } = await import("../../components/release-compile.js");
920
+ const { compileEnvironment, buildReleaseArtifacts, RELEASE_COMPILE_RESULT_ENV } = await import("../../components/release-compile.js");
921
+ // Read and cleared before the project loads, so neither a build command nor a project module inherits it.
922
+ const resultFile = process.env[RELEASE_COMPILE_RESULT_ENV];
923
+ delete process.env[RELEASE_COMPILE_RESULT_ENV];
901
924
  const params = parseParamFlags(args.param);
902
925
  const inputs = compileInputs(ctx, params);
903
926
  try {
927
+ let result;
904
928
  if (args.artifacts) {
905
929
  const names = (args.component ?? "").split(",").map((n) => n.trim()).filter(Boolean);
906
- console.log(JSON.stringify({ artifacts: await buildReleaseArtifacts(inputs, env, names) }));
930
+ result = { artifacts: await buildReleaseArtifacts(inputs, env, names) };
907
931
  }
908
932
  else {
909
- console.log(JSON.stringify(await compileEnvironment(inputs, env)));
933
+ result = await compileEnvironment(inputs, env);
910
934
  }
935
+ if (resultFile)
936
+ writeFileSync(resultFile, JSON.stringify(result));
937
+ else
938
+ console.log(JSON.stringify(result));
911
939
  return 0;
912
940
  }
913
941
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"run-generate.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/run-generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAAO,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,gHAAgH;AAChH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAI3D,CAAC;AAEF,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,UAAU,QAAQ;IAChB,GAAG,EAAE,eAAe,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AA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