@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
@@ -0,0 +1,103 @@
1
+ /**
2
+ * #4979: `chant lock --reach` end to end, in a clone of a bare remote that
3
+ * holds a pull request's head at `refs/pull/<n>/head`: the head is fetched
4
+ * and checked, the reach line reads the change from git, and what it prints
5
+ * is locked on `chant/lifecycle` and pushed.
6
+ */
7
+ import { execFileSync } from "node:child_process";
8
+ import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from "node:fs";
9
+ import { tmpdir } from "node:os";
10
+ import { join } from "node:path";
11
+ import { afterEach, describe, expect, test, vi } from "vitest";
12
+ import { commandRegistry, parseArgs } from "../main";
13
+ import { resolveCommand } from "../registry";
14
+
15
+ const home = process.cwd();
16
+
17
+ function git(cwd: string, ...args: string[]): string {
18
+ return execFileSync("git", args, { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
19
+ }
20
+
21
+ /** A bare remote with main and pull request 7's head, which changes envs/dev, and a clone of main. */
22
+ function world(): { clone: string; remote: string; base: string; head: string } {
23
+ const root = realpathSync(mkdtempSync(join(tmpdir(), "chant-lock-reach-")));
24
+ const remote = join(root, "remote.git");
25
+ git(root, "init", "-q", "--bare", "-b", "main", remote);
26
+ const work = join(root, "work");
27
+ mkdirSync(work);
28
+ git(work, "init", "-q", "-b", "main");
29
+ for (const [k, v] of [["user.email", "test@chant.dev"], ["user.name", "Test"], ["commit.gpgsign", "false"]]) git(work, "config", k!, v!);
30
+ mkdirSync(join(work, "envs", "dev"), { recursive: true });
31
+ mkdirSync(join(work, "envs", "prod"), { recursive: true });
32
+ writeFileSync(join(work, "envs", "dev", "main.tf"), "# dev\n");
33
+ writeFileSync(join(work, "envs", "prod", "main.tf"), "# prod\n");
34
+ git(work, "add", ".");
35
+ git(work, "commit", "-q", "-m", "init");
36
+ const base = git(work, "rev-parse", "HEAD");
37
+ git(work, "remote", "add", "origin", remote);
38
+ git(work, "push", "-q", "origin", "main");
39
+ writeFileSync(join(work, "envs", "dev", "main.tf"), "# dev, changed\n");
40
+ git(work, "commit", "-q", "-am", "change dev");
41
+ const head = git(work, "rev-parse", "HEAD");
42
+ git(work, "push", "-q", "origin", `${head}:refs/pull/7/head`);
43
+ const clone = join(root, "clone");
44
+ git(root, "clone", "-q", remote, clone);
45
+ for (const [k, v] of [["user.email", "test@chant.dev"], ["user.name", "Test"], ["commit.gpgsign", "false"]]) git(clone, "config", k!, v!);
46
+ return { clone, remote, base, head };
47
+ }
48
+
49
+ async function run(argv: string[], env: Record<string, string>): Promise<{ code: number; err: string }> {
50
+ let err = "";
51
+ vi.spyOn(console, "log").mockImplementation(() => undefined);
52
+ vi.spyOn(console, "error").mockImplementation((s) => void (err += String(s) + "\n"));
53
+ vi.spyOn(console, "warn").mockImplementation(() => undefined);
54
+ const saved = Object.fromEntries(Object.keys(env).map((k) => [k, process.env[k]]));
55
+ Object.assign(process.env, env);
56
+ try {
57
+ const args = parseArgs(argv);
58
+ const match = resolveCommand(args, commandRegistry);
59
+ const code = await match!.def.handler({ args, plugins: [], serializers: [] });
60
+ return { code: code ?? 0, err };
61
+ } finally {
62
+ for (const [k, v] of Object.entries(saved)) {
63
+ if (v === undefined) delete process.env[k];
64
+ else process.env[k] = v;
65
+ }
66
+ vi.restoreAllMocks();
67
+ }
68
+ }
69
+
70
+ // The forge's API is a port nothing listens on: the status post is a warning, and no other holder needs asking.
71
+ const forgeEnv = { GITHUB_REPOSITORY: "acme/infra", GITHUB_TOKEN: "t", GITHUB_API_URL: "http://127.0.0.1:9", CHANT_LOCK_REACH: 'git diff --name-only "$BASE_SHA" "$HEAD_SHA" | cut -d/ -f1-2 | sort -u' };
72
+
73
+ afterEach(() => process.chdir(home));
74
+
75
+ describe("chant lock --reach (#4979)", () => {
76
+ test("locks what the reach line prints for the pull request's head, and pushes chant/lifecycle", async () => {
77
+ const w = world();
78
+ process.chdir(w.clone);
79
+ const got = await run(["lock", "--reach", "--pr", "7", "--head", w.head, "--base", w.base, "--stage", "plan", "--gate", "tf-apply", "--forge", "github"], forgeEnv);
80
+ expect(got.err).toMatch(/pull request 7 holds envs\/dev on tf-apply/);
81
+ expect(got.code).toBe(0);
82
+ const locks = JSON.parse(git(w.remote, "show", "chant/lifecycle:_locks/tf-apply.json")) as { locks: Record<string, { pr: number; stage: string; head: string }> };
83
+ expect(Object.keys(locks.locks)).toEqual(["envs/dev"]);
84
+ expect(locks.locks["envs/dev"]).toMatchObject({ pr: 7, stage: "plan", head: w.head });
85
+ });
86
+
87
+ test("a head that moved since the job started locks nothing, and the job passes", async () => {
88
+ const w = world();
89
+ process.chdir(w.clone);
90
+ const got = await run(["lock", "--reach", "--pr", "7", "--head", w.base, "--base", w.base, "--stage", "plan", "--forge", "github"], forgeEnv);
91
+ expect(got.code).toBe(0);
92
+ expect(got.err).toMatch(/pull request 7 moved to .*, so the run of that push locks it/);
93
+ });
94
+
95
+ test("is refused without the line, the forge, or the two commits", async () => {
96
+ const w = world();
97
+ process.chdir(w.clone);
98
+ expect((await run(["lock", "--reach", "--pr", "7", "--head", w.head, "--base", w.base, "--forge", "github"], { ...forgeEnv, CHANT_LOCK_REACH: "" })).err).toMatch(/CHANT_LOCK_REACH, which is not set/);
99
+ expect((await run(["lock", "--reach", "--pr", "7", "--head", w.head, "--base", w.base], forgeEnv)).err).toMatch(/give --forge github, gitlab or forgejo/);
100
+ expect((await run(["lock", "--reach", "--pr", "7", "--head", w.head, "--forge", "github"], forgeEnv)).err).toMatch(/from --base <sha> to --head <sha>/);
101
+ expect((await run(["lock", "--reach", "envs/dev", "--pr", "7", "--head", w.head, "--base", w.base, "--forge", "github"], forgeEnv)).err).toMatch(/drop the names/);
102
+ });
103
+ });
@@ -6,6 +6,8 @@
6
6
  * chant lock <target>... --pr <n> [--stage plan|apply|lock] [--head <sha>] [--by <who>] [--gate <name>] [--forge <kind>] [--json]
7
7
  * chant lock --from-report <pr-plan.json> --pr <n> [--stage plan] [--forge <kind>] [--json]
8
8
  * chant lock --keep --pr <n> [--head <sha>] [--gate <name>] [--forge <kind>] [--json]
9
+ * chant lock --reach --pr <n> --head <sha> --base <sha> --forge <kind> [--stage plan|apply|lock] [--gate <name>] [--json]
10
+ * chant lock --reach --open --base <sha> --forge gitlab [--branch <name>] [--stage plan] [--gate <name>] [--json]
9
11
  * chant lock --list [--gate <name>] [--json]
10
12
  * chant lock --alive <run>
11
13
  * chant unlock --pr <n> [<target>...] [--gate <name>] [--json]
@@ -20,6 +22,13 @@
20
22
  * a member is on the resource lock grain (#4552) the report carries
21
23
  * `lockTargets`, its row keys, and those are locked instead.
22
24
  *
25
+ * `--reach` (#4979) locks what a change reaches by the pipeline's reach line
26
+ * in `CHANT_LOCK_REACH`, which prints target names one a line from the
27
+ * change's files read as data (../../lifecycle/reach-locks.ts). chant first
28
+ * fetches the pull request's head and checks it is `--head`. With `--open`
29
+ * (GitLab's plan notes pipeline) every open merge request into the branch is
30
+ * locked, and a holder that is no longer open releases its locks.
31
+ *
23
32
  * `--list` prints the target locks, then the apply rows of the gate's rows
24
33
  * file (#4552, #4594), each with the run that holds it and when it took it.
25
34
  *
@@ -53,8 +62,11 @@ import { CHANT_EXIT } from "../../exit-codes";
53
62
  import { resolve } from "node:path";
54
63
  import type { CommandContext } from "../registry";
55
64
  import { formatError, formatInfo, formatSuccess, formatWarning } from "../format";
56
- import { FORGE_KINDS, forgeFromEnv, type ForgeKind, type PrForge } from "../../pr-forge";
65
+ import { FORGE_KINDS, type ForgeKind, type PrForge } from "../../pr-forge";
66
+ // #4964: a status for a pull_request run's merge preview goes on the pull request's head.
67
+ import { forgeFromJobEnv } from "../../pr-forge-job";
57
68
  import { PR_APPLY_GATE } from "../../pr-loop";
69
+ import { actorFromEnv } from "../../actor";
58
70
  import {
59
71
  describeHeldTargetLocks,
60
72
  readTargetLocks,
@@ -65,6 +77,7 @@ import {
65
77
  TARGET_LOCK_STAGES,
66
78
  type TargetLockStage,
67
79
  } from "../../lifecycle/target-lock";
80
+ import { LOCK_REACH_ENV, reachedTargets, reachOpen } from "../../lifecycle/reach-locks";
68
81
 
69
82
  /** The exit for a target another open pull request holds: `CHANT_EXIT.held`, 5 (#4553). */
70
83
  const HELD_EXIT_CODE = CHANT_EXIT.held;
@@ -93,7 +106,7 @@ function forgeOf(ctx: CommandContext): PrForge | undefined | { error: string } {
93
106
  if (kind === undefined) return undefined;
94
107
  if (!(FORGE_KINDS as readonly string[]).includes(kind)) return { error: `--forge ${kind} is not one of ${FORGE_KINDS.join(", ")}` };
95
108
  try {
96
- return forgeFromEnv(kind as ForgeKind);
109
+ return forgeFromJobEnv(kind as ForgeKind);
97
110
  } catch (err) {
98
111
  return { error: err instanceof Error ? err.message : String(err) };
99
112
  }
@@ -194,13 +207,29 @@ export async function runLock(ctx: CommandContext): Promise<number> {
194
207
  return 0;
195
208
  }
196
209
 
210
+ // #4979: GitLab's lock job, in the target branch's plan notes pipeline, locks what every open merge request reaches.
211
+ if (args.lockReach && args.open) return runReachOpen(ctx, gate);
197
212
  if (args.pr === undefined) return fail("chant lock needs the pull or merge request that holds the locks: --pr <n>", "chant lock --list prints the locks held now.");
198
213
  const stage = (args.lockStage ?? "lock") as TargetLockStage;
199
214
  if (!(TARGET_LOCK_STAGES as readonly string[]).includes(stage)) return fail(`--stage ${args.lockStage} is not one of ${TARGET_LOCK_STAGES.join(", ")}`);
200
215
 
201
216
  let targets = targetsOf(ctx);
202
217
  let head = args.head;
203
- if (args.keepLocks) {
218
+ if (args.lockReach) {
219
+ // #4979: the targets the change reaches, from the pipeline's reach line, after the head is fetched and checked.
220
+ if (targets.length > 0 || args.fromReport || args.keepLocks) return fail("--reach locks what the reach line prints; drop the names, --from-report and --keep");
221
+ const line = process.env[LOCK_REACH_ENV] ?? "";
222
+ if (!line.trim()) return fail(`--reach runs the reach line in ${LOCK_REACH_ENV}, which is not set`, "The generated lock job sets it from the product plan's reach.");
223
+ if (args.forge === undefined || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail("--reach fetches the pull request's head from the forge: give --forge github, gitlab or forgejo");
224
+ if (!head || args.base === undefined) return fail("--reach measures the change from --base <sha> to --head <sha>");
225
+ const reached = reachedTargets({ forge: args.forge as ForgeKind, pr: args.pr, head, base: args.base, line });
226
+ if ("error" in reached) return fail(reached.error);
227
+ if ("moved" in reached) {
228
+ console.error(formatInfo(reached.moved));
229
+ return 0;
230
+ }
231
+ targets = reached.targets;
232
+ } else if (args.keepLocks) {
204
233
  if (targets.length > 0 || args.fromReport) return fail("--keep keeps the locks the pull request holds; drop the names and --from-report");
205
234
  let file;
206
235
  try {
@@ -224,7 +253,7 @@ export async function runLock(ctx: CommandContext): Promise<number> {
224
253
  const forge = forgeOf(ctx);
225
254
  if (forge && "error" in forge) return fail(forge.error);
226
255
  const isOpen = forge?.pullRequestOpen?.bind(forge);
227
- const by = args.by ?? process.env.GITHUB_ACTOR ?? process.env.GITLAB_USER_LOGIN ?? process.env.USER ?? "unknown";
256
+ const by = args.by ?? actorFromEnv();
228
257
  const name = prName(forge);
229
258
 
230
259
  let result;
@@ -261,6 +290,73 @@ export async function runLock(ctx: CommandContext): Promise<number> {
261
290
  return 0;
262
291
  }
263
292
 
293
+ /**
294
+ * `chant lock --reach --open --base <sha> --forge gitlab [--branch <name>]`
295
+ * (#4979): GitLab's lock job, in a pipeline of the target branch. Every
296
+ * open merge request from the project that merges into the branch (default
297
+ * `CI_COMMIT_BRANCH`) takes the locks of what its change reaches, and a
298
+ * holder that is no longer open releases its locks. Exit 3 when another
299
+ * merge request holds what one reaches, 1 when a reach could not be read.
300
+ */
301
+ async function runReachOpen(ctx: CommandContext, gate: string): Promise<number> {
302
+ const { args } = ctx;
303
+ const line = process.env[LOCK_REACH_ENV] ?? "";
304
+ if (!line.trim()) return fail(`--reach runs the reach line in ${LOCK_REACH_ENV}, which is not set`);
305
+ if (args.pr !== undefined || targetsOf(ctx).length > 0) return fail("--open locks every open merge request; drop --pr and the names");
306
+ if (args.base === undefined) return fail("--reach measures each change from --base <sha>, the target branch's commit");
307
+ const stage = (args.lockStage ?? "plan") as TargetLockStage;
308
+ if (!(TARGET_LOCK_STAGES as readonly string[]).includes(stage)) return fail(`--stage ${args.lockStage} is not one of ${TARGET_LOCK_STAGES.join(", ")}`);
309
+ const forge = forgeOf(ctx);
310
+ if (!forge) return fail("--open asks the forge for the open merge requests: give --forge gitlab");
311
+ if ("error" in forge) return fail(forge.error);
312
+ const branch = args.branch ?? process.env.CI_COMMIT_BRANCH ?? "";
313
+ if (!branch) return fail("--open locks the merge requests into one branch: give --branch <name>, or run it in a branch pipeline");
314
+ if (!forge.openPullRequests || !forge.pullRequestOpen) return fail(`the ${forge.kind} client cannot list the open merge requests`);
315
+ const isOpen = forge.pullRequestOpen.bind(forge);
316
+ const name = prName(forge);
317
+ let open;
318
+ try {
319
+ open = await forge.openPullRequests(branch);
320
+ } catch (err) {
321
+ return fail(`could not list the open merge requests into ${branch}: ${err instanceof Error ? err.message : String(err)}`);
322
+ }
323
+ const by = actorFromEnv();
324
+ const { outcomes, released } = await reachOpen({
325
+ forge: forge.kind,
326
+ base: args.base,
327
+ line,
328
+ branch,
329
+ open,
330
+ isOpen,
331
+ take: async (pr, head, targets) => {
332
+ const r = await takeTargetLocks(gate, targets, { pr, by, at: new Date().toISOString(), stage, head }, { isOpen, releaseStalePlan: stage === "plan" });
333
+ if (r.ok) {
334
+ await postStatus(forge, head, "success", r.taken.length > 0 ? `holds ${r.taken.join(", ")}` : "reaches no target");
335
+ return { ok: true, released: r.released };
336
+ }
337
+ await postStatus(forge, head, "failure", `locked by ${[...new Set(r.held.map((h) => h.pr))].map(name).join(", ")}: ${r.held.map((h) => h.target).join(", ")}`);
338
+ return { ok: false, held: `${describeHeldTargetLocks(r.held, name)}, so ${name(pr)} is not locked` };
339
+ },
340
+ holders: async () => [...new Set(Object.values((await readTargetLocks(gate)).locks).map((l) => l.pr))].sort((a, b) => a - b),
341
+ release: async (pr) => (await releaseTargetLocks(gate, pr)).released,
342
+ });
343
+ let code = 0;
344
+ for (const o of outcomes) {
345
+ if (o.kind === "locked") console.error(formatSuccess(`${name(o.pr)} ${o.targets.length > 0 ? `holds ${o.targets.join(", ")}` : "reaches no target"} on ${gate}${o.released.length > 0 ? `; released ${o.released.join(", ")}, which it no longer reaches` : ""}`));
346
+ else if (o.kind === "skipped") console.error(formatInfo(o.text));
347
+ else if (o.kind === "held") {
348
+ console.error(formatError({ message: o.text }));
349
+ if (code === 0) code = HELD_EXIT_CODE;
350
+ } else {
351
+ console.error(formatError({ message: `${name(o.pr)}: ${o.text}` }));
352
+ code = 1;
353
+ }
354
+ }
355
+ for (const r of released) console.error(formatInfo(`${name(r.pr)} is not open, so its locks on ${r.targets.join(", ")} are released`));
356
+ if (args.json) console.log(JSON.stringify({ gate, outcomes, released }, null, 2));
357
+ return code;
358
+ }
359
+
264
360
  /** chant unlock */
265
361
  export async function runUnlock(ctx: CommandContext): Promise<number> {
266
362
  const { args } = ctx;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * `chant components pr-comment --forge github|forgejo` (#4946): the comment
3
+ * job of GitHub's and Forgejo's product pipeline.
4
+ *
5
+ * It reads the `issue_comment` event from `GITHUB_EVENT_PATH`, and the jobs
6
+ * the pipeline has from `CHANT_COMMENT_JOBS` (JSON, written by the
7
+ * generator), and answers the comment when no other job of the pipeline
8
+ * does (`../../ci-comment-commands.ts`): a refusal, a command no job runs,
9
+ * or the re-run of a merged pull request's apply. The words are the
10
+ * product's, as its bin set them.
11
+ *
12
+ * It runs at the target branch's commit with the job's token
13
+ * (`GITHUB_TOKEN`), so none of the change's code runs here, and it loads no
14
+ * plugins.
15
+ */
16
+
17
+ import { readFileSync } from "node:fs";
18
+ import { activeProductWords } from "../../ci-product-words";
19
+ import { answerProductComment, COMMENT_JOBS_ENV, commentRuns, type CommentJobs } from "../../ci-comment-commands";
20
+ import { forgeFromEnv, forgeTargetFromEnv, type PrForge } from "../../pr-forge";
21
+ import { forgeReadsFor } from "../../pr-forge-reads";
22
+ import { formatError, formatInfo } from "../format";
23
+ import type { CommandContext } from "../registry";
24
+
25
+ const fail = (message: string): number => {
26
+ console.error(formatError({ message }));
27
+ return 1;
28
+ };
29
+
30
+ /** The jobs named in {@link COMMENT_JOBS_ENV}: each a boolean, `targets` a list of names, and anything else is refused. */
31
+ export function commentJobsFromEnv(raw: string | undefined): CommentJobs {
32
+ if (raw === undefined || raw.trim() === "") return {};
33
+ const v: unknown = JSON.parse(raw);
34
+ if (typeof v !== "object" || v === null || Array.isArray(v)) throw new Error(`${COMMENT_JOBS_ENV} is a JSON object of the jobs the pipeline has`);
35
+ const known = new Set(["preview", "applyBeforeMerge", "applyOnMerge", "locks", "agent", "commits", "actions", "skipForks", "targets", "noPlanFlags", "waves"]);
36
+ const jobs: Record<string, unknown> = {};
37
+ for (const [k, x] of Object.entries(v)) {
38
+ if (!known.has(k)) throw new Error(`${COMMENT_JOBS_ENV} names ${JSON.stringify(k)}, which is not one of ${[...known].join(", ")}`);
39
+ // #4979: the waves' op and count, for a wave stop on a re-run.
40
+ if (k === "waves") {
41
+ const w = x as { op?: unknown; count?: unknown } | null;
42
+ if (!w || typeof w !== "object" || typeof w.op !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(w.op) || !Number.isInteger(w.count) || (w.count as number) < 1) throw new Error(`${COMMENT_JOBS_ENV}.waves is { op, count }: the waves' op name and how many waves there are`);
43
+ jobs.waves = { op: w.op, count: w.count };
44
+ continue;
45
+ }
46
+ if (k === "targets") {
47
+ if (!Array.isArray(x) || x.some((t) => typeof t !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(t))) throw new Error(`${COMMENT_JOBS_ENV}.targets is a list of target names`);
48
+ if (x.length > 0) jobs.targets = x;
49
+ continue;
50
+ }
51
+ if (typeof x !== "boolean") throw new Error(`${COMMENT_JOBS_ENV}.${k} is true or false`);
52
+ if (x) jobs[k] = true;
53
+ }
54
+ return jobs as CommentJobs;
55
+ }
56
+
57
+ export async function runComponentsPrComment(ctx: CommandContext): Promise<number> {
58
+ const { args } = ctx;
59
+ const kind = args.forge;
60
+ if (kind !== "github" && kind !== "forgejo") return fail("pr-comment answers a GitHub or Forgejo comment: --forge github|forgejo (GitLab's notes are polled by pr-notes)");
61
+ const env = process.env;
62
+ const eventPath = env.GITHUB_EVENT_PATH;
63
+ if (!eventPath) return fail("pr-comment reads the comment from the event file, and GITHUB_EVENT_PATH is not set");
64
+ let event: unknown;
65
+ let jobs: CommentJobs;
66
+ let poster: PrForge;
67
+ let target: ReturnType<typeof forgeTargetFromEnv>;
68
+ try {
69
+ event = JSON.parse(readFileSync(eventPath, "utf8"));
70
+ jobs = commentJobsFromEnv(env[COMMENT_JOBS_ENV]);
71
+ poster = forgeFromEnv(kind, env);
72
+ target = forgeTargetFromEnv(env, { kind });
73
+ } catch (err) {
74
+ return fail(err instanceof Error ? err.message : String(err));
75
+ }
76
+ const repository = (event as { repository?: { default_branch?: unknown } } | null)?.repository;
77
+ const base = args.branch ?? (typeof repository?.default_branch === "string" ? repository.default_branch : undefined);
78
+ if (!base) return fail("pr-comment needs the default branch: --branch <name>, or repository.default_branch in the event");
79
+ const outcome = await answerProductComment({
80
+ forge: kind,
81
+ event,
82
+ repo: target.repo,
83
+ reads: forgeReadsFor(target),
84
+ poster,
85
+ runs: commentRuns({ apiBase: target.apiBase, repo: target.repo, token: target.token }),
86
+ words: activeProductWords(),
87
+ base,
88
+ jobs,
89
+ env,
90
+ // #4979: the wave stop goes on this checkout's chant/lifecycle, which the job pushes with its token.
91
+ ...(jobs.waves
92
+ ? {
93
+ stops: async (op, sha, stop) => {
94
+ const { setWaveStop } = await import("../../op/wave-stop");
95
+ await setWaveStop(op, sha, stop);
96
+ },
97
+ }
98
+ : {}),
99
+ });
100
+ const line = `pr-comment: ${outcome.reason}`;
101
+ if (outcome.fail) return fail(line);
102
+ console.error(formatInfo(line));
103
+ return 0;
104
+ }
@@ -74,11 +74,14 @@ import {
74
74
  import { forgePrEnvPublisher, lifecyclePrEnvPorts } from "../../components/pr-env-ports";
75
75
  import { applyPrSet, type PrPlanSet } from "../../components/pr-run";
76
76
  import { prOp } from "../../pr-loop";
77
- import { FORGE_KINDS, forgeFromEnv, forgePrincipalOf, type ForgeKind, type PrForge } from "../../pr-forge";
77
+ import { FORGE_KINDS, forgePrincipalOf, type ForgeKind, type PrForge } from "../../pr-forge";
78
+ // #4964: a status for a pull_request run's merge preview goes on the pull request's head.
79
+ import { forgeFromJobEnv } from "../../pr-forge-job";
78
80
  import { formatError, formatInfo, formatWarning } from "../format";
79
81
  import { withComponentEndpoint } from "../component-endpoint";
80
82
  import type { CommandContext } from "../registry";
81
83
  import type { Prepared } from "./pr";
84
+ import { actorFromEnv } from "../../actor";
82
85
 
83
86
  const USAGE = "chant components pr-env up --base <ref> --pr <n> [--no-push] | post --pr <n> --head <sha> | down --pr <n> [--reason closed|expired] | sweep";
84
87
 
@@ -102,14 +105,14 @@ function forgeOf(ctx: CommandContext): PrForge | undefined | number {
102
105
  if (kind === undefined || ctx.args.noStatus) return undefined;
103
106
  if (!(FORGE_KINDS as readonly string[]).includes(kind)) return fail(`--forge ${kind} is not one of ${FORGE_KINDS.join(", ")}`);
104
107
  try {
105
- return forgeFromEnv(kind as ForgeKind);
108
+ return forgeFromJobEnv(kind as ForgeKind);
106
109
  } catch (err) {
107
110
  return fail(err instanceof Error ? err.message : String(err));
108
111
  }
109
112
  }
110
113
 
111
114
  function actor(): string {
112
- return process.env.GITHUB_ACTOR || process.env.GITLAB_USER_LOGIN || process.env.USER || "chant";
115
+ return actorFromEnv(process.env, "chant");
113
116
  }
114
117
 
115
118
  function memberOf(ctx: CommandContext): string | undefined {
@@ -14,7 +14,7 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
14
14
  import type { DriverComponent } from "../../components/driver";
15
15
  import type { DeployContext } from "../../components/capability";
16
16
  import type { ParsedArgs } from "../registry";
17
- import { prStatusState } from "../../pr-loop";
17
+ import { prStatusState } from "../../pr-status";
18
18
 
19
19
  const HEAD = "a".repeat(40);
20
20
  const BASE = "b".repeat(40);