@intentius/chant 0.124.87 → 0.124.88

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 (342) hide show
  1. package/dist/action-pins.d.ts +1 -0
  2. package/dist/action-pins.d.ts.map +1 -1
  3. package/dist/action-pins.js +2 -0
  4. package/dist/actor.d.ts +12 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +18 -0
  7. package/dist/bundle-check.d.ts +20 -5
  8. package/dist/bundle-check.d.ts.map +1 -1
  9. package/dist/bundle-check.js +20 -5
  10. package/dist/chant-install.d.ts +98 -0
  11. package/dist/chant-install.d.ts.map +1 -1
  12. package/dist/chant-install.js +204 -2
  13. package/dist/ci-commit.d.ts +1 -1
  14. package/dist/ci-commit.d.ts.map +1 -1
  15. package/dist/ci-commit.js +1 -2
  16. package/dist/ci-control.d.ts +1 -1
  17. package/dist/ci-control.d.ts.map +1 -1
  18. package/dist/ci-control.js +1 -1
  19. package/dist/ci-evidence-claims.d.ts +59 -0
  20. package/dist/ci-evidence-claims.d.ts.map +1 -0
  21. package/dist/ci-evidence-claims.js +87 -0
  22. package/dist/ci-evidence-from-job.d.ts +103 -0
  23. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  24. package/dist/ci-evidence-from-job.js +162 -0
  25. package/dist/ci-evidence-jobs.d.ts +39 -4
  26. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  27. package/dist/ci-evidence-jobs.js +38 -4
  28. package/dist/ci-handover.d.ts +12 -0
  29. package/dist/ci-handover.d.ts.map +1 -1
  30. package/dist/ci-handover.js +15 -3
  31. package/dist/ci-identity.d.ts +32 -6
  32. package/dist/ci-identity.d.ts.map +1 -1
  33. package/dist/ci-identity.js +40 -8
  34. package/dist/ci-image.d.ts +47 -9
  35. package/dist/ci-image.d.ts.map +1 -1
  36. package/dist/ci-image.js +45 -18
  37. package/dist/ci-jobs.d.ts +1 -1
  38. package/dist/ci-jobs.d.ts.map +1 -1
  39. package/dist/ci-jobs.js +7 -2
  40. package/dist/ci-login.d.ts +75 -13
  41. package/dist/ci-login.d.ts.map +1 -1
  42. package/dist/ci-login.js +89 -37
  43. package/dist/ci-product-words.d.ts +20 -1
  44. package/dist/ci-product-words.d.ts.map +1 -1
  45. package/dist/ci-product-words.js +27 -1
  46. package/dist/ci-product.d.ts +21 -2
  47. package/dist/ci-product.d.ts.map +1 -1
  48. package/dist/ci-product.js +21 -2
  49. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  50. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  51. package/dist/cli/handlers/approve-confirm.js +46 -0
  52. package/dist/cli/handlers/build.d.ts +1 -1
  53. package/dist/cli/handlers/build.d.ts.map +1 -1
  54. package/dist/cli/handlers/build.js +22 -1
  55. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  56. package/dist/cli/handlers/ci-check.js +21 -1
  57. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  58. package/dist/cli/handlers/ci-evidence.js +227 -18
  59. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  60. package/dist/cli/handlers/ci-forge-check.js +34 -17
  61. package/dist/cli/handlers/generated-check.d.ts +3 -0
  62. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  63. package/dist/cli/handlers/generated-check.js +41 -0
  64. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  65. package/dist/cli/handlers/lifecycle.js +3 -0
  66. package/dist/cli/handlers/local-chant.d.ts +13 -0
  67. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  68. package/dist/cli/handlers/local-chant.js +42 -1
  69. package/dist/cli/handlers/pr.d.ts.map +1 -1
  70. package/dist/cli/handlers/pr.js +42 -5
  71. package/dist/cli/handlers/run-wave.js +8 -0
  72. package/dist/cli/main.d.ts.map +1 -1
  73. package/dist/cli/main.js +38 -4
  74. package/dist/cli/parse-args.d.ts.map +1 -1
  75. package/dist/cli/parse-args.js +66 -0
  76. package/dist/cli/registry.d.ts +24 -0
  77. package/dist/cli/registry.d.ts.map +1 -1
  78. package/dist/components/check-hooks.d.ts +10 -0
  79. package/dist/components/check-hooks.d.ts.map +1 -1
  80. package/dist/components/check-hooks.js +18 -0
  81. package/dist/components/pr-checks.d.ts +105 -0
  82. package/dist/components/pr-checks.d.ts.map +1 -0
  83. package/dist/components/pr-checks.js +119 -0
  84. package/dist/components/pr-pipeline.d.ts +34 -0
  85. package/dist/components/pr-pipeline.d.ts.map +1 -1
  86. package/dist/components/pr-pipeline.js +14 -1
  87. package/dist/components/product-pipeline.d.ts +16 -1
  88. package/dist/components/product-pipeline.d.ts.map +1 -1
  89. package/dist/components/product-pipeline.js +17 -2
  90. package/dist/components/product-plan.d.ts +257 -4
  91. package/dist/components/product-plan.d.ts.map +1 -1
  92. package/dist/components/product-plan.js +241 -11
  93. package/dist/config.d.ts +10 -6
  94. package/dist/config.d.ts.map +1 -1
  95. package/dist/config.js +11 -6
  96. package/dist/control/consumers.d.ts +6 -0
  97. package/dist/control/consumers.d.ts.map +1 -1
  98. package/dist/control/consumers.js +6 -0
  99. package/dist/dead-guards.d.ts.map +1 -1
  100. package/dist/dead-guards.js +9 -6
  101. package/dist/discovery/files.d.ts +1 -1
  102. package/dist/discovery/files.js +1 -1
  103. package/dist/drift-issue.d.ts +20 -3
  104. package/dist/drift-issue.d.ts.map +1 -1
  105. package/dist/drift-issue.js +16 -0
  106. package/dist/drift-record.d.ts +45 -5
  107. package/dist/drift-record.d.ts.map +1 -1
  108. package/dist/drift-record.js +27 -6
  109. package/dist/floor-table.d.ts +6 -6
  110. package/dist/floor-table.d.ts.map +1 -1
  111. package/dist/floor-table.data.d.ts.map +1 -1
  112. package/dist/floor-table.data.js +58 -21
  113. package/dist/floor-table.js +10 -7
  114. package/dist/forge-check/contract.d.ts +8 -0
  115. package/dist/forge-check/contract.d.ts.map +1 -1
  116. package/dist/forge-check/contract.js +4 -1
  117. package/dist/forge-check/index.d.ts +2 -0
  118. package/dist/forge-check/index.d.ts.map +1 -1
  119. package/dist/forge-check/index.js +2 -0
  120. package/dist/forge-flags.d.ts +10 -0
  121. package/dist/forge-flags.d.ts.map +1 -1
  122. package/dist/forge-flags.js +31 -0
  123. package/dist/forge-remote.d.ts +47 -0
  124. package/dist/forge-remote.d.ts.map +1 -0
  125. package/dist/forge-remote.js +69 -0
  126. package/dist/generated-check.d.ts +74 -0
  127. package/dist/generated-check.d.ts.map +1 -0
  128. package/dist/generated-check.js +216 -0
  129. package/dist/lexicon.d.ts +16 -0
  130. package/dist/lexicon.d.ts.map +1 -1
  131. package/dist/lifecycle/publish-npm.d.ts +15 -0
  132. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  133. package/dist/lifecycle/publish-npm.js +49 -3
  134. package/dist/lifecycle/release-images.d.ts +22 -1
  135. package/dist/lifecycle/release-images.d.ts.map +1 -1
  136. package/dist/lifecycle/release-images.js +27 -3
  137. package/dist/lifecycle/release-ledger.d.ts +4 -3
  138. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  139. package/dist/lifecycle/release-ledger.js +3 -2
  140. package/dist/local-chant.d.ts +57 -3
  141. package/dist/local-chant.d.ts.map +1 -1
  142. package/dist/local-chant.js +122 -13
  143. package/dist/op/op-waves-evidence-jobs.d.ts +92 -0
  144. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  145. package/dist/op/op-waves-evidence-jobs.js +112 -0
  146. package/dist/op/op-waves-evidence.d.ts +12 -1
  147. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  148. package/dist/op/op-waves-evidence.js +23 -2
  149. package/dist/op/op-waves-run.d.ts +12 -1
  150. package/dist/op/op-waves-run.d.ts.map +1 -1
  151. package/dist/op/op-waves-run.js +54 -3
  152. package/dist/op/op-waves.d.ts +8 -0
  153. package/dist/op/op-waves.d.ts.map +1 -1
  154. package/dist/op/op-waves.js +10 -0
  155. package/dist/op/schedule-overdue.d.ts +39 -2
  156. package/dist/op/schedule-overdue.d.ts.map +1 -1
  157. package/dist/op/schedule-overdue.js +89 -7
  158. package/dist/pr-forge-reads.d.ts +21 -1
  159. package/dist/pr-forge-reads.d.ts.map +1 -1
  160. package/dist/pr-forge-reads.js +19 -1
  161. package/dist/pr-forge.d.ts +7 -1
  162. package/dist/pr-forge.d.ts.map +1 -1
  163. package/dist/pr-forge.js +7 -2
  164. package/dist/pr-plan-note.d.ts +24 -0
  165. package/dist/pr-plan-note.d.ts.map +1 -1
  166. package/dist/pr-plan-note.js +11 -1
  167. package/dist/pr-plan-record.d.ts +47 -0
  168. package/dist/pr-plan-record.d.ts.map +1 -0
  169. package/dist/pr-plan-record.js +89 -0
  170. package/dist/pr-post.d.ts +40 -0
  171. package/dist/pr-post.d.ts.map +1 -1
  172. package/dist/pr-post.js +79 -6
  173. package/dist/pr-requires.d.ts +8 -0
  174. package/dist/pr-requires.d.ts.map +1 -1
  175. package/dist/pr-requires.js +3 -1
  176. package/dist/ref-gate-init.d.ts +76 -0
  177. package/dist/ref-gate-init.d.ts.map +1 -0
  178. package/dist/ref-gate-init.js +144 -0
  179. package/dist/ref-gate-rules.d.ts +19 -0
  180. package/dist/ref-gate-rules.d.ts.map +1 -0
  181. package/dist/ref-gate-rules.js +17 -0
  182. package/dist/release-floors.d.ts +64 -16
  183. package/dist/release-floors.d.ts.map +1 -1
  184. package/dist/release-floors.js +65 -17
  185. package/dist/state-migration.d.ts +24 -1
  186. package/dist/state-migration.d.ts.map +1 -1
  187. package/dist/state-migration.js +39 -3
  188. package/dist/state-unlock.d.ts +32 -1
  189. package/dist/state-unlock.d.ts.map +1 -1
  190. package/dist/state-unlock.js +31 -0
  191. package/dist/wave-runtime.mjs +292 -285
  192. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  193. package/dist/workspace/ci-green-cli.js +13 -7
  194. package/dist/workspace/drift-cli.d.ts +1 -1
  195. package/dist/workspace/drift-cli.d.ts.map +1 -1
  196. package/dist/workspace/drift-cli.js +5 -12
  197. package/dist/workspace/forge-work.d.ts +3 -2
  198. package/dist/workspace/forge-work.d.ts.map +1 -1
  199. package/dist/workspace/forge-work.js +7 -17
  200. package/dist/workspace/lexicon-outputs.js +2 -2
  201. package/dist/workspace/release-workflow.d.ts +26 -3
  202. package/dist/workspace/release-workflow.d.ts.map +1 -1
  203. package/dist/workspace/release-workflow.js +48 -6
  204. package/dist/workspace/trust/check-evidence-report.d.ts +18 -0
  205. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  206. package/dist/workspace/trust/check-evidence-report.js +13 -0
  207. package/dist/workspace/trust/check-evidence.d.ts +13 -1
  208. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  209. package/dist/workspace/trust/check-evidence.js +8 -3
  210. package/dist/workspace/trust/evidence.d.ts +5 -0
  211. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  212. package/dist/workspace/trust/evidence.js +5 -0
  213. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  214. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  215. package/dist/workspace/trust/open-evidence.js +92 -0
  216. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  217. package/dist/workspace/trust/ref-gate-cli.js +65 -3
  218. package/dist/workspace/trust/ref-gate.d.ts +61 -2
  219. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  220. package/dist/workspace/trust/ref-gate.js +72 -7
  221. package/package.json +1 -1
  222. package/src/action-pins.ts +2 -0
  223. package/src/actor.test.ts +12 -0
  224. package/src/actor.ts +19 -0
  225. package/src/bundle-check.test.ts +22 -0
  226. package/src/bundle-check.ts +33 -5
  227. package/src/chant-install.test.ts +109 -1
  228. package/src/chant-install.ts +243 -2
  229. package/src/ci-commit.test.ts +51 -5
  230. package/src/ci-commit.ts +1 -2
  231. package/src/ci-control.ts +1 -0
  232. package/src/ci-evidence-claims.ts +102 -0
  233. package/src/ci-evidence-from-job.test.ts +147 -0
  234. package/src/ci-evidence-from-job.ts +195 -0
  235. package/src/ci-evidence-jobs.ts +41 -4
  236. package/src/ci-handover.ts +16 -3
  237. package/src/ci-identity.test.ts +3 -3
  238. package/src/ci-identity.ts +51 -11
  239. package/src/ci-image.test.ts +60 -10
  240. package/src/ci-image.ts +78 -19
  241. package/src/ci-jobs.ts +7 -2
  242. package/src/ci-login.test.ts +131 -3
  243. package/src/ci-login.token-drop.test.ts +204 -0
  244. package/src/ci-login.ts +137 -39
  245. package/src/ci-product-words.ts +30 -0
  246. package/src/ci-product.ts +26 -1
  247. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  248. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  249. package/src/cli/handlers/approve-confirm.ts +44 -0
  250. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  251. package/src/cli/handlers/build.ts +20 -2
  252. package/src/cli/handlers/ci-check.ts +19 -1
  253. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  254. package/src/cli/handlers/ci-evidence.ts +210 -16
  255. package/src/cli/handlers/ci-forge-check.ts +22 -9
  256. package/src/cli/handlers/generated-check.ts +39 -0
  257. package/src/cli/handlers/lifecycle.test.ts +20 -0
  258. package/src/cli/handlers/lifecycle.ts +4 -0
  259. package/src/cli/handlers/local-chant.ts +39 -1
  260. package/src/cli/handlers/pr.ts +43 -5
  261. package/src/cli/handlers/run-wave.ts +7 -0
  262. package/src/cli/main.ts +38 -4
  263. package/src/cli/parse-args.ts +46 -0
  264. package/src/cli/registry.ts +24 -0
  265. package/src/components/check-hooks.ts +22 -0
  266. package/src/components/check-report-summary.test.ts +78 -0
  267. package/src/components/pr-checks.ts +159 -0
  268. package/src/components/pr-pipeline.ts +41 -1
  269. package/src/components/product-pipeline.ts +25 -3
  270. package/src/components/product-plan.test.ts +102 -1
  271. package/src/components/product-plan.ts +416 -15
  272. package/src/config.ts +13 -8
  273. package/src/control/consumers.ts +7 -0
  274. package/src/dead-guards.test.ts +27 -5
  275. package/src/dead-guards.ts +9 -6
  276. package/src/discovery/files.ts +1 -1
  277. package/src/drift-issue.test.ts +29 -1
  278. package/src/drift-issue.ts +28 -3
  279. package/src/drift-record.test.ts +25 -0
  280. package/src/drift-record.ts +55 -6
  281. package/src/floor-table.data.ts +58 -21
  282. package/src/floor-table.ts +12 -9
  283. package/src/forge-check/contract.ts +11 -1
  284. package/src/forge-check/forge-check.test.ts +8 -0
  285. package/src/forge-check/index.ts +2 -0
  286. package/src/forge-flags.test.ts +25 -1
  287. package/src/forge-flags.ts +34 -0
  288. package/src/forge-remote.test.ts +37 -0
  289. package/src/forge-remote.ts +79 -0
  290. package/src/generated-check.e2e.test.ts +98 -0
  291. package/src/generated-check.test.ts +104 -0
  292. package/src/generated-check.ts +269 -0
  293. package/src/lexicon.ts +17 -0
  294. package/src/lifecycle/publish-npm.ts +56 -3
  295. package/src/lifecycle/release-catalog.test.ts +2 -2
  296. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  297. package/src/lifecycle/release-images.test.ts +44 -0
  298. package/src/lifecycle/release-images.ts +39 -3
  299. package/src/lifecycle/release-ledger.ts +4 -3
  300. package/src/local-chant.e2e.test.ts +81 -6
  301. package/src/local-chant.test.ts +22 -3
  302. package/src/local-chant.ts +130 -13
  303. package/src/op/op-waves-evidence-jobs.ts +134 -0
  304. package/src/op/op-waves-evidence.test.ts +36 -3
  305. package/src/op/op-waves-evidence.ts +23 -3
  306. package/src/op/op-waves-run.ts +57 -2
  307. package/src/op/op-waves.ts +11 -0
  308. package/src/op/schedule-overdue.test.ts +83 -1
  309. package/src/op/schedule-overdue.ts +107 -9
  310. package/src/pr-forge-reads-compare.test.ts +2 -1
  311. package/src/pr-forge-reads.ts +37 -1
  312. package/src/pr-forge.ts +14 -3
  313. package/src/pr-plan-note.ts +32 -3
  314. package/src/pr-plan-record.test.ts +75 -0
  315. package/src/pr-plan-record.ts +101 -0
  316. package/src/pr-post-plan-note.test.ts +60 -0
  317. package/src/pr-post.test.ts +30 -0
  318. package/src/pr-post.ts +110 -6
  319. package/src/pr-requires.test.ts +20 -0
  320. package/src/pr-requires.ts +10 -1
  321. package/src/ref-gate-init.ts +189 -0
  322. package/src/ref-gate-rules.ts +26 -0
  323. package/src/release-floors.ts +86 -17
  324. package/src/state-migration-record.test.ts +90 -0
  325. package/src/state-migration.test.ts +1 -1
  326. package/src/state-migration.ts +52 -3
  327. package/src/state-unlock.test.ts +33 -1
  328. package/src/state-unlock.ts +49 -1
  329. package/src/workspace/ci-green-cli.ts +12 -6
  330. package/src/workspace/drift-cli.ts +6 -18
  331. package/src/workspace/forge-work.ts +7 -14
  332. package/src/workspace/lexicon-outputs.ts +2 -2
  333. package/src/workspace/release-workflow.test.ts +70 -0
  334. package/src/workspace/release-workflow.ts +56 -8
  335. package/src/workspace/trust/check-evidence-report.ts +24 -0
  336. package/src/workspace/trust/check-evidence.ts +17 -5
  337. package/src/workspace/trust/evidence.ts +5 -0
  338. package/src/workspace/trust/open-evidence.ts +129 -0
  339. package/src/workspace/trust/ref-gate-cli.ts +59 -3
  340. package/src/workspace/trust/ref-gate-pieces.test.ts +175 -0
  341. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  342. package/src/workspace/trust/ref-gate.ts +87 -6
@@ -0,0 +1,67 @@
1
+ /**
2
+ * `chant ci evidence sign --open` (#4914): the GitLab signing job, in a
3
+ * pipeline of the target branch, signs the checks of every open merge
4
+ * request into the branch from its newest pipeline's job.
5
+ *
6
+ * A merge request pipeline is built from the merge request's own files, so
7
+ * a job there that holds the runner key (or asks for a signing token) runs
8
+ * whatever the change wrote. The plan notes pipeline (#4328) is the target
9
+ * branch's: its jobs come from the branch's files, and its protected
10
+ * variables reach it. So the signing moves there, as the note posting did:
11
+ * for each open merge request GitLab names the newest pipeline's `job`
12
+ * (`plan`, `<target>-plan`, `check`), the report is read from that job's
13
+ * artifacts as data, the head is fetched, and the checks are signed for
14
+ * the head as `sign --from-report` signs them. What was signed and why the
15
+ * rest were not is kept as `<out>/<iid>/evidence.json`, with the merge
16
+ * request and the head, which the note job reads (`pr-post --open
17
+ * --evidence-dir`, ../../pr-post.ts) for the note's "Checks:" line.
18
+ *
19
+ * A job that has not settled is left for the next pipeline. A merge request
20
+ * whose report does not read, whose head does not fetch, or that the forge
21
+ * refuses is a warning, and the others go on.
22
+ */
23
+ import type { PrForge } from "../../pr-forge.js";
24
+ import { type CheckEvidenceNote } from "./check-evidence-report.js";
25
+ /** The report files a job's artifact is read for, in order: a plan report, a product's plan note hand-off, then a check job's report. */
26
+ export declare const OPEN_PLAN_FILES: readonly ["pr-plan.json", "pr-plan-note.json"];
27
+ export declare const OPEN_CHECK_FILE = "check-hooks.json";
28
+ /** What {@link signOpenReports} signs for. */
29
+ export interface OpenEvidenceInput {
30
+ /**
31
+ * A GitLab client with {@link PrForge.mergeRequestJobs} and
32
+ * {@link PrForge.jobArtifact}, and with `noForks` {@link PrForge.openPullRequests},
33
+ * which says which merge requests come from a fork. The fork test is read
34
+ * here, not in `mergeRequestJobs`, to keep it out of the pull request loop's
35
+ * bundle (its ceiling, pr-loop-bundle.test.ts).
36
+ */
37
+ forge: Pick<PrForge, "kind" | "mergeRequestJobs" | "jobArtifact" | "openPullRequests">;
38
+ /** The branch the merge requests merge into: the pipeline's own. */
39
+ branch: string;
40
+ /** The job whose report is signed: `plan`, `<target>-plan` or `check`. */
41
+ job: string;
42
+ /** The report directory from the repository root, as the job kept it as its artifact. */
43
+ artifactDir: string;
44
+ /** Where each merge request's report and `evidence.json` go: `<out>/<iid>/`. */
45
+ out: string;
46
+ /** Sign for no merge request from a fork, as a product plan with `forks: "skip"` plans none. */
47
+ noForks?: boolean;
48
+ /** Fetch merge request `pr`'s head into this checkout; true once the commit is here. */
49
+ fetchHead: (pr: number, head: string) => boolean;
50
+ /** Sign the checks of the report in `dir` for `head`, given the job's result, as `sign --from-report` does. */
51
+ sign: (dir: string, head: string, result: "success" | "failure" | "cancelled") => Promise<CheckEvidenceNote>;
52
+ }
53
+ /** What {@link signOpenReports} did for one merge request. */
54
+ export interface OpenEvidence {
55
+ pr: number;
56
+ head: string;
57
+ /** What was signed and what was not, as kept in `evidence.json`. */
58
+ note?: CheckEvidenceNote;
59
+ /** Why nothing was signed: the job has not settled, left no report, or its head did not fetch. */
60
+ skipped?: string;
61
+ }
62
+ /** Sign every open merge request's settled `job` into `branch` (#4914). */
63
+ export declare function signOpenReports(input: OpenEvidenceInput): Promise<{
64
+ done: OpenEvidence[];
65
+ warnings: string[];
66
+ }>;
67
+ //# sourceMappingURL=open-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-evidence.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/open-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAuB,KAAK,iBAAiB,EAAyB,MAAM,yBAAyB,CAAC;AAE7G,yIAAyI;AACzI,eAAO,MAAM,eAAe,YAAI,cAAc,EAAE,mBAAmB,CAAU,CAAC;AAC9E,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,aAAa,GAAG,kBAAkB,CAAC,CAAC;IACvF,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,yFAAyF;IACzF,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ,gGAAgG;IAChG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wFAAwF;IACxF,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,+GAA+G;IAC/G,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC9G;AAED,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,kGAAkG;IAClG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,2EAA2E;AAC3E,wBAAsB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA2DrH"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * `chant ci evidence sign --open` (#4914): the GitLab signing job, in a
3
+ * pipeline of the target branch, signs the checks of every open merge
4
+ * request into the branch from its newest pipeline's job.
5
+ *
6
+ * A merge request pipeline is built from the merge request's own files, so
7
+ * a job there that holds the runner key (or asks for a signing token) runs
8
+ * whatever the change wrote. The plan notes pipeline (#4328) is the target
9
+ * branch's: its jobs come from the branch's files, and its protected
10
+ * variables reach it. So the signing moves there, as the note posting did:
11
+ * for each open merge request GitLab names the newest pipeline's `job`
12
+ * (`plan`, `<target>-plan`, `check`), the report is read from that job's
13
+ * artifacts as data, the head is fetched, and the checks are signed for
14
+ * the head as `sign --from-report` signs them. What was signed and why the
15
+ * rest were not is kept as `<out>/<iid>/evidence.json`, with the merge
16
+ * request and the head, which the note job reads (`pr-post --open
17
+ * --evidence-dir`, ../../pr-post.ts) for the note's "Checks:" line.
18
+ *
19
+ * A job that has not settled is left for the next pipeline. A merge request
20
+ * whose report does not read, whose head does not fetch, or that the forge
21
+ * refuses is a warning, and the others go on.
22
+ */
23
+ import { mkdirSync, writeFileSync } from "node:fs";
24
+ import { join } from "node:path";
25
+ import { CHECK_EVIDENCE_FILE } from "./check-evidence-report.js";
26
+ /** The report files a job's artifact is read for, in order: a plan report, a product's plan note hand-off, then a check job's report. */
27
+ export const OPEN_PLAN_FILES = ["pr-plan.json", "pr-plan-note.json"];
28
+ export const OPEN_CHECK_FILE = "check-hooks.json";
29
+ /** Sign every open merge request's settled `job` into `branch` (#4914). */
30
+ export async function signOpenReports(input) {
31
+ const { forge } = input;
32
+ if (!forge.mergeRequestJobs || !forge.jobArtifact) {
33
+ throw new Error(`ci evidence sign --open reads the jobs of open merge requests, which ${forge.kind} cannot say; it is for GitLab`);
34
+ }
35
+ const done = [];
36
+ const warnings = [];
37
+ const at = input.artifactDir.replace(/\/+$/, "");
38
+ let forks = new Set();
39
+ if (input.noForks) {
40
+ if (!forge.openPullRequests)
41
+ throw new Error(`ci evidence sign --open --no-forks reads which merge requests come from a fork, which ${forge.kind} cannot say`);
42
+ forks = new Set((await forge.openPullRequests(input.branch)).filter((p) => p.fork).map((p) => p.number));
43
+ }
44
+ for (const job of await forge.mergeRequestJobs(input.branch, input.job)) {
45
+ if (forks.has(job.pr)) {
46
+ done.push({ pr: job.pr, head: job.head, skipped: "the merge request is from a fork" });
47
+ continue;
48
+ }
49
+ const result = job.status === "success" ? "success" : job.status === "failed" ? "failure" : job.status === "canceled" ? "cancelled" : undefined;
50
+ if (!result) {
51
+ done.push({ pr: job.pr, head: job.head, skipped: `the ${input.job} job is ${job.status}` });
52
+ continue;
53
+ }
54
+ try {
55
+ const dir = join(input.out, String(job.pr));
56
+ mkdirSync(dir, { recursive: true });
57
+ // A plan report wins over a check report, as `sign --from-report` reads a directory.
58
+ let found = false;
59
+ for (const file of OPEN_PLAN_FILES) {
60
+ const text = await forge.jobArtifact(job.id, `${at}/${file}`);
61
+ if (text === undefined)
62
+ continue;
63
+ writeFileSync(join(dir, file), text);
64
+ found = true;
65
+ break;
66
+ }
67
+ if (!found) {
68
+ const text = await forge.jobArtifact(job.id, `${at}/${OPEN_CHECK_FILE}`);
69
+ if (text !== undefined) {
70
+ writeFileSync(join(dir, OPEN_CHECK_FILE), text);
71
+ found = true;
72
+ }
73
+ }
74
+ if (!found) {
75
+ done.push({ pr: job.pr, head: job.head, skipped: `the ${input.job} job left no report under ${at}` });
76
+ continue;
77
+ }
78
+ if (!input.fetchHead(job.pr, job.head)) {
79
+ done.push({ pr: job.pr, head: job.head, skipped: `the head ${job.head.slice(0, 12)} did not fetch` });
80
+ continue;
81
+ }
82
+ const note = await input.sign(dir, job.head, result);
83
+ const kept = { pr: job.pr, head: job.head, ...note };
84
+ writeFileSync(join(dir, CHECK_EVIDENCE_FILE), JSON.stringify(kept, null, 2) + "\n");
85
+ done.push({ pr: job.pr, head: job.head, note });
86
+ }
87
+ catch (err) {
88
+ warnings.push(`!${job.pr}: ${err instanceof Error ? err.message : String(err)}`);
89
+ }
90
+ }
91
+ return { done, warnings };
92
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ref-gate-cli.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/ref-gate-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAYL,KAAK,WAAW,EAGjB,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,yBAAyB,kFAAkF,CAAC;AACzH,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAyF7D,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuE9E;AAED,qIAAqI;AACrI,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvM;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,EAAE,OAAO,SAAU,GAAG,MAAM,CAEvF"}
1
+ {"version":3,"file":"ref-gate-cli.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/ref-gate-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAYL,KAAK,WAAW,EAGjB,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,yBAAyB,kFAAkF,CAAC;AACzH,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AA0F7D,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E9E;AAqDD,qIAAqI;AACrI,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvM;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,EAAE,OAAO,SAAU,GAAG,MAAM,CAEvF"}
@@ -28,6 +28,7 @@ export const REF_GATE_HOOK_MARK = "# chant ref gate (#4867)";
28
28
  const OVERRIDE_REQUEST_HOURS = 72;
29
29
  const USAGE = "chant workspace ref-gate check --ref <ref> [--at <rev>] [--base <rev>] [--dry-run] [--ledger <file>] [--json]\n" +
30
30
  " chant workspace ref-gate status --ref <ref> [--at <rev>] [--base <rev>] [--dry-run] [--ledger <file>] [--json]\n" +
31
+ " chant workspace ref-gate status --open --ref refs/heads/<branch> [--base <rev>] [--dry-run] [--ledger <file>] [--json]\n" +
31
32
  " chant workspace ref-gate pre-receive|pre-push [--ledger <file>] [--dry-run] [--json] (git hook input on stdin)\n" +
32
33
  " chant workspace ref-gate attach --envelope <file> [--at <rev>]\n" +
33
34
  " chant workspace ref-gate install --hook pre-receive|pre-push [--git-dir <dir>] [--chant <command>]";
@@ -59,7 +60,7 @@ function repoHere() {
59
60
  }
60
61
  return { repo: top, bare: false };
61
62
  }
62
- function print(json, decisions, ledger, stream) {
63
+ function print(json, decisions, ledger, stream, site) {
63
64
  const ok = decisions.every((d) => d.decision === "admit");
64
65
  if (json) {
65
66
  console.log(JSON.stringify({ ...head(), ok, ...(ledger ? { ledger } : {}), decisions }, null, 2));
@@ -68,7 +69,7 @@ function print(json, decisions, ledger, stream) {
68
69
  for (const d of decisions) {
69
70
  if (d.status === null && d.checks.length === 0 && !d.error)
70
71
  continue;
71
- const text = describeDecision(d).join("\n");
72
+ const text = describeDecision(d, site ? { site } : {}).join("\n");
72
73
  if (stream === "err" || d.decision === "refuse")
73
74
  console.error(text);
74
75
  else
@@ -142,7 +143,7 @@ export async function runWorkspaceRefGate(ctx) {
142
143
  try {
143
144
  if (sub === "pre-receive") {
144
145
  const r = runPreReceive(here.repo, stdin, { ...(args.ledger ? { ledger: args.ledger } : {}), now });
145
- print(args.json, r.decisions, r.ledger, "err");
146
+ print(args.json, r.decisions, r.ledger, "err", "pre-receive");
146
147
  return r.ok ? 0 : 1;
147
148
  }
148
149
  const r = runPrePush(here.repo, stdin, { ...(args.ledger ? { ledger: args.ledger } : {}), now, base: (repo) => resolveBase(repo).commit });
@@ -160,6 +161,11 @@ export async function runWorkspaceRefGate(ctx) {
160
161
  // check and status: one update, from a checkout or a CI job.
161
162
  if (!args.ref || !args.ref.startsWith("refs/"))
162
163
  return usage("--ref <ref> is required, as a full ref name such as refs/heads/main");
164
+ if (args.open) {
165
+ if (sub !== "status")
166
+ return usage("--open sets the status of every open pull request, so it goes with status");
167
+ return statusOpen(here.repo, args.ref, args.base, args.ledger, args.dryRun === true, args.json, now);
168
+ }
163
169
  const at = commitOf(here.repo, args.at ?? "HEAD");
164
170
  if (!at)
165
171
  return fail(args.json, "revision-unknown", `--at ${args.at ?? "HEAD"} names no commit`);
@@ -191,6 +197,62 @@ export async function runWorkspaceRefGate(ctx) {
191
197
  }
192
198
  return d.decision === "admit" ? 0 : 1;
193
199
  }
200
+ /**
201
+ * `status --open --ref refs/heads/<branch>` (#4935): the status of every open
202
+ * pull request into the branch, from a pipeline of the branch. GitLab sets a
203
+ * commit status only with the protected token a target-branch pipeline holds
204
+ * (#4328), so its generated `ref-gate` job runs here, beside the plan notes.
205
+ * Each head is fetched and decided as `status --at <head>` decides it, against
206
+ * the policy at `base` (default this checkout's `HEAD`, the branch's commit).
207
+ * A head that does not fetch, or a forge that refuses one status, is said
208
+ * and the others go on. Exits 0 once each is set, whatever it decided: each
209
+ * pull request's status says it.
210
+ */
211
+ async function statusOpen(repo, ref, baseRev, ledgerFlag, dryRun, json, now) {
212
+ if (!ref.startsWith("refs/heads/"))
213
+ return usage("--open names the branch the pull requests merge into: --ref refs/heads/<branch>");
214
+ const base = commitOf(repo, baseRev ?? "HEAD");
215
+ if (!base)
216
+ return fail(json, "revision-unknown", `--base ${baseRev ?? "HEAD"} names no commit`);
217
+ const { detectForge, forgeFromEnv } = await import("../../pr-forge.js");
218
+ const kind = detectForge();
219
+ if (!kind && !dryRun) {
220
+ console.error(formatError({ message: "no forge detected, so no status was set", hint: "run it in a GitHub, GitLab or Forgejo job, or pass --dry-run" }));
221
+ return 1;
222
+ }
223
+ const forge = kind ? forgeFromEnv(kind) : undefined;
224
+ if (!forge?.openPullRequests)
225
+ return fail(json, "ref-update-invalid", `--open lists the open pull requests, which ${kind ?? "no"} forge client here can`);
226
+ const branch = ref.slice("refs/heads/".length);
227
+ const ledger = ledgerFlag ?? refGateLedgerPath(repo);
228
+ const decisions = [];
229
+ for (const pr of await forge.openPullRequests(branch)) {
230
+ const fetched = spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", pr.headSha], { cwd: repo, encoding: "utf-8" });
231
+ if (!commitOf(repo, pr.headSha)) {
232
+ console.error(`chant ref gate: #${pr.number}'s head ${pr.headSha.slice(0, 8)} did not fetch${fetched.stderr ? ` (${fetched.stderr.trim().split("\n")[0]})` : ""}, so its status is left as it is`);
233
+ continue;
234
+ }
235
+ const spent = spentOverrides(readRefGateLedger(ledger));
236
+ const d = decideRefUpdate({ repo, update: { ref, old: base, new: pr.headSha }, base, spent, now });
237
+ decisions.push(d);
238
+ if (dryRun) {
239
+ if (d.status !== null)
240
+ console.error(`chant ref gate: would set ${d.status} to ${d.decision === "admit" ? "success" : "failure"} on #${pr.number} at ${pr.headSha.slice(0, 8)}`);
241
+ continue;
242
+ }
243
+ appendRefGateLedger(ledger, [{ ...d, version: 1, kind: "ref-update", site: "status", timestamp: now }]);
244
+ try {
245
+ await postRefGateStatus(forge, d);
246
+ }
247
+ catch (err) {
248
+ console.error(`chant ref gate: could not set the status on #${pr.number}: ${err instanceof Error ? err.message : String(err)}`);
249
+ }
250
+ }
251
+ print(json, decisions, dryRun ? undefined : ledger, "err");
252
+ if (decisions.length === 0)
253
+ console.error(`chant ref gate: no open pull request into ${branch} to set a status on`);
254
+ return 0;
255
+ }
194
256
  /** The commit status a forge requires for `d`'s ref: `success` when it is admitted, `failure` naming the missing checks when not. */
195
257
  export async function postRefGateStatus(forge, d) {
196
258
  if (d.status === null || d.new === null)
@@ -106,6 +106,50 @@ export declare function rulesFor(policy: Pick<TrustPolicy, "refs">, ref: string)
106
106
  status: string;
107
107
  overrides?: "ledger" | "sealed";
108
108
  };
109
+ /** The ref gate's rules for one ref, read at base, as a product reads them (#4913). */
110
+ export interface RefGateRules {
111
+ ref: string;
112
+ /** The commit the policy was read at, or null when there is none. */
113
+ base: string | null;
114
+ /** A rule of the policy at base matches the ref. */
115
+ matched: boolean;
116
+ /** The commit status the ref gate's status job sets for the ref, which the forge should require; null when no rule matches. */
117
+ status: string | null;
118
+ /** The checks an update of the ref needs current evidence for, each once, as {@link rulesFor} merges them. */
119
+ checks: RefRule["checks"];
120
+ overrides?: "ledger" | "sealed";
121
+ /**
122
+ * Why the policy at base cannot be read. The gate then refuses every
123
+ * update of the ref and sets no status, so a product should refuse too.
124
+ */
125
+ problems: string[];
126
+ }
127
+ /**
128
+ * The ref gate's rules for `ref` from the policy at `base` (#4913), the same
129
+ * read {@link decideRefUpdate} makes, for a product that acts on them
130
+ * without deciding an update: an apply that waits for the status the gate
131
+ * sets (`@intentius/chant/ref-gate-rules`), or a forge check that requires
132
+ * it. `base` defaults as `check` and `status` default it: `origin/HEAD`,
133
+ * then `main`, then `master`. A base that names no commit is a problem; no
134
+ * base at all is no policy, so nothing is required.
135
+ */
136
+ export declare function refGateRulesAt(repo: string, opts: {
137
+ ref: string;
138
+ base?: string;
139
+ }): RefGateRules;
140
+ /**
141
+ * The status a forge's default branch should require for the ref gate
142
+ * (#4913), for a forge check whose pipeline renders the `ref-gate` job: the
143
+ * policy's status for `refs/heads/<defaultBranch>`, read at
144
+ * `origin/<defaultBranch>` when the checkout has it, else at `HEAD`. With
145
+ * no rule for the branch the job sets no status, so none is required and
146
+ * `note` says so; a policy that can't be read is a `problem`.
147
+ */
148
+ export declare function refGateStatusFor(repo: string, defaultBranch: string): {
149
+ status?: string;
150
+ note?: string;
151
+ problem?: string;
152
+ };
109
153
  /** The envelopes in a note's text: one per line, or the whole note as one envelope or an array of them. */
110
154
  export declare function parseEvidenceNote(text: string): unknown[];
111
155
  /** The envelopes attached to `commit`, read from the notes commit `notes` (default: {@link EVIDENCE_NOTES_REF}'s tip). */
@@ -182,6 +226,21 @@ export declare function runPrePush(repo: string, stdin: string, opts?: {
182
226
  now?: string;
183
227
  base?: (repo: string) => string | null;
184
228
  }): SiteResult;
185
- /** What the gate says about one decision: each missing check and its command, and how to override a blocked one. */
186
- export declare function describeDecision(d: RefDecision): string[];
229
+ /**
230
+ * The command that records the request for an override of `d`'s blocked
231
+ * checks from a checkout (#4913): `check` for the same ref, commit and base
232
+ * the remote decided, so it reaches the same decision and records the
233
+ * request on `chant/lifecycle`, which a pre-receive hook can't move.
234
+ */
235
+ export declare function requestCommand(d: Pick<RefDecision, "ref" | "new" | "base">): string;
236
+ /**
237
+ * What the gate says about one decision: each missing check and its command,
238
+ * and how to override a blocked one. At `pre-receive` (#4913) the request
239
+ * can't be recorded where the decision is made, so the refusal prints the
240
+ * exact command that records it from the checkout, then the override and
241
+ * the push that spends it.
242
+ */
243
+ export declare function describeDecision(d: RefDecision, opts?: {
244
+ site?: RefGateSite;
245
+ }): string[];
187
246
  //# sourceMappingURL=ref-gate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ref-gate.d.ts","sourceRoot":"","sources":["../../../src/workspace/trust/ref-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAQH,OAAO,EAAa,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAQL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAK7B,gHAAgH;AAChH,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAC9D,6DAA6D;AAC7D,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAC1D,mEAAmE;AACnE,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAIhD,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,wGAAyI,CAAC;AAC3K,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,uGAAuG;AACvG,eAAO,MAAM,oBAAoB,sLAQS,CAAC;AAC3C,MAAM,MAAM,gBAAgB,GAAG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E,MAAM,EAAE,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;CAAO,GAAG,UAAU,CAUxJ;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,GAAG,MAAM,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,WAAW,CAAA;CAAO,GAAG,MAAM,EAAE,CAiC5F"}
@@ -35,7 +35,7 @@ import { execFileSync, spawnSync } from "node:child_process";
35
35
  import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
36
36
  import { dirname, isAbsolute, join } from "node:path";
37
37
  import { verifyEvidence } from "./evidence.js";
38
- import { policyAtBase } from "./provenance.js";
38
+ import { policyAtBase, resolveBase } from "./provenance.js";
39
39
  import { runnersAt } from "./policy.js";
40
40
  import { OVERRIDE_APPLIED, OVERRIDE_LEDGER, OVERRIDERS_PATH, decideOverride, overrideCommand, overridersAt, parseAppliedOverrides, } from "../../override-gate.js";
41
41
  import { parseGateLedger } from "../../lifecycle/gate-ledger.js";
@@ -104,6 +104,46 @@ export function rulesFor(policy, ref) {
104
104
  ...(overrides ? { overrides } : {}),
105
105
  };
106
106
  }
107
+ /**
108
+ * The ref gate's rules for `ref` from the policy at `base` (#4913), the same
109
+ * read {@link decideRefUpdate} makes, for a product that acts on them
110
+ * without deciding an update: an apply that waits for the status the gate
111
+ * sets (`@intentius/chant/ref-gate-rules`), or a forge check that requires
112
+ * it. `base` defaults as `check` and `status` default it: `origin/HEAD`,
113
+ * then `main`, then `master`. A base that names no commit is a problem; no
114
+ * base at all is no policy, so nothing is required.
115
+ */
116
+ export function refGateRulesAt(repo, opts) {
117
+ const resolved = resolveBase(repo, opts.base);
118
+ const none = { ref: opts.ref, base: resolved.commit, matched: false, status: null, checks: [] };
119
+ if (!resolved.commit)
120
+ return { ...none, problems: opts.base !== undefined && resolved.problem ? [resolved.problem] : [] };
121
+ const policy = policyAtBase(repo, resolved);
122
+ if (policy.problems.length > 0)
123
+ return { ...none, problems: [...policy.problems] };
124
+ const rules = rulesFor(policy, opts.ref);
125
+ if (!rules.matched)
126
+ return { ...none, problems: [] };
127
+ return { ref: opts.ref, base: resolved.commit, matched: true, status: rules.status, checks: rules.checks, ...(rules.overrides ? { overrides: rules.overrides } : {}), problems: [] };
128
+ }
129
+ /**
130
+ * The status a forge's default branch should require for the ref gate
131
+ * (#4913), for a forge check whose pipeline renders the `ref-gate` job: the
132
+ * policy's status for `refs/heads/<defaultBranch>`, read at
133
+ * `origin/<defaultBranch>` when the checkout has it, else at `HEAD`. With
134
+ * no rule for the branch the job sets no status, so none is required and
135
+ * `note` says so; a policy that can't be read is a `problem`.
136
+ */
137
+ export function refGateStatusFor(repo, defaultBranch) {
138
+ const remote = `refs/remotes/origin/${defaultBranch}`;
139
+ const rules = refGateRulesAt(repo, { ref: `refs/heads/${defaultBranch}`, base: commitOf(repo, remote) ? remote : "HEAD" });
140
+ if (rules.problems.length > 0)
141
+ return { problem: `the trust policy can't be read, so the ref gate sets no status to require: ${rules.problems.join("; ")}` };
142
+ if (!rules.matched || !rules.status) {
143
+ return { note: `no refs rule in .chant/trust.json${rules.base ? ` at ${rules.base.slice(0, 8)}` : ""} matches refs/heads/${defaultBranch}, so the ref-gate job sets no status there and none is required` };
144
+ }
145
+ return { status: rules.status };
146
+ }
107
147
  // ── evidence notes ───────────────────────────────────────────────────────
108
148
  /** The envelopes in a note's text: one per line, or the whole note as one envelope or an array of them. */
109
149
  export function parseEvidenceNote(text) {
@@ -401,8 +441,23 @@ export function runPrePush(repo, stdin, opts = {}) {
401
441
  }
402
442
  // ── words ────────────────────────────────────────────────────────────────
403
443
  const short = (s) => (s ? s.slice(0, 8) : "(none)");
404
- /** What the gate says about one decision: each missing check and its command, and how to override a blocked one. */
405
- export function describeDecision(d) {
444
+ /**
445
+ * The command that records the request for an override of `d`'s blocked
446
+ * checks from a checkout (#4913): `check` for the same ref, commit and base
447
+ * the remote decided, so it reaches the same decision and records the
448
+ * request on `chant/lifecycle`, which a pre-receive hook can't move.
449
+ */
450
+ export function requestCommand(d) {
451
+ return `chant workspace ref-gate check --ref ${d.ref} --at ${d.new ?? "HEAD"}${d.base ? ` --base ${d.base}` : ""}`;
452
+ }
453
+ /**
454
+ * What the gate says about one decision: each missing check and its command,
455
+ * and how to override a blocked one. At `pre-receive` (#4913) the request
456
+ * can't be recorded where the decision is made, so the refusal prints the
457
+ * exact command that records it from the checkout, then the override and
458
+ * the push that spends it.
459
+ */
460
+ export function describeDecision(d, opts = {}) {
406
461
  const out = [];
407
462
  const verb = d.decision === "admit" ? "admitted" : "refused";
408
463
  out.push(`chant ref gate: ${verb} ${d.ref} ${short(d.old)}..${short(d.new)}`);
@@ -423,10 +478,20 @@ export function describeDecision(d) {
423
478
  const blocked = d.checks.filter((c) => c.action === "block" && (c.status === "missing" || c.status === "stale"));
424
479
  if (blocked.length > 0) {
425
480
  out.push(` Attach each check's evidence to ${short(d.new)} (chant workspace ref-gate attach --envelope <file> --at ${short(d.new)}) and push ${EVIDENCE_NOTES_REF} with the ref.`);
426
- out.push(` To let ${short(d.new)} through without a check, a person listed in ${OVERRIDERS_PATH} at base can override it once the request is recorded`);
427
- out.push(` (the pre-push hook records it, or chant workspace ref-gate check --ref ${d.ref} --at ${short(d.new)}):`);
428
- for (const c of blocked)
429
- out.push(` ${overrideCommand(c.subject, [c.check])}`);
481
+ if (opts.site === "pre-receive") {
482
+ out.push(` To let ${short(d.new)} through without a check, record the request for an override in your checkout (this remote can't):`);
483
+ out.push(` ${requestCommand(d)}`);
484
+ out.push(` then a person listed in ${OVERRIDERS_PATH} at base overrides each check:`);
485
+ for (const c of blocked)
486
+ out.push(` ${overrideCommand(c.subject, [c.check])}`);
487
+ out.push(` and the push goes again with chant/lifecycle: git push origin chant/lifecycle ${d.new ?? "HEAD"}:${d.ref}`);
488
+ }
489
+ else {
490
+ out.push(` To let ${short(d.new)} through without a check, a person listed in ${OVERRIDERS_PATH} at base can override it once the request is recorded`);
491
+ out.push(` (the pre-push hook records it, or ${requestCommand(d)}):`);
492
+ for (const c of blocked)
493
+ out.push(` ${overrideCommand(c.subject, [c.check])}`);
494
+ }
430
495
  }
431
496
  return out;
432
497
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant",
3
- "version": "0.124.87",
3
+ "version": "0.124.88",
4
4
  "description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -49,6 +49,8 @@ export const ACTION_PINS = {
49
49
  setupBun2: pin("oven-sh/setup-bun", "v2", "0c5077e51419868618aeaa5fe8019c62421857d6", "v2.2.0"),
50
50
  golangciLint9: pin("golangci/golangci-lint-action", "v9", "ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a", "v9.3.0"),
51
51
  dockerLogin4: pin("docker/login-action", "v4", "81c6f93d4bc991e510b342a00b419b3bb4efc5c6", "v4.7.0"),
52
+ // #4876: the release workflow's QEMU binfmt setup for a `release.images` platform the runner can't run.
53
+ dockerSetupQemu4: pin("docker/setup-qemu-action", "v4", "99012661954931238ded8c8b007157a8430204e1", "v4.4.0"),
52
54
  dockerSetupBuildx4: pin("docker/setup-buildx-action", "v4", "f87e5991a6d7451dcb8d9637bfbc97413f497069", "v4.4.1"),
53
55
  dockerMetadata6: pin("docker/metadata-action", "v6", "dc802804100637a589fabce1cb79ff13a1411302", "v6.2.0"),
54
56
  dockerBuildPush7: pin("docker/build-push-action", "v7", "c3c9e263c25d99ce0380d002d59b67737d91b0dc", "v7.4.0"),
@@ -0,0 +1,12 @@
1
+ /** #4911: one actor fallback for the lexicons' gated requests and the products' requesters. */
2
+ import { expect, test } from "vitest";
3
+ import { actorFromEnv } from "./actor";
4
+
5
+ test("the forge's actor, then the login, then unknown", () => {
6
+ expect(actorFromEnv({ GITHUB_ACTOR: "octo", GITLAB_USER_LOGIN: "gl", USER: "me" })).toBe("octo");
7
+ expect(actorFromEnv({ GITLAB_USER_LOGIN: "gl", USER: "me" })).toBe("gl");
8
+ expect(actorFromEnv({ GITHUB_ACTOR: " ", USER: "me" })).toBe("me");
9
+ expect(actorFromEnv({ USERNAME: "win" })).toBe("win");
10
+ expect(actorFromEnv({})).toBe("unknown");
11
+ expect(actorFromEnv({}, "chant")).toBe("chant");
12
+ });
package/src/actor.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Who runs a command, when the caller names nobody (#4911): the forge's
3
+ * actor in a job (`GITHUB_ACTOR`, which Forgejo sets too, then
4
+ * `GITLAB_USER_LOGIN`), else the login (`USER`, `USERNAME` on Windows).
5
+ * The terraform and pulumi lexicons' gated requests and the products'
6
+ * requesters read it here rather than each writing the order.
7
+ */
8
+
9
+ /** The actor fallback's variables, in the order {@link actorFromEnv} reads them. */
10
+ export const ACTOR_ENV_ORDER = ["GITHUB_ACTOR", "GITLAB_USER_LOGIN", "USER", "USERNAME"] as const;
11
+
12
+ /** The first of {@link ACTOR_ENV_ORDER} set to something other than blanks, else `fallback` (default `unknown`). */
13
+ export function actorFromEnv(env: Record<string, string | undefined> = process.env, fallback = "unknown"): string {
14
+ for (const name of ACTOR_ENV_ORDER) {
15
+ const v = env[name]?.trim();
16
+ if (v) return v;
17
+ }
18
+ return fallback;
19
+ }
@@ -64,6 +64,28 @@ describe("chantRuntimeTarget (#4787)", () => {
64
64
  expect(cb!({ path: "@intentius/chant/ts-only" })).toBeUndefined();
65
65
  expect([...external]).toEqual(["@intentius/chant/notify"]);
66
66
  });
67
+
68
+ it("keeps external only the chant packages in the package's dependencies, or the ones it is given (#4922)", () => {
69
+ const { app, root } = product();
70
+ const lexicon = join(root, "node_modules/@intentius/chant-lexicon-k8s");
71
+ write(join(lexicon, "package.json"), { name: "@intentius/chant-lexicon-k8s", version: "1.2.3", exports: { ".": { import: "./dist/index.js" } } });
72
+ write(join(lexicon, "dist/index.js"), "export {};\n");
73
+ const resolver = (plugin: ReturnType<typeof chantExternalPlugin>) => {
74
+ let cb: ((a: { path: string }) => unknown) | undefined;
75
+ plugin.setup({ onResolve: (_o, f) => { cb = f; } });
76
+ return cb!;
77
+ };
78
+ // The app depends on @intentius/chant only, so the lexicon (a devDependency it bundles) stays in the bundle.
79
+ const byDeps = resolver(chantExternalPlugin(app));
80
+ expect(byDeps({ path: "@intentius/chant/notify" })).toEqual({ path: "@intentius/chant/notify", external: true });
81
+ expect(byDeps({ path: "@intentius/chant-lexicon-k8s" })).toBeUndefined();
82
+ // Named packages win over the dependencies.
83
+ const external = new Set<string>();
84
+ const named = resolver(chantExternalPlugin(app, { packages: ["@intentius/chant-lexicon-k8s"], external }));
85
+ expect(named({ path: "@intentius/chant-lexicon-k8s" })).toEqual({ path: "@intentius/chant-lexicon-k8s", external: true });
86
+ expect(named({ path: "@intentius/chant" })).toBeUndefined();
87
+ expect([...external]).toEqual(["@intentius/chant-lexicon-k8s"]);
88
+ });
67
89
  });
68
90
 
69
91
  describe("bundleImports (#4787)", () => {
@@ -113,18 +113,46 @@ export interface EsbuildPluginLike {
113
113
  }): void;
114
114
  }
115
115
 
116
+ /** What {@link chantExternalPlugin} keeps external, and where it records it. */
117
+ export interface ChantExternalOptions {
118
+ /**
119
+ * The chant packages whose imports may stay external (#4922). Default: the
120
+ * `@intentius/chant*` packages in the `dependencies` of `pkgDir`'s
121
+ * package.json, the ones an install of the published package brings. A
122
+ * product that bundles its lexicons (devDependencies) and depends only on
123
+ * `@intentius/chant` gets core external and the lexicons bundled.
124
+ */
125
+ packages?: Iterable<string>;
126
+ /** Collects the specifiers left external. */
127
+ external?: Set<string>;
128
+ }
129
+
130
+ /** The `@intentius/chant*` names in the `dependencies` of the package at `pkgDir`. */
131
+ function chantDependencies(pkgDir: string): string[] {
132
+ const f = join(pkgDir, "package.json");
133
+ if (!existsSync(f)) return [];
134
+ const deps = (JSON.parse(readFileSync(f, "utf8")) as { dependencies?: Record<string, string> }).dependencies ?? {};
135
+ return Object.keys(deps).filter((n) => CHANT.test(n));
136
+ }
137
+
116
138
  /**
117
139
  * An esbuild plugin that leaves an `@intentius/chant*` import external when
118
- * the chant installed for `pkgDir` (where the bin runs) serves it as compiled
119
- * JS, so the bundle runs the installed, pinned chant. Any other chant import
120
- * goes on to the next plugin and esbuild, which bundle it. `external`, when
121
- * given, collects the specifiers left external.
140
+ * its package is one of `options.packages` (by default the package's chant
141
+ * `dependencies`, #4922) and the chant installed for `pkgDir` (where the bin
142
+ * runs) serves it as compiled JS, so the bundle runs the installed, pinned
143
+ * chant. Any other chant import goes on to the next plugin and esbuild, which
144
+ * bundle it. A bundled lexicon's own imports of core come through here too.
145
+ * The second argument may still be the `external` set alone.
122
146
  */
123
- export function chantExternalPlugin(pkgDir: string, external?: Set<string>): EsbuildPluginLike {
147
+ export function chantExternalPlugin(pkgDir: string, options?: ChantExternalOptions | Set<string>): EsbuildPluginLike {
148
+ const opts: ChantExternalOptions = options instanceof Set ? { external: options } : (options ?? {});
149
+ const external = opts.external;
150
+ const keep = new Set(opts.packages ?? chantDependencies(pkgDir));
124
151
  return {
125
152
  name: "chant-external",
126
153
  setup(b) {
127
154
  b.onResolve({ filter: CHANT }, (args) => {
155
+ if (!keep.has(CHANT.exec(args.path)![1])) return undefined;
128
156
  if (chantRuntimeTarget(args.path, pkgDir) === undefined) return undefined;
129
157
  external?.add(args.path);
130
158
  return { path: args.path, external: true };