@intentius/chant 0.124.88 → 0.124.90

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 (377) hide show
  1. package/dist/actor.d.ts +36 -1
  2. package/dist/actor.d.ts.map +1 -1
  3. package/dist/actor.js +39 -1
  4. package/dist/chant-install.d.ts.map +1 -1
  5. package/dist/chant-install.js +1 -2
  6. package/dist/ci-base.d.ts +30 -0
  7. package/dist/ci-base.d.ts.map +1 -0
  8. package/dist/ci-base.js +33 -0
  9. package/dist/ci-comment-commands.d.ts +193 -0
  10. package/dist/ci-comment-commands.d.ts.map +1 -0
  11. package/dist/ci-comment-commands.js +353 -0
  12. package/dist/ci-comment-replies.d.ts +40 -0
  13. package/dist/ci-comment-replies.d.ts.map +1 -0
  14. package/dist/ci-comment-replies.js +59 -0
  15. package/dist/ci-evidence-from-job.d.ts +25 -0
  16. package/dist/ci-evidence-from-job.d.ts.map +1 -1
  17. package/dist/ci-evidence-from-job.js +43 -2
  18. package/dist/ci-evidence-jobs.d.ts +30 -1
  19. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  20. package/dist/ci-evidence-jobs.js +46 -3
  21. package/dist/ci-image.d.ts +21 -4
  22. package/dist/ci-image.d.ts.map +1 -1
  23. package/dist/ci-image.js +62 -10
  24. package/dist/ci-job-guard.d.ts +42 -45
  25. package/dist/ci-job-guard.d.ts.map +1 -1
  26. package/dist/ci-job-guard.js +206 -3
  27. package/dist/ci-note-commands.d.ts +104 -4
  28. package/dist/ci-note-commands.d.ts.map +1 -1
  29. package/dist/ci-note-commands.js +131 -38
  30. package/dist/ci-product-words.d.ts +42 -0
  31. package/dist/ci-product-words.d.ts.map +1 -1
  32. package/dist/ci-product-words.js +25 -0
  33. package/dist/ci-product.d.ts +72 -1
  34. package/dist/ci-product.d.ts.map +1 -1
  35. package/dist/ci-product.js +73 -6
  36. package/dist/cli/commands/build.d.ts.map +1 -1
  37. package/dist/cli/commands/build.js +29 -2
  38. package/dist/cli/handlers/approve.d.ts.map +1 -1
  39. package/dist/cli/handlers/approve.js +2 -1
  40. package/dist/cli/handlers/ci-check.d.ts +1 -1
  41. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  42. package/dist/cli/handlers/ci-check.js +17 -7
  43. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  44. package/dist/cli/handlers/ci-evidence.js +33 -7
  45. package/dist/cli/handlers/components.d.ts.map +1 -1
  46. package/dist/cli/handlers/components.js +3 -1
  47. package/dist/cli/handlers/generated-check.d.ts +8 -0
  48. package/dist/cli/handlers/generated-check.d.ts.map +1 -1
  49. package/dist/cli/handlers/generated-check.js +31 -1
  50. package/dist/cli/handlers/lock.d.ts.map +1 -1
  51. package/dist/cli/handlers/lock.js +121 -4
  52. package/dist/cli/handlers/pr-comment.d.ts +33 -0
  53. package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
  54. package/dist/cli/handlers/pr-comment.js +201 -0
  55. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  56. package/dist/cli/handlers/pr-env.js +6 -3
  57. package/dist/cli/handlers/pr-notes.d.ts.map +1 -1
  58. package/dist/cli/handlers/pr-notes.js +23 -1
  59. package/dist/cli/handlers/pr.d.ts +23 -1
  60. package/dist/cli/handlers/pr.d.ts.map +1 -1
  61. package/dist/cli/handlers/pr.js +71 -23
  62. package/dist/cli/handlers/promote.d.ts.map +1 -1
  63. package/dist/cli/handlers/promote.js +2 -1
  64. package/dist/cli/handlers/release.d.ts.map +1 -1
  65. package/dist/cli/handlers/release.js +11 -2
  66. package/dist/cli/handlers/run-wave.d.ts.map +1 -1
  67. package/dist/cli/handlers/run-wave.js +180 -4
  68. package/dist/cli/handlers/run.d.ts.map +1 -1
  69. package/dist/cli/handlers/run.js +2 -1
  70. package/dist/cli/main.d.ts.map +1 -1
  71. package/dist/cli/main.js +41 -2
  72. package/dist/cli/parse-args.d.ts.map +1 -1
  73. package/dist/cli/parse-args.js +31 -0
  74. package/dist/cli/registry.d.ts +19 -1
  75. package/dist/cli/registry.d.ts.map +1 -1
  76. package/dist/components/auto-release.d.ts.map +1 -1
  77. package/dist/components/auto-release.js +2 -1
  78. package/dist/components/pr-checks.d.ts +97 -6
  79. package/dist/components/pr-checks.d.ts.map +1 -1
  80. package/dist/components/pr-checks.js +107 -13
  81. package/dist/components/pr-pipeline.d.ts +19 -14
  82. package/dist/components/pr-pipeline.d.ts.map +1 -1
  83. package/dist/components/pr-pipeline.js +7 -13
  84. package/dist/components/product-pipeline.d.ts +96 -3
  85. package/dist/components/product-pipeline.d.ts.map +1 -1
  86. package/dist/components/product-pipeline.js +120 -14
  87. package/dist/components/product-plan.d.ts +203 -6
  88. package/dist/components/product-plan.d.ts.map +1 -1
  89. package/dist/components/product-plan.js +250 -43
  90. package/dist/drift-record.d.ts +7 -0
  91. package/dist/drift-record.d.ts.map +1 -1
  92. package/dist/drift-record.js +19 -0
  93. package/dist/floor-table.data.d.ts.map +1 -1
  94. package/dist/floor-table.data.js +63 -31
  95. package/dist/forge-check/contract.d.ts +11 -1
  96. package/dist/forge-check/contract.d.ts.map +1 -1
  97. package/dist/forge-check/contract.js +4 -1
  98. package/dist/forge-check/index.d.ts +2 -0
  99. package/dist/forge-check/index.d.ts.map +1 -1
  100. package/dist/forge-check/index.js +2 -0
  101. package/dist/gate-resume-run.d.ts +9 -1
  102. package/dist/gate-resume-run.d.ts.map +1 -1
  103. package/dist/gate-resume-run.js +26 -3
  104. package/dist/generated-check.d.ts +18 -4
  105. package/dist/generated-check.d.ts.map +1 -1
  106. package/dist/generated-check.js +37 -5
  107. package/dist/image-pins.d.ts +26 -0
  108. package/dist/image-pins.d.ts.map +1 -0
  109. package/dist/image-pins.js +19 -0
  110. package/dist/lexicon.d.ts +93 -4
  111. package/dist/lexicon.d.ts.map +1 -1
  112. package/dist/lifecycle/gate-applied.d.ts +9 -0
  113. package/dist/lifecycle/gate-applied.d.ts.map +1 -1
  114. package/dist/lifecycle/git.d.ts +11 -0
  115. package/dist/lifecycle/git.d.ts.map +1 -1
  116. package/dist/lifecycle/git.js +30 -3
  117. package/dist/lifecycle/publish-npm.d.ts +11 -0
  118. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  119. package/dist/lifecycle/publish-npm.js +27 -1
  120. package/dist/lifecycle/reach-locks.d.ts +131 -0
  121. package/dist/lifecycle/reach-locks.d.ts.map +1 -0
  122. package/dist/lifecycle/reach-locks.js +118 -0
  123. package/dist/lifecycle/release-cut.d.ts +3 -1
  124. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  125. package/dist/lifecycle/release-cut.js +15 -0
  126. package/dist/lifecycle/release-images.d.ts.map +1 -1
  127. package/dist/lifecycle/release-images.js +1 -2
  128. package/dist/notify-product.d.ts +12 -3
  129. package/dist/notify-product.d.ts.map +1 -1
  130. package/dist/notify-product.js +10 -6
  131. package/dist/op/activities/source-release.d.ts.map +1 -1
  132. package/dist/op/activities/source-release.js +2 -1
  133. package/dist/op/activities/source-rollback.d.ts.map +1 -1
  134. package/dist/op/activities/source-rollback.js +2 -1
  135. package/dist/op/apply-status.d.ts +84 -0
  136. package/dist/op/apply-status.d.ts.map +1 -0
  137. package/dist/op/apply-status.js +106 -0
  138. package/dist/op/before-merge-decide.d.ts +102 -0
  139. package/dist/op/before-merge-decide.d.ts.map +1 -0
  140. package/dist/op/before-merge-decide.js +142 -0
  141. package/dist/op/before-merge-done.d.ts +56 -0
  142. package/dist/op/before-merge-done.d.ts.map +1 -0
  143. package/dist/op/before-merge-done.js +69 -0
  144. package/dist/op/before-merge-store.d.ts +20 -0
  145. package/dist/op/before-merge-store.d.ts.map +1 -0
  146. package/dist/op/before-merge-store.js +48 -0
  147. package/dist/op/before-merge.d.ts +150 -0
  148. package/dist/op/before-merge.d.ts.map +1 -0
  149. package/dist/op/before-merge.js +207 -0
  150. package/dist/op/follow-on-run.d.ts +117 -0
  151. package/dist/op/follow-on-run.d.ts.map +1 -0
  152. package/dist/op/follow-on-run.js +154 -0
  153. package/dist/op/follow-on-store.d.ts +17 -0
  154. package/dist/op/follow-on-store.d.ts.map +1 -0
  155. package/dist/op/follow-on-store.js +54 -0
  156. package/dist/op/gate.d.ts +6 -0
  157. package/dist/op/gate.d.ts.map +1 -1
  158. package/dist/op/gate.js +10 -1
  159. package/dist/op/index.d.ts +5 -1
  160. package/dist/op/index.d.ts.map +1 -1
  161. package/dist/op/index.js +2 -0
  162. package/dist/op/op-waves-after-plan.d.ts +13 -0
  163. package/dist/op/op-waves-after-plan.d.ts.map +1 -1
  164. package/dist/op/op-waves-evidence-jobs.d.ts +10 -2
  165. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
  166. package/dist/op/op-waves-evidence-jobs.js +19 -5
  167. package/dist/op/op-waves-follow-on.d.ts +162 -0
  168. package/dist/op/op-waves-follow-on.d.ts.map +1 -0
  169. package/dist/op/op-waves-follow-on.js +355 -0
  170. package/dist/op/op-waves-render-spec.d.ts +100 -0
  171. package/dist/op/op-waves-render-spec.d.ts.map +1 -0
  172. package/dist/op/op-waves-render-spec.js +162 -0
  173. package/dist/op/op-waves-run.d.ts +148 -6
  174. package/dist/op/op-waves-run.d.ts.map +1 -1
  175. package/dist/op/op-waves-run.js +873 -100
  176. package/dist/op/op-waves-split.d.ts +122 -0
  177. package/dist/op/op-waves-split.d.ts.map +1 -0
  178. package/dist/op/op-waves-split.js +166 -0
  179. package/dist/op/op-waves.d.ts +24 -0
  180. package/dist/op/op-waves.d.ts.map +1 -1
  181. package/dist/op/op-waves.js +18 -1
  182. package/dist/op/schedule-overdue.d.ts +15 -1
  183. package/dist/op/schedule-overdue.d.ts.map +1 -1
  184. package/dist/op/schedule-overdue.js +77 -5
  185. package/dist/op/stage-hooks.d.ts +36 -1
  186. package/dist/op/stage-hooks.d.ts.map +1 -1
  187. package/dist/op/stage-hooks.js +17 -3
  188. package/dist/op/wave-stop.d.ts +67 -0
  189. package/dist/op/wave-stop.d.ts.map +1 -0
  190. package/dist/op/wave-stop.js +129 -0
  191. package/dist/planned-files.d.ts +76 -0
  192. package/dist/planned-files.d.ts.map +1 -0
  193. package/dist/planned-files.js +108 -0
  194. package/dist/pr-forge-job.d.ts +22 -0
  195. package/dist/pr-forge-job.d.ts.map +1 -0
  196. package/dist/pr-forge-job.js +46 -0
  197. package/dist/pr-loop.d.ts +3 -6
  198. package/dist/pr-loop.d.ts.map +1 -1
  199. package/dist/pr-loop.js +4 -81
  200. package/dist/pr-plan-note.d.ts +97 -0
  201. package/dist/pr-plan-note.d.ts.map +1 -1
  202. package/dist/pr-plan-note.js +94 -1
  203. package/dist/pr-post.d.ts +28 -3
  204. package/dist/pr-post.d.ts.map +1 -1
  205. package/dist/pr-post.js +146 -13
  206. package/dist/pr-status.d.ts +16 -0
  207. package/dist/pr-status.d.ts.map +1 -0
  208. package/dist/pr-status.js +90 -0
  209. package/dist/ref-gate-init.d.ts +16 -2
  210. package/dist/ref-gate-init.d.ts.map +1 -1
  211. package/dist/ref-gate-init.js +24 -13
  212. package/dist/release-floors.d.ts +39 -1
  213. package/dist/release-floors.d.ts.map +1 -1
  214. package/dist/release-floors.js +63 -25
  215. package/dist/render-module.d.ts +15 -0
  216. package/dist/render-module.d.ts.map +1 -0
  217. package/dist/render-module.js +73 -0
  218. package/dist/state-migration.d.ts.map +1 -1
  219. package/dist/state-migration.js +1 -2
  220. package/dist/wave-blocked.d.ts +7 -1
  221. package/dist/wave-blocked.d.ts.map +1 -1
  222. package/dist/wave-blocked.js +7 -2
  223. package/dist/wave-runtime.mjs +366 -350
  224. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  225. package/dist/workspace/ci-green-cli.js +3 -2
  226. package/dist/workspace/release-train.d.ts.map +1 -1
  227. package/dist/workspace/release-train.js +2 -1
  228. package/dist/workspace/release-workflow.d.ts +4 -3
  229. package/dist/workspace/release-workflow.d.ts.map +1 -1
  230. package/dist/workspace/release-workflow.js +10 -7
  231. package/dist/workspace/trust/check-evidence-report.d.ts +7 -2
  232. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  233. package/dist/workspace/trust/check-evidence-report.js +15 -8
  234. package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
  235. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  236. package/dist/workspace/trust/ref-gate-cli.js +30 -10
  237. package/dist/workspace/workspace-run.d.ts.map +1 -1
  238. package/dist/workspace/workspace-run.js +2 -1
  239. package/package.json +1 -1
  240. package/src/actor.test.ts +68 -2
  241. package/src/actor.ts +61 -1
  242. package/src/chant-install.test.ts +2 -3
  243. package/src/chant-install.ts +1 -2
  244. package/src/ci-base.test.ts +41 -0
  245. package/src/ci-base.ts +43 -0
  246. package/src/ci-comment-commands.test.ts +439 -0
  247. package/src/ci-comment-commands.ts +428 -0
  248. package/src/ci-comment-replies.ts +78 -0
  249. package/src/ci-commit.test.ts +2 -3
  250. package/src/ci-evidence-from-job.test.ts +18 -0
  251. package/src/ci-evidence-from-job.ts +58 -2
  252. package/src/ci-evidence-jobs.ts +50 -5
  253. package/src/ci-image.test.ts +130 -10
  254. package/src/ci-image.ts +85 -12
  255. package/src/ci-job-guard.before-merge.test.ts +148 -0
  256. package/src/ci-job-guard.follow-on-record.test.ts +137 -0
  257. package/src/ci-job-guard.follow-on.test.ts +144 -0
  258. package/src/ci-job-guard.ts +221 -3
  259. package/src/ci-note-commands.test.ts +76 -1
  260. package/src/ci-note-commands.ts +198 -46
  261. package/src/ci-product-words.ts +59 -0
  262. package/src/ci-product.ts +90 -6
  263. package/src/cli/commands/build.test.ts +41 -0
  264. package/src/cli/commands/build.ts +27 -2
  265. package/src/cli/handlers/approve.ts +2 -1
  266. package/src/cli/handlers/ci-check.ts +19 -7
  267. package/src/cli/handlers/ci-evidence.ts +29 -8
  268. package/src/cli/handlers/components.ts +3 -1
  269. package/src/cli/handlers/generated-check.ts +31 -1
  270. package/src/cli/handlers/lock-reach.test.ts +103 -0
  271. package/src/cli/handlers/lock.ts +100 -4
  272. package/src/cli/handlers/pr-comment.ts +187 -0
  273. package/src/cli/handlers/pr-env.ts +6 -3
  274. package/src/cli/handlers/pr-notes.ts +30 -6
  275. package/src/cli/handlers/pr-record.test.ts +1 -1
  276. package/src/cli/handlers/pr.ts +64 -21
  277. package/src/cli/handlers/promote.ts +2 -1
  278. package/src/cli/handlers/release.e2e.test.ts +35 -0
  279. package/src/cli/handlers/release.ts +14 -2
  280. package/src/cli/handlers/run-wave.ts +170 -4
  281. package/src/cli/handlers/run.ts +2 -1
  282. package/src/cli/main.ts +41 -2
  283. package/src/cli/parse-args.ts +23 -0
  284. package/src/cli/registry.ts +19 -1
  285. package/src/components/auto-release.ts +2 -1
  286. package/src/components/pr-checks.ts +165 -17
  287. package/src/components/pr-pipeline.ts +22 -18
  288. package/src/components/product-pipeline.apply-status.test.ts +50 -0
  289. package/src/components/product-pipeline.ts +204 -17
  290. package/src/components/product-plan.test.ts +60 -4
  291. package/src/components/product-plan.ts +367 -50
  292. package/src/drift-record.test.ts +20 -0
  293. package/src/drift-record.ts +16 -0
  294. package/src/floor-table.data.ts +63 -31
  295. package/src/forge-check/contract.ts +12 -1
  296. package/src/forge-check/forge-check.test.ts +17 -0
  297. package/src/forge-check/index.ts +2 -0
  298. package/src/gate-resume-run.ts +27 -3
  299. package/src/generated-check.e2e.test.ts +21 -1
  300. package/src/generated-check.test.ts +66 -0
  301. package/src/generated-check.ts +51 -10
  302. package/src/image-pins.ts +31 -0
  303. package/src/lexicon.ts +89 -1
  304. package/src/lifecycle/gate-applied.ts +7 -0
  305. package/src/lifecycle/git.test.ts +48 -0
  306. package/src/lifecycle/git.ts +27 -4
  307. package/src/lifecycle/publish-npm.ts +31 -1
  308. package/src/lifecycle/reach-locks.test.ts +87 -0
  309. package/src/lifecycle/reach-locks.ts +169 -0
  310. package/src/lifecycle/release-cut.ts +17 -1
  311. package/src/lifecycle/release-images.test.ts +56 -0
  312. package/src/lifecycle/release-images.ts +1 -2
  313. package/src/notify-product.ts +19 -8
  314. package/src/op/activities/source-release.ts +2 -1
  315. package/src/op/activities/source-rollback.ts +2 -1
  316. package/src/op/apply-status.test.ts +83 -0
  317. package/src/op/apply-status.ts +132 -0
  318. package/src/op/before-merge-decide.ts +190 -0
  319. package/src/op/before-merge-done.ts +99 -0
  320. package/src/op/before-merge-store.ts +44 -0
  321. package/src/op/before-merge.test.ts +201 -0
  322. package/src/op/before-merge.ts +266 -0
  323. package/src/op/follow-on-run.ts +206 -0
  324. package/src/op/follow-on-store.ts +54 -0
  325. package/src/op/gate-resume.test.ts +27 -0
  326. package/src/op/gate.ts +16 -1
  327. package/src/op/index.ts +15 -0
  328. package/src/op/op-waves-after-plan.ts +13 -0
  329. package/src/op/op-waves-evidence-jobs.ts +21 -7
  330. package/src/op/op-waves-follow-on-record.test.ts +152 -0
  331. package/src/op/op-waves-follow-on.test.ts +247 -0
  332. package/src/op/op-waves-follow-on.ts +385 -0
  333. package/src/op/op-waves-notify-words.test.ts +18 -0
  334. package/src/op/op-waves-render-spec.test.ts +159 -0
  335. package/src/op/op-waves-render-spec.ts +171 -0
  336. package/src/op/op-waves-run.ts +973 -94
  337. package/src/op/op-waves-split-product.test.ts +288 -0
  338. package/src/op/op-waves-split-step.test.ts +298 -0
  339. package/src/op/op-waves-split.test.ts +196 -0
  340. package/src/op/op-waves-split.ts +189 -0
  341. package/src/op/op-waves.ts +31 -3
  342. package/src/op/schedule-overdue.test.ts +72 -1
  343. package/src/op/schedule-overdue.ts +84 -6
  344. package/src/op/stage-hooks.ts +52 -4
  345. package/src/op/wave-stop.test.ts +72 -0
  346. package/src/op/wave-stop.ts +139 -0
  347. package/src/planned-files.test.ts +80 -0
  348. package/src/planned-files.ts +134 -0
  349. package/src/pr-forge-job.test.ts +53 -0
  350. package/src/pr-forge-job.ts +46 -0
  351. package/src/pr-loop-narrowed.test.ts +2 -1
  352. package/src/pr-loop-words.test.ts +2 -1
  353. package/src/pr-loop.test.ts +1 -2
  354. package/src/pr-loop.ts +4 -80
  355. package/src/pr-plan-note.ts +155 -3
  356. package/src/pr-post-replan.test.ts +144 -0
  357. package/src/pr-post-subject.test.ts +230 -0
  358. package/src/pr-post.test.ts +2 -1
  359. package/src/pr-post.ts +151 -15
  360. package/src/pr-status.ts +91 -0
  361. package/src/ref-gate-init.ts +30 -11
  362. package/src/release-floors.ts +81 -25
  363. package/src/render-module.ts +73 -0
  364. package/src/state-migration-record.test.ts +2 -3
  365. package/src/state-migration.ts +1 -2
  366. package/src/wave-blocked.ts +9 -4
  367. package/src/workspace/ci-green-cli.ts +3 -2
  368. package/src/workspace/ci-green-workflow.test.ts +32 -1
  369. package/src/workspace/release-train.ts +2 -1
  370. package/src/workspace/release-workflow.test.ts +36 -5
  371. package/src/workspace/release-workflow.ts +10 -7
  372. package/src/workspace/trust/check-evidence-report.ts +15 -8
  373. package/src/workspace/trust/check-evidence.test.ts +5 -0
  374. package/src/workspace/trust/ref-gate-cli.ts +30 -8
  375. package/src/workspace/trust/ref-gate-pieces.test.ts +46 -1
  376. package/src/workspace/trust/ref-gate.test.ts +10 -0
  377. package/src/workspace/workspace-run.ts +2 -1
@@ -28,23 +28,30 @@ import { controlNoteCheckout, type ControlNoteCheckout } from "../control/dispat
28
28
  import {
29
29
  assertProductWords,
30
30
  CHANT_WORDS,
31
+ CI_PRODUCT_COMMANDS,
31
32
  commentLine,
33
+ productStatusContext,
32
34
  type CiProductApplyMode,
33
35
  type CiProductCommand,
34
36
  type CiProductWords,
35
37
  type CiProductWordsInput,
36
38
  } from "../ci-product-words";
37
- import { prActionJob, prCommentLockJobs, prCommentPreviewJob, prLoopJobs, prLoopPostJob, prLoopRunner, prNoteCommandsJob, prStaleJob, withProductBin, type PrActionJob, type PrCommentLockJob, type PrCommentPreviewJob, type PrLoopJob, type PrLoopPipelineOptions } from "./pr-pipeline";
39
+ import { checkJobOptions, PR_LOOP_REPORT_DIR, prActionJob, prCommentLockJobs, prCommentPreviewJob, prLoopJobs, prLoopPostJob, prLoopRunner, prNoteCommandsJob, prStaleJob, withProductBin, type PrActionJob, type PrCommentLockJob, type PrCommentPreviewJob, type PrLoopJob, type PrLoopPipelineOptions } from "./pr-pipeline";
38
40
  import type { DriverComponent } from "./driver";
39
- import type { ScheduledOpSpec } from "../lexicon";
41
+ import type { OpWavesPipelineOptions, ScheduledOpSpec } from "../lexicon";
40
42
  import type { CiRunner } from "../ci-jobs";
41
43
  import { resolveAgentSpec, type OpAgentSpec } from "../ci-agent";
42
44
  import { resolveCommitSpec, type OpCommitSpec } from "../ci-commit";
43
45
  import type { CiResponses } from "../ci-respond";
44
- import { planEvidenceOf, productPlanJobs, type ProductPlanJob, type ProductPlanOptions } from "./product-plan";
46
+ import { planEvidenceOf, productPlanJobs, productPlanReachLock, type ProductPlanJob, type ProductPlanOptions, type ProductPlanReachLock } from "./product-plan";
45
47
  import { gitlabOpenEvidenceDir, type PipelineEvidence } from "../ci-evidence-jobs";
46
48
  import { prCheckJob, prRefGateJob, type PrCheckJob, type PrRefGateJob } from "./pr-checks";
47
- import { assertRootChecks } from "./pr-pipeline";
49
+ import { COMMENT_JOBS_ENV, PR_COMMENT_JOB, type CommentJobs } from "../ci-comment-commands";
50
+ import { GITHUB_JOB_TOKEN } from "../ci-jobs";
51
+ import type { OpWavesBeforeMerge } from "../op/before-merge";
52
+ import { defaultPipelineFiles, type WavesBeforeMergeJobs } from "../op/before-merge-decide";
53
+ import type { PrApplyRequire } from "../pr-requires";
54
+ import { LOCK_REACH_ENV } from "../lifecycle/reach-locks";
48
55
 
49
56
  /** Where the generator writes a product's waves spec, which chant reads at base (#4550). */
50
57
  export const PRODUCT_WAVES_SPEC_DIR = ".chant/op-waves";
@@ -134,6 +141,68 @@ export interface ProductPipelineOptions extends Omit<PrLoopPipelineOptions, "wor
134
141
  * Absent: nothing is signed, and the jobs are as before.
135
142
  */
136
143
  evidence?: PipelineEvidence;
144
+ /**
145
+ * The comment job (#4946), GitHub and Forgejo: one job on every
146
+ * `/<product>` comment (and every alias's) that answers what no other job
147
+ * of the pipeline takes, with `chant components pr-comment`: a refusal,
148
+ * a command the pipeline has no job for (the words' `replies`, else
149
+ * chant's), and with waves on merge the re-run of a merged pull request's
150
+ * apply. The jobs it leaves comments to are the ones these options write.
151
+ * On GitLab the note-commands job answers every note already; refused
152
+ * there.
153
+ */
154
+ commentJob?: boolean;
155
+ /**
156
+ * Waves before merge (#4984, maintainer decision 2026-11-10): `/<product>
157
+ * apply [wave-<n>]` on an open pull request runs the waves on its head.
158
+ * The comment job (GitHub, Forgejo; needs `commentJob`) or the note poll
159
+ * (GitLab; needs `noteCommands`) decides it by the product plan's rules
160
+ * (../op/before-merge-decide.ts): this repository's pull request into the
161
+ * default branch, its head unmoved, `requires` met, every plan status
162
+ * passed on the head, none of `pipelineFiles` touched, and with the
163
+ * product plan's `reach` the locks at stage apply. It records the head
164
+ * and the decision's digest on `chant/lifecycle` and starts the waves
165
+ * workflow for it, whose guard admits that head alone. After the last
166
+ * wave, `merge: "auto"` merges the pull request at that head and releases
167
+ * its locks. Needs `waves` (or `componentWaves`).
168
+ */
169
+ wavesBeforeMerge?: ProductWavesBeforeMerge;
170
+ /**
171
+ * The apply statuses (#4987): the waves workflow posts `<product>/apply`
172
+ * (`<product>/apply/<member>` for a member) on the commit the waves
173
+ * applied, from a job after each wave that runs none of the change's
174
+ * code (`@intentius/chant/op/apply-status`): pending after each wave,
175
+ * success after the last, failed when a run failed. Needs `waves` (or
176
+ * `componentWaves`); the product passes `waves.pipeline` on when it
177
+ * renders them.
178
+ */
179
+ applyStatus?: boolean;
180
+ }
181
+
182
+ /** {@link ProductPipelineOptions.wavesBeforeMerge} (#4984). */
183
+ export interface ProductWavesBeforeMerge {
184
+ /** The requires the forge is asked before the apply (`apply.requires`). Default every one: approved, mergeable, undiverged, checks. */
185
+ requires?: PrApplyRequire[];
186
+ /** `auto`: merge after the last wave, and release the locks. `manual` (default): reply that it is ready. */
187
+ merge?: "auto" | "manual";
188
+ /** The merge token's secret or CI/CD variable, with `merge: "auto"` (needed on Forgejo and GitLab). */
189
+ mergeTokenSecret?: string;
190
+ /** Paths a change may not touch to apply before merge; one ending in `/` is a directory. Default the forge's workflow directory and `.chant/op-waves/`. */
191
+ pipelineFiles?: string[];
192
+ }
193
+
194
+ /** The comment job (#4946): its command, the values it reads, and the comment prefixes that start it. */
195
+ export interface ProductCommentJob {
196
+ jobName: typeof PR_COMMENT_JOB;
197
+ /** `<bin> components pr-comment --forge <forge>`. */
198
+ command: string;
199
+ /** `GITHUB_TOKEN` and {@link COMMENT_JOBS_ENV}. */
200
+ env: Record<string, string>;
201
+ /** What a comment starts with for the job to start: `/<product>`, then each alias. */
202
+ prefixes: string[];
203
+ /** The jobs it leaves comments to. */
204
+ jobs: CommentJobs;
205
+ runner?: CiRunner;
137
206
  }
138
207
 
139
208
  /** The jobs of one product pipeline. */
@@ -156,8 +225,25 @@ export interface ProductPipelineJobs {
156
225
  applyBeforeMerge?: PrLoopJob;
157
226
  /** The comment each command answers, `/<product> <word>`, for the commands the pipeline has a job for. */
158
227
  comments: Partial<Record<CiProductCommand, string>>;
159
- /** The apply on merge: the spec with the words' names, its file, and a job per wave (per share or group). */
160
- waves?: { spec: OpWavesSpec; specFile: string; jobs: OpWaveJob[] };
228
+ /**
229
+ * The apply on merge: the spec with the words' names, its file, and a job
230
+ * per wave (per share or group). With `wavesBeforeMerge` (#4984),
231
+ * `beforeMerge` is the generators' `OpWavesPipelineOptions.beforeMerge`:
232
+ * the product passes it on when it renders the waves.
233
+ */
234
+ waves?: {
235
+ spec: OpWavesSpec;
236
+ specFile: string;
237
+ jobs: OpWaveJob[];
238
+ beforeMerge?: OpWavesBeforeMerge;
239
+ /**
240
+ * What the generators take from the pipeline (#4987): `beforeMerge`,
241
+ * `applyStatus` and, with `staleNotes`, the stale marking job that runs
242
+ * beside wave 1 on a push (one `--member` per product plan target). The
243
+ * product spreads it into the `OpWavesPipelineOptions` it renders with.
244
+ */
245
+ pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes">;
246
+ };
161
247
  /**
162
248
  * The comment lock and unlock jobs (#4588), under `locks: "plan"`:
163
249
  * `/<product> lock` keeps the locks the plan took, `/<product> unlock`
@@ -185,7 +271,7 @@ export interface ProductPipelineJobs {
185
271
  * lexicon renders the same job from `chant build --pr-loop
186
272
  * --note-commands`. Refused on GitHub and Forgejo.
187
273
  */
188
- noteCommands?: { command: string; runner?: CiRunner };
274
+ noteCommands?: { command: string; runner?: CiRunner; env?: Record<string, string> };
189
275
  /**
190
276
  * The agent (#4616), with `agent`: the comment it answers, `/<product>
191
277
  * agent <ask>`, and the scheduled Op spec whose generated workflow runs
@@ -212,6 +298,14 @@ export interface ProductPipelineJobs {
212
298
  check?: PrCheckJob & { runner?: CiRunner; evidenceRunner?: CiRunner };
213
299
  /** The ref gate's status job (#4935), with `refGateStatus` (./pr-checks.ts). */
214
300
  refGate?: PrRefGateJob & { runner?: CiRunner };
301
+ /** The comment job (#4946), with `commentJob`. */
302
+ comment?: ProductCommentJob;
303
+ /**
304
+ * The reach lock job (#4979), with `locks: "plan"` and the product plan's
305
+ * `reach`: `chant lock --reach`, in place of the lock jobs that read a
306
+ * `PrReport`. The forge lexicons render it.
307
+ */
308
+ reachLock?: ProductPlanReachLock;
215
309
  }
216
310
 
217
311
  /** An agent's settings as a product passes them (#4616): {@link OpAgentSpec} without the trigger, which the pipeline names. */
@@ -313,11 +407,12 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
313
407
  // Words that ask for before-merge keep it when the pipeline has that job beside its waves.
314
408
  const built: CiProductApplyMode = options.waves || options.componentWaves ? "on-merge" : options.applyBeforeMerge ? "before-merge" : "release";
315
409
  const applyMode: CiProductApplyMode = options.words.applyMode === "before-merge" && options.applyBeforeMerge ? "before-merge" : built;
316
- const words = assertProductWords({ ...options.words, applyMode }, { jobs });
317
- const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, ...loop } = options;
410
+ // #4946: the comment job answers every command but a commit word (the commit job's) with a reply, so the words may name any.
411
+ const answered: CiProductCommand[] = options.commentJob ? [...new Set<CiProductCommand>([...jobs, ...CI_PRODUCT_COMMANDS.filter((c) => c !== "commit")])] : jobs;
412
+ const words = assertProductWords({ ...options.words, applyMode }, { jobs: answered });
413
+ const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, commentJob: _commentJob, wavesBeforeMerge, applyStatus: _applyStatus, ...loop } = options;
414
+ if (options.applyStatus && !given && !componentWaves) throw new Error("applyStatus posts the waves' apply statuses, and there are none: give waves (or componentWaves)");
318
415
  const { respond } = options;
319
- // #4935: the check job and the ref gate's status judge the commit once, from the root pipeline.
320
- assertRootChecks({ checkJob: options.checkJob, refGateStatus: options.refGateStatus }, member);
321
416
  // #4629: the pull request loop puts the responses on the apply and note jobs, as `chant build --pr-loop --respond` does.
322
417
  const prLoop: PrLoopPipelineOptions = { ...loop, words, gate: options.gate ?? words.prGate };
323
418
  const [plan, apply, record] = prLoopJobs(forge, env, prLoop, member);
@@ -337,24 +432,34 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
337
432
  const out: ProductPipelineJobs = {
338
433
  words,
339
434
  plan: plan!,
340
- // #4870: the note job signs the plan job's plan and policy checks before it posts.
341
- post: { ...post, ...(controlTarget ? { control: controlNoteCheckout(forge, controlTarget, words) } : {}), ...defaultRunner, ...(evidence ? { evidence: planEvidenceOf(forge, evidence, words, plan!.jobName) } : {}) },
435
+ // #4870: the note job signs the plan job's plan and policy checks before it posts; #4964: a member's under its name.
436
+ post: { ...post, ...(controlTarget ? { control: controlNoteCheckout(forge, controlTarget, words) } : {}), ...defaultRunner, ...(evidence ? { evidence: planEvidenceOf(forge, evidence, words, plan!.jobName, member ? { member: { name: member, reportPath: PR_LOOP_REPORT_DIR } } : {}) } : {}) },
342
437
  comments,
343
438
  ...(options.applyBeforeMerge ? { applyBeforeMerge: apply! } : {}),
344
439
  // #4799: the product's plan verb, a plan job and a note job per target.
345
440
  ...(productPlan ? { productPlan: productPlanJobs(forge, env, { ...prLoop, plan: productPlan }, words, evidence) } : {}),
346
441
  };
347
442
  // #4935: the check job runs the change's code on the plan runner; the signing and the status run on the default one.
348
- if (options.checkJob) {
443
+ // #4964: with the product's own services, variables, lines and report directory.
444
+ const checkOptions = checkJobOptions(options.checkJob);
445
+ if (checkOptions) {
349
446
  const planRunner = prLoopRunner(options, "plan");
350
- out.check = { ...prCheckJob(forge, { ...(words.bin ? { bin: words.bin } : {}), ...(evidence ? { evidence } : {}), ...(productPlan?.forks === "skip" ? { noForks: true } : {}) }), ...(planRunner !== undefined ? { runner: planRunner } : {}), ...(runnerOfDefault !== undefined ? { evidenceRunner: runnerOfDefault } : {}) };
447
+ out.check = { ...prCheckJob(forge, { ...checkOptions, ...(words.bin ? { bin: words.bin } : {}), ...(evidence ? { evidence } : {}), ...(productPlan?.forks === "skip" ? { noForks: true } : {}) }), ...(planRunner !== undefined ? { runner: planRunner } : {}), ...(runnerOfDefault !== undefined ? { evidenceRunner: runnerOfDefault } : {}) };
351
448
  }
352
449
  if (options.refGateStatus) out.refGate = { ...prRefGateJob(forge, { ...(words.bin ? { bin: words.bin } : {}), ...(options.branch ? { branch: options.branch } : {}) }), ...defaultRunner };
353
450
  const locks = prCommentLockJobs(forge, { locks: options.locks, words });
354
451
  if (locks.length > 0) out.locks = locks.map((job) => ({ ...job, ...defaultRunner }));
452
+ // #4979: the product plan's reach says what the lock job locks.
453
+ const reachLock = productPlan ? productPlanReachLock(forge, { ...prLoop, plan: productPlan }, words) : undefined;
454
+ if (reachLock) out.reachLock = reachLock;
355
455
  const action = prActionJob(forge, prLoop);
356
456
  if (action) out.action = { ...action, ...(prLoopRunner(options, "apply") !== undefined ? { runner: prLoopRunner(options, "apply")! } : {}) };
357
- const stale = prStaleJob(forge, env, prLoop, member);
457
+ // #4987: a product plan's notes are marked from the waves workflow's push run, one --member per target, naming the re-plan comment.
458
+ const planStale = productPlan
459
+ ? prStaleJob(forge, env, { ...prLoop, ...(productPlan.replan ? { previewComment: true } : {}) }, productPlan.targets?.map((t) => t.name) ?? member)
460
+ : undefined;
461
+ if (planStale && !options.waves && !options.componentWaves) throw new Error("staleNotes with the product plan marks the notes from the waves workflow's push run, beside wave 1, and there are no waves: give waves (or componentWaves), or drop staleNotes");
462
+ const stale = productPlan ? undefined : prStaleJob(forge, env, prLoop, member);
358
463
  if (stale) out.stale = { ...stale, ...defaultRunner };
359
464
  // #4785: GitLab's comment commands, polled from the notes; waves on merge are retried by an apply on a merged merge request.
360
465
  // #4899: the product plan's comment re-plan runs in the preview's pipeline, so the poll starts it as it starts a preview.
@@ -380,6 +485,59 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
380
485
  const spec = given ?? (componentWaves
381
486
  ? componentWavesSpec(componentWaves.components, words, componentWaveSteps({ ...(words.bin ? { bin: words.bin } : {}), env, base: componentWaves.base ?? "HEAD^1", ...(member ? { member } : {}), op, gate: prLoop.gate }), { ...(componentWaves.waveGate ? { gate: componentWaves.waveGate } : {}) })
382
487
  : undefined);
488
+ // #4984: the waves before merge: the comment job (the note poll on GitLab) decides an open pull request's apply and starts them.
489
+ const wavesOp = spec ? (words.op ?? spec.name) : undefined;
490
+ let bmJobs: WavesBeforeMergeJobs | undefined;
491
+ if (wavesBeforeMerge) {
492
+ if (!spec || !wavesOp) throw new Error("wavesBeforeMerge runs the waves on an open pull request's head, and there are none: give waves (or componentWaves)");
493
+ if (options.applyBeforeMerge) throw new Error("wavesBeforeMerge and applyBeforeMerge both answer an open pull request's apply; give one");
494
+ if (forge === "gitlab" ? !options.noteCommands : !options.commentJob) throw new Error(`wavesBeforeMerge is decided by ${forge === "gitlab" ? "the note poll: set noteCommands" : "the comment job: set commentJob"}`);
495
+ const targets = productPlan?.targets?.map((t) => t.name);
496
+ bmJobs = {
497
+ ...(forge !== "gitlab" ? { workflow: `${wavesOp}.yml` } : {}),
498
+ ...(wavesBeforeMerge.requires ? { requires: [...wavesBeforeMerge.requires] } : {}),
499
+ plan: targets?.length ? targets.map((t) => productStatusContext(words, "plan", t)) : [productStatusContext(words, "plan", member)],
500
+ pipelineFiles: wavesBeforeMerge.pipelineFiles ?? defaultPipelineFiles(forge),
501
+ ...(productPlan?.reach ? { locks: { ...(productPlan.reach.gate ? { gate: productPlan.reach.gate } : {}) } } : {}),
502
+ };
503
+ }
504
+ // #4984: GitLab's note poll writes a wave stop for a merged merge request, and decides the waves before merge.
505
+ if (out.noteCommands && spec && wavesOp) {
506
+ out.noteCommands = {
507
+ ...out.noteCommands,
508
+ env: {
509
+ [COMMENT_JOBS_ENV]: JSON.stringify({ waves: { op: wavesOp, count: spec.waves.length }, ...(bmJobs ? { wavesBeforeMerge: bmJobs } : {}) }),
510
+ ...(bmJobs && productPlan?.reach ? { [LOCK_REACH_ENV]: productPlan.reach.command } : {}),
511
+ },
512
+ };
513
+ }
514
+ // #4946: the comment job answers what no other job of the pipeline takes, so it is told which jobs there are.
515
+ if (options.commentJob) {
516
+ // #4963's re-plan reply answers the same stray comments, so one of the two answers them.
517
+ if (typeof productPlan?.replan === "object" && productPlan.replan.reply) throw new Error("commentJob answers every /<product> comment no other job takes, and so does the product plan's replan.reply; drop replan.reply, since the comment job answers the re-plan's refusals too");
518
+ // The product plan's re-plan skips a target that is none of its own and, with forks: "skip", a fork's pull request without a word; the comment job says why.
519
+ const planTargets = productPlan?.replan ? productPlan.targets?.map((t) => t.name) : undefined;
520
+ const commentJobs: CommentJobs = {
521
+ ...(productPlan?.replan || options.previewComment ? { preview: true } : {}),
522
+ ...(planTargets?.length ? { targets: planTargets } : {}),
523
+ ...(productPlan?.replan && productPlan.forks === "skip" ? { skipForks: true } : {}),
524
+ ...(options.applyBeforeMerge ? { applyBeforeMerge: true } : {}),
525
+ ...(given || componentWaves ? { applyOnMerge: true } : {}),
526
+ // #4979: the waves' op (the name productWavesSpec gives them) and count, so a wave-<n> stops a re-run after wave n.
527
+ ...(spec ? { waves: { op: words.op ?? spec.name, count: spec.waves.length } } : {}),
528
+ ...(bmJobs ? { wavesBeforeMerge: bmJobs } : {}),
529
+ // #4979: the product plan's re-plan takes no flags, so the comment job answers a plan comment that carries them.
530
+ ...(productPlan?.replan ? { noPlanFlags: true } : {}),
531
+ ...(locks.length > 0 ? { locks: true } : {}),
532
+ ...(out.agent ? { agent: true } : {}),
533
+ ...(out.commits ? { commits: true } : {}),
534
+ ...(options.actions || options.actionJob ? { actions: true } : {}),
535
+ };
536
+ const comment = productCommentJob(forge, words, commentJobs);
537
+ // #4984: the decision before merge locks what the reach line prints, at stage apply.
538
+ if (bmJobs && productPlan?.reach) comment.env = { ...comment.env, [LOCK_REACH_ENV]: productPlan.reach.command };
539
+ out.comment = { ...comment, ...defaultRunner };
540
+ }
383
541
  if (!spec) return { ...out, record: record! };
384
542
  const wavesRespond = respond ? Object.fromEntries(Object.entries(respond).filter(([e]) => e !== "description")) : {};
385
543
  // #4625: the waves run on the apply runner and with the plan's parallelism, unless the spec names its own.
@@ -396,7 +554,17 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
396
554
  ...(Object.keys(wavesRespond).length > 0 ? { respond: { ...(spec.respond ?? {}), ...wavesRespond } } : {}),
397
555
  };
398
556
  const specFile = wavesSpecFile ?? productWavesSpecFile(named.name);
399
- return { ...out, waves: { spec: named, specFile, jobs: opWaveJobs(named, specFile, { bin: words.bin }) } };
557
+ // #4984: what the generator's before-merge mode takes: the merge after the last wave and the lock file it releases.
558
+ const beforeMerge: OpWavesBeforeMerge | undefined = wavesBeforeMerge
559
+ ? { ...(wavesBeforeMerge.merge ? { merge: wavesBeforeMerge.merge } : {}), ...(wavesBeforeMerge.mergeTokenSecret ? { mergeTokenSecret: wavesBeforeMerge.mergeTokenSecret } : {}), ...(productPlan?.reach?.gate ? { gate: productPlan.reach.gate } : {}) }
560
+ : undefined;
561
+ // #4987: the apply statuses after each wave, and with a product plan the stale marking beside wave 1, one --member per target.
562
+ const pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes"> = {
563
+ ...(beforeMerge ? { beforeMerge } : {}),
564
+ ...(options.applyStatus ? { applyStatus: { context: productStatusContext(words, "apply", member) } } : {}),
565
+ ...(planStale ? { staleNotes: planStale } : {}),
566
+ };
567
+ return { ...out, waves: { spec: named, specFile, jobs: opWaveJobs(named, specFile, { bin: words.bin, ...(beforeMerge ? { beforeMerge: true } : {}) }), ...(beforeMerge ? { beforeMerge } : {}), pipeline } };
400
568
  }
401
569
 
402
570
  /** The capability steps a component waves spec runs (#4545, #4541): argv templates over `{runs}` and `{plans}`. */
@@ -508,6 +676,25 @@ export function componentWavesSpec(
508
676
  };
509
677
  }
510
678
 
679
+ /**
680
+ * The comment job's descriptor (#4946): `chant components pr-comment
681
+ * --forge <forge>` through the words' bin, the jobs it leaves comments to as
682
+ * {@link COMMENT_JOBS_ENV}, and the comment prefixes the forge's `if:`
683
+ * starts it on. Throws on GitLab, whose note-commands job answers every
684
+ * note.
685
+ */
686
+ export function productCommentJob(forge: ForgeKind, words: CiProductWords, jobs: CommentJobs): ProductCommentJob {
687
+ if (forge === "gitlab") throw new Error("the comment job answers a GitHub or Forgejo comment; on GitLab the note-commands job (noteCommands) answers every note, so drop commentJob");
688
+ for (const a of words.aliases) if (/['\\]/.test(a.from)) throw new Error(`the alias ${JSON.stringify(a.from)} holds a quote, which the comment job's condition cannot carry`);
689
+ return {
690
+ jobName: PR_COMMENT_JOB,
691
+ command: withProductBin(`chant components pr-comment --forge ${forge}`, words.bin),
692
+ env: { GITHUB_TOKEN: GITHUB_JOB_TOKEN, [COMMENT_JOBS_ENV]: JSON.stringify(jobs) },
693
+ prefixes: [`/${words.product}`, ...words.aliases.map((a) => a.from)],
694
+ jobs,
695
+ };
696
+ }
697
+
511
698
  /** A shell line with the product's bin in place of `chant`, for a product's own jobs beside these. */
512
699
  export function productCommand(words: CiProductWords, line: string): string {
513
700
  return withProductBin(line, words.bin);
@@ -65,6 +65,17 @@ describe("the product plan (#4799)", () => {
65
65
  expect(() => productPipelineJobs(forge, "default", { words: terragucci, productPlan: { command: "terragucci plan", watches: [drift, drift] } })).toThrow(/name an Op twice/);
66
66
  });
67
67
 
68
+ // #4988: an environment's drift watch scoped to that environment's note, as sql-yodeler warned per environment.
69
+ test.each(["github", "forgejo", "gitlab"] as const)("on %s, a watch's targets reach every target's note job, and a target the plan lacks is refused", (forge) => {
70
+ const staging = { op: "yodel-watch-staging", cron: "0 6 * * *", targets: ["staging"] };
71
+ const prod = { op: "yodel-watch-prod", cron: "0 6 * * *", targets: ["prod"] };
72
+ const jobs = productPipelineJobs(forge, "default", { words: yodel, productPlan: { ...environments, watches: [staging, prod] } }).productPlan!;
73
+ // pr-post --member <target> picks its own (watchesForTarget), so every note job reads the one list.
74
+ for (const j of jobs) expect(JSON.parse(j.post.env[PLAN_WATCHES_ENV]!)).toEqual([staging, prod]);
75
+ expect(() => productPipelineJobs(forge, "default", { words: yodel, productPlan: { ...environments, watches: [{ ...prod, targets: ["dev"] }] } })).toThrow("the product plan's watch yodel-watch-prod names target dev, which the plan does not have");
76
+ expect(() => productPipelineJobs(forge, "default", { words: terragucci, productPlan: { command: "terragucci plan", watches: [prod] } })).toThrow("the product plan's watch yodel-watch-prod names target prod, which the plan cannot scope to: it has no targets");
77
+ });
78
+
68
79
  test("the pipeline's passed values reach every target, and a name both give is refused", () => {
69
80
  const [staging] = productPipelineJobs("github", "default", { words: yodel, variables: { YODEL_LOG: "info" }, productPlan: environments }).productPlan!;
70
81
  expect(staging!.env.YODEL_LOG).toBe("info");
@@ -82,7 +93,7 @@ describe("the product plan (#4799)", () => {
82
93
 
83
94
  test.each([
84
95
  ["previewComment", { previewComment: true }],
85
- ["staleNotes", { staleNotes: true }],
96
+ // #4987: staleNotes is carried now, one note per target, marked from the waves' push run (product-pipeline.apply-status.test.ts).
86
97
  ["applyBeforeMerge", { applyBeforeMerge: true }],
87
98
  ["build", { build: true }],
88
99
  ])("refuses %s, which the product plan does not carry", (key, extra) => {
@@ -175,14 +186,59 @@ describe("the re-plan decision and the pending status scripts (#4899)", () => {
175
186
  const { gitlabReplanCommentIf } = await import("./product-plan");
176
187
  expect(gitlabReplanCommentIf({ comments: ["/yodel plan"], gated: [] }, "prod")).toBe("$CHANT_PREVIEW_COMMENT =~ /^\\/yodel plan( +prod)? *$/");
177
188
  expect(gitlabReplanCommentIf({ comments: ["/terragucci plan"], gated: [{ comment: "atlantis plan", when: "TG_ATLANTIS_COMMENTS" }] })).toBe(
178
- "$CHANT_PREVIEW_COMMENT =~ /^\\/terragucci plan( +[A-Za-z0-9_.\\/@+=,:-]+)? *$/ || ($TG_ATLANTIS_COMMENTS && $CHANT_PREVIEW_COMMENT =~ /^atlantis plan( +[A-Za-z0-9_.\\/@+=,:-]+)? *$/)",
189
+ "$CHANT_PREVIEW_COMMENT =~ /^\\/terragucci plan( +[A-Za-z0-9_.\\/@+=,:][A-Za-z0-9_.\\/@+=,:-]*)? *$/ || ($TG_ATLANTIS_COMMENTS && $CHANT_PREVIEW_COMMENT =~ /^atlantis plan( +[A-Za-z0-9_.\\/@+=,:][A-Za-z0-9_.\\/@+=,:-]*)? *$/)",
179
190
  );
180
191
  });
192
+
193
+ test("a re-plan word never starts with - (#4984), so a flag is not read as a root", async () => {
194
+ const { isReplanWord } = await import("./product-plan");
195
+ expect(isReplanWord("live/app")).toBe(true);
196
+ expect(isReplanWord("a-b")).toBe(true);
197
+ expect(isReplanWord("--target=x")).toBe(false);
198
+ expect(isReplanWord("-r")).toBe(false);
199
+ });
181
200
  });
182
201
 
183
202
  test("PRODUCT_PLAN_STEPS_FLOOR marks the plan-job steps in the ci-product entry", async () => {
184
- const { NEXT_RELEASE } = await import("../release-floors");
185
203
  const ciProduct = (await import("../ci-product")) as Record<string, unknown>;
186
- expect(ciProduct.PRODUCT_PLAN_STEPS_FLOOR).toBe(NEXT_RELEASE);
204
+ expect(ciProduct.PRODUCT_PLAN_STEPS_FLOOR).toBe("0.124.88");
187
205
  expect(ciProduct.PLAN_NOTE_NOTICES_ENV).toBe("CHANT_PLAN_NOTE_NOTICES");
188
206
  });
207
+
208
+ describe("what terragucci's and sql-yodeler's plan jobs need (#4963)", () => {
209
+ const trade = { aws: { region: "us-east-1", audience: "sts.amazonaws.com", role: "arn:aws:iam::123456789012:role/plan" } };
210
+
211
+ test("PRODUCT_PLAN_REPLAN_FLOOR is the release that shipped it, in the ci-product entry", async () => {
212
+ const ciProduct = (await import("../ci-product")) as Record<string, unknown>;
213
+ expect(ciProduct.PRODUCT_PLAN_REPLAN_FLOOR).toBe("0.124.89");
214
+ expect(typeof ciProduct.planBodyHandoff).toBe("function");
215
+ });
216
+
217
+ test("a trade's OIDC token is the job's, beside its own; a target's login or trade stands in for the plan's", () => {
218
+ const [one] = productPipelineJobs("gitlab", "default", { words: terragucci, productPlan: { command: "x", trade, idTokens: { TG_OIDC: "tg" } } }).productPlan!;
219
+ expect(one!.trade).toEqual(trade);
220
+ expect(one!.idTokens).toEqual({ CHANT_ID_TOKEN_AWS: "sts.amazonaws.com", TG_OIDC: "tg" });
221
+ const [a, b] = productPipelineJobs("github", "default", { words: yodel, productPlan: { ...environments, trade, targets: [{ name: "a", login: { aws: { role: "arn:aws:iam::1:role/r" } } }, { name: "b" }] } }).productPlan!;
222
+ expect(a!.trade).toBeUndefined();
223
+ expect(a!.login).toBeDefined();
224
+ expect(b!.trade).toEqual(trade);
225
+ expect(() => productPipelineJobs("github", "default", { words: terragucci, productPlan: { command: "x", trade, idTokens: { CHANT_ID_TOKEN_AWS: "other" } } })).toThrow(/the trade's, with another audience/);
226
+ });
227
+
228
+ test("the re-plan's options are checked", () => {
229
+ const plan = (replan: unknown) => () => productPipelineJobs("github", "default", { words: terragucci, productPlan: { command: "x", replan: replan as never } });
230
+ expect(plan({ dispatch: { argument: "pr" } })).toThrow(/input name/);
231
+ expect(plan({ dispatch: { argument: "Root Dir" } })).toThrow(/input name/);
232
+ expect(plan({ reply: { others: ["/plywood up"] } })).toThrow(/not a \/terragucci comment/);
233
+ expect(plan({ reply: { others: ["/terragucci it's"] } })).toThrow(/quote/);
234
+ const [p] = productPipelineJobs("github", "default", { words: terragucci, productPlan: { command: "x", replan: { dispatch: true, reply: true, notAffected: true } } }).productPlan!;
235
+ expect(p!.replan).toMatchObject({ dispatch: { argument: "argument" }, reply: { prefix: "/terragucci", others: [] }, notAffected: true });
236
+ expect(p!.replan!.post.command).toMatch(/ --not-affected "\$CHANT_PLAN_ARGUMENT"$/);
237
+ expect(p!.post.command).not.toContain("--not-affected");
238
+ });
239
+
240
+ test("previousMarker names chant's marker for the target and the product's marker", () => {
241
+ const [, prod] = productPipelineJobs("forgejo", "default", { words: yodel, productPlan: { ...environments, previousMarker: true, noteWords: { productMarker: "yodel:plan" } } }).productPlan!;
242
+ expect(prod!.previous).toEqual({ marker: "<!-- chant-pr:default:prod -->", name: "yodel:plan" });
243
+ });
244
+ });