@intentius/chant 0.124.55 → 0.124.57

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 (419) hide show
  1. package/dist/ci-agent.d.ts.map +1 -1
  2. package/dist/ci-agent.js +1 -2
  3. package/dist/ci-audit/attribution.d.ts +111 -0
  4. package/dist/ci-audit/attribution.d.ts.map +1 -0
  5. package/dist/ci-audit/attribution.js +194 -0
  6. package/dist/ci-audit/audit-log.d.ts +144 -0
  7. package/dist/ci-audit/audit-log.d.ts.map +1 -0
  8. package/dist/ci-audit/audit-log.js +149 -0
  9. package/dist/ci-audit/index.d.ts +12 -0
  10. package/dist/ci-audit/index.d.ts.map +1 -0
  11. package/dist/ci-audit/index.js +11 -0
  12. package/dist/ci-audit/unrecorded.d.ts +74 -0
  13. package/dist/ci-audit/unrecorded.d.ts.map +1 -0
  14. package/dist/ci-audit/unrecorded.js +95 -0
  15. package/dist/ci-audit.d.ts +3 -0
  16. package/dist/ci-audit.d.ts.map +1 -0
  17. package/dist/ci-audit.js +2 -0
  18. package/dist/ci-control.d.ts.map +1 -1
  19. package/dist/ci-control.js +3 -4
  20. package/dist/ci-estate.d.ts +24 -0
  21. package/dist/ci-estate.d.ts.map +1 -1
  22. package/dist/ci-estate.js +1 -2
  23. package/dist/ci-identity.d.ts.map +1 -1
  24. package/dist/ci-identity.js +2 -3
  25. package/dist/ci-job-guard.d.ts +139 -0
  26. package/dist/ci-job-guard.d.ts.map +1 -0
  27. package/dist/ci-job-guard.js +287 -0
  28. package/dist/ci-jobs.d.ts +7 -0
  29. package/dist/ci-jobs.d.ts.map +1 -1
  30. package/dist/ci-jobs.js +7 -0
  31. package/dist/ci-product-words.d.ts +7 -1
  32. package/dist/ci-product-words.d.ts.map +1 -1
  33. package/dist/ci-product-words.js +38 -4
  34. package/dist/ci-product.d.ts +35 -0
  35. package/dist/ci-product.d.ts.map +1 -1
  36. package/dist/ci-product.js +38 -4
  37. package/dist/ci-respond-run.d.ts +73 -0
  38. package/dist/ci-respond-run.d.ts.map +1 -0
  39. package/dist/ci-respond-run.js +247 -0
  40. package/dist/ci-respond.d.ts +189 -0
  41. package/dist/ci-respond.d.ts.map +1 -0
  42. package/dist/ci-respond.js +285 -0
  43. package/dist/cli/handlers/audit-log.d.ts +12 -0
  44. package/dist/cli/handlers/audit-log.d.ts.map +1 -0
  45. package/dist/cli/handlers/audit-log.js +81 -0
  46. package/dist/cli/handlers/build.d.ts +7 -0
  47. package/dist/cli/handlers/build.d.ts.map +1 -1
  48. package/dist/cli/handlers/build.js +81 -0
  49. package/dist/cli/handlers/ci-check-job.d.ts +11 -0
  50. package/dist/cli/handlers/ci-check-job.d.ts.map +1 -0
  51. package/dist/cli/handlers/ci-check-job.js +27 -0
  52. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  53. package/dist/cli/handlers/ci-check.js +38 -9
  54. package/dist/cli/handlers/e2e-safe-run.d.ts +12 -0
  55. package/dist/cli/handlers/e2e-safe-run.d.ts.map +1 -0
  56. package/dist/cli/handlers/e2e-safe-run.js +23 -0
  57. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  58. package/dist/cli/handlers/lifecycle.js +14 -0
  59. package/dist/cli/handlers/pr.d.ts +5 -0
  60. package/dist/cli/handlers/pr.d.ts.map +1 -1
  61. package/dist/cli/handlers/pr.js +346 -36
  62. package/dist/cli/handlers/run-wave.js +89 -1
  63. package/dist/cli/main.d.ts.map +1 -1
  64. package/dist/cli/main.js +56 -2
  65. package/dist/cli/parse-args.d.ts.map +1 -1
  66. package/dist/cli/parse-args.js +107 -0
  67. package/dist/cli/registry.d.ts +38 -0
  68. package/dist/cli/registry.d.ts.map +1 -1
  69. package/dist/components/adoption.d.ts.map +1 -1
  70. package/dist/components/adoption.js +1 -2
  71. package/dist/components/auto-release.d.ts +5 -2
  72. package/dist/components/auto-release.d.ts.map +1 -1
  73. package/dist/components/auto-release.js +9 -4
  74. package/dist/components/capability.d.ts +47 -0
  75. package/dist/components/capability.d.ts.map +1 -1
  76. package/dist/components/capability.js +25 -0
  77. package/dist/components/check-hooks.d.ts +4 -1
  78. package/dist/components/check-hooks.d.ts.map +1 -1
  79. package/dist/components/check-steps.d.ts +74 -0
  80. package/dist/components/check-steps.d.ts.map +1 -0
  81. package/dist/components/check-steps.js +102 -0
  82. package/dist/components/ci-services.d.ts.map +1 -1
  83. package/dist/components/ci-services.js +1 -2
  84. package/dist/components/deploy-units.d.ts +12 -0
  85. package/dist/components/deploy-units.d.ts.map +1 -1
  86. package/dist/components/deploy-units.js +20 -1
  87. package/dist/components/driver.d.ts +12 -0
  88. package/dist/components/driver.d.ts.map +1 -1
  89. package/dist/components/driver.js +35 -1
  90. package/dist/components/groups.d.ts.map +1 -1
  91. package/dist/components/groups.js +4 -3
  92. package/dist/components/pr-env-ledger.d.ts.map +1 -1
  93. package/dist/components/pr-env-ledger.js +1 -2
  94. package/dist/components/pr-environment.d.ts +1 -1
  95. package/dist/components/pr-environment.d.ts.map +1 -1
  96. package/dist/components/pr-environment.js +1 -1
  97. package/dist/components/pr-pipeline.d.ts +137 -5
  98. package/dist/components/pr-pipeline.d.ts.map +1 -1
  99. package/dist/components/pr-pipeline.js +164 -20
  100. package/dist/components/pr-run.d.ts +8 -0
  101. package/dist/components/pr-run.d.ts.map +1 -1
  102. package/dist/components/pr-run.js +9 -4
  103. package/dist/components/product-pipeline.d.ts +35 -2
  104. package/dist/components/product-pipeline.d.ts.map +1 -1
  105. package/dist/components/product-pipeline.js +24 -5
  106. package/dist/components/row-lease.d.ts +22 -1
  107. package/dist/components/row-lease.d.ts.map +1 -1
  108. package/dist/components/row-lease.js +32 -6
  109. package/dist/components/wave-plan.d.ts +8 -0
  110. package/dist/components/wave-plan.d.ts.map +1 -1
  111. package/dist/components/wave-plan.js +18 -2
  112. package/dist/e2e-harness/bucket.d.ts +21 -0
  113. package/dist/e2e-harness/bucket.d.ts.map +1 -0
  114. package/dist/e2e-harness/bucket.js +61 -0
  115. package/dist/e2e-harness/claim.d.ts +70 -0
  116. package/dist/e2e-harness/claim.d.ts.map +1 -0
  117. package/dist/e2e-harness/claim.js +98 -0
  118. package/dist/e2e-harness/driver.d.ts +64 -0
  119. package/dist/e2e-harness/driver.d.ts.map +1 -0
  120. package/dist/e2e-harness/driver.js +243 -0
  121. package/dist/e2e-harness/forgejo.d.ts +77 -0
  122. package/dist/e2e-harness/forgejo.d.ts.map +1 -0
  123. package/dist/e2e-harness/forgejo.js +205 -0
  124. package/dist/e2e-harness/git.d.ts +32 -0
  125. package/dist/e2e-harness/git.d.ts.map +1 -0
  126. package/dist/e2e-harness/git.js +67 -0
  127. package/dist/e2e-harness/index.d.ts +22 -0
  128. package/dist/e2e-harness/index.d.ts.map +1 -0
  129. package/dist/e2e-harness/index.js +47 -0
  130. package/dist/e2e-harness/jobs.d.ts +8 -0
  131. package/dist/e2e-harness/jobs.d.ts.map +1 -0
  132. package/dist/e2e-harness/jobs.js +34 -0
  133. package/dist/e2e-harness/pins.d.ts +45 -0
  134. package/dist/e2e-harness/pins.d.ts.map +1 -0
  135. package/dist/e2e-harness/pins.js +44 -0
  136. package/dist/e2e-harness/ports.d.ts +113 -0
  137. package/dist/e2e-harness/ports.d.ts.map +1 -0
  138. package/dist/e2e-harness/ports.js +4 -0
  139. package/dist/e2e-harness/reports.d.ts +45 -0
  140. package/dist/e2e-harness/reports.d.ts.map +1 -0
  141. package/dist/e2e-harness/reports.js +57 -0
  142. package/dist/e2e-harness/safe-run-cli.d.ts +17 -0
  143. package/dist/e2e-harness/safe-run-cli.d.ts.map +1 -0
  144. package/dist/e2e-harness/safe-run-cli.js +43 -0
  145. package/dist/e2e-harness/safe-run.d.ts +61 -0
  146. package/dist/e2e-harness/safe-run.d.ts.map +1 -0
  147. package/dist/e2e-harness/safe-run.js +172 -0
  148. package/dist/e2e-harness/scenario.d.ts +11 -0
  149. package/dist/e2e-harness/scenario.d.ts.map +1 -0
  150. package/dist/e2e-harness/scenario.js +89 -0
  151. package/dist/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  152. package/dist/e2e-harness/schemas/demo-step.schema.json +245 -0
  153. package/dist/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  154. package/dist/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  155. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  156. package/dist/e2e-harness/schemas/index.d.ts +191 -0
  157. package/dist/e2e-harness/schemas/index.d.ts.map +1 -0
  158. package/dist/e2e-harness/schemas/index.js +62 -0
  159. package/dist/e2e-harness/stack.d.ts +124 -0
  160. package/dist/e2e-harness/stack.d.ts.map +1 -0
  161. package/dist/e2e-harness/stack.js +207 -0
  162. package/dist/e2e-harness/steps.d.ts +11 -0
  163. package/dist/e2e-harness/steps.d.ts.map +1 -0
  164. package/dist/e2e-harness/steps.js +22 -0
  165. package/dist/e2e-harness.d.ts +3 -0
  166. package/dist/e2e-harness.d.ts.map +1 -0
  167. package/dist/e2e-harness.js +2 -0
  168. package/dist/exit-codes.d.ts +7 -1
  169. package/dist/exit-codes.d.ts.map +1 -1
  170. package/dist/exit-codes.js +7 -1
  171. package/dist/lexicon.d.ts +55 -0
  172. package/dist/lexicon.d.ts.map +1 -1
  173. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  174. package/dist/lifecycle/gate-ledger.js +2 -3
  175. package/dist/lifecycle/gated-request.d.ts.map +1 -1
  176. package/dist/lifecycle/gated-request.js +1 -2
  177. package/dist/lifecycle/git.d.ts +39 -3
  178. package/dist/lifecycle/git.d.ts.map +1 -1
  179. package/dist/lifecycle/git.js +223 -15
  180. package/dist/lifecycle/lock-rows.d.ts +23 -0
  181. package/dist/lifecycle/lock-rows.d.ts.map +1 -1
  182. package/dist/lifecycle/lock-rows.js +47 -8
  183. package/dist/lifecycle/query.d.ts.map +1 -1
  184. package/dist/lifecycle/query.js +4 -5
  185. package/dist/lifecycle/release-catalog.d.ts.map +1 -1
  186. package/dist/lifecycle/release-catalog.js +1 -1
  187. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  188. package/dist/lifecycle/release-ledger.js +1 -2
  189. package/dist/lifecycle/release-status.d.ts +20 -0
  190. package/dist/lifecycle/release-status.d.ts.map +1 -1
  191. package/dist/lifecycle/release-status.js +1 -22
  192. package/dist/lifecycle/resource-lock.d.ts +70 -0
  193. package/dist/lifecycle/resource-lock.d.ts.map +1 -1
  194. package/dist/lifecycle/resource-lock.js +241 -5
  195. package/dist/lifecycle/wave-plans.d.ts +23 -7
  196. package/dist/lifecycle/wave-plans.d.ts.map +1 -1
  197. package/dist/lifecycle/wave-plans.js +9 -2
  198. package/dist/op/approval-status.d.ts +103 -0
  199. package/dist/op/approval-status.d.ts.map +1 -0
  200. package/dist/op/approval-status.js +197 -0
  201. package/dist/op/gate.js +21 -4
  202. package/dist/op/index.d.ts +1 -1
  203. package/dist/op/index.d.ts.map +1 -1
  204. package/dist/op/index.js +1 -1
  205. package/dist/op/op-waves-capability-spec.d.ts +8 -0
  206. package/dist/op/op-waves-capability-spec.d.ts.map +1 -1
  207. package/dist/op/op-waves-capability-spec.js +21 -0
  208. package/dist/op/op-waves-release-port.js +1 -1
  209. package/dist/op/op-waves-release.d.ts +2 -1
  210. package/dist/op/op-waves-release.d.ts.map +1 -1
  211. package/dist/op/op-waves-release.js +1 -2
  212. package/dist/op/op-waves-run.d.ts +15 -2
  213. package/dist/op/op-waves-run.d.ts.map +1 -1
  214. package/dist/op/op-waves-run.js +195 -31
  215. package/dist/op/op-waves-stand-down.d.ts.map +1 -1
  216. package/dist/op/op-waves-stand-down.js +1 -2
  217. package/dist/op/op-waves.d.ts +53 -0
  218. package/dist/op/op-waves.d.ts.map +1 -1
  219. package/dist/op/op-waves.js +62 -6
  220. package/dist/op/runtime.d.ts +4 -0
  221. package/dist/op/runtime.d.ts.map +1 -1
  222. package/dist/op/runtime.js +2 -3
  223. package/dist/otlp.d.ts.map +1 -1
  224. package/dist/otlp.js +1 -2
  225. package/dist/parallelism.d.ts +17 -0
  226. package/dist/parallelism.d.ts.map +1 -0
  227. package/dist/parallelism.js +33 -0
  228. package/dist/policy-source.d.ts.map +1 -1
  229. package/dist/policy-source.js +1 -2
  230. package/dist/pr-forge.d.ts.map +1 -1
  231. package/dist/pr-forge.js +56 -39
  232. package/dist/pr-loop.d.ts +9 -0
  233. package/dist/pr-loop.d.ts.map +1 -1
  234. package/dist/pr-loop.js +22 -4
  235. package/dist/pr-merge.d.ts +64 -0
  236. package/dist/pr-merge.d.ts.map +1 -0
  237. package/dist/pr-merge.js +78 -0
  238. package/dist/pr-post.d.ts +70 -1
  239. package/dist/pr-post.d.ts.map +1 -1
  240. package/dist/pr-post.js +116 -5
  241. package/dist/pr-report-url.d.ts.map +1 -1
  242. package/dist/pr-report-url.js +1 -2
  243. package/dist/release-floors.d.ts +1 -1
  244. package/dist/release-floors.js +1 -1
  245. package/dist/run-event.d.ts.map +1 -1
  246. package/dist/run-event.js +1 -2
  247. package/dist/scheduled-op-cloud.d.ts +32 -0
  248. package/dist/scheduled-op-cloud.d.ts.map +1 -0
  249. package/dist/scheduled-op-cloud.js +69 -0
  250. package/dist/wave-runtime.mjs +351 -328
  251. package/dist/workspace/ci-lock-grain.d.ts +5 -0
  252. package/dist/workspace/ci-lock-grain.d.ts.map +1 -1
  253. package/dist/workspace/ci-lock-grain.js +1 -7
  254. package/dist/workspace/ci-run.d.ts.map +1 -1
  255. package/dist/workspace/ci-run.js +5 -1
  256. package/dist/workspace/pr-report.schema.json +5 -0
  257. package/package.json +1 -1
  258. package/src/ci-agent.ts +1 -2
  259. package/src/ci-audit/__fixtures__/cloudtrail-lookup-bucket.json +37 -0
  260. package/src/ci-audit/__fixtures__/cloudtrail-writes-window.json +59 -0
  261. package/src/ci-audit/attribution.ts +260 -0
  262. package/src/ci-audit/audit-log.ts +220 -0
  263. package/src/ci-audit/ci-audit.test.ts +175 -0
  264. package/src/ci-audit/index.ts +14 -0
  265. package/src/ci-audit/unrecorded.ts +140 -0
  266. package/src/ci-audit.ts +2 -0
  267. package/src/ci-control.ts +3 -4
  268. package/src/ci-estate.ts +1 -2
  269. package/src/ci-identity-database.test.ts +2 -3
  270. package/src/ci-identity-targets.test.ts +1 -3
  271. package/src/ci-identity.ts +2 -3
  272. package/src/ci-job-guard.test.ts +154 -0
  273. package/src/ci-job-guard.ts +319 -0
  274. package/src/ci-jobs.ts +8 -0
  275. package/src/ci-product-comment-targets.test.ts +45 -0
  276. package/src/ci-product-words.ts +35 -6
  277. package/src/ci-product.ts +55 -4
  278. package/src/ci-respond-run.ts +291 -0
  279. package/src/ci-respond.test.ts +264 -0
  280. package/src/ci-respond.ts +412 -0
  281. package/src/cli/handlers/audit-log.ts +74 -0
  282. package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
  283. package/src/cli/handlers/build.ts +69 -0
  284. package/src/cli/handlers/ci-check-job.test.ts +114 -0
  285. package/src/cli/handlers/ci-check-job.ts +33 -0
  286. package/src/cli/handlers/ci-check.ts +38 -8
  287. package/src/cli/handlers/e2e-safe-run.ts +27 -0
  288. package/src/cli/handlers/lifecycle.ts +13 -0
  289. package/src/cli/handlers/pr-before-merge.test.ts +1 -1
  290. package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
  291. package/src/cli/handlers/pr-endpoint.test.ts +1 -1
  292. package/src/cli/handlers/pr-green.test.ts +1 -1
  293. package/src/cli/handlers/pr-plan-comment-targets.test.ts +166 -0
  294. package/src/cli/handlers/pr-plan-flags.test.ts +161 -0
  295. package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
  296. package/src/cli/handlers/pr-record.test.ts +34 -2
  297. package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
  298. package/src/cli/handlers/pr-waves.test.ts +1 -1
  299. package/src/cli/handlers/pr.test.ts +1 -1
  300. package/src/cli/handlers/pr.ts +311 -32
  301. package/src/cli/handlers/run-wave.ts +79 -1
  302. package/src/cli/main.test.ts +1 -1
  303. package/src/cli/main.ts +56 -2
  304. package/src/cli/parse-args.ts +77 -0
  305. package/src/cli/registry.ts +38 -0
  306. package/src/components/adoption.ts +1 -2
  307. package/src/components/auto-release.test.ts +4 -2
  308. package/src/components/auto-release.ts +9 -5
  309. package/src/components/capability.ts +60 -0
  310. package/src/components/check-hooks.ts +4 -1
  311. package/src/components/check-steps.test.ts +70 -0
  312. package/src/components/check-steps.ts +158 -0
  313. package/src/components/ci-services.ts +1 -2
  314. package/src/components/deploy-units.test.ts +18 -1
  315. package/src/components/deploy-units.ts +26 -1
  316. package/src/components/driver.ts +35 -1
  317. package/src/components/groups.ts +4 -2
  318. package/src/components/plan-flags.test.ts +46 -0
  319. package/src/components/pr-comment-preview-targets.test.ts +34 -0
  320. package/src/components/pr-env-ledger.ts +1 -2
  321. package/src/components/pr-env-run-bundle.test.ts +0 -20
  322. package/src/components/pr-environment.ts +1 -1
  323. package/src/components/pr-pipeline-runners.test.ts +80 -0
  324. package/src/components/pr-pipeline.ts +244 -20
  325. package/src/components/pr-run.ts +17 -6
  326. package/src/components/pr-stale-job.test.ts +34 -0
  327. package/src/components/product-pipeline.ts +50 -8
  328. package/src/components/row-lease.test.ts +61 -1
  329. package/src/components/row-lease.ts +48 -7
  330. package/src/components/wave-plan.ts +18 -2
  331. package/src/e2e-harness/__project__/chant.config.ts +4 -0
  332. package/src/e2e-harness/__project__/src/compose.ts +33 -0
  333. package/src/e2e-harness/bucket.ts +69 -0
  334. package/src/e2e-harness/claim.test.ts +150 -0
  335. package/src/e2e-harness/claim.ts +140 -0
  336. package/src/e2e-harness/driver.test.ts +304 -0
  337. package/src/e2e-harness/driver.ts +294 -0
  338. package/src/e2e-harness/forgejo.ts +267 -0
  339. package/src/e2e-harness/git.ts +96 -0
  340. package/src/e2e-harness/index.ts +49 -0
  341. package/src/e2e-harness/jobs.ts +35 -0
  342. package/src/e2e-harness/pins.ts +52 -0
  343. package/src/e2e-harness/ports.ts +130 -0
  344. package/src/e2e-harness/reports.ts +79 -0
  345. package/src/e2e-harness/safe-run-cli.test.ts +102 -0
  346. package/src/e2e-harness/safe-run-cli.ts +54 -0
  347. package/src/e2e-harness/safe-run.ts +198 -0
  348. package/src/e2e-harness/scenario.ts +89 -0
  349. package/src/e2e-harness/schemas/README.md +62 -0
  350. package/src/e2e-harness/schemas/demo-cycle.schema.json +282 -0
  351. package/src/e2e-harness/schemas/demo-step.schema.json +245 -0
  352. package/src/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
  353. package/src/e2e-harness/schemas/e2e-claims.schema.json +18 -0
  354. package/src/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
  355. package/src/e2e-harness/schemas/index.ts +220 -0
  356. package/src/e2e-harness/schemas.test.ts +145 -0
  357. package/src/e2e-harness/stack.test.ts +124 -0
  358. package/src/e2e-harness/stack.ts +306 -0
  359. package/src/e2e-harness/steps.ts +30 -0
  360. package/src/e2e-harness.ts +2 -0
  361. package/src/exit-codes.test.ts +3 -2
  362. package/src/exit-codes.ts +7 -1
  363. package/src/gate-decision-bundle.test.ts +0 -2
  364. package/src/lexicon.ts +57 -0
  365. package/src/lifecycle/control-entries-ledger.test.ts +2 -3
  366. package/src/lifecycle/gate-ledger.ts +2 -3
  367. package/src/lifecycle/gated-request.ts +1 -2
  368. package/src/lifecycle/git.test.ts +155 -0
  369. package/src/lifecycle/git.ts +213 -17
  370. package/src/lifecycle/lock-rows.test.ts +6 -1
  371. package/src/lifecycle/lock-rows.ts +58 -7
  372. package/src/lifecycle/query.ts +4 -5
  373. package/src/lifecycle/release-catalog.test.ts +3 -4
  374. package/src/lifecycle/release-catalog.ts +1 -1
  375. package/src/lifecycle/release-ledger.ts +1 -2
  376. package/src/lifecycle/release-status.test.ts +3 -4
  377. package/src/lifecycle/release-status.ts +1 -2
  378. package/src/lifecycle/resource-lock-wait.test.ts +292 -0
  379. package/src/lifecycle/resource-lock.ts +261 -7
  380. package/src/lifecycle/wave-plans.ts +33 -5
  381. package/src/op/approval-status.test.ts +134 -0
  382. package/src/op/approval-status.ts +235 -0
  383. package/src/op/gate-review.test.ts +2 -1
  384. package/src/op/gate.test.ts +7 -5
  385. package/src/op/gate.ts +20 -4
  386. package/src/op/index.ts +2 -0
  387. package/src/op/op-waves-after-plan.test.ts +11 -0
  388. package/src/op/op-waves-capability-spec.ts +20 -0
  389. package/src/op/op-waves-ledger-lock.test.ts +208 -0
  390. package/src/op/op-waves-parallelism.test.ts +89 -0
  391. package/src/op/op-waves-pull-request.test.ts +78 -1
  392. package/src/op/op-waves-release-port.ts +1 -1
  393. package/src/op/op-waves-release.ts +2 -3
  394. package/src/op/op-waves-run.ts +196 -31
  395. package/src/op/op-waves-stand-down.ts +1 -2
  396. package/src/op/op-waves.ts +81 -6
  397. package/src/op/runtime.ts +6 -3
  398. package/src/otlp.ts +1 -2
  399. package/src/parallelism.test.ts +38 -0
  400. package/src/parallelism.ts +33 -0
  401. package/src/policy-source.ts +1 -2
  402. package/src/pr-forge-bundle.test.ts +1 -1
  403. package/src/pr-forge.ts +54 -35
  404. package/src/pr-loop-bundle.test.ts +0 -2
  405. package/src/pr-loop-narrowed.test.ts +63 -0
  406. package/src/pr-loop.ts +30 -4
  407. package/src/pr-merge.test.ts +100 -0
  408. package/src/pr-merge.ts +105 -0
  409. package/src/pr-post-stale.test.ts +163 -0
  410. package/src/pr-post.ts +159 -5
  411. package/src/pr-report-url.ts +1 -2
  412. package/src/product-subpaths-plain-node.e2e.test.ts +1 -0
  413. package/src/release-floors.ts +1 -1
  414. package/src/run-event.ts +1 -2
  415. package/src/scheduled-op-cloud.ts +68 -0
  416. package/src/stage-hooks-bundle.test.ts +0 -2
  417. package/src/workspace/ci-lock-grain.ts +1 -2
  418. package/src/workspace/ci-run.ts +5 -1
  419. package/src/workspace/pr-report.schema.json +5 -0
@@ -88,8 +88,10 @@
88
88
  import type { ForgeKind } from "../pr-forge";
89
89
  import { PR_APPLY_GATE } from "../pr-loop";
90
90
  import { parseRequiresList } from "../pr-requires";
91
- import { CI_IMAGE, GITHUB_JOB_TOKEN } from "../ci-jobs";
92
- import { withoutForgeTokens } from "../ci-handover";
91
+ import { CI_IMAGE, GITHUB_JOB_TOKEN, githubSecret, PR_ENV_REPORT_DIR, type CiRunner } from "../ci-jobs";
92
+ import { FORGE_TOKEN_VARS, withoutForgeTokens } from "../ci-handover";
93
+ import { OIDC_REQUEST_VARS } from "../ci-identity";
94
+ import { parallelismProblem } from "../parallelism";
93
95
  import { EMPTY_TREE_SHA } from "./changed-files";
94
96
  import { layerWaves } from "../gated-waves";
95
97
  import type { DriverComponent } from "./driver";
@@ -97,6 +99,7 @@ import type { GatedWavePipelineOptions } from "./gated-wave-pipeline";
97
99
  import type { CloudTradeSpec, PipelineCloudIdentity } from "../ci-identity";
98
100
  import { commentLine, resolveProductWords, type CiProductWords, type CiProductWordsInput } from "../ci-product-words";
99
101
  import type { ControlTarget } from "../control/dispatch";
102
+ import { CI_RESPOND_ENV, respondList, type CiResponses } from "../ci-respond";
100
103
 
101
104
  /** The variable `chant ci run` reads its runner key from (`RUNNER_KEY_ENV` in ../workspace/ci-green.ts). */
102
105
  const RUNNER_KEY_ENV = "CHANT_RUNNER_KEY";
@@ -187,6 +190,14 @@ export interface PrLoopPipelineOptions {
187
190
  * four. Only with `applyBeforeMerge`.
188
191
  */
189
192
  applyRequires?: readonly string[];
193
+ /**
194
+ * Merge the pull request once its update before merge applied (#4636):
195
+ * `pr-apply --merge auto --merge-token-env <tokenEnv>`. The token is the
196
+ * merge's alone: on GitHub and Forgejo the job maps it from the secret of
197
+ * that name, on GitLab it is a protected variable the project sets. Only
198
+ * with `applyBeforeMerge`.
199
+ */
200
+ applyMerge?: { tokenEnv: string; method?: "merge" | "squash" | "rebase" };
190
201
  /**
191
202
  * Stream each job's run events (#4007): `--events-json` on both commands,
192
203
  * and `CHANT_RUN_EVENTS_DIR` set to {@link PR_LOOP_EVENTS_DIR}. Default false.
@@ -295,20 +306,159 @@ export interface PrLoopPipelineOptions {
295
306
  * Default false.
296
307
  */
297
308
  previewComment?: boolean;
309
+ /**
310
+ * Where the pull request loop's jobs run (#4625), by stage: `plan` for the
311
+ * plan and the comment preview, `apply` for the apply jobs, the record
312
+ * job and a pull request environment's up, down and sweep, and `default`
313
+ * for every other job (the note jobs, the lock jobs, the control
314
+ * dispatch) and for a stage left out. A plywood `runners` key maps
315
+ * `preview` onto `plan` and `up` onto `apply`. Absent: the forge's
316
+ * default runner.
317
+ */
318
+ runners?: PrLoopRunners;
319
+ /**
320
+ * Variables for the jobs that plan or apply (#4625): the plan, the
321
+ * comment preview, the apply and the record. Values as the forge reads
322
+ * them; a name of a forge token or a token request variable is refused.
323
+ */
324
+ variables?: Record<string, string>;
325
+ /**
326
+ * Secrets passed to the same jobs (#4625), as `{ <variable>: <secret> }`:
327
+ * the repository secret named `<secret>` as `<variable>`. GitHub and
328
+ * Forgejo map `secrets.<secret>`; GitLab, where every job has the CI/CD
329
+ * variables, maps `$<secret>` when the names differ. The plan job still
330
+ * drops the forge tokens before the change's code runs, and a passed name
331
+ * of a forge token is refused.
332
+ */
333
+ secrets?: Record<string, string>;
334
+ /**
335
+ * How many members of a wave the plan job plans at once (#4625): `pr-plan
336
+ * --parallelism <n>`, on the plan and the comment preview. Absent: all of
337
+ * a wave's members at once.
338
+ */
339
+ parallelism?: number;
340
+ /**
341
+ * The plan narrows to the `--target` addresses of the preview comment
342
+ * (#4626): `pr-plan --comment-targets`, which reads the comment from
343
+ * {@link PREVIEW_COMMENT_ENV}. {@link prCommentPreviewJob} sets it on its
344
+ * own plan; a caller never needs to.
345
+ */
346
+ commentTargets?: boolean;
347
+ /**
348
+ * The plan and the comment preview refresh each step's state first
349
+ * (#4627): `pr-plan --refresh`, pulumi/actions' `refresh`. A member whose
350
+ * capability cannot is refused by name. Default false.
351
+ */
352
+ refresh?: boolean;
353
+ /**
354
+ * Stale marking (#4628): the plan note carries the target branch's commit
355
+ * it was posted against, and a `stale-notes` job on each push to the
356
+ * target branch marks every open pull request's note posted against
357
+ * another commit stale, naming the plan comment under `previewComment`,
358
+ * and sets its plan status back to pending ({@link prStaleJob}). Set
359
+ * from `--stale-notes` beside `--pr-loop`. Default false.
360
+ */
361
+ staleNotes?: boolean;
362
+ /**
363
+ * The responses to pipeline events (#4629, ../ci-respond.ts), from
364
+ * `chant build --pr-loop --respond <list>`: the apply job and the
365
+ * plan-note job carry the list as `CHANT_RESPOND`. Absent, or every event
366
+ * at its default: neither job sets it.
367
+ */
368
+ respond?: CiResponses;
369
+ /**
370
+ * The decide service the description check asks (#4629), from
371
+ * `--decide-backend` and `--decide-model`: the plan-note job passes both
372
+ * to `pr-post`. Needed with `respond.description: "check"`.
373
+ */
374
+ decide?: { backend: string; model: string };
375
+ }
376
+
377
+ /** The `CHANT_RESPOND` value of `respond` (#4629), or undefined when every event is at its default. Throws on a description check with no decide service. */
378
+ export function prLoopRespondEnv(options: Pick<PrLoopPipelineOptions, "respond" | "decide">): Record<string, string> {
379
+ if (options.respond?.description === "check" && !options.decide) throw new Error("respond.description: check asks a decide service, so the pipeline needs decide: { backend, model }");
380
+ const list = options.respond ? respondList(options.respond) : "";
381
+ return list ? { [CI_RESPOND_ENV]: list } : {};
382
+ }
383
+
384
+ /** The variable the comment preview's plan reads the comment from (#4626); never a shell argument. */
385
+ export const PREVIEW_COMMENT_ENV = "CHANT_PREVIEW_COMMENT";
386
+
387
+ /** Where the pull request loop's jobs run, by stage (#4625). */
388
+ export interface PrLoopRunners {
389
+ plan?: CiRunner;
390
+ apply?: CiRunner;
391
+ default?: CiRunner;
392
+ }
393
+
394
+ /** A pull request loop job's stage for its runner (#4625). */
395
+ export type PrLoopRunnerStage = keyof PrLoopRunners;
396
+
397
+ /** The runner of `stage` (#4625): the stage's own, else `default`, else undefined for the forge's default. */
398
+ export function prLoopRunner(options: Pick<PrLoopPipelineOptions, "runners">, stage: PrLoopRunnerStage): CiRunner | undefined {
399
+ return options.runners?.[stage] ?? options.runners?.default;
400
+ }
401
+
402
+ /**
403
+ * The runner stage of a pull request loop job by its name (#4625), with a
404
+ * workspace member's `<member>-` prefix taken off first: the plan and the
405
+ * comment preview plan; the apply jobs, the record job and a pull request
406
+ * environment's up, down and sweep apply; every other job runs on the
407
+ * default.
408
+ */
409
+ export function prLoopJobStage(name: string, member?: string): PrLoopRunnerStage {
410
+ const bare = member && name.startsWith(`${member}-`) ? name.slice(member.length + 1) : name;
411
+ if (bare === "plan" || bare === PR_COMMENT_PREVIEW_JOB) return "plan";
412
+ if (bare === "apply" || bare === "record" || /^apply-wave-\d+$/.test(bare) || bare === "env-up" || bare === "env-down" || bare === "env-sweep") return "apply";
413
+ return "default";
414
+ }
415
+
416
+ /**
417
+ * The variables and passed secrets of the jobs that plan or apply (#4625),
418
+ * as the forge spells them. Throws on a name the loop sets itself or a
419
+ * forge token, which the plan must be able to drop.
420
+ */
421
+ export function prLoopPassedEnv(forge: ForgeKind, options: Pick<PrLoopPipelineOptions, "variables" | "secrets">): Record<string, string> {
422
+ const reserved = new Set<string>([...FORGE_TOKEN_VARS, ...OIDC_REQUEST_VARS, "BASE_SHA", "PR_NUMBER", "HEAD_SHA", "GREEN_SHA", "CHANT_RUN_EVENTS_DIR", "CHANT_RUNNER_KEY"]);
423
+ const out: Record<string, string> = {};
424
+ const name = /^[A-Za-z_][A-Za-z0-9_]*$/;
425
+ for (const [key, value] of Object.entries(options.variables ?? {})) {
426
+ if (!name.test(key)) throw new Error(`the pull request jobs' variable ${JSON.stringify(key)} is not a variable name`);
427
+ if (reserved.has(key)) throw new Error(`the pull request jobs' variable ${key} is one the jobs set or drop themselves; give it another name`);
428
+ out[key] = value;
429
+ }
430
+ for (const [key, secret] of Object.entries(options.secrets ?? {})) {
431
+ if (!name.test(key) || !name.test(secret)) throw new Error(`the passed secret ${JSON.stringify(key)}: ${JSON.stringify(secret)} must map a variable name to a secret name`);
432
+ if (reserved.has(key)) throw new Error(`the passed secret ${key} is a name the jobs set or drop themselves, and the plan job drops the forge tokens before the change's code runs; pass it under another name`);
433
+ if (key in out) throw new Error(`${key} is both a variable and a passed secret of the pull request jobs; give one`);
434
+ if (forge === "gitlab") {
435
+ if (key !== secret) out[key] = `$${secret}`;
436
+ } else out[key] = githubSecret(secret);
437
+ }
438
+ return out;
298
439
  }
299
440
 
300
441
  /** The lock job's step names and commands (#4327), shared by the GitHub-shaped generators. */
301
442
  export const PR_LOCK_JOB = "lock";
302
443
  export const PR_UNLOCK_JOB = "unlock";
303
444
 
304
- /** `chant lock --from-report` for the plan's report in {@link PR_LOOP_REPORT_DIR}; reads `PR_NUMBER` and `HEAD_SHA`. */
305
- export function prLockCommand(forge: ForgeKind): string {
306
- return ["chant", "lock", "--from-report", `${PR_LOOP_REPORT_DIR}/pr-plan.json`, "--pr", '"$PR_NUMBER"', "--head", '"$HEAD_SHA"', "--stage", "plan", "--forge", forge].join(" ");
445
+ /**
446
+ * `chant lock --from-report` for the plan's report in {@link PR_LOOP_REPORT_DIR}; reads `PR_NUMBER` and `HEAD_SHA`.
447
+ * With a product's `bin` (its words), the line runs through it, as the comment lock jobs do
448
+ * (INTENTIUS/plywood#22): a product's job image need not carry `chant` on PATH.
449
+ */
450
+ export function prLockCommand(forge: ForgeKind, bin?: string): string {
451
+ return withProductBin(["chant", "lock", "--from-report", `${PR_LOOP_REPORT_DIR}/pr-plan.json`, "--pr", '"$PR_NUMBER"', "--head", '"$HEAD_SHA"', "--stage", "plan", "--forge", forge].join(" "), bin);
307
452
  }
308
453
 
309
454
  /** `chant unlock` for the pull request that closed; reads `PR_NUMBER`. */
310
455
  export const PR_UNLOCK_COMMAND = 'chant unlock --pr "$PR_NUMBER"';
311
456
 
457
+ /** {@link PR_UNLOCK_COMMAND} through a product's `bin`, as {@link prLockCommand} takes it. */
458
+ export function prUnlockCommand(bin?: string): string {
459
+ return withProductBin(PR_UNLOCK_COMMAND, bin);
460
+ }
461
+
312
462
  /** The job answering `/<product> lock` (#4588). */
313
463
  export const PR_COMMENT_LOCK_JOB = "comment-lock";
314
464
  /** The job answering `/<product> unlock` (#4588). */
@@ -428,13 +578,15 @@ export function prCommentPreviewJob(forge: ForgeKind, env: string, options: PrLo
428
578
  const comment = commentLine(words, "plan");
429
579
  if (!comment) throw new Error(`--preview-comment answers /${words.product} <plan command>, and the words name no plan command; name one in the words' commands, or drop --preview-comment`);
430
580
  // The plan job's own command: the apply side's options never reach it, so they are left out here.
431
- const { applyBeforeMerge: _early, applyRequires: _requires, applyOnMerge: _onMerge, ...planSide } = options;
432
- const [plan] = prLoopJobs(forge, env, planSide, member);
581
+ const { applyBeforeMerge: _early, applyRequires: _requires, applyMerge: _merge, applyOnMerge: _onMerge, respond: _respond, decide: _decide, ...planSide } = options;
582
+ // #4626: the comment's --target addresses narrow the preview, read from the comment in a variable.
583
+ const [plan] = prLoopJobs(forge, env, { ...planSide, commentTargets: true }, member);
433
584
  const github = forge !== "gitlab";
434
585
  const prNumber = github ? "${{ github.event.issue.number }}" : `$${GITLAB_PREVIEW_PR_VAR}`;
586
+ // GitLab: whoever starts the target-branch pipeline passes the comment as CHANT_PREVIEW_COMMENT, a pipeline variable every job has.
435
587
  const fromComment = (jobEnv: Record<string, string>): Record<string, string> => {
436
588
  const { BASE_SHA: _base, ...rest } = jobEnv;
437
- return github ? { ...rest, PR_NUMBER: prNumber } : { ...rest, PR_NUMBER: prNumber, BASE_SHA: "$CI_COMMIT_SHA" };
589
+ return github ? { ...rest, PR_NUMBER: prNumber, [PREVIEW_COMMENT_ENV]: "${{ github.event.comment.body }}" } : { ...rest, PR_NUMBER: prNumber, BASE_SHA: "$CI_COMMIT_SHA" };
438
590
  };
439
591
  const branch = options.branch ?? "main";
440
592
  const base = github
@@ -446,9 +598,12 @@ export function prCommentPreviewJob(forge: ForgeKind, env: string, options: PrLo
446
598
  "--env", env, "--output", PR_LOOP_REPORT_DIR, "--forge", forge,
447
599
  ...(member ? ["--member", member] : []),
448
600
  ...(github ? ["--result", '"$PLAN_RESULT"'] : []),
601
+ // #4628: the target branch's commit the preview measured from, for the note's tip line.
602
+ ...(options.staleNotes ? ["--tip", '"$TIP_SHA"'] : []),
449
603
  ].join(" "),
450
604
  words.bin,
451
605
  );
606
+ const tipEnv: Record<string, string> = options.staleNotes ? { TIP_SHA: github ? "${{ github.sha }}" : "$CI_COMMIT_SHA" } : {};
452
607
  return {
453
608
  jobName: PR_COMMENT_PREVIEW_JOB,
454
609
  noteJobName: PR_COMMENT_PREVIEW_NOTE_JOB,
@@ -463,12 +618,13 @@ export function prCommentPreviewJob(forge: ForgeKind, env: string, options: PrLo
463
618
  PR_NUMBER: prNumber,
464
619
  HEAD_SHA: `\${{ needs.${PR_COMMENT_PREVIEW_JOB}.outputs.${PREVIEW_HEAD_OUTPUT} }}`,
465
620
  PLAN_RESULT: `\${{ needs.${PR_COMMENT_PREVIEW_JOB}.result }}`,
621
+ ...tipEnv,
466
622
  GITHUB_TOKEN: GITHUB_JOB_TOKEN,
467
623
  },
468
624
  }
469
625
  : {
470
626
  command: postCommand,
471
- env: { PR_NUMBER: prNumber },
627
+ env: { PR_NUMBER: prNumber, ...tipEnv },
472
628
  setup: ['HEAD_SHA="$(git ls-remote origin "refs/merge-requests/$PR_NUMBER/head" | cut -f1)" && export HEAD_SHA'],
473
629
  },
474
630
  ...(github ? {} : { gitlabVar: GITLAB_PREVIEW_PR_VAR }),
@@ -517,6 +673,8 @@ export interface PrLoopJob {
517
673
  * pipeline never gets.
518
674
  */
519
675
  run: { command: string; env: Record<string, string> };
676
+ /** Where the job runs (#4625), from the loop's `runners`: the plan's or the apply's, else `default`. Absent: the forge's default. */
677
+ runner?: CiRunner;
520
678
  }
521
679
 
522
680
  /** The lines `build` (#4088) runs before a job's command: the build, then the lint. Empty without the option. */
@@ -541,6 +699,10 @@ export function prLoopJobs(forge: ForgeKind, env: string, options: PrLoopPipelin
541
699
  const asked = options.applyRequires ? parseRequiresList(options.applyRequires) : undefined;
542
700
  if (asked && "error" in asked) throw new Error(asked.error);
543
701
  const requires = early && asked ? ["--requires", asked.checks.join(",")] : [];
702
+ if (options.applyMerge && !early) throw new Error("--merge auto merges a pull request after its update before merge, so it needs --apply-before-merge");
703
+ if (options.applyMerge && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(options.applyMerge.tokenEnv)) throw new Error(`the merge token variable ${JSON.stringify(options.applyMerge.tokenEnv)} is not a variable name`);
704
+ // #4636: the merge after the update, with its own token.
705
+ const merge = early && options.applyMerge ? ["--merge", "auto", "--merge-token-env", options.applyMerge.tokenEnv, ...(options.applyMerge.method ? ["--merge-method", options.applyMerge.method] : [])] : [];
544
706
  const common = [
545
707
  "--env", env, "--gate", gate, "--output", PR_LOOP_REPORT_DIR, "--forge", forge,
546
708
  ...(member ? ["--member", member] : []),
@@ -550,15 +712,27 @@ export function prLoopJobs(forge: ForgeKind, env: string, options: PrLoopPipelin
550
712
  const github = forge !== "gitlab";
551
713
  const buildLines = prLoopBuildLines(env, options);
552
714
  const build = buildLines.length > 0 ? { build: buildLines } : {};
715
+ // #4625: the caller's variables and passed secrets, in every job that plans or applies.
553
716
  const jobEnv: Record<string, string> = {
717
+ ...prLoopPassedEnv(forge, options),
554
718
  ...(github ? { GITHUB_TOKEN: GITHUB_JOB_TOKEN } : {}),
555
719
  ...(options.events ? { CHANT_RUN_EVENTS_DIR: PR_LOOP_EVENTS_DIR } : {}),
556
720
  };
721
+ const planRunner = prLoopRunner(options, "plan");
722
+ if (options.parallelism !== undefined) {
723
+ const problem = parallelismProblem("parallelism", options.parallelism);
724
+ if (problem) throw new Error(`the pull request plan's ${problem}`);
725
+ }
726
+ const parallelism = options.parallelism !== undefined ? ["--parallelism", String(options.parallelism)] : [];
727
+ const applyRunner = prLoopRunner(options, "apply");
557
728
  // #4156: the flags `chant ci run` rebuilds `command` from. It finds the member from the directory it runs in.
558
729
  const ciRun = (job: PrLoopJob["jobName"]): string[] => [
559
730
  "chant", "ci", "run", job, "--in-place", ...(job === "plan" ? ["--no-push"] : []),
560
731
  ...(job === "apply" && !early ? [] : ["--base", '"$BASE_SHA"']), ...(job === "plan" || (job === "apply" && early) ? ["--pr", '"$PR_NUMBER"'] : []),
561
- ...(job === "apply" && early ? ["--apply-before-merge", ...requires] : []),
732
+ ...(job === "apply" && early ? ["--apply-before-merge", ...requires, ...merge] : []),
733
+ ...(job === "plan" ? parallelism : []),
734
+ ...(job === "plan" && options.commentTargets ? ["--comment-targets"] : []),
735
+ ...(job === "plan" && options.refresh ? ["--refresh"] : []),
562
736
  "--env", env, "--gate", gate, "--forge", forge,
563
737
  ...(job !== "record" && options.waveGate ? ["--wave-gate", options.waveGate] : []),
564
738
  ...(job !== "plan" && options.branch ? ["--branch", JSON.stringify(options.branch)] : []),
@@ -576,8 +750,9 @@ export function prLoopJobs(forge: ForgeKind, env: string, options: PrLoopPipelin
576
750
  const greenBranch = github ? JSON.stringify(options.branch ?? "main") : options.branch ? JSON.stringify(options.branch) : "$CI_DEFAULT_BRANCH";
577
751
  const applyEnv = github ? { BASE_SHA: "${{ github.event.before }}", ...jobEnv } : { BASE_SHA: "$CI_COMMIT_BEFORE_SHA", ...jobEnv };
578
752
  // #4301: the apply before merge runs in a job of the target branch, whose commit is the base, at the pull request's head.
753
+ const mergeSecret = github && options.applyMerge ? { [options.applyMerge.tokenEnv]: `\${{ secrets.${options.applyMerge.tokenEnv} }}` } : {};
579
754
  const earlyEnv = github
580
- ? { BASE_SHA: "${{ github.sha }}", PR_NUMBER: "${{ github.event.issue.number }}", ...jobEnv }
755
+ ? { BASE_SHA: "${{ github.sha }}", PR_NUMBER: "${{ github.event.issue.number }}", ...jobEnv, ...mergeSecret }
581
756
  : { BASE_SHA: "$CI_COMMIT_SHA", PR_NUMBER: `$${GITLAB_APPLY_PR_VAR}`, ...jobEnv };
582
757
  const greenApply: PrLoopJob = {
583
758
  // #4168 step 9: the apply applies the newest green commit, measured from the one applied before it.
@@ -591,6 +766,7 @@ export function prLoopJobs(forge: ForgeKind, env: string, options: PrLoopPipelin
591
766
  env: jobEnv,
592
767
  checkout: [greenCheckout(greenBranch)],
593
768
  greenBranch,
769
+ ...(applyRunner !== undefined ? { runner: applyRunner } : {}),
594
770
  ...build,
595
771
  run: { command: ciRun("apply").join(" "), env: runEnv(jobEnv) },
596
772
  };
@@ -598,32 +774,39 @@ export function prLoopJobs(forge: ForgeKind, env: string, options: PrLoopPipelin
598
774
  // #4301: the requires checks run inside pr-apply, before any of the head's code loads.
599
775
  jobName: "apply",
600
776
  command: [
601
- "chant", "components", "pr-apply", "--before-merge", ...requires, "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...common,
777
+ "chant", "components", "pr-apply", "--before-merge", ...requires, ...merge, "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...common,
602
778
  ...(options.requireReview === true ? ["--require-review"] : []),
603
779
  "--resume", PR_APPLY_RECORD,
604
780
  ].join(" "),
605
781
  env: earlyEnv,
606
782
  checkout: [pullRequestCheckout(forge)],
783
+ ...(applyRunner !== undefined ? { runner: applyRunner } : {}),
607
784
  run: { command: ciRun("apply").join(" "), env: runEnv(earlyEnv) },
608
785
  };
609
786
  const bin = options.words?.bin;
787
+ // #4629: the apply posts a failed apply's triage and a refused one's diff as CHANT_RESPOND says.
788
+ const respondEnv = prLoopRespondEnv(options);
789
+ const withRespond = (job: PrLoopJob): PrLoopJob => (Object.keys(respondEnv).length > 0 ? { ...job, env: { ...job.env, ...respondEnv }, run: { ...job.run, env: { ...job.run.env, ...respondEnv } } } : job);
610
790
  return [
611
791
  {
612
792
  jobName: "plan",
613
793
  // With `waveGate` the plan's note says the later waves may stop at their own gates (#4003).
614
- command: ["chant", "components", "pr-plan", "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...common, ...(options.waveGate ? ["--wave-gate", options.waveGate] : []), "--no-status"].join(" "),
794
+ command: ["chant", "components", "pr-plan", "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...common, ...(options.waveGate ? ["--wave-gate", options.waveGate] : []), ...parallelism, ...(options.commentTargets ? ["--comment-targets"] : []), ...(options.refresh ? ["--refresh"] : []), "--no-status"].join(" "),
615
795
  env: planEnv,
616
796
  ...build,
797
+ ...(planRunner !== undefined ? { runner: planRunner } : {}),
617
798
  // #4328: no runner key either. The step drops it, but the job's environment is the pull request's code's too.
618
799
  run: { command: ciRun("plan").join(" "), env: planEnv },
619
800
  },
620
- early ? earlyApply : greenApply,
801
+ withRespond(early ? earlyApply : greenApply),
621
802
  {
622
803
  jobName: "record",
623
804
  command: ["chant", "components", "pr-record", "--base", '"$BASE_SHA"', ...common].join(" "),
624
805
  env: applyEnv,
625
806
  setup: [github ? githubBaseFallback(options.branch) : gitlabBaseFallback(options.branch)],
626
807
  ...build,
808
+ // The record runs on merge, where the apply would.
809
+ ...(applyRunner !== undefined ? { runner: applyRunner } : {}),
627
810
  run: { command: ciRun("record").join(" "), env: runEnv(applyEnv) },
628
811
  },
629
812
  ].map((job) => jobWithBin(job as PrLoopJob, bin));
@@ -648,11 +831,21 @@ export const PR_PLAN_NOTE_JOB = "plan-note";
648
831
  * asks GitLab for each open merge request's plan job and reads its report
649
832
  * from the job's artifacts.
650
833
  */
651
- export function prLoopPostJob(forge: ForgeKind, env: string, member?: string, words?: Pick<CiProductWordsInput, "bin">): { command: string; env: Record<string, string> } {
834
+ export function prLoopPostJob(forge: ForgeKind, env: string, member?: string, words?: Pick<CiProductWordsInput, "bin">, opts: { staleNotes?: boolean } & Pick<PrLoopPipelineOptions, "respond" | "decide"> = {}): { command: string; env: Record<string, string> } {
835
+ // #4629: the responses as CHANT_RESPOND, and with the description check its decide service on the line.
836
+ const respondEnv = prLoopRespondEnv(opts);
837
+ const decide = opts.respond?.description === "check" && opts.decide ? ` --decide-backend ${JSON.stringify(opts.decide.backend)} --decide-model ${JSON.stringify(opts.decide.model)}` : "";
838
+ const job = prLoopPostJobBase(forge, env, member, words, opts);
839
+ return decide || Object.keys(respondEnv).length > 0 ? { command: `${job.command}${decide}`, env: { ...job.env, ...respondEnv } } : job;
840
+ }
841
+
842
+ function prLoopPostJobBase(forge: ForgeKind, env: string, member: string | undefined, words: Pick<CiProductWordsInput, "bin"> | undefined, opts: { staleNotes?: boolean }): { command: string; env: Record<string, string> } {
843
+ // #4628: with staleNotes the note carries the target branch's commit, so a later push can mark it stale.
844
+ const tip = opts.staleNotes ? ["--tip", '"$TIP_SHA"'] : [];
652
845
  if (forge === "gitlab") {
653
846
  return {
654
- command: withProductBin(["chant", "components", "pr-post", "--open", "--env", env, "--output", PR_LOOP_REPORT_DIR, "--forge", forge, ...(member ? ["--member", member] : [])].join(" "), words?.bin),
655
- env: {},
847
+ command: withProductBin(["chant", "components", "pr-post", "--open", "--env", env, "--output", PR_LOOP_REPORT_DIR, "--forge", forge, ...(member ? ["--member", member] : []), ...tip].join(" "), words?.bin),
848
+ env: opts.staleNotes ? { TIP_SHA: "$CI_COMMIT_SHA" } : {},
656
849
  };
657
850
  }
658
851
  const command = [
@@ -660,10 +853,42 @@ export function prLoopPostJob(forge: ForgeKind, env: string, member?: string, wo
660
853
  "--env", env, "--output", PR_LOOP_REPORT_DIR, "--forge", forge,
661
854
  ...(member ? ["--member", member] : []),
662
855
  "--result", '"$PLAN_RESULT"',
856
+ ...tip,
663
857
  ].join(" ");
664
858
  return {
665
859
  command: withProductBin(command, words?.bin),
666
- env: { PR_NUMBER: "${{ github.event.pull_request.number }}", HEAD_SHA: "${{ github.sha }}", PLAN_RESULT: "${{ needs.plan.result }}", GITHUB_TOKEN: GITHUB_JOB_TOKEN },
860
+ env: {
861
+ PR_NUMBER: "${{ github.event.pull_request.number }}",
862
+ HEAD_SHA: "${{ github.sha }}",
863
+ PLAN_RESULT: "${{ needs.plan.result }}",
864
+ ...(opts.staleNotes ? { TIP_SHA: "${{ github.event.pull_request.base.sha }}" } : {}),
865
+ GITHUB_TOKEN: GITHUB_JOB_TOKEN,
866
+ },
867
+ };
868
+ }
869
+
870
+ /** The job that marks the open pull requests' notes stale after a push to the target branch (#4628). */
871
+ export const PR_STALE_JOB = "stale-notes";
872
+
873
+ /**
874
+ * The stale job's command and the values it reads (#4628), with
875
+ * `staleNotes`: on a push to the target branch, at its commit, `pr-post
876
+ * --stale` marks each open pull request's note posted against another
877
+ * commit stale and sets its plan status back to pending. It names the plan
878
+ * comment with `previewComment`. Undefined without `staleNotes`.
879
+ */
880
+ export function prStaleJob(forge: ForgeKind, env: string, options: Pick<PrLoopPipelineOptions, "staleNotes" | "previewComment" | "branch" | "words"> = {}, member?: string): { command: string; env: Record<string, string> } | undefined {
881
+ if (!options.staleNotes) return undefined;
882
+ const words = resolveProductWords(options.words);
883
+ const command = [
884
+ "chant", "components", "pr-post", "--stale", "--tip", '"$TIP_SHA"', "--env", env, "--forge", forge,
885
+ ...(options.branch ? ["--branch", JSON.stringify(options.branch)] : []),
886
+ ...(member ? ["--member", member] : []),
887
+ ...(options.previewComment ? ["--preview-comment"] : []),
888
+ ].join(" ");
889
+ return {
890
+ command: withProductBin(command, words.bin),
891
+ env: forge === "gitlab" ? { TIP_SHA: "$CI_COMMIT_SHA" } : { TIP_SHA: "${{ github.sha }}", GITHUB_TOKEN: GITHUB_JOB_TOKEN },
667
892
  };
668
893
  }
669
894
 
@@ -873,8 +1098,7 @@ export function githubBaseFallback(branch?: string): string {
873
1098
  return pushBaseFallback(JSON.stringify(branch ?? "main"), "$GITHUB_SHA");
874
1099
  }
875
1100
 
876
- /** Where the pull request environment jobs (#4298) write their reports, kept as a CI artifact. */
877
- export const PR_ENV_REPORT_DIR = ".chant/pr-env";
1101
+ export { PR_ENV_REPORT_DIR } from "../ci-jobs";
878
1102
 
879
1103
  /** The cron the generated `env-sweep` job runs on (#4298): hourly, at a minute off the hour. */
880
1104
  export const PR_ENV_SWEEP_CRON = "17 * * * *";
@@ -116,6 +116,7 @@ import type { RunEventSink } from "../run-event-stream";
116
116
  import { capabilitySteps, planWaveComponent, readDeployedOutputs, type CapabilityPolicyFindings, type WaveComponentPlan } from "./wave-plan";
117
117
  import type { PrMigrationFile } from "../pr-migrations";
118
118
  import { markCrossStackEdges, type CrossStackRead } from "../control/edges";
119
+ import { mapLimited } from "../parallelism";
119
120
 
120
121
  export interface PrPlanSetOptions {
121
122
  /** Every component in the project, not the selection: a planned member's dependency outside it is read too (#4104). */
@@ -129,6 +130,12 @@ export interface PrPlanSetOptions {
129
130
  seededOutputs?: Record<string, Record<string, unknown>>;
130
131
  /** The addresses each component narrows to (#4300), by component: its steps' `DeployContext.targets`. */
131
132
  targets?: Readonly<Record<string, readonly string[]>>;
133
+ /** How many members of a wave plan at once (#4625, `pr-plan --parallelism`); a group counts as one. Default: all of them. */
134
+ parallelism?: number;
135
+ /** `pr-plan --refresh` (#4627): every step's `DeployContext.refresh`. */
136
+ refresh?: boolean;
137
+ /** `pr-plan --target-dependents` (#4627): `DeployContext.targetDependents` for each component with targets. */
138
+ targetDependents?: boolean;
132
139
  /** `ci.lockGrain` as declared at base (#4552); absent, each member takes its lexicon's default. */
133
140
  lockGrain?: LockGrain;
134
141
  /** The commit policy is read at (#4613), every step's `DeployContext.policyBase`: the pull request's base. */
@@ -184,6 +191,8 @@ export interface PrPlanSet {
184
191
  groups?: PrPlanGroup[];
185
192
  /** The components that could have grouped and did not, with why (ws-107, ruling 1): the fan-out's `fallbacks`. */
186
193
  fallbacks?: FanOutGroupFallback[];
194
+ /** The addresses each component's plan was narrowed to (#4626, `pr-plan --target`), by component. Absent when nothing was narrowed. */
195
+ targets?: Record<string, string[]>;
187
196
  /** Whether any component failed to plan. */
188
197
  failed: boolean;
189
198
  /** A capability's plan threw `policyDenied` (#4550): the stage exits 7, not 1. */
@@ -279,18 +288,18 @@ export async function planPrSet(options: PrPlanSetOptions): Promise<PrPlanSet> {
279
288
  });
280
289
  };
281
290
  const groupsHere = [...new Set(wave.map((name) => groupOf.get(name)).filter((g): g is FanOutGroup => g !== undefined))];
282
- const results = (
283
- await Promise.all([
291
+ // #4625: at most `parallelism` plans at once, members and groups alike.
292
+ const tasks: Array<() => Promise<WaveComponentPlan[]>> = [
284
293
  ...wave
285
294
  .filter((name) => !groupOf.has(name))
286
- .map(async (name) => {
295
+ .map((name) => async () => {
287
296
  emit?.({ type: "step-start", component: name, phase: PR_PLAN_PHASE, step: "plan" });
288
297
  const start = Date.now();
289
298
  const p = await planWaveComponent(byName.get(name)!, options.registry, deployContext(options, name), outputs);
290
299
  settle(name, start, p);
291
300
  return [p];
292
301
  }),
293
- ...groupsHere.map(async (group) => {
302
+ ...groupsHere.map((group) => async () => {
294
303
  for (const name of group.components) emit?.({ type: "step-start", component: name, phase: PR_PLAN_PHASE, step: "plan" });
295
304
  const start = Date.now();
296
305
  const g = await planComponentGroup({
@@ -307,8 +316,8 @@ export async function planPrSet(options: PrPlanSetOptions): Promise<PrPlanSet> {
307
316
  groups.push({ ...group, digest: g.digest ?? null, ...(error !== undefined ? { error } : {}), ...(g.run ? { run: g.run } : {}) });
308
317
  return g.plans;
309
318
  }),
310
- ])
311
- ).flat();
319
+ ];
320
+ const results = (await mapLimited(tasks, options.parallelism, (task) => task())).flat();
312
321
  /** What each member of a group planned to expose, for its group-mates' reads. */
313
322
  const plannedHere = new Map(results.map((p) => [p.component, "error" in p ? undefined : p.outputs?.known]));
314
323
  for (const p of results) {
@@ -381,6 +390,7 @@ export async function planPrSet(options: PrPlanSetOptions): Promise<PrPlanSet> {
381
390
  ...(Object.keys(locations).length > 0 ? { locations } : {}),
382
391
  ...(Object.keys(deployedOutputs).length > 0 ? { deployedOutputs } : {}),
383
392
  ...(Object.keys(plannedOutputs).length > 0 ? { plannedOutputs } : {}),
393
+ ...(options.targets && Object.keys(options.targets).length > 0 ? { targets: Object.fromEntries(Object.entries(options.targets).map(([c, a]) => [c, [...a]])) } : {}),
384
394
  };
385
395
  }
386
396
 
@@ -1248,6 +1258,7 @@ export function prReport(input: PrReportInput): PrReport {
1248
1258
  ...(input.resumed ? { resumed: { applied: [...input.resumed].sort() } } : {}),
1249
1259
  ...(input.set.deployedOutputs ? { deployedOutputs: input.set.deployedOutputs } : {}),
1250
1260
  ...(input.set.plannedOutputs ? { plannedOutputs: input.set.plannedOutputs } : {}),
1261
+ ...(input.set.targets ? { narrowed: input.set.targets } : {}),
1251
1262
  ...(input.rounds && input.rounds.length > 0 ? { rounds: input.rounds } : {}),
1252
1263
  ...(input.migrations && input.migrations.length > 0 ? { migrations: input.migrations } : {}),
1253
1264
  approval: input.approval,
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The stale job's descriptor (#4628): `prStaleJob` on the three forges, the
3
+ * note job's tip, and productPipelineJobs returning both. Written for the
4
+ * ci-products post-merge pass.
5
+ */
6
+ import { describe, expect, test } from "vitest";
7
+ import { prLoopPostJob, prStaleJob } from "./pr-pipeline";
8
+ import { productPipelineJobs } from "./product-pipeline";
9
+ import { PLYWOOD } from "../__fixtures__/product-words";
10
+
11
+ describe("the stale job (#4628)", () => {
12
+ test("none without staleNotes", () => {
13
+ expect(prStaleJob("github", "prod", {})).toBeUndefined();
14
+ });
15
+
16
+ test("GitHub and Forgejo read the pushed commit; GitLab the pipeline's", () => {
17
+ expect(prStaleJob("github", "prod", { staleNotes: true })).toEqual({ command: 'chant components pr-post --stale --tip "$TIP_SHA" --env prod --forge github', env: { TIP_SHA: "${{ github.sha }}", GITHUB_TOKEN: "${{ github.token }}" } });
18
+ expect(prStaleJob("forgejo", "prod", { staleNotes: true, branch: "trunk" }, "shop")!.command).toBe('chant components pr-post --stale --tip "$TIP_SHA" --env prod --forge forgejo --branch "trunk" --member shop');
19
+ expect(prStaleJob("gitlab", "prod", { staleNotes: true })!.env).toEqual({ TIP_SHA: "$CI_COMMIT_SHA" });
20
+ });
21
+
22
+ test("the note job passes the tip only with staleNotes", () => {
23
+ expect(prLoopPostJob("github", "prod").command).not.toContain("--tip");
24
+ expect(prLoopPostJob("github", "prod", undefined, undefined, { staleNotes: true }).env.TIP_SHA).toBe("${{ github.event.pull_request.base.sha }}");
25
+ expect(prLoopPostJob("gitlab", "prod", undefined, undefined, { staleNotes: true }).command).toContain('--tip "$TIP_SHA"');
26
+ });
27
+
28
+ test("productPipelineJobs returns the stale job in the product's bin, naming the preview comment", () => {
29
+ const words = { ...PLYWOOD, commands: { preview: "plan" as const } };
30
+ const jobs = productPipelineJobs("github", "prod", { words, staleNotes: true, previewComment: true });
31
+ expect(jobs.stale!.command).toBe('npx --no-install plywood components pr-post --stale --tip "$TIP_SHA" --env prod --forge github --preview-comment');
32
+ expect(jobs.post.command).toContain('--tip "$TIP_SHA"');
33
+ });
34
+ });