@intentius/chant 0.124.87 → 0.124.89

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 (483) 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 +47 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +56 -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 +203 -2
  13. package/dist/ci-base.d.ts +30 -0
  14. package/dist/ci-base.d.ts.map +1 -0
  15. package/dist/ci-base.js +33 -0
  16. package/dist/ci-comment-commands.d.ts +177 -0
  17. package/dist/ci-comment-commands.d.ts.map +1 -0
  18. package/dist/ci-comment-commands.js +325 -0
  19. package/dist/ci-comment-replies.d.ts +40 -0
  20. package/dist/ci-comment-replies.d.ts.map +1 -0
  21. package/dist/ci-comment-replies.js +59 -0
  22. package/dist/ci-commit.d.ts +1 -1
  23. package/dist/ci-commit.d.ts.map +1 -1
  24. package/dist/ci-commit.js +1 -2
  25. package/dist/ci-control.d.ts +1 -1
  26. package/dist/ci-control.d.ts.map +1 -1
  27. package/dist/ci-control.js +1 -1
  28. package/dist/ci-evidence-claims.d.ts +59 -0
  29. package/dist/ci-evidence-claims.d.ts.map +1 -0
  30. package/dist/ci-evidence-claims.js +87 -0
  31. package/dist/ci-evidence-from-job.d.ts +128 -0
  32. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  33. package/dist/ci-evidence-from-job.js +203 -0
  34. package/dist/ci-evidence-jobs.d.ts +68 -4
  35. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  36. package/dist/ci-evidence-jobs.js +82 -5
  37. package/dist/ci-handover.d.ts +12 -0
  38. package/dist/ci-handover.d.ts.map +1 -1
  39. package/dist/ci-handover.js +15 -3
  40. package/dist/ci-identity.d.ts +32 -6
  41. package/dist/ci-identity.d.ts.map +1 -1
  42. package/dist/ci-identity.js +40 -8
  43. package/dist/ci-image.d.ts +65 -10
  44. package/dist/ci-image.d.ts.map +1 -1
  45. package/dist/ci-image.js +101 -22
  46. package/dist/ci-jobs.d.ts +1 -1
  47. package/dist/ci-jobs.d.ts.map +1 -1
  48. package/dist/ci-jobs.js +7 -2
  49. package/dist/ci-login.d.ts +75 -13
  50. package/dist/ci-login.d.ts.map +1 -1
  51. package/dist/ci-login.js +89 -37
  52. package/dist/ci-note-commands.d.ts +63 -3
  53. package/dist/ci-note-commands.d.ts.map +1 -1
  54. package/dist/ci-note-commands.js +69 -35
  55. package/dist/ci-product-words.d.ts +62 -1
  56. package/dist/ci-product-words.d.ts.map +1 -1
  57. package/dist/ci-product-words.js +52 -1
  58. package/dist/ci-product.d.ts +52 -2
  59. package/dist/ci-product.d.ts.map +1 -1
  60. package/dist/ci-product.js +51 -2
  61. package/dist/cli/commands/build.d.ts.map +1 -1
  62. package/dist/cli/commands/build.js +29 -2
  63. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  64. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  65. package/dist/cli/handlers/approve-confirm.js +46 -0
  66. package/dist/cli/handlers/approve.d.ts.map +1 -1
  67. package/dist/cli/handlers/approve.js +2 -1
  68. package/dist/cli/handlers/build.d.ts +1 -1
  69. package/dist/cli/handlers/build.d.ts.map +1 -1
  70. package/dist/cli/handlers/build.js +22 -1
  71. package/dist/cli/handlers/ci-check.d.ts +1 -1
  72. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  73. package/dist/cli/handlers/ci-check.js +37 -7
  74. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  75. package/dist/cli/handlers/ci-evidence.js +255 -20
  76. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  77. package/dist/cli/handlers/ci-forge-check.js +34 -17
  78. package/dist/cli/handlers/components.d.ts.map +1 -1
  79. package/dist/cli/handlers/components.js +3 -1
  80. package/dist/cli/handlers/generated-check.d.ts +11 -0
  81. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  82. package/dist/cli/handlers/generated-check.js +71 -0
  83. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  84. package/dist/cli/handlers/lifecycle.js +3 -0
  85. package/dist/cli/handlers/local-chant.d.ts +13 -0
  86. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  87. package/dist/cli/handlers/local-chant.js +42 -1
  88. package/dist/cli/handlers/lock.d.ts.map +1 -1
  89. package/dist/cli/handlers/lock.js +121 -4
  90. package/dist/cli/handlers/pr-comment.d.ts +21 -0
  91. package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
  92. package/dist/cli/handlers/pr-comment.js +112 -0
  93. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  94. package/dist/cli/handlers/pr-env.js +6 -3
  95. package/dist/cli/handlers/pr.d.ts +23 -1
  96. package/dist/cli/handlers/pr.d.ts.map +1 -1
  97. package/dist/cli/handlers/pr.js +97 -14
  98. package/dist/cli/handlers/promote.d.ts.map +1 -1
  99. package/dist/cli/handlers/promote.js +2 -1
  100. package/dist/cli/handlers/release.d.ts.map +1 -1
  101. package/dist/cli/handlers/release.js +11 -2
  102. package/dist/cli/handlers/run-wave.d.ts.map +1 -1
  103. package/dist/cli/handlers/run-wave.js +36 -2
  104. package/dist/cli/handlers/run.d.ts.map +1 -1
  105. package/dist/cli/handlers/run.js +2 -1
  106. package/dist/cli/main.d.ts.map +1 -1
  107. package/dist/cli/main.js +60 -4
  108. package/dist/cli/parse-args.d.ts.map +1 -1
  109. package/dist/cli/parse-args.js +82 -0
  110. package/dist/cli/registry.d.ts +35 -0
  111. package/dist/cli/registry.d.ts.map +1 -1
  112. package/dist/components/auto-release.d.ts.map +1 -1
  113. package/dist/components/auto-release.js +2 -1
  114. package/dist/components/check-hooks.d.ts +10 -0
  115. package/dist/components/check-hooks.d.ts.map +1 -1
  116. package/dist/components/check-hooks.js +18 -0
  117. package/dist/components/pr-checks.d.ts +169 -0
  118. package/dist/components/pr-checks.d.ts.map +1 -0
  119. package/dist/components/pr-checks.js +180 -0
  120. package/dist/components/pr-pipeline.d.ts +38 -0
  121. package/dist/components/pr-pipeline.d.ts.map +1 -1
  122. package/dist/components/pr-pipeline.js +6 -1
  123. package/dist/components/product-pipeline.d.ts +58 -2
  124. package/dist/components/product-pipeline.d.ts.map +1 -1
  125. package/dist/components/product-pipeline.js +76 -9
  126. package/dist/components/product-plan.d.ts +445 -7
  127. package/dist/components/product-plan.d.ts.map +1 -1
  128. package/dist/components/product-plan.js +426 -15
  129. package/dist/config.d.ts +10 -6
  130. package/dist/config.d.ts.map +1 -1
  131. package/dist/config.js +11 -6
  132. package/dist/control/consumers.d.ts +6 -0
  133. package/dist/control/consumers.d.ts.map +1 -1
  134. package/dist/control/consumers.js +6 -0
  135. package/dist/dead-guards.d.ts.map +1 -1
  136. package/dist/dead-guards.js +9 -6
  137. package/dist/discovery/files.d.ts +1 -1
  138. package/dist/discovery/files.js +1 -1
  139. package/dist/drift-issue.d.ts +20 -3
  140. package/dist/drift-issue.d.ts.map +1 -1
  141. package/dist/drift-issue.js +16 -0
  142. package/dist/drift-record.d.ts +52 -5
  143. package/dist/drift-record.d.ts.map +1 -1
  144. package/dist/drift-record.js +46 -6
  145. package/dist/floor-table.d.ts +6 -6
  146. package/dist/floor-table.d.ts.map +1 -1
  147. package/dist/floor-table.data.d.ts.map +1 -1
  148. package/dist/floor-table.data.js +81 -21
  149. package/dist/floor-table.js +10 -7
  150. package/dist/forge-check/contract.d.ts +19 -1
  151. package/dist/forge-check/contract.d.ts.map +1 -1
  152. package/dist/forge-check/contract.js +8 -2
  153. package/dist/forge-check/index.d.ts +4 -0
  154. package/dist/forge-check/index.d.ts.map +1 -1
  155. package/dist/forge-check/index.js +4 -0
  156. package/dist/forge-flags.d.ts +10 -0
  157. package/dist/forge-flags.d.ts.map +1 -1
  158. package/dist/forge-flags.js +31 -0
  159. package/dist/forge-remote.d.ts +47 -0
  160. package/dist/forge-remote.d.ts.map +1 -0
  161. package/dist/forge-remote.js +69 -0
  162. package/dist/gate-resume-run.d.ts +9 -1
  163. package/dist/gate-resume-run.d.ts.map +1 -1
  164. package/dist/gate-resume-run.js +26 -3
  165. package/dist/generated-check.d.ts +88 -0
  166. package/dist/generated-check.d.ts.map +1 -0
  167. package/dist/generated-check.js +248 -0
  168. package/dist/image-pins.d.ts +26 -0
  169. package/dist/image-pins.d.ts.map +1 -0
  170. package/dist/image-pins.js +19 -0
  171. package/dist/lexicon.d.ts +27 -0
  172. package/dist/lexicon.d.ts.map +1 -1
  173. package/dist/lifecycle/git.d.ts +11 -0
  174. package/dist/lifecycle/git.d.ts.map +1 -1
  175. package/dist/lifecycle/git.js +30 -3
  176. package/dist/lifecycle/publish-npm.d.ts +26 -0
  177. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  178. package/dist/lifecycle/publish-npm.js +76 -4
  179. package/dist/lifecycle/reach-locks.d.ts +131 -0
  180. package/dist/lifecycle/reach-locks.d.ts.map +1 -0
  181. package/dist/lifecycle/reach-locks.js +118 -0
  182. package/dist/lifecycle/release-cut.d.ts +3 -1
  183. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  184. package/dist/lifecycle/release-cut.js +15 -0
  185. package/dist/lifecycle/release-images.d.ts +22 -1
  186. package/dist/lifecycle/release-images.d.ts.map +1 -1
  187. package/dist/lifecycle/release-images.js +26 -3
  188. package/dist/lifecycle/release-ledger.d.ts +4 -3
  189. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  190. package/dist/lifecycle/release-ledger.js +3 -2
  191. package/dist/local-chant.d.ts +57 -3
  192. package/dist/local-chant.d.ts.map +1 -1
  193. package/dist/local-chant.js +122 -13
  194. package/dist/notify-product.d.ts +12 -3
  195. package/dist/notify-product.d.ts.map +1 -1
  196. package/dist/notify-product.js +10 -6
  197. package/dist/op/activities/source-release.d.ts.map +1 -1
  198. package/dist/op/activities/source-release.js +2 -1
  199. package/dist/op/activities/source-rollback.d.ts.map +1 -1
  200. package/dist/op/activities/source-rollback.js +2 -1
  201. package/dist/op/index.d.ts +2 -0
  202. package/dist/op/index.d.ts.map +1 -1
  203. package/dist/op/index.js +1 -0
  204. package/dist/op/op-waves-evidence-jobs.d.ts +97 -0
  205. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  206. package/dist/op/op-waves-evidence-jobs.js +118 -0
  207. package/dist/op/op-waves-evidence.d.ts +12 -1
  208. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  209. package/dist/op/op-waves-evidence.js +23 -2
  210. package/dist/op/op-waves-render-spec.d.ts +100 -0
  211. package/dist/op/op-waves-render-spec.d.ts.map +1 -0
  212. package/dist/op/op-waves-render-spec.js +162 -0
  213. package/dist/op/op-waves-run.d.ts +14 -1
  214. package/dist/op/op-waves-run.d.ts.map +1 -1
  215. package/dist/op/op-waves-run.js +56 -4
  216. package/dist/op/op-waves.d.ts +12 -0
  217. package/dist/op/op-waves.d.ts.map +1 -1
  218. package/dist/op/op-waves.js +14 -1
  219. package/dist/op/schedule-overdue.d.ts +39 -2
  220. package/dist/op/schedule-overdue.d.ts.map +1 -1
  221. package/dist/op/schedule-overdue.js +148 -10
  222. package/dist/op/wave-stop.d.ts +64 -0
  223. package/dist/op/wave-stop.d.ts.map +1 -0
  224. package/dist/op/wave-stop.js +127 -0
  225. package/dist/planned-files.d.ts +76 -0
  226. package/dist/planned-files.d.ts.map +1 -0
  227. package/dist/planned-files.js +108 -0
  228. package/dist/pr-forge-job.d.ts +22 -0
  229. package/dist/pr-forge-job.d.ts.map +1 -0
  230. package/dist/pr-forge-job.js +46 -0
  231. package/dist/pr-forge-reads.d.ts +21 -1
  232. package/dist/pr-forge-reads.d.ts.map +1 -1
  233. package/dist/pr-forge-reads.js +19 -1
  234. package/dist/pr-forge.d.ts +7 -1
  235. package/dist/pr-forge.d.ts.map +1 -1
  236. package/dist/pr-forge.js +7 -2
  237. package/dist/pr-loop.d.ts +3 -6
  238. package/dist/pr-loop.d.ts.map +1 -1
  239. package/dist/pr-loop.js +4 -81
  240. package/dist/pr-plan-note.d.ts +121 -0
  241. package/dist/pr-plan-note.d.ts.map +1 -1
  242. package/dist/pr-plan-note.js +104 -1
  243. package/dist/pr-plan-record.d.ts +47 -0
  244. package/dist/pr-plan-record.d.ts.map +1 -0
  245. package/dist/pr-plan-record.js +89 -0
  246. package/dist/pr-post.d.ts +68 -3
  247. package/dist/pr-post.d.ts.map +1 -1
  248. package/dist/pr-post.js +218 -13
  249. package/dist/pr-requires.d.ts +8 -0
  250. package/dist/pr-requires.d.ts.map +1 -1
  251. package/dist/pr-requires.js +3 -1
  252. package/dist/pr-status.d.ts +16 -0
  253. package/dist/pr-status.d.ts.map +1 -0
  254. package/dist/pr-status.js +90 -0
  255. package/dist/ref-gate-init.d.ts +90 -0
  256. package/dist/ref-gate-init.d.ts.map +1 -0
  257. package/dist/ref-gate-init.js +155 -0
  258. package/dist/ref-gate-rules.d.ts +19 -0
  259. package/dist/ref-gate-rules.d.ts.map +1 -0
  260. package/dist/ref-gate-rules.js +17 -0
  261. package/dist/release-floors.d.ts +100 -16
  262. package/dist/release-floors.d.ts.map +1 -1
  263. package/dist/release-floors.js +101 -17
  264. package/dist/render-module.d.ts +15 -0
  265. package/dist/render-module.d.ts.map +1 -0
  266. package/dist/render-module.js +73 -0
  267. package/dist/state-migration.d.ts +24 -1
  268. package/dist/state-migration.d.ts.map +1 -1
  269. package/dist/state-migration.js +39 -4
  270. package/dist/state-unlock.d.ts +32 -1
  271. package/dist/state-unlock.d.ts.map +1 -1
  272. package/dist/state-unlock.js +31 -0
  273. package/dist/wave-runtime.mjs +307 -297
  274. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  275. package/dist/workspace/ci-green-cli.js +15 -8
  276. package/dist/workspace/drift-cli.d.ts +1 -1
  277. package/dist/workspace/drift-cli.d.ts.map +1 -1
  278. package/dist/workspace/drift-cli.js +5 -12
  279. package/dist/workspace/forge-work.d.ts +3 -2
  280. package/dist/workspace/forge-work.d.ts.map +1 -1
  281. package/dist/workspace/forge-work.js +7 -17
  282. package/dist/workspace/lexicon-outputs.js +2 -2
  283. package/dist/workspace/release-train.d.ts.map +1 -1
  284. package/dist/workspace/release-train.js +2 -1
  285. package/dist/workspace/release-workflow.d.ts +27 -3
  286. package/dist/workspace/release-workflow.d.ts.map +1 -1
  287. package/dist/workspace/release-workflow.js +52 -7
  288. package/dist/workspace/trust/check-evidence-report.d.ts +25 -2
  289. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  290. package/dist/workspace/trust/check-evidence-report.js +28 -8
  291. package/dist/workspace/trust/check-evidence.d.ts +13 -1
  292. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  293. package/dist/workspace/trust/check-evidence.js +8 -3
  294. package/dist/workspace/trust/evidence.d.ts +5 -0
  295. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  296. package/dist/workspace/trust/evidence.js +5 -0
  297. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  298. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  299. package/dist/workspace/trust/open-evidence.js +92 -0
  300. package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
  301. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  302. package/dist/workspace/trust/ref-gate-cli.js +93 -11
  303. package/dist/workspace/trust/ref-gate.d.ts +61 -2
  304. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  305. package/dist/workspace/trust/ref-gate.js +72 -7
  306. package/dist/workspace/workspace-run.d.ts.map +1 -1
  307. package/dist/workspace/workspace-run.js +2 -1
  308. package/package.json +1 -1
  309. package/src/action-pins.ts +2 -0
  310. package/src/actor.test.ts +78 -0
  311. package/src/actor.ts +79 -0
  312. package/src/bundle-check.test.ts +22 -0
  313. package/src/bundle-check.ts +33 -5
  314. package/src/chant-install.test.ts +108 -1
  315. package/src/chant-install.ts +242 -2
  316. package/src/ci-base.test.ts +41 -0
  317. package/src/ci-base.ts +43 -0
  318. package/src/ci-comment-commands.test.ts +376 -0
  319. package/src/ci-comment-commands.ts +389 -0
  320. package/src/ci-comment-replies.ts +78 -0
  321. package/src/ci-commit.test.ts +51 -6
  322. package/src/ci-commit.ts +1 -2
  323. package/src/ci-control.ts +1 -0
  324. package/src/ci-evidence-claims.ts +102 -0
  325. package/src/ci-evidence-from-job.test.ts +165 -0
  326. package/src/ci-evidence-from-job.ts +251 -0
  327. package/src/ci-evidence-jobs.ts +88 -6
  328. package/src/ci-handover.ts +16 -3
  329. package/src/ci-identity.test.ts +3 -3
  330. package/src/ci-identity.ts +51 -11
  331. package/src/ci-image.test.ts +187 -16
  332. package/src/ci-image.ts +157 -25
  333. package/src/ci-jobs.ts +7 -2
  334. package/src/ci-login.test.ts +131 -3
  335. package/src/ci-login.token-drop.test.ts +204 -0
  336. package/src/ci-login.ts +137 -39
  337. package/src/ci-note-commands.ts +104 -41
  338. package/src/ci-product-words.ts +89 -0
  339. package/src/ci-product.ts +62 -1
  340. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  341. package/src/cli/commands/build.test.ts +41 -0
  342. package/src/cli/commands/build.ts +27 -2
  343. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  344. package/src/cli/handlers/approve-confirm.ts +44 -0
  345. package/src/cli/handlers/approve.ts +2 -1
  346. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  347. package/src/cli/handlers/build.ts +20 -2
  348. package/src/cli/handlers/ci-check.ts +37 -7
  349. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  350. package/src/cli/handlers/ci-evidence.ts +233 -18
  351. package/src/cli/handlers/ci-forge-check.ts +22 -9
  352. package/src/cli/handlers/components.ts +3 -1
  353. package/src/cli/handlers/generated-check.ts +69 -0
  354. package/src/cli/handlers/lifecycle.test.ts +20 -0
  355. package/src/cli/handlers/lifecycle.ts +4 -0
  356. package/src/cli/handlers/local-chant.ts +39 -1
  357. package/src/cli/handlers/lock-reach.test.ts +103 -0
  358. package/src/cli/handlers/lock.ts +100 -4
  359. package/src/cli/handlers/pr-comment.ts +104 -0
  360. package/src/cli/handlers/pr-env.ts +6 -3
  361. package/src/cli/handlers/pr-record.test.ts +1 -1
  362. package/src/cli/handlers/pr.ts +93 -15
  363. package/src/cli/handlers/promote.ts +2 -1
  364. package/src/cli/handlers/release.e2e.test.ts +35 -0
  365. package/src/cli/handlers/release.ts +14 -2
  366. package/src/cli/handlers/run-wave.ts +35 -2
  367. package/src/cli/handlers/run.ts +2 -1
  368. package/src/cli/main.ts +60 -4
  369. package/src/cli/parse-args.ts +58 -0
  370. package/src/cli/registry.ts +35 -0
  371. package/src/components/auto-release.ts +2 -1
  372. package/src/components/check-hooks.ts +22 -0
  373. package/src/components/check-report-summary.test.ts +78 -0
  374. package/src/components/pr-checks.ts +254 -0
  375. package/src/components/pr-pipeline.ts +43 -1
  376. package/src/components/product-pipeline.ts +113 -9
  377. package/src/components/product-plan.test.ts +140 -1
  378. package/src/components/product-plan.ts +707 -20
  379. package/src/config.ts +13 -8
  380. package/src/control/consumers.ts +7 -0
  381. package/src/dead-guards.test.ts +27 -5
  382. package/src/dead-guards.ts +9 -6
  383. package/src/discovery/files.ts +1 -1
  384. package/src/drift-issue.test.ts +29 -1
  385. package/src/drift-issue.ts +28 -3
  386. package/src/drift-record.test.ts +45 -0
  387. package/src/drift-record.ts +71 -6
  388. package/src/floor-table.data.ts +81 -21
  389. package/src/floor-table.ts +12 -9
  390. package/src/forge-check/contract.ts +23 -2
  391. package/src/forge-check/forge-check.test.ts +25 -0
  392. package/src/forge-check/index.ts +4 -0
  393. package/src/forge-flags.test.ts +25 -1
  394. package/src/forge-flags.ts +34 -0
  395. package/src/forge-remote.test.ts +37 -0
  396. package/src/forge-remote.ts +79 -0
  397. package/src/gate-resume-run.ts +27 -3
  398. package/src/generated-check.e2e.test.ts +118 -0
  399. package/src/generated-check.test.ts +170 -0
  400. package/src/generated-check.ts +310 -0
  401. package/src/image-pins.ts +31 -0
  402. package/src/lexicon.ts +28 -0
  403. package/src/lifecycle/git.test.ts +48 -0
  404. package/src/lifecycle/git.ts +27 -4
  405. package/src/lifecycle/publish-npm.ts +87 -4
  406. package/src/lifecycle/reach-locks.test.ts +87 -0
  407. package/src/lifecycle/reach-locks.ts +169 -0
  408. package/src/lifecycle/release-catalog.test.ts +2 -2
  409. package/src/lifecycle/release-cut.ts +17 -1
  410. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  411. package/src/lifecycle/release-images.test.ts +100 -0
  412. package/src/lifecycle/release-images.ts +38 -3
  413. package/src/lifecycle/release-ledger.ts +4 -3
  414. package/src/local-chant.e2e.test.ts +81 -6
  415. package/src/local-chant.test.ts +22 -3
  416. package/src/local-chant.ts +130 -13
  417. package/src/notify-product.ts +19 -8
  418. package/src/op/activities/source-release.ts +2 -1
  419. package/src/op/activities/source-rollback.ts +2 -1
  420. package/src/op/gate-resume.test.ts +27 -0
  421. package/src/op/index.ts +10 -0
  422. package/src/op/op-waves-evidence-jobs.ts +140 -0
  423. package/src/op/op-waves-evidence.test.ts +36 -3
  424. package/src/op/op-waves-evidence.ts +23 -3
  425. package/src/op/op-waves-notify-words.test.ts +18 -0
  426. package/src/op/op-waves-render-spec.test.ts +160 -0
  427. package/src/op/op-waves-render-spec.ts +171 -0
  428. package/src/op/op-waves-run.ts +59 -3
  429. package/src/op/op-waves.ts +16 -2
  430. package/src/op/schedule-overdue.test.ts +126 -1
  431. package/src/op/schedule-overdue.ts +164 -12
  432. package/src/op/wave-stop.test.ts +72 -0
  433. package/src/op/wave-stop.ts +137 -0
  434. package/src/planned-files.test.ts +80 -0
  435. package/src/planned-files.ts +134 -0
  436. package/src/pr-forge-job.test.ts +53 -0
  437. package/src/pr-forge-job.ts +46 -0
  438. package/src/pr-forge-reads-compare.test.ts +2 -1
  439. package/src/pr-forge-reads.ts +37 -1
  440. package/src/pr-forge.ts +14 -3
  441. package/src/pr-loop-narrowed.test.ts +2 -1
  442. package/src/pr-loop-words.test.ts +2 -1
  443. package/src/pr-loop.test.ts +1 -2
  444. package/src/pr-loop.ts +4 -80
  445. package/src/pr-plan-note.ts +184 -3
  446. package/src/pr-plan-record.test.ts +75 -0
  447. package/src/pr-plan-record.ts +101 -0
  448. package/src/pr-post-plan-note.test.ts +60 -0
  449. package/src/pr-post-replan.test.ts +144 -0
  450. package/src/pr-post-subject.test.ts +230 -0
  451. package/src/pr-post.test.ts +32 -1
  452. package/src/pr-post.ts +254 -15
  453. package/src/pr-requires.test.ts +20 -0
  454. package/src/pr-requires.ts +10 -1
  455. package/src/pr-status.ts +91 -0
  456. package/src/ref-gate-init.ts +208 -0
  457. package/src/ref-gate-rules.ts +26 -0
  458. package/src/release-floors.ts +139 -17
  459. package/src/render-module.ts +73 -0
  460. package/src/state-migration-record.test.ts +89 -0
  461. package/src/state-migration.test.ts +1 -1
  462. package/src/state-migration.ts +52 -4
  463. package/src/state-unlock.test.ts +33 -1
  464. package/src/state-unlock.ts +49 -1
  465. package/src/workspace/ci-green-cli.ts +14 -7
  466. package/src/workspace/ci-green-workflow.test.ts +32 -1
  467. package/src/workspace/drift-cli.ts +6 -18
  468. package/src/workspace/forge-work.ts +7 -14
  469. package/src/workspace/lexicon-outputs.ts +2 -2
  470. package/src/workspace/release-train.ts +2 -1
  471. package/src/workspace/release-workflow.test.ts +104 -3
  472. package/src/workspace/release-workflow.ts +60 -9
  473. package/src/workspace/trust/check-evidence-report.ts +39 -8
  474. package/src/workspace/trust/check-evidence.test.ts +5 -0
  475. package/src/workspace/trust/check-evidence.ts +17 -5
  476. package/src/workspace/trust/evidence.ts +5 -0
  477. package/src/workspace/trust/open-evidence.ts +129 -0
  478. package/src/workspace/trust/ref-gate-cli.ts +88 -10
  479. package/src/workspace/trust/ref-gate-pieces.test.ts +220 -0
  480. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  481. package/src/workspace/trust/ref-gate.test.ts +10 -0
  482. package/src/workspace/trust/ref-gate.ts +87 -6
  483. package/src/workspace/workspace-run.ts +2 -1
@@ -28,7 +28,8 @@
28
28
  * renders the tag-triggered file it always did.
29
29
  */
30
30
  import { ACTION_PINS, tagComments, usesRef } from "../action-pins";
31
- import { resolveReleaseImages } from "../lifecycle/release-images";
31
+ import { IMAGE_PINS, imageRef } from "../image-pins";
32
+ import { releaseImagePlatforms, resolveReleaseImages } from "../lifecycle/release-images";
32
33
  import { GENERATED_MARKER } from "../discovery/files";
33
34
  import type { SecurityGroup } from "./security";
34
35
  import type { OpSetupStep } from "../lexicon";
@@ -74,9 +75,9 @@ export interface ReleasePipelineConfig {
74
75
  env?: Record<string, string>;
75
76
  /**
76
77
  * Steps the cut and publish jobs run after the install (#4751): `{ run }`,
77
- * or `{ uses, with }` on GitHub and Forgejo, such as QEMU's binfmt handlers
78
- * for a two-platform image build, or a newer npm. GitLab takes `run` steps
79
- * as script lines and refuses `uses` by name.
78
+ * or `{ uses, with }` on GitHub and Forgejo, such as a newer npm. GitLab
79
+ * takes `run` steps as script lines and refuses `uses` by name. QEMU for
80
+ * the platforms `release.images` builds is set up without one (#4876).
80
81
  */
81
82
  setup?: OpSetupStep[];
82
83
  /** Where the workflow is written, from the repository root, such as `.github/workflows/publish.yml` for an npm trusted publisher that names that file. Default {@link RELEASE_WORKFLOW_FILES}. */
@@ -107,6 +108,12 @@ export interface ReleaseWorkflowInput {
107
108
  * two jobs cannot change what is published.
108
109
  */
109
110
  imageArchives?: string[];
111
+ /**
112
+ * The platforms `release.images` builds (#4876). Those the runner can't run
113
+ * ({@link RELEASE_RUNNER_PLATFORM}) get QEMU's binfmt handlers in the cut
114
+ * and publish jobs, before `release.workflow.setup`.
115
+ */
116
+ imagePlatforms?: string[];
110
117
  /** `release.lane` (#4692): the gate's green lane. */
111
118
  lane?: string;
112
119
  /**
@@ -174,6 +181,36 @@ export function targetExtras(forge: ReleaseWorkflowForge, targets: ReadonlyArray
174
181
  return { ...(permissions ? { permissions } : {}), ...(Object.keys(env).length > 0 ? { env } : {}), ...(setup.length > 0 ? { setup } : {}) };
175
182
  }
176
183
 
184
+ /** The platform the jobs `chant release workflow` writes run on: GitHub's and Forgejo's `ubuntu-latest`, and a GitLab runner's default (#4876). */
185
+ export const RELEASE_RUNNER_PLATFORM = "linux/amd64";
186
+
187
+ /** The binfmt image a GitLab job installs QEMU's handlers with (#4876): the repository, which a config's own setup line is recognised by. */
188
+ export const RELEASE_BINFMT_IMAGE = IMAGE_PINS.binfmt.repository;
189
+
190
+ /** The architectures among `platforms` the runner can't run, as QEMU names them (`linux/arm/v7` is `arm`), each once. */
191
+ export function qemuArchitectures(platforms: readonly string[]): string[] {
192
+ return [...new Set(platforms.filter((p) => p.split("/").slice(0, 2).join("/") !== RELEASE_RUNNER_PLATFORM).map((p) => p.split("/")[1] ?? p))].sort();
193
+ }
194
+
195
+ /**
196
+ * QEMU's binfmt setup for the platforms `release.images` builds that the
197
+ * runner can't, such as `linux/arm64` on an amd64 runner (#4876), so no
198
+ * product names it in `release.workflow.setup`. GitHub and Forgejo get
199
+ * `docker/setup-qemu-action` at its pin; GitLab a `docker run --privileged`
200
+ * of {@link RELEASE_BINFMT_IMAGE} by the digest `IMAGE_PINS.binfmt` records
201
+ * (#4941, ../image-pins.ts), which `chant release workflow` notes needs
202
+ * an executor that runs privileged containers. A config whose `setup` names
203
+ * the action or the binfmt image already gets nothing more, so its file
204
+ * renders as it did.
205
+ */
206
+ export function qemuSetup(forge: ReleaseWorkflowForge, platforms: readonly string[], p: ReleasePipelineConfig): OpSetupStep[] {
207
+ const archs = qemuArchitectures(platforms);
208
+ if (archs.length === 0) return [];
209
+ const named = (p.setup ?? []).some((s) => ("uses" in s ? /^docker\/setup-qemu-action@/.test(s.uses) : s.run.includes(RELEASE_BINFMT_IMAGE)));
210
+ if (named) return [];
211
+ return forge === "gitlab" ? [{ run: `docker run --privileged --rm ${imageRef(IMAGE_PINS.binfmt)} --install ${archs.join(",")}` }] : [{ uses: usesRef(ACTION_PINS.dockerSetupQemu4), with: { platforms: archs.join(",") } }];
212
+ }
213
+
177
214
  /** The flags `chant release publish` gets under the groups. */
178
215
  export function publishFlags(groups: ReadonlySet<SecurityGroup>): string[] {
179
216
  return [...(groups.has("supply-chain") ? ["--require-provenance"] : []), "--yes"];
@@ -214,12 +251,14 @@ export function renderReleaseWorkflow(input: ReleaseWorkflowInput): string {
214
251
  const version = input.version === true;
215
252
  // #4786: the targets' own needs first, then the config's, so a config that set them by hand renders the same file without them.
216
253
  const derived = targetExtras(input.forge, input.publish ?? [], p);
254
+ // #4876: QEMU before the config's setup, where the products named it.
255
+ const qemu = images ? qemuSetup(input.forge, input.imagePlatforms ?? [], p) : [];
217
256
  const extra = jobExtras(
218
257
  {
219
258
  ...p,
220
259
  ...(derived.permissions ? { permissions: { ...p.permissions, ...derived.permissions } } : {}),
221
260
  ...(derived.env ? { env: { ...p.env, ...derived.env } } : {}),
222
- ...(derived.setup ? { setup: [...(p.setup ?? []), ...derived.setup] } : {}),
261
+ ...(derived.setup || qemu.length > 0 ? { setup: [...qemu, ...(p.setup ?? []), ...(derived.setup ?? [])] } : {}),
223
262
  },
224
263
  input.forge,
225
264
  );
@@ -347,11 +386,14 @@ function jobExtras(p: ReleasePipelineConfig, forge: ReleaseWorkflowForge): JobEx
347
386
  if (!/^[a-z][a-z-]*$/.test(k) || (v !== "read" && v !== "write")) throw new Error(`${where}.permissions: ${k}: ${String(v)} is not a scope and read or write`);
348
387
  }
349
388
  for (const s of setup) if (!("uses" in s) && s.run.trim() === "") throw new Error(`${where}.setup: a run step is empty`);
389
+ for (const s of setup) if (s.name !== undefined && (s.name.trim() === "" || /[\r\n]/.test(s.name))) throw new Error(`${where}.setup: a step's name is blank or more than one line`);
350
390
  }
351
391
  const q = (v: string | number | boolean): string => JSON.stringify(v);
352
392
  const map = (indent: string, entries: Array<[string, string | number | boolean]>): string[] => entries.map(([k, v]) => `${indent}${k}: ${q(v)}`);
393
+ // #4932: a named step opens with its name.
353
394
  const githubSteps = setup.flatMap((s) => [
354
- "uses" in s ? ` - uses: ${s.uses}` : ` - run: ${q(s.run)}`,
395
+ ...(s.name !== undefined ? [` - name: ${q(s.name)}`] : []),
396
+ ` ${s.name !== undefined ? " " : "-"} ${"uses" in s ? `uses: ${s.uses}` : `run: ${q(s.run)}`}`,
355
397
  ...("uses" in s && s.with && Object.keys(s.with).length > 0 ? [" with:", ...map(" ", Object.entries(s.with))] : []),
356
398
  ...(s.env && Object.keys(s.env).length > 0 ? [" env:", ...map(" ", Object.entries(s.env))] : []),
357
399
  ]);
@@ -664,7 +706,7 @@ export async function runReleaseWorkflow(ctx: import("../cli/registry").CommandC
664
706
  groups,
665
707
  workspaceRoot,
666
708
  ...(release?.workflow ? { pipeline: release.workflow } : {}),
667
- ...((release?.images?.length ?? 0) > 0 ? { images: true, imageArchives: resolveReleaseImages(release!.images!).map((i) => i.archive) } : {}),
709
+ ...((release?.images?.length ?? 0) > 0 ? { images: true, imageArchives: resolveReleaseImages(release!.images!).map((i) => i.archive), imagePlatforms: releaseImagePlatforms(release!.images!) } : {}),
668
710
  ...(release?.lane ? { lane: release.lane } : {}),
669
711
  ...(release?.version ? { version: true } : {}),
670
712
  ...(release?.publish ? { publish: release.publish } : {}),
@@ -672,12 +714,17 @@ export async function runReleaseWorkflow(ctx: import("../cli/registry").CommandC
672
714
  ...(args.buildCommand ? { build: args.buildCommand } : {}),
673
715
  ...(args.ciChant ? { chant: args.ciChant } : {}),
674
716
  });
675
- const target = args.output ? resolve(process.cwd(), args.output) : join(repoRoot, release?.workflow?.file ?? RELEASE_WORKFLOW_FILES[forge]);
717
+ // #4909: under `chant dev generated-check` the header names the committed file the render stands for.
718
+ // #4950: with no --output the file goes to the render tree too, so a render needs no `--output {out}/...`.
719
+ const { committedPathOf, isRenderPath, renderPathOf } = await import("../generated-check");
720
+ const defaultTarget = join(repoRoot, release?.workflow?.file ?? RELEASE_WORKFLOW_FILES[forge]);
721
+ const target = args.output ? resolve(process.cwd(), args.output) : renderPathOf(defaultTarget);
722
+ const asCommitted = committedPathOf(target);
676
723
  const parts = ["chant", "release", "workflow", "--forge", forge];
677
724
  if (args.ciInstall) parts.push("--install", args.ciInstall);
678
725
  if (args.buildCommand) parts.push("--build", args.buildCommand);
679
726
  if (args.ciChant) parts.push("--chant", args.ciChant);
680
- if (args.output) parts.push("--output", relative(root, target).split(sep).join("/"));
727
+ if (args.output && !(isRenderPath(target) && asCommitted === defaultTarget)) parts.push("--output", relative(root, asCommitted).split(sep).join("/"));
681
728
  mkdirSync(dirname(target), { recursive: true });
682
729
  writeFileSync(target, releaseWorkflowHeader(parts.map(shellArg).join(" ")) + text);
683
730
  const shown = relative(process.cwd(), target).split(sep).join("/") || target;
@@ -685,6 +732,10 @@ export async function runReleaseWorkflow(ctx: import("../cli/registry").CommandC
685
732
  const what = release?.workflow?.trigger === "dispatch" ? "cuts and publishes a release started by hand with its label, from a green commit" : "publishes the release a release/** tag names";
686
733
  console.log(formatSuccess(`Wrote ${shown}: ${what}${extras.length > 0 ? `, and ${extras.join(" and ")}` : ""}.`));
687
734
  if (forge === "gitlab") console.log(`Include it from .gitlab-ci.yml: include: [{ local: ${release?.workflow?.file ?? RELEASE_WORKFLOW_FILES.gitlab} }]`);
735
+ // #4876: a GitLab executor that refuses privileged containers can't install the handlers from the job.
736
+ const archs = (release?.images?.length ?? 0) > 0 ? qemuArchitectures(releaseImagePlatforms(release!.images!)) : [];
737
+ if (forge === "gitlab" && archs.length > 0 && text.includes(`${RELEASE_BINFMT_IMAGE} --install`))
738
+ console.log(`The cut and publish jobs install QEMU's binfmt handlers for ${archs.join(", ")} with docker run --privileged ${RELEASE_BINFMT_IMAGE}: the runner's executor must run privileged containers, or have the handlers installed on its host.`);
688
739
  if (forge === "gitlab" && release?.workflow?.trigger === "dispatch") console.log("The cut and publish jobs push with CHANT_RELEASE_TOKEN: a project access token with write_repository, as a masked CI/CD variable.");
689
740
  return 0;
690
741
  }
@@ -76,27 +76,58 @@ function policyOf(dir: string): { passed: boolean; reason: string } | null {
76
76
  return standing === 0 ? { passed: true, reason: "the policy denied nothing that stands" } : { passed: false, reason: `the policy denied ${standing} unit${standing === 1 ? "" : "s"} with no override` };
77
77
  }
78
78
 
79
- /** The checks to sign from the plan job's hand-off directory and result, and those left unsigned with why. */
80
- export function planReportChecks(dir: string, result: string | undefined): { sign: Array<{ check: string; claim?: Buffer }>; skipped: CheckEvidenceNote["skipped"] } {
79
+ /**
80
+ * The checks to sign from the plan job's hand-off directory and result, and
81
+ * those left unsigned with why. #4964: a workspace member's plan job plans
82
+ * that member alone, so with `member` the two are `plan:<member>` and
83
+ * `policy:<member>`.
84
+ */
85
+ export function planReportChecks(dir: string, result: string | undefined, member?: string): { sign: Array<{ check: string; claim?: Buffer }>; skipped: CheckEvidenceNote["skipped"] } {
86
+ const planCheck = member ? `plan:${member}` : "plan";
87
+ const policyCheck = member ? `policy:${member}` : "policy";
81
88
  const file = [REPORT_FILE, HANDOFF_FILE].map((f) => join(dir, f)).find((f) => existsSync(f));
82
89
  if (result !== "success") {
83
90
  const why = `the plan job's result is ${result ?? "not given"}`;
84
- return { sign: [], skipped: [{ check: "plan", reason: why }, { check: "policy", reason: why }] };
91
+ return { sign: [], skipped: [{ check: planCheck, reason: why }, { check: policyCheck, reason: why }] };
85
92
  }
86
93
  if (!file) {
87
94
  const why = `the plan job left no ${REPORT_FILE} or ${HANDOFF_FILE}`;
88
- return { sign: [], skipped: [{ check: "plan", reason: why }, { check: "policy", reason: why }] };
95
+ return { sign: [], skipped: [{ check: planCheck, reason: why }, { check: policyCheck, reason: why }] };
89
96
  }
90
97
  const claim = readFileSync(file);
91
- const sign: Array<{ check: string; claim?: Buffer }> = [{ check: "plan", claim }];
98
+ const sign: Array<{ check: string; claim?: Buffer }> = [{ check: planCheck, claim }];
92
99
  const skipped: CheckEvidenceNote["skipped"] = [];
93
100
  const policy = policyOf(dir);
94
- if (policy === null) skipped.push({ check: "policy", reason: "the plan ran no policy" });
95
- else if (policy.passed) sign.push({ check: "policy", claim });
96
- else skipped.push({ check: "policy", reason: policy.reason });
101
+ if (policy === null) skipped.push({ check: policyCheck, reason: "the plan ran no policy" });
102
+ else if (policy.passed) sign.push({ check: policyCheck, claim });
103
+ else skipped.push({ check: policyCheck, reason: policy.reason });
97
104
  return { sign, skipped };
98
105
  }
99
106
 
107
+ /**
108
+ * What a GitLab signing job in the target branch's pipeline keeps for one
109
+ * merge request (#4914), `<out>/<iid>/evidence.json`: the note, with the
110
+ * merge request and the head it was signed for, so the note job uses it
111
+ * only for that head.
112
+ */
113
+ export interface OpenEvidenceFile extends CheckEvidenceNote {
114
+ pr: number;
115
+ head: string;
116
+ }
117
+
118
+ /**
119
+ * The `evidence.json` the signing job kept for merge request `pr` at
120
+ * `head` under `dir` (#4914), as text for the note job's report directory,
121
+ * or undefined when it kept none for that head. The file comes from a job
122
+ * of the same target-branch pipeline, which ran none of the change's code;
123
+ * it is read as data all the same.
124
+ */
125
+ export function openEvidenceFor(dir: string, pr: number, head: string): string | undefined {
126
+ const doc = readJson(join(dir, String(pr), CHECK_EVIDENCE_FILE)) as Partial<OpenEvidenceFile> | undefined;
127
+ if (!doc || doc.pr !== pr || doc.head !== head || !Array.isArray(doc.signed) || !Array.isArray(doc.skipped)) return undefined;
128
+ return JSON.stringify({ signed: doc.signed, skipped: doc.skipped }, null, 2) + "\n";
129
+ }
130
+
100
131
  /**
101
132
  * The line the plan note ends with when the signing step wrote
102
133
  * {@link CHECK_EVIDENCE_FILE} in `dir`, or undefined when it did not.
@@ -120,6 +120,11 @@ describe("the plan job's two checks (#4870)", () => {
120
120
  expect(planReportChecks(dir(handoff([{ member: "a", rules: ["r"], overriders: [] }])), "success").sign.map((c) => c.check)).toEqual(["plan"]);
121
121
  });
122
122
 
123
+ test("a workspace member's plan job signs its checks under the member's name (#4964)", () => {
124
+ expect(planReportChecks(dir({ "pr-plan.json": { policy: { result: "passed" } } }), "success", "app").sign.map((c) => c.check)).toEqual(["plan:app", "policy:app"]);
125
+ expect(planReportChecks(dir({ "pr-plan.json": {} }), "failure", "app").skipped.map((s) => s.check)).toEqual(["plan:app", "policy:app"]);
126
+ });
127
+
123
128
  test("a failed plan job signs neither, and the note line says which were signed", () => {
124
129
  const failed = planReportChecks(dir({ "pr-plan.json": { policy: { result: "passed" } } }), "failure");
125
130
  expect(failed.sign).toEqual([]);
@@ -159,8 +159,19 @@ export function commitAndTree(repo: string, rev: string): { commit: string; tree
159
159
  return { commit, tree: git(repo, ["rev-parse", `${commit}^{tree}`]) };
160
160
  }
161
161
 
162
- /** The check's statement over `commit`, with the digest of what it said when given. */
163
- export function checkStatement(input: { commit: string; tree: string; check: string; runner: string; claim?: Buffer | string }): EvidenceStatement {
162
+ /** Where a check's pass was read from (#4926): the forge's run and job ids, and the step whose conclusion said so. */
163
+ export interface CheckSource {
164
+ run: number;
165
+ job: number;
166
+ step?: string;
167
+ }
168
+
169
+ /**
170
+ * The check's statement over `commit`, with the digest of what it said when
171
+ * given, and (#4926) the run, job and step a signer outside the check's job
172
+ * read its pass from, so a verifier can look them up.
173
+ */
174
+ export function checkStatement(input: { commit: string; tree: string; check: string; runner: string; claim?: Buffer | string; source?: CheckSource }): EvidenceStatement {
164
175
  if (!input.check.trim()) throw new Error("a check's evidence needs the check's name");
165
176
  return {
166
177
  _type: STATEMENT_TYPE,
@@ -172,6 +183,7 @@ export function checkStatement(input: { commit: string; tree: string; check: str
172
183
  tree: input.tree,
173
184
  check: input.check,
174
185
  ...(input.claim !== undefined ? { claim: { sha256: createHash("sha256").update(input.claim).digest("hex") } } : {}),
186
+ ...(input.source ? { source: { run: input.source.run, job: input.source.job, ...(input.source.step ? { step: input.source.step } : {}) } } : {}),
175
187
  },
176
188
  };
177
189
  }
@@ -186,11 +198,11 @@ export interface SignedCheck {
186
198
  }
187
199
 
188
200
  /** Sign each of `checks` over `at` with `signer`. Writes nothing. */
189
- export async function signChecks(repo: string, at: string, checks: readonly { check: string; claim?: Buffer | string }[], signer: EvidenceSigner): Promise<SignedCheck[]> {
201
+ export async function signChecks(repo: string, at: string, checks: readonly { check: string; claim?: Buffer | string; source?: CheckSource }[], signer: EvidenceSigner): Promise<SignedCheck[]> {
190
202
  const { commit, tree } = commitAndTree(repo, at);
191
203
  const out: SignedCheck[] = [];
192
- for (const { check, claim } of checks) {
193
- const statement = checkStatement({ commit, tree, check, runner: signer.principal, ...(claim !== undefined ? { claim } : {}) });
204
+ for (const { check, claim, source } of checks) {
205
+ const statement = checkStatement({ commit, tree, check, runner: signer.principal, ...(claim !== undefined ? { claim } : {}), ...(source ? { source } : {}) });
194
206
  out.push({ check, commit, tree, runner: signer.principal, envelope: await signer.sign(IN_TOTO_PAYLOAD_TYPE, Buffer.from(canonicalJson(statement), "utf8")) });
195
207
  }
196
208
  return out;
@@ -81,6 +81,11 @@ export const evidenceStatementSchema = z
81
81
  check: z.string().min(1),
82
82
  claim: z.object({ sha256: sha256Hex }).strict().optional(),
83
83
  environment: z.object({ sha256: sha256Hex }).strict().optional(),
84
+ // #4926: the forge's record the signer relied on: the run, the job, and the step whose conclusion it read.
85
+ source: z
86
+ .object({ run: z.number().int().nonnegative(), job: z.number().int().nonnegative(), step: z.string().min(1).optional() })
87
+ .strict()
88
+ .optional(),
84
89
  })
85
90
  .strict(),
86
91
  })
@@ -0,0 +1,129 @@
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
+
24
+ import { mkdirSync, writeFileSync } from "node:fs";
25
+ import { join } from "node:path";
26
+ import type { PrForge } from "../../pr-forge";
27
+ import { CHECK_EVIDENCE_FILE, type CheckEvidenceNote, type OpenEvidenceFile } from "./check-evidence-report";
28
+
29
+ /** 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. */
30
+ export const OPEN_PLAN_FILES = ["pr-plan.json", "pr-plan-note.json"] as const;
31
+ export const OPEN_CHECK_FILE = "check-hooks.json";
32
+
33
+ /** What {@link signOpenReports} signs for. */
34
+ export interface OpenEvidenceInput {
35
+ /**
36
+ * A GitLab client with {@link PrForge.mergeRequestJobs} and
37
+ * {@link PrForge.jobArtifact}, and with `noForks` {@link PrForge.openPullRequests},
38
+ * which says which merge requests come from a fork. The fork test is read
39
+ * here, not in `mergeRequestJobs`, to keep it out of the pull request loop's
40
+ * bundle (its ceiling, pr-loop-bundle.test.ts).
41
+ */
42
+ forge: Pick<PrForge, "kind" | "mergeRequestJobs" | "jobArtifact" | "openPullRequests">;
43
+ /** The branch the merge requests merge into: the pipeline's own. */
44
+ branch: string;
45
+ /** The job whose report is signed: `plan`, `<target>-plan` or `check`. */
46
+ job: string;
47
+ /** The report directory from the repository root, as the job kept it as its artifact. */
48
+ artifactDir: string;
49
+ /** Where each merge request's report and `evidence.json` go: `<out>/<iid>/`. */
50
+ out: string;
51
+ /** Sign for no merge request from a fork, as a product plan with `forks: "skip"` plans none. */
52
+ noForks?: boolean;
53
+ /** Fetch merge request `pr`'s head into this checkout; true once the commit is here. */
54
+ fetchHead: (pr: number, head: string) => boolean;
55
+ /** Sign the checks of the report in `dir` for `head`, given the job's result, as `sign --from-report` does. */
56
+ sign: (dir: string, head: string, result: "success" | "failure" | "cancelled") => Promise<CheckEvidenceNote>;
57
+ }
58
+
59
+ /** What {@link signOpenReports} did for one merge request. */
60
+ export interface OpenEvidence {
61
+ pr: number;
62
+ head: string;
63
+ /** What was signed and what was not, as kept in `evidence.json`. */
64
+ note?: CheckEvidenceNote;
65
+ /** Why nothing was signed: the job has not settled, left no report, or its head did not fetch. */
66
+ skipped?: string;
67
+ }
68
+
69
+ /** Sign every open merge request's settled `job` into `branch` (#4914). */
70
+ export async function signOpenReports(input: OpenEvidenceInput): Promise<{ done: OpenEvidence[]; warnings: string[] }> {
71
+ const { forge } = input;
72
+ if (!forge.mergeRequestJobs || !forge.jobArtifact) {
73
+ throw new Error(`ci evidence sign --open reads the jobs of open merge requests, which ${forge.kind} cannot say; it is for GitLab`);
74
+ }
75
+ const done: OpenEvidence[] = [];
76
+ const warnings: string[] = [];
77
+ const at = input.artifactDir.replace(/\/+$/, "");
78
+ let forks = new Set<number>();
79
+ if (input.noForks) {
80
+ if (!forge.openPullRequests) throw new Error(`ci evidence sign --open --no-forks reads which merge requests come from a fork, which ${forge.kind} cannot say`);
81
+ forks = new Set((await forge.openPullRequests(input.branch)).filter((p) => p.fork).map((p) => p.number));
82
+ }
83
+ for (const job of await forge.mergeRequestJobs(input.branch, input.job)) {
84
+ if (forks.has(job.pr)) {
85
+ done.push({ pr: job.pr, head: job.head, skipped: "the merge request is from a fork" });
86
+ continue;
87
+ }
88
+ const result = job.status === "success" ? "success" : job.status === "failed" ? "failure" : job.status === "canceled" ? "cancelled" : undefined;
89
+ if (!result) {
90
+ done.push({ pr: job.pr, head: job.head, skipped: `the ${input.job} job is ${job.status}` });
91
+ continue;
92
+ }
93
+ try {
94
+ const dir = join(input.out, String(job.pr));
95
+ mkdirSync(dir, { recursive: true });
96
+ // A plan report wins over a check report, as `sign --from-report` reads a directory.
97
+ let found = false;
98
+ for (const file of OPEN_PLAN_FILES) {
99
+ const text = await forge.jobArtifact(job.id, `${at}/${file}`);
100
+ if (text === undefined) continue;
101
+ writeFileSync(join(dir, file), text);
102
+ found = true;
103
+ break;
104
+ }
105
+ if (!found) {
106
+ const text = await forge.jobArtifact(job.id, `${at}/${OPEN_CHECK_FILE}`);
107
+ if (text !== undefined) {
108
+ writeFileSync(join(dir, OPEN_CHECK_FILE), text);
109
+ found = true;
110
+ }
111
+ }
112
+ if (!found) {
113
+ done.push({ pr: job.pr, head: job.head, skipped: `the ${input.job} job left no report under ${at}` });
114
+ continue;
115
+ }
116
+ if (!input.fetchHead(job.pr, job.head)) {
117
+ done.push({ pr: job.pr, head: job.head, skipped: `the head ${job.head.slice(0, 12)} did not fetch` });
118
+ continue;
119
+ }
120
+ const note = await input.sign(dir, job.head, result);
121
+ const kept: OpenEvidenceFile = { pr: job.pr, head: job.head, ...note };
122
+ writeFileSync(join(dir, CHECK_EVIDENCE_FILE), JSON.stringify(kept, null, 2) + "\n");
123
+ done.push({ pr: job.pr, head: job.head, note });
124
+ } catch (err) {
125
+ warnings.push(`!${job.pr}: ${err instanceof Error ? err.message : String(err)}`);
126
+ }
127
+ }
128
+ return { done, warnings };
129
+ }
@@ -27,6 +27,7 @@ import {
27
27
  describeDecision,
28
28
  readRefGateLedger,
29
29
  refGateLedgerPath,
30
+ REF_GATE_STATUS,
30
31
  RefUpdateInputError,
31
32
  runPrePush,
32
33
  runPreReceive,
@@ -48,6 +49,7 @@ const OVERRIDE_REQUEST_HOURS = 72;
48
49
  const USAGE =
49
50
  "chant workspace ref-gate check --ref <ref> [--at <rev>] [--base <rev>] [--dry-run] [--ledger <file>] [--json]\n" +
50
51
  " chant workspace ref-gate status --ref <ref> [--at <rev>] [--base <rev>] [--dry-run] [--ledger <file>] [--json]\n" +
52
+ " chant workspace ref-gate status --open --ref refs/heads/<branch> [--base <rev>] [--dry-run] [--ledger <file>] [--json]\n" +
51
53
  " chant workspace ref-gate pre-receive|pre-push [--ledger <file>] [--dry-run] [--json] (git hook input on stdin)\n" +
52
54
  " chant workspace ref-gate attach --envelope <file> [--at <rev>]\n" +
53
55
  " chant workspace ref-gate install --hook pre-receive|pre-push [--git-dir <dir>] [--chant <command>]";
@@ -82,7 +84,7 @@ function repoHere(): { repo: string; bare: boolean } | null {
82
84
  return { repo: top, bare: false };
83
85
  }
84
86
 
85
- function print(json: boolean | undefined, decisions: RefDecision[], ledger: string | undefined, stream: "out" | "err"): void {
87
+ function print(json: boolean | undefined, decisions: RefDecision[], ledger: string | undefined, stream: "out" | "err", site?: RefGateSite): void {
86
88
  const ok = decisions.every((d) => d.decision === "admit");
87
89
  if (json) {
88
90
  console.log(JSON.stringify({ ...head(), ok, ...(ledger ? { ledger } : {}), decisions }, null, 2));
@@ -90,7 +92,7 @@ function print(json: boolean | undefined, decisions: RefDecision[], ledger: stri
90
92
  }
91
93
  for (const d of decisions) {
92
94
  if (d.status === null && d.checks.length === 0 && !d.error) continue;
93
- const text = describeDecision(d).join("\n");
95
+ const text = describeDecision(d, site ? { site } : {}).join("\n");
94
96
  if (stream === "err" || d.decision === "refuse") console.error(text);
95
97
  else console.log(text);
96
98
  }
@@ -161,7 +163,7 @@ export async function runWorkspaceRefGate(ctx: CommandContext): Promise<number>
161
163
  try {
162
164
  if (sub === "pre-receive") {
163
165
  const r = runPreReceive(here.repo, stdin, { ...(args.ledger ? { ledger: args.ledger } : {}), now });
164
- print(args.json, r.decisions, r.ledger, "err");
166
+ print(args.json, r.decisions, r.ledger, "err", "pre-receive");
165
167
  return r.ok ? 0 : 1;
166
168
  }
167
169
  const r = runPrePush(here.repo, stdin, { ...(args.ledger ? { ledger: args.ledger } : {}), now, base: (repo) => resolveBase(repo).commit });
@@ -176,6 +178,10 @@ export async function runWorkspaceRefGate(ctx: CommandContext): Promise<number>
176
178
 
177
179
  // check and status: one update, from a checkout or a CI job.
178
180
  if (!args.ref || !args.ref.startsWith("refs/")) return usage("--ref <ref> is required, as a full ref name such as refs/heads/main");
181
+ if (args.open) {
182
+ if (sub !== "status") return usage("--open sets the status of every open pull request, so it goes with status");
183
+ return statusOpen(here.repo, args.ref, args.base, args.ledger, args.dryRun === true, args.json, now);
184
+ }
179
185
  const at = commitOf(here.repo, args.at ?? "HEAD");
180
186
  if (!at) return fail(args.json, "revision-unknown", `--at ${args.at ?? "HEAD"} names no commit`);
181
187
  const resolved = resolveBase(here.repo, args.base);
@@ -187,25 +193,97 @@ export async function runWorkspaceRefGate(ctx: CommandContext): Promise<number>
187
193
  if (!args.dryRun) appendRefGateLedger(ledger, [{ ...d, version: 1, kind: "ref-update", site, timestamp: now }]);
188
194
  print(args.json, [d], args.dryRun ? undefined : ledger, "out");
189
195
  if (site === "check" && d.decision === "refuse" && !args.dryRun && !here.bare) await recordRequests(here.repo, [d], now);
190
- if (site === "status" && d.status !== null) {
196
+ const context = refGateStatusContext(d);
197
+ if (site === "status" && context !== null) {
191
198
  if (args.dryRun) {
192
- console.error(`chant ref gate: would set ${d.status} to ${d.decision === "admit" ? "success" : "failure"} on ${at.slice(0, 8)}`);
199
+ console.error(`chant ref gate: would set ${context} to ${d.decision === "admit" ? "success" : "failure"} on ${at.slice(0, 8)}`);
193
200
  } else {
194
- const { detectForge, forgeFromEnv } = await import("../../pr-forge");
201
+ const { detectForge } = await import("../../pr-forge");
195
202
  const kind = detectForge();
196
203
  if (!kind) {
197
- console.error(formatError({ message: `no forge detected, so ${d.status} was not set`, hint: "run it in a GitHub, GitLab or Forgejo job, or pass --dry-run" }));
204
+ console.error(formatError({ message: `no forge detected, so ${context} was not set`, hint: "run it in a GitHub, GitLab or Forgejo job, or pass --dry-run" }));
198
205
  return 1;
199
206
  }
200
- await postRefGateStatus(forgeFromEnv(kind), d);
207
+ // #4964: `--at` is a pull_request run's merge preview; the status goes on the pull request's head.
208
+ const { forgeFromJobEnv } = await import("../../pr-forge-job");
209
+ await postRefGateStatus(forgeFromJobEnv(kind), d);
201
210
  }
202
211
  }
203
212
  return d.decision === "admit" ? 0 : 1;
204
213
  }
205
214
 
206
- /** The commit status a forge requires for `d`'s ref: `success` when it is admitted, `failure` naming the missing checks when not. */
215
+ /**
216
+ * `status --open --ref refs/heads/<branch>` (#4935): the status of every open
217
+ * pull request into the branch, from a pipeline of the branch. GitLab sets a
218
+ * commit status only with the protected token a target-branch pipeline holds
219
+ * (#4328), so its generated `ref-gate` job runs here, beside the plan notes.
220
+ * Each head is fetched and decided as `status --at <head>` decides it, against
221
+ * the policy at `base` (default this checkout's `HEAD`, the branch's commit).
222
+ * A head that does not fetch, or a forge that refuses one status, is said
223
+ * and the others go on. Exits 0 once each is set, whatever it decided: each
224
+ * pull request's status says it.
225
+ */
226
+ async function statusOpen(repo: string, ref: string, baseRev: string | undefined, ledgerFlag: string | undefined, dryRun: boolean, json: boolean | undefined, now: string): Promise<number> {
227
+ if (!ref.startsWith("refs/heads/")) return usage("--open names the branch the pull requests merge into: --ref refs/heads/<branch>");
228
+ const base = commitOf(repo, baseRev ?? "HEAD");
229
+ if (!base) return fail(json, "revision-unknown", `--base ${baseRev ?? "HEAD"} names no commit`);
230
+ const { detectForge, forgeFromEnv } = await import("../../pr-forge");
231
+ const kind = detectForge();
232
+ if (!kind && !dryRun) {
233
+ 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" }));
234
+ return 1;
235
+ }
236
+ const forge = kind ? forgeFromEnv(kind) : undefined;
237
+ if (!forge?.openPullRequests) return fail(json, "ref-update-invalid", `--open lists the open pull requests, which ${kind ?? "no"} forge client here can`);
238
+ const branch = ref.slice("refs/heads/".length);
239
+ const ledger = ledgerFlag ?? refGateLedgerPath(repo);
240
+ const decisions: RefDecision[] = [];
241
+ for (const pr of await forge.openPullRequests(branch)) {
242
+ const fetched = spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", pr.headSha], { cwd: repo, encoding: "utf-8" });
243
+ if (!commitOf(repo, pr.headSha)) {
244
+ 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`);
245
+ continue;
246
+ }
247
+ const spent = spentOverrides(readRefGateLedger(ledger));
248
+ const d = decideRefUpdate({ repo, update: { ref, old: base, new: pr.headSha }, base, spent, now });
249
+ decisions.push(d);
250
+ if (dryRun) {
251
+ const context = refGateStatusContext(d);
252
+ if (context !== null) console.error(`chant ref gate: would set ${context} to ${d.decision === "admit" ? "success" : "failure"} on #${pr.number} at ${pr.headSha.slice(0, 8)}`);
253
+ continue;
254
+ }
255
+ appendRefGateLedger(ledger, [{ ...d, version: 1, kind: "ref-update", site: "status", timestamp: now }]);
256
+ try {
257
+ await postRefGateStatus(forge, d);
258
+ } catch (err) {
259
+ console.error(`chant ref gate: could not set the status on #${pr.number}: ${err instanceof Error ? err.message : String(err)}`);
260
+ }
261
+ }
262
+ print(json, decisions, dryRun ? undefined : ledger, "err");
263
+ if (decisions.length === 0) console.error(`chant ref gate: no open pull request into ${branch} to set a status on`);
264
+ return 0;
265
+ }
266
+
267
+ /** The status `d` sets: its rule's, or `chant/ref-gate` when the gate could not decide (#4964); null when no rule matched. */
268
+ export function refGateStatusContext(d: Pick<RefDecision, "status" | "error">): string | null {
269
+ return d.status ?? (d.error ? REF_GATE_STATUS : null);
270
+ }
271
+
272
+ /**
273
+ * The commit status a forge requires for `d`'s ref: `success` when it is
274
+ * admitted, `failure` naming the missing checks when not. A gate that could
275
+ * not decide (#4964: the policy at base does not read, or the commit is not
276
+ * there) fails `chant/ref-gate` closed: the policy that would name another
277
+ * status is the one that did not read, and a forge that requires the status
278
+ * then refuses the merge rather than waiting for a status that never comes.
279
+ */
207
280
  export async function postRefGateStatus(forge: { setStatus(sha: string, status: { context: string; state: "success" | "failure"; description: string }): Promise<void> }, d: RefDecision): Promise<void> {
208
- if (d.status === null || d.new === null) return;
281
+ const context = refGateStatusContext(d);
282
+ if (context === null || d.new === null) return;
283
+ if (d.status === null) {
284
+ await forge.setStatus(d.new, { context, state: "failure", description: `refused: ${d.error!.code}` });
285
+ return;
286
+ }
209
287
  const missing = d.checks.filter((c) => c.action === "block" && (c.status === "missing" || c.status === "stale"));
210
288
  const overridden = d.checks.filter((c) => c.status === "overridden").map((c) => c.check);
211
289
  const description = d.error