@intentius/chant 0.124.85 → 0.124.86

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 (254) hide show
  1. package/dist/bundle-check.d.ts +102 -0
  2. package/dist/bundle-check.d.ts.map +1 -0
  3. package/dist/bundle-check.js +310 -0
  4. package/dist/chant-install.d.ts +100 -0
  5. package/dist/chant-install.d.ts.map +1 -0
  6. package/dist/chant-install.js +158 -0
  7. package/dist/ci-commit.d.ts +19 -6
  8. package/dist/ci-commit.d.ts.map +1 -1
  9. package/dist/ci-commit.js +23 -4
  10. package/dist/ci-evidence-jobs.d.ts +54 -0
  11. package/dist/ci-evidence-jobs.d.ts.map +1 -0
  12. package/dist/ci-evidence-jobs.js +55 -0
  13. package/dist/ci-image.d.ts +274 -0
  14. package/dist/ci-image.d.ts.map +1 -0
  15. package/dist/ci-image.js +635 -0
  16. package/dist/ci-login.d.ts +150 -0
  17. package/dist/ci-login.d.ts.map +1 -0
  18. package/dist/ci-login.js +240 -0
  19. package/dist/ci-product.d.ts +16 -0
  20. package/dist/ci-product.d.ts.map +1 -1
  21. package/dist/ci-product.js +17 -0
  22. package/dist/cli/commands/import-index.js +2 -2
  23. package/dist/cli/handlers/build.d.ts +8 -0
  24. package/dist/cli/handlers/build.d.ts.map +1 -1
  25. package/dist/cli/handlers/build.js +22 -4
  26. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  27. package/dist/cli/handlers/ci-check.js +57 -2
  28. package/dist/cli/handlers/ci-evidence.d.ts +3 -0
  29. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
  30. package/dist/cli/handlers/ci-evidence.js +171 -0
  31. package/dist/cli/handlers/components.js +3 -3
  32. package/dist/cli/handlers/dead-guards.d.ts +3 -0
  33. package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
  34. package/dist/cli/handlers/dead-guards.js +35 -0
  35. package/dist/cli/handlers/graph.js +4 -4
  36. package/dist/cli/handlers/lifecycle.d.ts +2 -1
  37. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  38. package/dist/cli/handlers/lifecycle.js +5 -4
  39. package/dist/cli/handlers/local-chant.d.ts +16 -0
  40. package/dist/cli/handlers/local-chant.d.ts.map +1 -0
  41. package/dist/cli/handlers/local-chant.js +109 -0
  42. package/dist/cli/handlers/operator.js +2 -2
  43. package/dist/cli/handlers/search.js +5 -5
  44. package/dist/cli/main.d.ts.map +1 -1
  45. package/dist/cli/main.js +38 -0
  46. package/dist/cli/parse-args.d.ts.map +1 -1
  47. package/dist/cli/parse-args.js +28 -0
  48. package/dist/cli/registry.d.ts +16 -0
  49. package/dist/cli/registry.d.ts.map +1 -1
  50. package/dist/components/check-hooks.d.ts +49 -0
  51. package/dist/components/check-hooks.d.ts.map +1 -1
  52. package/dist/components/check-hooks.js +64 -4
  53. package/dist/components/check-steps.d.ts +17 -0
  54. package/dist/components/check-steps.d.ts.map +1 -1
  55. package/dist/components/check-steps.js +37 -5
  56. package/dist/components/product-pipeline.d.ts +23 -0
  57. package/dist/components/product-pipeline.d.ts.map +1 -1
  58. package/dist/components/product-pipeline.js +6 -2
  59. package/dist/components/product-plan.d.ts +137 -0
  60. package/dist/components/product-plan.d.ts.map +1 -0
  61. package/dist/components/product-plan.js +143 -0
  62. package/dist/components/release-compile.d.ts.map +1 -1
  63. package/dist/components/release-compile.js +2 -2
  64. package/dist/config.d.ts +39 -1
  65. package/dist/config.d.ts.map +1 -1
  66. package/dist/config.js +35 -3
  67. package/dist/dead-guards.d.ts +82 -0
  68. package/dist/dead-guards.d.ts.map +1 -0
  69. package/dist/dead-guards.js +436 -0
  70. package/dist/discovery/files.d.ts +3 -1
  71. package/dist/discovery/files.d.ts.map +1 -1
  72. package/dist/discovery/files.js +5 -3
  73. package/dist/drift-issue.d.ts +152 -0
  74. package/dist/drift-issue.d.ts.map +1 -0
  75. package/dist/drift-issue.js +167 -0
  76. package/dist/floor-table.d.ts +30 -0
  77. package/dist/floor-table.d.ts.map +1 -0
  78. package/dist/floor-table.data.d.ts +3 -0
  79. package/dist/floor-table.data.d.ts.map +1 -0
  80. package/dist/floor-table.data.js +178 -0
  81. package/dist/floor-table.js +56 -0
  82. package/dist/forge-flags.d.ts +90 -0
  83. package/dist/forge-flags.d.ts.map +1 -0
  84. package/dist/forge-flags.js +184 -0
  85. package/dist/lexicon.d.ts +69 -0
  86. package/dist/lexicon.d.ts.map +1 -1
  87. package/dist/lifecycle/gated-op.d.ts +7 -1
  88. package/dist/lifecycle/gated-op.d.ts.map +1 -1
  89. package/dist/lifecycle/gated-op.js +7 -4
  90. package/dist/local-chant.d.ts +98 -0
  91. package/dist/local-chant.d.ts.map +1 -0
  92. package/dist/local-chant.js +307 -0
  93. package/dist/op/activities/predict-behaviour.js +2 -2
  94. package/dist/op/op-waves-evidence-spec.d.ts +13 -0
  95. package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
  96. package/dist/op/op-waves-evidence-spec.js +21 -0
  97. package/dist/op/op-waves-evidence.d.ts +38 -0
  98. package/dist/op/op-waves-evidence.d.ts.map +1 -0
  99. package/dist/op/op-waves-evidence.js +57 -0
  100. package/dist/op/op-waves-run.d.ts +4 -0
  101. package/dist/op/op-waves-run.d.ts.map +1 -1
  102. package/dist/op/op-waves-run.js +24 -1
  103. package/dist/op/op-waves.d.ts +17 -1
  104. package/dist/op/op-waves.d.ts.map +1 -1
  105. package/dist/op/op-waves.js +23 -0
  106. package/dist/op/schedule-overdue.d.ts +41 -9
  107. package/dist/op/schedule-overdue.d.ts.map +1 -1
  108. package/dist/op/schedule-overdue.js +154 -25
  109. package/dist/plan-summary.d.ts +25 -0
  110. package/dist/plan-summary.d.ts.map +1 -1
  111. package/dist/plan-summary.js +31 -0
  112. package/dist/pr-plan-note.d.ts +35 -0
  113. package/dist/pr-plan-note.d.ts.map +1 -1
  114. package/dist/pr-plan-note.js +10 -0
  115. package/dist/pr-post.d.ts +23 -0
  116. package/dist/pr-post.d.ts.map +1 -1
  117. package/dist/pr-post.js +125 -3
  118. package/dist/release-floors.d.ts +31 -1
  119. package/dist/release-floors.d.ts.map +1 -1
  120. package/dist/release-floors.js +31 -1
  121. package/dist/state-migration.d.ts +24 -0
  122. package/dist/state-migration.d.ts.map +1 -1
  123. package/dist/state-migration.js +100 -5
  124. package/dist/wave-runtime.mjs +305 -298
  125. package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
  126. package/dist/workspace/lexicon-outputs.js +21 -7
  127. package/dist/workspace/reason-codes.d.ts +3 -0
  128. package/dist/workspace/reason-codes.d.ts.map +1 -1
  129. package/dist/workspace/reason-codes.js +4 -0
  130. package/dist/workspace/ref-gate.schema.json +85 -0
  131. package/dist/workspace/search-contract.d.ts +1 -1
  132. package/dist/workspace/search-contract.d.ts.map +1 -1
  133. package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
  134. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
  135. package/dist/workspace/trust/check-evidence-report.js +102 -0
  136. package/dist/workspace/trust/check-evidence.d.ts +126 -0
  137. package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
  138. package/dist/workspace/trust/check-evidence.js +237 -0
  139. package/dist/workspace/trust/local-evidence.d.ts +120 -0
  140. package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
  141. package/dist/workspace/trust/local-evidence.js +259 -0
  142. package/dist/workspace/trust/policy.d.ts +84 -0
  143. package/dist/workspace/trust/policy.d.ts.map +1 -1
  144. package/dist/workspace/trust/policy.js +94 -1
  145. package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
  146. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
  147. package/dist/workspace/trust/ref-gate-cli.js +234 -0
  148. package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
  149. package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
  150. package/dist/workspace/trust/ref-gate-fixture.js +97 -0
  151. package/dist/workspace/trust/ref-gate.d.ts +187 -0
  152. package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
  153. package/dist/workspace/trust/ref-gate.js +430 -0
  154. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  155. package/dist/workspace/trust/trust-files.js +18 -1
  156. package/package.json +1 -1
  157. package/src/bundle-check.test.ts +140 -0
  158. package/src/bundle-check.ts +352 -0
  159. package/src/chant-install.test.ts +112 -0
  160. package/src/chant-install.ts +179 -0
  161. package/src/ci-commit.test.ts +45 -0
  162. package/src/ci-commit.ts +38 -4
  163. package/src/ci-evidence-jobs.ts +67 -0
  164. package/src/ci-image.test.ts +506 -0
  165. package/src/ci-image.ts +822 -0
  166. package/src/ci-login.test.ts +235 -0
  167. package/src/ci-login.ts +307 -0
  168. package/src/ci-product.ts +18 -0
  169. package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
  170. package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
  171. package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
  172. package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
  173. package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
  174. package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
  175. package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
  176. package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
  177. package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
  178. package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
  179. package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
  180. package/src/cli/commands/import-index.ts +2 -2
  181. package/src/cli/handlers/build-source-dir.test.ts +64 -0
  182. package/src/cli/handlers/build.ts +21 -4
  183. package/src/cli/handlers/ci-check.ts +56 -3
  184. package/src/cli/handlers/ci-evidence.ts +162 -0
  185. package/src/cli/handlers/components.ts +3 -3
  186. package/src/cli/handlers/dead-guards.ts +37 -0
  187. package/src/cli/handlers/graph.ts +4 -4
  188. package/src/cli/handlers/lifecycle.ts +5 -4
  189. package/src/cli/handlers/local-chant.ts +106 -0
  190. package/src/cli/handlers/operator.ts +2 -2
  191. package/src/cli/handlers/search.ts +5 -5
  192. package/src/cli/main.test.ts +7 -0
  193. package/src/cli/main.ts +38 -0
  194. package/src/cli/parse-args.ts +21 -0
  195. package/src/cli/registry.ts +16 -0
  196. package/src/components/check-evidence-stage.test.ts +80 -0
  197. package/src/components/check-hooks.ts +84 -4
  198. package/src/components/check-local-evidence-stage.test.ts +141 -0
  199. package/src/components/check-steps.ts +56 -6
  200. package/src/components/product-pipeline.ts +28 -3
  201. package/src/components/product-plan.test.ts +87 -0
  202. package/src/components/product-plan.ts +226 -0
  203. package/src/components/release-compile.ts +2 -2
  204. package/src/config.ts +44 -3
  205. package/src/dead-guards.test.ts +206 -0
  206. package/src/dead-guards.ts +446 -0
  207. package/src/discovery/files.ts +5 -3
  208. package/src/drift-issue-bundle.test.ts +31 -0
  209. package/src/drift-issue.test.ts +206 -0
  210. package/src/drift-issue.ts +274 -0
  211. package/src/fit-note.test.ts +44 -0
  212. package/src/floor-table.data.ts +180 -0
  213. package/src/floor-table.ts +77 -0
  214. package/src/forge-flags.test.ts +110 -0
  215. package/src/forge-flags.ts +208 -0
  216. package/src/gate-decision-bundle.test.ts +1 -0
  217. package/src/lexicon.ts +68 -0
  218. package/src/lifecycle/gated-op.ts +10 -5
  219. package/src/local-chant.e2e.test.ts +94 -0
  220. package/src/local-chant.test.ts +162 -0
  221. package/src/local-chant.ts +341 -0
  222. package/src/op/activities/predict-behaviour.ts +2 -2
  223. package/src/op/op-waves-evidence-spec.ts +24 -0
  224. package/src/op/op-waves-evidence.test.ts +130 -0
  225. package/src/op/op-waves-evidence.ts +57 -0
  226. package/src/op/op-waves-run.ts +25 -1
  227. package/src/op/op-waves.ts +31 -1
  228. package/src/op/schedule-overdue.test.ts +85 -0
  229. package/src/op/schedule-overdue.ts +162 -26
  230. package/src/plan-summary.ts +40 -0
  231. package/src/pr-plan-note.ts +34 -0
  232. package/src/pr-post-plan-note.test.ts +146 -0
  233. package/src/pr-post.ts +127 -3
  234. package/src/release-floors.ts +44 -1
  235. package/src/stage-hooks-bundle.test.ts +1 -0
  236. package/src/state-migration.test.ts +52 -1
  237. package/src/state-migration.ts +107 -5
  238. package/src/workspace/lexicon-outputs.ts +23 -6
  239. package/src/workspace/reason-codes.test.ts +3 -0
  240. package/src/workspace/reason-codes.ts +4 -0
  241. package/src/workspace/ref-gate.schema.json +85 -0
  242. package/src/workspace/trust/check-evidence-report.ts +106 -0
  243. package/src/workspace/trust/check-evidence.test.ts +133 -0
  244. package/src/workspace/trust/check-evidence.ts +257 -0
  245. package/src/workspace/trust/local-evidence.test.ts +127 -0
  246. package/src/workspace/trust/local-evidence.ts +266 -0
  247. package/src/workspace/trust/policy.ts +134 -1
  248. package/src/workspace/trust/ref-gate-cli.ts +244 -0
  249. package/src/workspace/trust/ref-gate-fixture.ts +125 -0
  250. package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
  251. package/src/workspace/trust/ref-gate.test.ts +247 -0
  252. package/src/workspace/trust/ref-gate.ts +538 -0
  253. package/src/workspace/trust/trust-files.test.ts +16 -0
  254. package/src/workspace/trust/trust-files.ts +41 -1
@@ -24,6 +24,7 @@ import {
24
24
  COMMIT_PR_ENV,
25
25
  CI_COMMIT_ARG_FLOOR,
26
26
  CI_COMMIT_HARNESS_BREAK_FLOOR,
27
+ CI_COMMIT_REFUSAL_REPLY_FLOOR,
27
28
  COMMIT_HARNESS_BREAK_ENV,
28
29
  COMMIT_HARNESS_FORGE,
29
30
  commitHarnessBreaks,
@@ -36,6 +37,7 @@ import {
36
37
  } from "./ci-commit";
37
38
  import { assertProductWords, parseProductComment } from "./ci-product-words";
38
39
  import { PLYWOOD } from "./__fixtures__/product-words";
40
+ import { NEXT_RELEASE } from "./release-floors";
39
41
  import type { OpRunRecord, OpRunRecordInput } from "./op/runtime";
40
42
  import type { PullRequestHead } from "./pr-forge";
41
43
 
@@ -577,6 +579,49 @@ describe("the comment's argument (#4820)", () => {
577
579
  });
578
580
  });
579
581
 
582
+ describe("a comment refused as it is read gets a reply (#4838)", () => {
583
+ const named = () => settings({ commentArg: { pattern: "^[a-z0-9]+(?:[-_][a-z0-9]+)*$", position: 1 } });
584
+
585
+ test("a bad argument and a stray word are answered on the pull request, naming the comment and why, on GitHub and Forgejo", async () => {
586
+ // Forgejo's event has GitHub's shape, so the one path answers both.
587
+ for (const [s, body, why] of [
588
+ [named(), "/plywood fmt Bad", "`/plywood fmt` takes nothing, or one name after it matching `^[a-z0-9]+(?:[-_][a-z0-9]+)*$`"],
589
+ [settings(), "/plywood fmt now", "`/plywood fmt` takes nothing after it"],
590
+ ] as const) {
591
+ const w = world();
592
+ const { out } = await cycle(w, s, { event: comment(body) });
593
+ expect(out).toMatchObject({ result: "refused", reason: why, requestedBy: "ana" });
594
+ expect(w.replies).toEqual([`plywood: \`${body}\` was refused: ${why}. plywood-fmt did not run, and nothing was pushed.`]);
595
+ expect(w.records[0]!.outcomes.commit).toMatchObject({ result: "refused", pr: 7, requestedBy: "ana" });
596
+ expect(sh(["rev-parse", "refs/heads/feature"], w.r.origin).trim()).toBe(w.r.head);
597
+ }
598
+ });
599
+
600
+ test("GitLab answers a bad argument from its pipeline variables", async () => {
601
+ const w = world();
602
+ const env = { GITLAB_CI: "true", CHANT_COMMIT_PR: "7", CHANT_COMMIT: "fmt", [GITLAB_COMMIT_ARG_VAR]: "Bad", GITLAB_USER_LOGIN: "ana" };
603
+ const { out } = await cycle(w, named(), { event: {}, env });
604
+ expect(out.result).toBe("refused");
605
+ expect(w.replies).toEqual([expect.stringMatching(/^plywood: `\/plywood fmt Bad` was refused: `\/plywood fmt` takes nothing, or one name after it/)]);
606
+ });
607
+
608
+ test("a comment for another word gets no reply from this job, and a long or many-line comment is quoted by its first line, cut short", async () => {
609
+ const other = world();
610
+ await cycle(other, settings(), { event: comment("/plywood up") });
611
+ expect(other.replies).toEqual([]);
612
+ const many = world();
613
+ await cycle(many, settings(), { event: comment("/plywood fmt\nand more") });
614
+ expect(many.replies).toEqual(["plywood: `/plywood fmt` was refused: a command is one line, and nothing else in the comment. plywood-fmt did not run, and nothing was pushed."]);
615
+ const long = world();
616
+ await cycle(long, settings(), { event: comment(`/plywood fmt ${"x".repeat(200)}`) });
617
+ expect(long.replies[0]).toMatch(new RegExp(`^plywood: \`/plywood fmt x{84}\\.\\.\\.\` was refused`));
618
+ });
619
+
620
+ test("the floor is the next release until it ships", () => {
621
+ expect(CI_COMMIT_REFUSAL_REPLY_FLOOR).toBe(NEXT_RELEASE);
622
+ });
623
+ });
624
+
580
625
  describe("the harness's BREAK switch for land (#4836)", () => {
581
626
  const harness = (checks: string) => ({ [COMMIT_HARNESS_BREAK_ENV]: checks, BREAK: "1", GITHUB_SERVER_URL: COMMIT_HARNESS_FORGE });
582
627
 
package/src/ci-commit.ts CHANGED
@@ -29,6 +29,7 @@ import { spawn } from "node:child_process";
29
29
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
30
30
  import { join } from "node:path";
31
31
  import { CHANT_EXIT } from "./exit-codes";
32
+ import { NEXT_RELEASE } from "./release-floors";
32
33
  import { FORGE_TOKEN_VARS } from "./ci-handover";
33
34
  import { agentForbiddenPaths, AgentError, branchOk, errText, LOGIN, readSmall, SHA, type AgentGit } from "./ci-agent";
34
35
  import { COMMIT_COMMENT_ARG, parseProductComment, type CiProductWords } from "./ci-product-words";
@@ -53,6 +54,8 @@ export const CI_COMMIT_REPLY_FLOOR = "0.124.77";
53
54
  export const CI_COMMIT_ARG_FLOOR = "0.124.78";
54
55
  /** The first chant whose `commit land` reads {@link COMMIT_HARNESS_BREAK_ENV} in a BREAK arm of chant's e2e harness (#4836). */
55
56
  export const CI_COMMIT_HARNESS_BREAK_FLOOR = "0.124.78";
57
+ /** The first chant whose `commit land` replies to a comment refused as it is read, such as a bad argument or a stray word (#4838). */
58
+ export const CI_COMMIT_REFUSAL_REPLY_FLOOR = NEXT_RELEASE;
56
59
 
57
60
  /** What starts a commit run: a person's comment, or a check job's finding. */
58
61
  export type CommitTrigger = "comment" | "check";
@@ -442,6 +445,27 @@ export interface CommitRequest {
442
445
  arg?: string;
443
446
  }
444
447
 
448
+ /**
449
+ * A request refused (#4838). `replyOn` is set when the comment named this
450
+ * job's command and was refused as it was read (a bad argument, a stray
451
+ * word): the pull request, who asked, and the comment's first line, so land
452
+ * can say why on the pull request. A comment for another word has none,
453
+ * since that word's own job answers it.
454
+ */
455
+ export interface CommitRequestRefusal {
456
+ refused: string;
457
+ replyOn?: { pr: number; user: string; asked: string };
458
+ }
459
+
460
+ /** The most of a comment a refusal reply quotes (#4838). */
461
+ const ASKED_MAX = 100;
462
+
463
+ /** The comment's first line as a reply quotes it, cut at {@link ASKED_MAX}. */
464
+ function askedLine(body: string): string {
465
+ const line = body.trim().split(/\r?\n/)[0]!.trim();
466
+ return line.length > ASKED_MAX ? `${line.slice(0, ASKED_MAX - 3)}...` : line;
467
+ }
468
+
445
469
  /**
446
470
  * The request from the run. `comment`: the event's comment on GitHub and
447
471
  * Forgejo, read against the product's grammar, which must name this job's
@@ -450,7 +474,7 @@ export interface CommitRequest {
450
474
  * pull request the check ran for, from the `pull_request` event or the
451
475
  * merge request pipeline.
452
476
  */
453
- export function commitRequestFromRun(words: CiProductWords, s: Pick<CommitSettings, "on" | "comment"> & Partial<Pick<CommitSettings, "commentArg">>, env: Record<string, string | undefined>, event: unknown): CommitRequest | { refused: string } {
477
+ export function commitRequestFromRun(words: CiProductWords, s: Pick<CommitSettings, "on" | "comment"> & Partial<Pick<CommitSettings, "commentArg">>, env: Record<string, string | undefined>, event: unknown): CommitRequest | CommitRequestRefusal {
454
478
  const gitlab = env.GITLAB_CI === "true";
455
479
  let pr: unknown;
456
480
  if (s.on === "check") {
@@ -475,7 +499,12 @@ export function commitRequestFromRun(words: CiProductWords, s: Pick<CommitSettin
475
499
  if (typeof pr !== "number" || !Number.isInteger(pr) || pr < 1) return { refused: "the run names no pull request" };
476
500
  if (typeof user !== "string" || !LOGIN.test(user)) return { refused: "the run names nobody who asked" };
477
501
  const parsed = parseProductComment(words, body, env, commentArgPatterns(s));
478
- if (parsed?.kind === "refused") return { refused: parsed.reason };
502
+ if (parsed?.kind === "refused") {
503
+ // #4838: answered only when the comment's command is this job's, so two jobs never both reply.
504
+ const said = typeof body === "string" ? body.trim().split(/[ \t\r\n]+/) : [];
505
+ const ours = said[0] === `/${words.product}` && said[1] === word;
506
+ return { refused: parsed.reason, ...(ours ? { replyOn: { pr, user, asked: askedLine(body as string) } } : {}) };
507
+ }
479
508
  if (parsed?.kind !== "commit" || parsed.word !== word) return { refused: `the comment is not ${s.comment}` };
480
509
  return { pr, user, ...(parsed.arg !== undefined ? { arg: parsed.arg } : {}) };
481
510
  }
@@ -518,7 +547,7 @@ export async function resolveCommitRequest(
518
547
  env: Record<string, string | undefined>,
519
548
  event: unknown,
520
549
  forge?: Partial<Pick<PrForge, "findPullRequest">>,
521
- ): Promise<CommitRequest | { refused: string }> {
550
+ ): Promise<CommitRequest | CommitRequestRefusal> {
522
551
  const req = commitRequestFromRun(words, s, env, event);
523
552
  if (!("refused" in req) || s.on !== "check" || env.GITLAB_CI === "true" || !forge?.findPullRequest) return req;
524
553
  const branch = pushedBranch(env);
@@ -1014,7 +1043,12 @@ export async function landCommitChange(i: CommitLandInput): Promise<CommitLandOu
1014
1043
 
1015
1044
  // Who asked and for which pull request: from the event, never from the commit job's files.
1016
1045
  const req = await resolveCommitRequest(i.words, s, i.env, i.event, i.forge);
1017
- if ("refused" in req) return finish({ result: s.on === "check" ? "skipped" : "refused", reason: req.refused });
1046
+ if ("refused" in req) {
1047
+ // #4838: a comment refused as it was read is answered, naming it and why.
1048
+ if (!req.replyOn) return finish({ result: s.on === "check" ? "skipped" : "refused", reason: req.refused });
1049
+ ({ pr, user } = req.replyOn);
1050
+ return finish({ result: "refused", reason: req.refused }, `${code(req.replyOn.asked)} was refused: ${req.refused}. ${s.name} did not run, and nothing was pushed.`);
1051
+ }
1018
1052
  ({ pr, user } = req);
1019
1053
  // #4836: a BREAK arm of the harness may turn a check off; anywhere else the switch fails the land.
1020
1054
  const harness = commitHarnessBreaks(i.env);
@@ -0,0 +1,67 @@
1
+ /**
2
+ * What a generated pipeline adds to sign evidence for the named checks it
3
+ * runs (#4870), for the forge lexicons to render. No import beyond the
4
+ * words' bin swap, so the generators' bundles stay small.
5
+ *
6
+ * A project switches it on by naming the secret (GitHub, Forgejo) or CI/CD
7
+ * variable (GitLab) that holds its runner key, the PEM key whose public half
8
+ * `.chant/trust.json` lists under `runners`: the same secret the green
9
+ * workflow takes as `--runner-key-secret`. Without it nothing is added and
10
+ * every generated file is as before.
11
+ *
12
+ * - The plan note job (the product plan pipeline, GitHub and Forgejo) signs
13
+ * `plan` and `policy` from the plan job's report, after taking it back and
14
+ * before posting the note, which then says which checks were signed. The
15
+ * key is in that one step, in a job that runs none of the change's code.
16
+ * GitLab posts its notes from a target-branch pipeline that reads every
17
+ * open merge request, so there a job of its own after each plan job
18
+ * (`<plan job>-evidence`) signs from the plan job's artifact.
19
+ * - A wave job (the waves pipeline) gets the key on its `chant run wave`
20
+ * step, and signs `plan:<wave>` and `policy:<wave>` once the wave is
21
+ * planned (../op/op-waves-evidence.ts).
22
+ * - A product's check job runs `chant ci check` with the key in
23
+ * `CHANT_RUNNER_KEY`; the check runner signs each hook (./components/check-steps.ts).
24
+ *
25
+ * The key is a stored secret today. #4869 swaps it for the job's OIDC
26
+ * identity: the steps stay where they are and request a token instead.
27
+ */
28
+
29
+ import type { ForgeKind } from "./pr-forge";
30
+
31
+ /** The variable the signing steps read the key from. */
32
+ export const EVIDENCE_KEY_ENV = "CHANT_RUNNER_KEY";
33
+
34
+ export { CHECK_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR } from "./release-floors";
35
+
36
+ /** A pipeline's runner identity (#4870). */
37
+ export interface PipelineEvidence {
38
+ /** The secret (GitHub, Forgejo) or CI/CD variable (GitLab) holding the runner key as PEM. */
39
+ runnerKeySecret: string;
40
+ }
41
+
42
+ const SECRET_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
43
+
44
+ /** Refuse a secret name the forge could not hold. */
45
+ export function assertPipelineEvidence(evidence: PipelineEvidence | undefined): void {
46
+ if (evidence === undefined) return;
47
+ if (!SECRET_NAME.test(evidence.runnerKeySecret ?? "")) throw new Error(`evidence.runnerKeySecret ${JSON.stringify(evidence.runnerKeySecret)} is not a secret name: letters, digits and _, not starting with a digit`);
48
+ }
49
+
50
+ /** The signing step's key variable, from the forge's secret. */
51
+ export function evidenceKeyEnv(forge: ForgeKind, evidence: PipelineEvidence): Record<string, string> {
52
+ return { [EVIDENCE_KEY_ENV]: forge === "gitlab" ? `$${evidence.runnerKeySecret}` : `\${{ secrets.${evidence.runnerKeySecret} }}` };
53
+ }
54
+
55
+ /**
56
+ * The plan job's evidence step (#4870): fetch the planned commit (the note
57
+ * job checks out the target branch's), then sign `plan` and `policy` from
58
+ * the report directory. `result` is the plan job's result as the shell
59
+ * reads it.
60
+ */
61
+ export function planEvidenceLines(opts: { dir: string; at: string; base: string; result: string; bin?: string }): string[] {
62
+ const chant = opts.bin ?? "chant";
63
+ return [
64
+ `git fetch --quiet --no-tags --depth=1 origin ${opts.at} || true`,
65
+ `${chant} ci evidence sign --from-report ${opts.dir} --result ${opts.result} --at ${opts.at} --base ${opts.base}`,
66
+ ];
67
+ }