@intentius/chant 0.124.87 → 0.124.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/dist/action-pins.d.ts +1 -0
  2. package/dist/action-pins.d.ts.map +1 -1
  3. package/dist/action-pins.js +2 -0
  4. package/dist/actor.d.ts +47 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +56 -0
  7. package/dist/bundle-check.d.ts +20 -5
  8. package/dist/bundle-check.d.ts.map +1 -1
  9. package/dist/bundle-check.js +20 -5
  10. package/dist/chant-install.d.ts +98 -0
  11. package/dist/chant-install.d.ts.map +1 -1
  12. package/dist/chant-install.js +203 -2
  13. package/dist/ci-base.d.ts +30 -0
  14. package/dist/ci-base.d.ts.map +1 -0
  15. package/dist/ci-base.js +33 -0
  16. package/dist/ci-comment-commands.d.ts +177 -0
  17. package/dist/ci-comment-commands.d.ts.map +1 -0
  18. package/dist/ci-comment-commands.js +325 -0
  19. package/dist/ci-comment-replies.d.ts +40 -0
  20. package/dist/ci-comment-replies.d.ts.map +1 -0
  21. package/dist/ci-comment-replies.js +59 -0
  22. package/dist/ci-commit.d.ts +1 -1
  23. package/dist/ci-commit.d.ts.map +1 -1
  24. package/dist/ci-commit.js +1 -2
  25. package/dist/ci-control.d.ts +1 -1
  26. package/dist/ci-control.d.ts.map +1 -1
  27. package/dist/ci-control.js +1 -1
  28. package/dist/ci-evidence-claims.d.ts +59 -0
  29. package/dist/ci-evidence-claims.d.ts.map +1 -0
  30. package/dist/ci-evidence-claims.js +87 -0
  31. package/dist/ci-evidence-from-job.d.ts +128 -0
  32. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  33. package/dist/ci-evidence-from-job.js +203 -0
  34. package/dist/ci-evidence-jobs.d.ts +68 -4
  35. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  36. package/dist/ci-evidence-jobs.js +82 -5
  37. package/dist/ci-handover.d.ts +12 -0
  38. package/dist/ci-handover.d.ts.map +1 -1
  39. package/dist/ci-handover.js +15 -3
  40. package/dist/ci-identity.d.ts +32 -6
  41. package/dist/ci-identity.d.ts.map +1 -1
  42. package/dist/ci-identity.js +40 -8
  43. package/dist/ci-image.d.ts +65 -10
  44. package/dist/ci-image.d.ts.map +1 -1
  45. package/dist/ci-image.js +101 -22
  46. package/dist/ci-jobs.d.ts +1 -1
  47. package/dist/ci-jobs.d.ts.map +1 -1
  48. package/dist/ci-jobs.js +7 -2
  49. package/dist/ci-login.d.ts +75 -13
  50. package/dist/ci-login.d.ts.map +1 -1
  51. package/dist/ci-login.js +89 -37
  52. package/dist/ci-note-commands.d.ts +63 -3
  53. package/dist/ci-note-commands.d.ts.map +1 -1
  54. package/dist/ci-note-commands.js +69 -35
  55. package/dist/ci-product-words.d.ts +62 -1
  56. package/dist/ci-product-words.d.ts.map +1 -1
  57. package/dist/ci-product-words.js +52 -1
  58. package/dist/ci-product.d.ts +52 -2
  59. package/dist/ci-product.d.ts.map +1 -1
  60. package/dist/ci-product.js +51 -2
  61. package/dist/cli/commands/build.d.ts.map +1 -1
  62. package/dist/cli/commands/build.js +29 -2
  63. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  64. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  65. package/dist/cli/handlers/approve-confirm.js +46 -0
  66. package/dist/cli/handlers/approve.d.ts.map +1 -1
  67. package/dist/cli/handlers/approve.js +2 -1
  68. package/dist/cli/handlers/build.d.ts +1 -1
  69. package/dist/cli/handlers/build.d.ts.map +1 -1
  70. package/dist/cli/handlers/build.js +22 -1
  71. package/dist/cli/handlers/ci-check.d.ts +1 -1
  72. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  73. package/dist/cli/handlers/ci-check.js +37 -7
  74. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  75. package/dist/cli/handlers/ci-evidence.js +255 -20
  76. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  77. package/dist/cli/handlers/ci-forge-check.js +34 -17
  78. package/dist/cli/handlers/components.d.ts.map +1 -1
  79. package/dist/cli/handlers/components.js +3 -1
  80. package/dist/cli/handlers/generated-check.d.ts +11 -0
  81. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  82. package/dist/cli/handlers/generated-check.js +71 -0
  83. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  84. package/dist/cli/handlers/lifecycle.js +3 -0
  85. package/dist/cli/handlers/local-chant.d.ts +13 -0
  86. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  87. package/dist/cli/handlers/local-chant.js +42 -1
  88. package/dist/cli/handlers/lock.d.ts.map +1 -1
  89. package/dist/cli/handlers/lock.js +121 -4
  90. package/dist/cli/handlers/pr-comment.d.ts +21 -0
  91. package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
  92. package/dist/cli/handlers/pr-comment.js +112 -0
  93. package/dist/cli/handlers/pr-env.d.ts.map +1 -1
  94. package/dist/cli/handlers/pr-env.js +6 -3
  95. package/dist/cli/handlers/pr.d.ts +23 -1
  96. package/dist/cli/handlers/pr.d.ts.map +1 -1
  97. package/dist/cli/handlers/pr.js +97 -14
  98. package/dist/cli/handlers/promote.d.ts.map +1 -1
  99. package/dist/cli/handlers/promote.js +2 -1
  100. package/dist/cli/handlers/release.d.ts.map +1 -1
  101. package/dist/cli/handlers/release.js +11 -2
  102. package/dist/cli/handlers/run-wave.d.ts.map +1 -1
  103. package/dist/cli/handlers/run-wave.js +36 -2
  104. package/dist/cli/handlers/run.d.ts.map +1 -1
  105. package/dist/cli/handlers/run.js +2 -1
  106. package/dist/cli/main.d.ts.map +1 -1
  107. package/dist/cli/main.js +60 -4
  108. package/dist/cli/parse-args.d.ts.map +1 -1
  109. package/dist/cli/parse-args.js +82 -0
  110. package/dist/cli/registry.d.ts +35 -0
  111. package/dist/cli/registry.d.ts.map +1 -1
  112. package/dist/components/auto-release.d.ts.map +1 -1
  113. package/dist/components/auto-release.js +2 -1
  114. package/dist/components/check-hooks.d.ts +10 -0
  115. package/dist/components/check-hooks.d.ts.map +1 -1
  116. package/dist/components/check-hooks.js +18 -0
  117. package/dist/components/pr-checks.d.ts +169 -0
  118. package/dist/components/pr-checks.d.ts.map +1 -0
  119. package/dist/components/pr-checks.js +180 -0
  120. package/dist/components/pr-pipeline.d.ts +38 -0
  121. package/dist/components/pr-pipeline.d.ts.map +1 -1
  122. package/dist/components/pr-pipeline.js +6 -1
  123. package/dist/components/product-pipeline.d.ts +58 -2
  124. package/dist/components/product-pipeline.d.ts.map +1 -1
  125. package/dist/components/product-pipeline.js +76 -9
  126. package/dist/components/product-plan.d.ts +445 -7
  127. package/dist/components/product-plan.d.ts.map +1 -1
  128. package/dist/components/product-plan.js +426 -15
  129. package/dist/config.d.ts +10 -6
  130. package/dist/config.d.ts.map +1 -1
  131. package/dist/config.js +11 -6
  132. package/dist/control/consumers.d.ts +6 -0
  133. package/dist/control/consumers.d.ts.map +1 -1
  134. package/dist/control/consumers.js +6 -0
  135. package/dist/dead-guards.d.ts.map +1 -1
  136. package/dist/dead-guards.js +9 -6
  137. package/dist/discovery/files.d.ts +1 -1
  138. package/dist/discovery/files.js +1 -1
  139. package/dist/drift-issue.d.ts +20 -3
  140. package/dist/drift-issue.d.ts.map +1 -1
  141. package/dist/drift-issue.js +16 -0
  142. package/dist/drift-record.d.ts +52 -5
  143. package/dist/drift-record.d.ts.map +1 -1
  144. package/dist/drift-record.js +46 -6
  145. package/dist/floor-table.d.ts +6 -6
  146. package/dist/floor-table.d.ts.map +1 -1
  147. package/dist/floor-table.data.d.ts.map +1 -1
  148. package/dist/floor-table.data.js +81 -21
  149. package/dist/floor-table.js +10 -7
  150. package/dist/forge-check/contract.d.ts +19 -1
  151. package/dist/forge-check/contract.d.ts.map +1 -1
  152. package/dist/forge-check/contract.js +8 -2
  153. package/dist/forge-check/index.d.ts +4 -0
  154. package/dist/forge-check/index.d.ts.map +1 -1
  155. package/dist/forge-check/index.js +4 -0
  156. package/dist/forge-flags.d.ts +10 -0
  157. package/dist/forge-flags.d.ts.map +1 -1
  158. package/dist/forge-flags.js +31 -0
  159. package/dist/forge-remote.d.ts +47 -0
  160. package/dist/forge-remote.d.ts.map +1 -0
  161. package/dist/forge-remote.js +69 -0
  162. package/dist/gate-resume-run.d.ts +9 -1
  163. package/dist/gate-resume-run.d.ts.map +1 -1
  164. package/dist/gate-resume-run.js +26 -3
  165. package/dist/generated-check.d.ts +88 -0
  166. package/dist/generated-check.d.ts.map +1 -0
  167. package/dist/generated-check.js +248 -0
  168. package/dist/image-pins.d.ts +26 -0
  169. package/dist/image-pins.d.ts.map +1 -0
  170. package/dist/image-pins.js +19 -0
  171. package/dist/lexicon.d.ts +27 -0
  172. package/dist/lexicon.d.ts.map +1 -1
  173. package/dist/lifecycle/git.d.ts +11 -0
  174. package/dist/lifecycle/git.d.ts.map +1 -1
  175. package/dist/lifecycle/git.js +30 -3
  176. package/dist/lifecycle/publish-npm.d.ts +26 -0
  177. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  178. package/dist/lifecycle/publish-npm.js +76 -4
  179. package/dist/lifecycle/reach-locks.d.ts +131 -0
  180. package/dist/lifecycle/reach-locks.d.ts.map +1 -0
  181. package/dist/lifecycle/reach-locks.js +118 -0
  182. package/dist/lifecycle/release-cut.d.ts +3 -1
  183. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  184. package/dist/lifecycle/release-cut.js +15 -0
  185. package/dist/lifecycle/release-images.d.ts +22 -1
  186. package/dist/lifecycle/release-images.d.ts.map +1 -1
  187. package/dist/lifecycle/release-images.js +26 -3
  188. package/dist/lifecycle/release-ledger.d.ts +4 -3
  189. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  190. package/dist/lifecycle/release-ledger.js +3 -2
  191. package/dist/local-chant.d.ts +57 -3
  192. package/dist/local-chant.d.ts.map +1 -1
  193. package/dist/local-chant.js +122 -13
  194. package/dist/notify-product.d.ts +12 -3
  195. package/dist/notify-product.d.ts.map +1 -1
  196. package/dist/notify-product.js +10 -6
  197. package/dist/op/activities/source-release.d.ts.map +1 -1
  198. package/dist/op/activities/source-release.js +2 -1
  199. package/dist/op/activities/source-rollback.d.ts.map +1 -1
  200. package/dist/op/activities/source-rollback.js +2 -1
  201. package/dist/op/index.d.ts +2 -0
  202. package/dist/op/index.d.ts.map +1 -1
  203. package/dist/op/index.js +1 -0
  204. package/dist/op/op-waves-evidence-jobs.d.ts +97 -0
  205. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  206. package/dist/op/op-waves-evidence-jobs.js +118 -0
  207. package/dist/op/op-waves-evidence.d.ts +12 -1
  208. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  209. package/dist/op/op-waves-evidence.js +23 -2
  210. package/dist/op/op-waves-render-spec.d.ts +100 -0
  211. package/dist/op/op-waves-render-spec.d.ts.map +1 -0
  212. package/dist/op/op-waves-render-spec.js +162 -0
  213. package/dist/op/op-waves-run.d.ts +14 -1
  214. package/dist/op/op-waves-run.d.ts.map +1 -1
  215. package/dist/op/op-waves-run.js +56 -4
  216. package/dist/op/op-waves.d.ts +12 -0
  217. package/dist/op/op-waves.d.ts.map +1 -1
  218. package/dist/op/op-waves.js +14 -1
  219. package/dist/op/schedule-overdue.d.ts +39 -2
  220. package/dist/op/schedule-overdue.d.ts.map +1 -1
  221. package/dist/op/schedule-overdue.js +148 -10
  222. package/dist/op/wave-stop.d.ts +64 -0
  223. package/dist/op/wave-stop.d.ts.map +1 -0
  224. package/dist/op/wave-stop.js +127 -0
  225. package/dist/planned-files.d.ts +76 -0
  226. package/dist/planned-files.d.ts.map +1 -0
  227. package/dist/planned-files.js +108 -0
  228. package/dist/pr-forge-job.d.ts +22 -0
  229. package/dist/pr-forge-job.d.ts.map +1 -0
  230. package/dist/pr-forge-job.js +46 -0
  231. package/dist/pr-forge-reads.d.ts +21 -1
  232. package/dist/pr-forge-reads.d.ts.map +1 -1
  233. package/dist/pr-forge-reads.js +19 -1
  234. package/dist/pr-forge.d.ts +7 -1
  235. package/dist/pr-forge.d.ts.map +1 -1
  236. package/dist/pr-forge.js +7 -2
  237. package/dist/pr-loop.d.ts +3 -6
  238. package/dist/pr-loop.d.ts.map +1 -1
  239. package/dist/pr-loop.js +4 -81
  240. package/dist/pr-plan-note.d.ts +121 -0
  241. package/dist/pr-plan-note.d.ts.map +1 -1
  242. package/dist/pr-plan-note.js +104 -1
  243. package/dist/pr-plan-record.d.ts +47 -0
  244. package/dist/pr-plan-record.d.ts.map +1 -0
  245. package/dist/pr-plan-record.js +89 -0
  246. package/dist/pr-post.d.ts +68 -3
  247. package/dist/pr-post.d.ts.map +1 -1
  248. package/dist/pr-post.js +218 -13
  249. package/dist/pr-requires.d.ts +8 -0
  250. package/dist/pr-requires.d.ts.map +1 -1
  251. package/dist/pr-requires.js +3 -1
  252. package/dist/pr-status.d.ts +16 -0
  253. package/dist/pr-status.d.ts.map +1 -0
  254. package/dist/pr-status.js +90 -0
  255. package/dist/ref-gate-init.d.ts +90 -0
  256. package/dist/ref-gate-init.d.ts.map +1 -0
  257. package/dist/ref-gate-init.js +155 -0
  258. package/dist/ref-gate-rules.d.ts +19 -0
  259. package/dist/ref-gate-rules.d.ts.map +1 -0
  260. package/dist/ref-gate-rules.js +17 -0
  261. package/dist/release-floors.d.ts +100 -16
  262. package/dist/release-floors.d.ts.map +1 -1
  263. package/dist/release-floors.js +101 -17
  264. package/dist/render-module.d.ts +15 -0
  265. package/dist/render-module.d.ts.map +1 -0
  266. package/dist/render-module.js +73 -0
  267. package/dist/state-migration.d.ts +24 -1
  268. package/dist/state-migration.d.ts.map +1 -1
  269. package/dist/state-migration.js +39 -4
  270. package/dist/state-unlock.d.ts +32 -1
  271. package/dist/state-unlock.d.ts.map +1 -1
  272. package/dist/state-unlock.js +31 -0
  273. package/dist/wave-runtime.mjs +307 -297
  274. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  275. package/dist/workspace/ci-green-cli.js +15 -8
  276. package/dist/workspace/drift-cli.d.ts +1 -1
  277. package/dist/workspace/drift-cli.d.ts.map +1 -1
  278. package/dist/workspace/drift-cli.js +5 -12
  279. package/dist/workspace/forge-work.d.ts +3 -2
  280. package/dist/workspace/forge-work.d.ts.map +1 -1
  281. package/dist/workspace/forge-work.js +7 -17
  282. package/dist/workspace/lexicon-outputs.js +2 -2
  283. package/dist/workspace/release-train.d.ts.map +1 -1
  284. package/dist/workspace/release-train.js +2 -1
  285. package/dist/workspace/release-workflow.d.ts +27 -3
  286. package/dist/workspace/release-workflow.d.ts.map +1 -1
  287. package/dist/workspace/release-workflow.js +52 -7
  288. package/dist/workspace/trust/check-evidence-report.d.ts +25 -2
  289. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  290. package/dist/workspace/trust/check-evidence-report.js +28 -8
  291. package/dist/workspace/trust/check-evidence.d.ts +13 -1
  292. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  293. package/dist/workspace/trust/check-evidence.js +8 -3
  294. package/dist/workspace/trust/evidence.d.ts +5 -0
  295. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  296. package/dist/workspace/trust/evidence.js +5 -0
  297. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  298. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  299. package/dist/workspace/trust/open-evidence.js +92 -0
  300. package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
  301. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  302. package/dist/workspace/trust/ref-gate-cli.js +93 -11
  303. package/dist/workspace/trust/ref-gate.d.ts +61 -2
  304. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  305. package/dist/workspace/trust/ref-gate.js +72 -7
  306. package/dist/workspace/workspace-run.d.ts.map +1 -1
  307. package/dist/workspace/workspace-run.js +2 -1
  308. package/package.json +1 -1
  309. package/src/action-pins.ts +2 -0
  310. package/src/actor.test.ts +78 -0
  311. package/src/actor.ts +79 -0
  312. package/src/bundle-check.test.ts +22 -0
  313. package/src/bundle-check.ts +33 -5
  314. package/src/chant-install.test.ts +108 -1
  315. package/src/chant-install.ts +242 -2
  316. package/src/ci-base.test.ts +41 -0
  317. package/src/ci-base.ts +43 -0
  318. package/src/ci-comment-commands.test.ts +376 -0
  319. package/src/ci-comment-commands.ts +389 -0
  320. package/src/ci-comment-replies.ts +78 -0
  321. package/src/ci-commit.test.ts +51 -6
  322. package/src/ci-commit.ts +1 -2
  323. package/src/ci-control.ts +1 -0
  324. package/src/ci-evidence-claims.ts +102 -0
  325. package/src/ci-evidence-from-job.test.ts +165 -0
  326. package/src/ci-evidence-from-job.ts +251 -0
  327. package/src/ci-evidence-jobs.ts +88 -6
  328. package/src/ci-handover.ts +16 -3
  329. package/src/ci-identity.test.ts +3 -3
  330. package/src/ci-identity.ts +51 -11
  331. package/src/ci-image.test.ts +187 -16
  332. package/src/ci-image.ts +157 -25
  333. package/src/ci-jobs.ts +7 -2
  334. package/src/ci-login.test.ts +131 -3
  335. package/src/ci-login.token-drop.test.ts +204 -0
  336. package/src/ci-login.ts +137 -39
  337. package/src/ci-note-commands.ts +104 -41
  338. package/src/ci-product-words.ts +89 -0
  339. package/src/ci-product.ts +62 -1
  340. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  341. package/src/cli/commands/build.test.ts +41 -0
  342. package/src/cli/commands/build.ts +27 -2
  343. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  344. package/src/cli/handlers/approve-confirm.ts +44 -0
  345. package/src/cli/handlers/approve.ts +2 -1
  346. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  347. package/src/cli/handlers/build.ts +20 -2
  348. package/src/cli/handlers/ci-check.ts +37 -7
  349. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  350. package/src/cli/handlers/ci-evidence.ts +233 -18
  351. package/src/cli/handlers/ci-forge-check.ts +22 -9
  352. package/src/cli/handlers/components.ts +3 -1
  353. package/src/cli/handlers/generated-check.ts +69 -0
  354. package/src/cli/handlers/lifecycle.test.ts +20 -0
  355. package/src/cli/handlers/lifecycle.ts +4 -0
  356. package/src/cli/handlers/local-chant.ts +39 -1
  357. package/src/cli/handlers/lock-reach.test.ts +103 -0
  358. package/src/cli/handlers/lock.ts +100 -4
  359. package/src/cli/handlers/pr-comment.ts +104 -0
  360. package/src/cli/handlers/pr-env.ts +6 -3
  361. package/src/cli/handlers/pr-record.test.ts +1 -1
  362. package/src/cli/handlers/pr.ts +93 -15
  363. package/src/cli/handlers/promote.ts +2 -1
  364. package/src/cli/handlers/release.e2e.test.ts +35 -0
  365. package/src/cli/handlers/release.ts +14 -2
  366. package/src/cli/handlers/run-wave.ts +35 -2
  367. package/src/cli/handlers/run.ts +2 -1
  368. package/src/cli/main.ts +60 -4
  369. package/src/cli/parse-args.ts +58 -0
  370. package/src/cli/registry.ts +35 -0
  371. package/src/components/auto-release.ts +2 -1
  372. package/src/components/check-hooks.ts +22 -0
  373. package/src/components/check-report-summary.test.ts +78 -0
  374. package/src/components/pr-checks.ts +254 -0
  375. package/src/components/pr-pipeline.ts +43 -1
  376. package/src/components/product-pipeline.ts +113 -9
  377. package/src/components/product-plan.test.ts +140 -1
  378. package/src/components/product-plan.ts +707 -20
  379. package/src/config.ts +13 -8
  380. package/src/control/consumers.ts +7 -0
  381. package/src/dead-guards.test.ts +27 -5
  382. package/src/dead-guards.ts +9 -6
  383. package/src/discovery/files.ts +1 -1
  384. package/src/drift-issue.test.ts +29 -1
  385. package/src/drift-issue.ts +28 -3
  386. package/src/drift-record.test.ts +45 -0
  387. package/src/drift-record.ts +71 -6
  388. package/src/floor-table.data.ts +81 -21
  389. package/src/floor-table.ts +12 -9
  390. package/src/forge-check/contract.ts +23 -2
  391. package/src/forge-check/forge-check.test.ts +25 -0
  392. package/src/forge-check/index.ts +4 -0
  393. package/src/forge-flags.test.ts +25 -1
  394. package/src/forge-flags.ts +34 -0
  395. package/src/forge-remote.test.ts +37 -0
  396. package/src/forge-remote.ts +79 -0
  397. package/src/gate-resume-run.ts +27 -3
  398. package/src/generated-check.e2e.test.ts +118 -0
  399. package/src/generated-check.test.ts +170 -0
  400. package/src/generated-check.ts +310 -0
  401. package/src/image-pins.ts +31 -0
  402. package/src/lexicon.ts +28 -0
  403. package/src/lifecycle/git.test.ts +48 -0
  404. package/src/lifecycle/git.ts +27 -4
  405. package/src/lifecycle/publish-npm.ts +87 -4
  406. package/src/lifecycle/reach-locks.test.ts +87 -0
  407. package/src/lifecycle/reach-locks.ts +169 -0
  408. package/src/lifecycle/release-catalog.test.ts +2 -2
  409. package/src/lifecycle/release-cut.ts +17 -1
  410. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  411. package/src/lifecycle/release-images.test.ts +100 -0
  412. package/src/lifecycle/release-images.ts +38 -3
  413. package/src/lifecycle/release-ledger.ts +4 -3
  414. package/src/local-chant.e2e.test.ts +81 -6
  415. package/src/local-chant.test.ts +22 -3
  416. package/src/local-chant.ts +130 -13
  417. package/src/notify-product.ts +19 -8
  418. package/src/op/activities/source-release.ts +2 -1
  419. package/src/op/activities/source-rollback.ts +2 -1
  420. package/src/op/gate-resume.test.ts +27 -0
  421. package/src/op/index.ts +10 -0
  422. package/src/op/op-waves-evidence-jobs.ts +140 -0
  423. package/src/op/op-waves-evidence.test.ts +36 -3
  424. package/src/op/op-waves-evidence.ts +23 -3
  425. package/src/op/op-waves-notify-words.test.ts +18 -0
  426. package/src/op/op-waves-render-spec.test.ts +160 -0
  427. package/src/op/op-waves-render-spec.ts +171 -0
  428. package/src/op/op-waves-run.ts +59 -3
  429. package/src/op/op-waves.ts +16 -2
  430. package/src/op/schedule-overdue.test.ts +126 -1
  431. package/src/op/schedule-overdue.ts +164 -12
  432. package/src/op/wave-stop.test.ts +72 -0
  433. package/src/op/wave-stop.ts +137 -0
  434. package/src/planned-files.test.ts +80 -0
  435. package/src/planned-files.ts +134 -0
  436. package/src/pr-forge-job.test.ts +53 -0
  437. package/src/pr-forge-job.ts +46 -0
  438. package/src/pr-forge-reads-compare.test.ts +2 -1
  439. package/src/pr-forge-reads.ts +37 -1
  440. package/src/pr-forge.ts +14 -3
  441. package/src/pr-loop-narrowed.test.ts +2 -1
  442. package/src/pr-loop-words.test.ts +2 -1
  443. package/src/pr-loop.test.ts +1 -2
  444. package/src/pr-loop.ts +4 -80
  445. package/src/pr-plan-note.ts +184 -3
  446. package/src/pr-plan-record.test.ts +75 -0
  447. package/src/pr-plan-record.ts +101 -0
  448. package/src/pr-post-plan-note.test.ts +60 -0
  449. package/src/pr-post-replan.test.ts +144 -0
  450. package/src/pr-post-subject.test.ts +230 -0
  451. package/src/pr-post.test.ts +32 -1
  452. package/src/pr-post.ts +254 -15
  453. package/src/pr-requires.test.ts +20 -0
  454. package/src/pr-requires.ts +10 -1
  455. package/src/pr-status.ts +91 -0
  456. package/src/ref-gate-init.ts +208 -0
  457. package/src/ref-gate-rules.ts +26 -0
  458. package/src/release-floors.ts +139 -17
  459. package/src/render-module.ts +73 -0
  460. package/src/state-migration-record.test.ts +89 -0
  461. package/src/state-migration.test.ts +1 -1
  462. package/src/state-migration.ts +52 -4
  463. package/src/state-unlock.test.ts +33 -1
  464. package/src/state-unlock.ts +49 -1
  465. package/src/workspace/ci-green-cli.ts +14 -7
  466. package/src/workspace/ci-green-workflow.test.ts +32 -1
  467. package/src/workspace/drift-cli.ts +6 -18
  468. package/src/workspace/forge-work.ts +7 -14
  469. package/src/workspace/lexicon-outputs.ts +2 -2
  470. package/src/workspace/release-train.ts +2 -1
  471. package/src/workspace/release-workflow.test.ts +104 -3
  472. package/src/workspace/release-workflow.ts +60 -9
  473. package/src/workspace/trust/check-evidence-report.ts +39 -8
  474. package/src/workspace/trust/check-evidence.test.ts +5 -0
  475. package/src/workspace/trust/check-evidence.ts +17 -5
  476. package/src/workspace/trust/evidence.ts +5 -0
  477. package/src/workspace/trust/open-evidence.ts +129 -0
  478. package/src/workspace/trust/ref-gate-cli.ts +88 -10
  479. package/src/workspace/trust/ref-gate-pieces.test.ts +220 -0
  480. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  481. package/src/workspace/trust/ref-gate.test.ts +10 -0
  482. package/src/workspace/trust/ref-gate.ts +87 -6
  483. package/src/workspace/workspace-run.ts +2 -1
@@ -0,0 +1,204 @@
1
+ /**
2
+ * #4912: after the cloud login, the rest of the job reaches neither the
3
+ * forge's token request nor the token file unless it needs them, and
4
+ * GitLab's trade writes no file of variables. The tests run the rendered
5
+ * lines as a runner runs a step: GitHub and Forgejo run the step's script
6
+ * as a file (`bash --noprofile --norc -eo pipefail <file>`), GitLab runs the
7
+ * job's script in one shell. Each runs against the local emulator of the
8
+ * forge's token URL and the clouds (./__fixtures__/oidc-emulator.ts). Test
9
+ * values only; no cloud is reached.
10
+ */
11
+
12
+ import { execFile } from "node:child_process";
13
+ import { mkdtempSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
14
+ import { tmpdir } from "node:os";
15
+ import { join } from "node:path";
16
+ import { promisify } from "node:util";
17
+ import { afterAll, beforeAll, describe, expect, test } from "vitest";
18
+ import { cloudLogin, LOGIN_CLEAR_TOKENS, LOGIN_TOKEN_FILES_ENV, type CloudLoginSpec, type LoginForge } from "./ci-login";
19
+ import { GITLAB_TRADE_VARS, gitlabTradeLines, idTokenVar, OIDC_REQUEST_VARS, TRADE_SPEC_ENV, type CloudTradeSpec } from "./ci-identity";
20
+ import { emulatedCredentials, EMULATED_JWT_PREFIX, startOidcEmulator, type OidcEmulator } from "./__fixtures__/oidc-emulator";
21
+
22
+ const run = promisify(execFile);
23
+
24
+ const PROVIDER = "projects/123/locations/global/workloadIdentityPools/ci/providers/forge";
25
+ const TENANT = "00000000-0000-0000-0000-000000000001";
26
+ const SPEC: CloudLoginSpec = {
27
+ aws: { role: "arn:aws:iam::111111111111:role/plan", region: "eu-west-1" },
28
+ gcp: { serviceAccount: "plan@proj.iam.gserviceaccount.com", provider: PROVIDER },
29
+ azure: { clientId: "11111111-1111-1111-1111-111111111111", tenantId: TENANT },
30
+ };
31
+ const FORGES: LoginForge[] = ["github", "gitlab", "forgejo"];
32
+ const FORGE_SECRET = "forge-secret-4912";
33
+
34
+ /** A child of the step that asks the forge for a token, as the change's code could: it prints what it got. */
35
+ const ASK = `node -e 'const u=process.env.ACTIONS_ID_TOKEN_REQUEST_URL,k=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!u||!k){console.log("request:none");process.exit(0)}fetch(u+"&audience=x",{headers:{authorization:"bearer "+k}}).then(r=>r.text()).then(t=>console.log("request:"+t))'`;
36
+
37
+ const parseEnv = (text: string): Record<string, string> => Object.fromEntries(text.trim().split("\n").filter((l) => l.includes("=")).map((l) => [l.slice(0, l.indexOf("=")), l.slice(l.indexOf("=") + 1)]));
38
+
39
+ let emu: OidcEmulator;
40
+ beforeAll(async () => {
41
+ emu = await startOidcEmulator();
42
+ });
43
+ afterAll(async () => {
44
+ await emu.close();
45
+ });
46
+
47
+ /**
48
+ * Runs the login with `restart` and then `rest` as one step of `forge`,
49
+ * with a forge token and the job's token request (GitLab: its id_tokens) in
50
+ * the step's environment.
51
+ */
52
+ async function loginStep(forge: LoginForge, spec: CloudLoginSpec, rest: string[]) {
53
+ const dir = mkdtempSync(join(tmpdir(), "chant-login-4912-"));
54
+ const runnerTemp = mkdtempSync(join(dir, "runner-"));
55
+ const scripts = mkdtempSync(join(dir, "scripts-"));
56
+ const githubEnv = join(scripts, "github-env");
57
+ writeFileSync(githubEnv, "");
58
+ const { steps, idTokens } = cloudLogin(forge, spec, { restart: { also: ["CHANT_FORGE_TOKEN"] } });
59
+ const file = join(scripts, "step.sh");
60
+ writeFileSync(file, [...steps[0]!.run, ...rest].join("\n") + "\n");
61
+ const tokens = forge === "gitlab" ? Object.fromEntries(Object.keys(idTokens).map((k) => [k, `${EMULATED_JWT_PREFIX}.${k}.gitlab`])) : emu.requestEnv;
62
+ const env = { PATH: process.env.PATH!, GITHUB_ENV: githubEnv, RUNNER_TEMP: runnerTemp, TMPDIR: runnerTemp, CHANT_FORGE_TOKEN: FORGE_SECRET, SCRATCH: scripts, ...tokens };
63
+ const args = forge === "gitlab" ? ["-e", file] : ["--noprofile", "--norc", "-eo", "pipefail", file];
64
+ const r = await run(forge === "gitlab" ? "sh" : "bash", args, { env }).catch((e: { stdout: string; stderr: string; code: number }) => ({ stdout: e.stdout, stderr: e.stderr, failed: e.code }));
65
+ return { r, scripts, runnerTemp, githubEnv };
66
+ }
67
+
68
+ describe("the login, then the step without the token request (#4912)", () => {
69
+ test.each(FORGES)("%s: the tool reads its token file; the step's children reach no token request, forge token or id token; the token file is empty once the step ends", async (forge) => {
70
+ const before = emu.log.minted.length;
71
+ const { r, scripts } = await loginStep(forge, SPEC, [
72
+ 'env > "$SCRATCH/seen"',
73
+ `${ASK} >> "$SCRATCH/seen"`,
74
+ // The cloud's tool reads the token file while the step runs.
75
+ 'cat "$AWS_WEB_IDENTITY_TOKEN_FILE" > "$SCRATCH/during"',
76
+ 'printf "%s" "$AWS_WEB_IDENTITY_TOKEN_FILE" > "$SCRATCH/aws-file"',
77
+ ]);
78
+ expect(r).not.toHaveProperty("failed");
79
+ const seen = readFileSync(join(scripts, "seen"), "utf-8");
80
+ const env = parseEnv(seen);
81
+ expect(env).toMatchObject({ AWS_ROLE_ARN: SPEC.aws!.role, ARM_CLIENT_ID: SPEC.azure!.clientId });
82
+ expect(seen).toContain("request:none");
83
+ expect(seen).not.toContain(FORGE_SECRET);
84
+ for (const v of OIDC_REQUEST_VARS) expect(env[v], v).toBeUndefined();
85
+ // The login ran once: a restarted step skips it.
86
+ expect(emu.log.minted.length - before).toBe(forge === "gitlab" ? 0 : 3);
87
+ expect(r.stderr.split(`logged in from the OIDC token file as ${SPEC.aws!.role}`).length - 1).toBe(1);
88
+ expect(readFileSync(join(scripts, "during"), "utf-8")).toContain(EMULATED_JWT_PREFIX);
89
+ // Once the step is done, a later step finds the login's token files empty.
90
+ const files = env[LOGIN_TOKEN_FILES_ENV]!.split(":");
91
+ expect(files).toHaveLength(3);
92
+ expect(files).toContain(readFileSync(join(scripts, "aws-file"), "utf-8"));
93
+ for (const f of files) expect(readFileSync(f, "utf-8"), f).toBe("");
94
+ });
95
+
96
+ test.each(["github", "forgejo"] as const)("%s: a step whose script is no file keeps running, with the request variables unset", async (forge) => {
97
+ const { steps } = cloudLogin(forge, { aws: SPEC.aws }, { restart: true });
98
+ const dir = mkdtempSync(join(tmpdir(), "chant-login-4912-c-"));
99
+ const r = await run("bash", ["-e", "-c", [...steps[0]!.run, "env", ASK].join("\n")], { env: { PATH: process.env.PATH!, RUNNER_TEMP: dir, ...emu.requestEnv } });
100
+ const env = parseEnv(r.stdout);
101
+ expect(env.AWS_ROLE_ARN).toBe(SPEC.aws!.role);
102
+ expect(r.stdout).toContain("request:none");
103
+ expect(env.ACTIONS_ID_TOKEN_REQUEST_URL).toBeUndefined();
104
+ });
105
+
106
+ test("a runner's own token file is never emptied, and is not listed", async () => {
107
+ const dir = mkdtempSync(join(tmpdir(), "chant-login-4912-runner-"));
108
+ writeFileSync(join(dir, "token"), "eyJrunner.token.1\n");
109
+ const { steps } = cloudLogin("forgejo", { aws: { ...SPEC.aws!, tokenFile: `${dir}/token` }, azure: SPEC.azure }, { restart: true });
110
+ const scripts = mkdtempSync(join(tmpdir(), "chant-login-4912-rs-"));
111
+ const file = join(scripts, "step.sh");
112
+ writeFileSync(file, [...steps[0]!.run, `env > "${scripts}/seen"`].join("\n") + "\n");
113
+ await run("bash", ["--noprofile", "--norc", "-eo", "pipefail", file], { env: { PATH: process.env.PATH!, RUNNER_TEMP: scripts, ...emu.requestEnv } });
114
+ const env = parseEnv(readFileSync(join(scripts, "seen"), "utf-8"));
115
+ expect(env[LOGIN_TOKEN_FILES_ENV]!.split(":")).toEqual([env.AZURE_FEDERATED_TOKEN_FILE]);
116
+ expect(readFileSync(join(dir, "token"), "utf-8")).toBe("eyJrunner.token.1\n");
117
+ expect(readFileSync(env.AZURE_FEDERATED_TOKEN_FILE!, "utf-8")).toBe("");
118
+ });
119
+
120
+ test.each(["github", "forgejo"] as const)("%s: a login in a step of its own lists its token files for later steps, and LOGIN_CLEAR_TOKENS empties them", async (forge) => {
121
+ const dir = mkdtempSync(join(tmpdir(), "chant-login-4912-sep-"));
122
+ const githubEnv = join(dir, "github-env");
123
+ writeFileSync(githubEnv, "");
124
+ const { steps } = cloudLogin(forge, SPEC);
125
+ await run("bash", ["-e", "-c", steps[0]!.run.join("\n")], { env: { PATH: process.env.PATH!, GITHUB_ENV: githubEnv, RUNNER_TEMP: dir, ...emu.requestEnv } });
126
+ const vars = parseEnv(readFileSync(githubEnv, "utf-8"));
127
+ const files = vars[LOGIN_TOKEN_FILES_ENV]!.split(":");
128
+ expect(files.sort()).toEqual([vars.AWS_WEB_IDENTITY_TOKEN_FILE, vars.AZURE_FEDERATED_TOKEN_FILE, JSON.parse(readFileSync(vars.GOOGLE_APPLICATION_CREDENTIALS!, "utf-8")).credential_source.file].sort());
129
+ for (const f of files) expect(readFileSync(f, "utf-8")).toContain(EMULATED_JWT_PREFIX);
130
+ // The job's last step, after the tool.
131
+ await run("bash", ["-e", "-c", LOGIN_CLEAR_TOKENS], { env: { PATH: process.env.PATH!, ...vars } });
132
+ for (const f of files) expect(readFileSync(f, "utf-8")).toBe("");
133
+ });
134
+
135
+ test("the restart is rendered as one block at the top of the step, and GitLab, whose script is no file, unsets instead", () => {
136
+ const github = cloudLogin("github", SPEC, { restart: { also: ["CHANT_FORGE_TOKEN"] } }).steps[0]!.run;
137
+ expect(github[0]).toBe('if [ -z "${CHANT_CLOUD_LOGGED_IN:-}" ]; then');
138
+ expect(github.find((l) => l.startsWith("if [ -z \"${CHANT_CLOUD_LOGGED_IN:-}\" ] && "))).toContain("exec env -u ACTIONS_ID_TOKEN_REQUEST_URL -u ACTIONS_ID_TOKEN_REQUEST_TOKEN -u CHANT_FORGE_TOKEN CHANT_CLOUD_LOGGED_IN=1 bash");
139
+ expect(cloudLogin("forgejo", SPEC, { restart: { shell: "sh" } }).steps[0]!.run.join("\n")).toContain('CHANT_CLOUD_LOGGED_IN=1 sh -e "$0"');
140
+ const gitlab = cloudLogin("gitlab", SPEC, { restart: { also: ["CHANT_FORGE_TOKEN"] } }).steps[0]!.run;
141
+ expect(gitlab.join("\n")).not.toContain("exec env");
142
+ expect(gitlab).toContain("unset CHANT_FORGE_TOKEN");
143
+ // restart takes the step's form: sameStep is implied.
144
+ for (const forge of FORGES) expect(cloudLogin(forge, SPEC, { restart: true }).steps[0]!.run.join("\n")).not.toContain("$GITHUB_ENV");
145
+ });
146
+ });
147
+
148
+ describe("GitLab's trade writes no file (#4912)", () => {
149
+ test("the trade's exports are captured and evaluated, the token variables unset, and no file is written", async () => {
150
+ const lines = gitlabTradeLines(["CHANT_FORGE_TOKEN"]);
151
+ expect(lines).toHaveLength(3);
152
+ expect(lines.join("\n")).not.toMatch(/\brm\b/);
153
+ expect(lines[0]).toMatch(new RegExp(`^${GITLAB_TRADE_VARS}="\\$\\(cd / && node -e '.*' "-" sh\\)"$`));
154
+ const tmp = mkdtempSync(join(tmpdir(), "chant-trade-4912-tmp-"));
155
+ const scripts = mkdtempSync(join(tmpdir(), "chant-trade-4912-"));
156
+ const file = join(scripts, "job.sh");
157
+ writeFileSync(file, [...lines, "env"].join("\n"));
158
+ const spec: CloudTradeSpec = emu.pointAt({ aws: { role: "arn:aws:iam::111111111111:role/plan", region: "eu-west-1", audience: "sts.amazonaws.com" } });
159
+ const r = await run("sh", ["-e", file], { env: { PATH: process.env.PATH!, TMPDIR: tmp, CI_JOB_ID: "4912", CHANT_FORGE_TOKEN: FORGE_SECRET, [idTokenVar("aws")]: `${EMULATED_JWT_PREFIX}.aws.gitlab`, [TRADE_SPEC_ENV]: JSON.stringify(spec) } });
160
+ const env = parseEnv(r.stdout);
161
+ expect(env.AWS_ACCESS_KEY_ID).toBe(emulatedCredentials("arn:aws:iam::111111111111:role/plan").accessKeyId);
162
+ for (const v of [...OIDC_REQUEST_VARS, GITLAB_TRADE_VARS, "CHANT_FORGE_TOKEN"]) expect(env[v], v).toBeUndefined();
163
+ expect(readdirSync(tmp)).toEqual([]);
164
+ });
165
+
166
+ test("a failed trade stops the script", async () => {
167
+ const scripts = mkdtempSync(join(tmpdir(), "chant-trade-4912-f-"));
168
+ const file = join(scripts, "job.sh");
169
+ writeFileSync(file, [...gitlabTradeLines(), "echo went-on"].join("\n"));
170
+ const r = await run("sh", ["-e", file], { env: { PATH: process.env.PATH!, CI_JOB_ID: "4912", [TRADE_SPEC_ENV]: JSON.stringify({ aws: { role: "r", region: "eu-west-1", audience: "a" } }) } }).catch((e: { stdout: string; code: number }) => e);
171
+ expect(r).toMatchObject({ code: 1 });
172
+ expect((r as { stdout: string }).stdout).not.toContain("went-on");
173
+ });
174
+ });
175
+
176
+ describe("GCP's stsEndpoint takes a full token URL too (#4912)", () => {
177
+ test("the login writes it as the credential file's token_url, and the base form still gains /v1/token", async () => {
178
+ const dir = mkdtempSync(join(tmpdir(), "chant-login-4912-gcp-"));
179
+ for (const [sts, url] of [
180
+ ["https://sts.us-east1.rep.googleapis.com/v1/token", "https://sts.us-east1.rep.googleapis.com/v1/token"],
181
+ ["https://sts.googleapis.com/", "https://sts.googleapis.com/v1/token"],
182
+ ] as const) {
183
+ const githubEnv = join(dir, `env-${Math.random().toString(16).slice(2)}`);
184
+ writeFileSync(githubEnv, "");
185
+ const { steps } = cloudLogin("github", { gcp: { ...SPEC.gcp!, stsEndpoint: sts } });
186
+ await run("bash", ["-e", "-c", steps[0]!.run.join("\n")], { env: { PATH: process.env.PATH!, GITHUB_ENV: githubEnv, RUNNER_TEMP: dir, ...emu.requestEnv } });
187
+ const vars = parseEnv(readFileSync(githubEnv, "utf-8"));
188
+ expect(JSON.parse(readFileSync(vars.GOOGLE_APPLICATION_CREDENTIALS!, "utf-8")).token_url).toBe(url);
189
+ }
190
+ });
191
+
192
+ test("the trade posts to a full token URL as given", async () => {
193
+ const lines = gitlabTradeLines();
194
+ const scripts = mkdtempSync(join(tmpdir(), "chant-trade-4912-gcp-"));
195
+ const file = join(scripts, "job.sh");
196
+ writeFileSync(file, [...lines, "env"].join("\n"));
197
+ const pointed = emu.pointAt({ gcp: { serviceAccount: "plan@proj.iam.gserviceaccount.com", provider: PROVIDER, audience: `https://iam.googleapis.com/${PROVIDER}` } });
198
+ const spec = { gcp: { ...pointed.gcp!, stsEndpoint: `${pointed.gcp!.stsEndpoint}/v1/token` } };
199
+ const before = emu.log.impersonated.length;
200
+ const r = await run("sh", ["-e", file], { env: { PATH: process.env.PATH!, CI_JOB_ID: "4912", [idTokenVar("gcp")]: `${EMULATED_JWT_PREFIX}.gcp.gitlab`, [TRADE_SPEC_ENV]: JSON.stringify(spec) } });
201
+ expect(parseEnv(r.stdout).GOOGLE_OAUTH_ACCESS_TOKEN).toMatch(/^ya29\./);
202
+ expect(emu.log.impersonated.slice(before)).toEqual(["plan@proj.iam.gserviceaccount.com"]);
203
+ });
204
+ });
package/src/ci-login.ts CHANGED
@@ -23,8 +23,11 @@
23
23
  * `/tmp`), mode 0600. Then it sets:
24
24
  *
25
25
  * AWS AWS_ROLE_ARN, AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_SESSION_NAME,
26
- * AWS_REGION, AWS_DEFAULT_REGION (and AWS_ENDPOINT_URL_STS with
27
- * `endpoint`)
26
+ * with `region` AWS_REGION and AWS_DEFAULT_REGION (else the job
27
+ * keeps its own, #4930), and AWS_ENDPOINT_URL_STS with
28
+ * `endpoint`. With no role the job gets the token file and the
29
+ * session name alone, for a tool that assumes its own roles,
30
+ * such as Terragrunt's `credentials` (#4930)
28
31
  * GCP GOOGLE_APPLICATION_CREDENTIALS and
29
32
  * CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, an `external_account`
30
33
  * file per service account that trades the token at Google's STS
@@ -37,9 +40,11 @@
37
40
  *
38
41
  * gcloud reads CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, so it needs no
39
42
  * `gcloud auth login`. On GitHub and Forgejo the variables go to
40
- * `$GITHUB_ENV`; on GitLab the script evaluates the `export` lines the
41
- * login prints, which name files and hold no token, then unsets the token
42
- * variables and the spec. No file of variables is left to delete.
43
+ * `$GITHUB_ENV`, which later steps read; on GitLab the script evaluates the
44
+ * `export` lines the login prints, which name files and hold no token, then
45
+ * unsets the token variables and the spec. No file of variables is left to
46
+ * delete. With {@link CloudLoginOptions.sameStep} every forge takes the
47
+ * GitLab form, so the step that logs in can run the tool too (#4930).
43
48
  *
44
49
  * Per target and per stage: the spec is a {@link CloudTradeSpec} without
45
50
  * Pulumi, the plan or apply side of what `resolveCloudIdentity` gives, so a
@@ -47,7 +52,9 @@
47
52
  * other targets take (#4332). The step then writes the
48
53
  * {@link CLOUD_TARGETS_ENV} file the trade writes, each identity's
49
54
  * variables in it, and a product hands each target's tool its own with
50
- * `targetCloudEnv`, as after the trade.
55
+ * `targetCloudEnv`, as after the trade. The login sets no
56
+ * `CLOUD_TRADED_ENV`, which the trade does, so a product tells the login's
57
+ * targets file from a trade's (#4930).
51
58
  *
52
59
  * The functions return {@link OpWaveRunStep}s and the job's `idTokens`, the
53
60
  * shape `OpWavesPipelineOptions.waveJobs[].before` and `recordPlans` take
@@ -62,6 +69,7 @@ import {
62
69
  type Cloud,
63
70
  type CloudTradeSpec,
64
71
  } from "./ci-identity";
72
+ import { restartWithout } from "./ci-handover";
65
73
  import type { OpWaveRunStep } from "./lexicon";
66
74
 
67
75
  /** The variable the login step reads its {@link CloudLoginSpec} from, as JSON. */
@@ -85,7 +93,7 @@ interface TokenFileOption {
85
93
  export interface CloudLoginSpec {
86
94
  aws?: Omit<NonNullable<CloudTradeSpec["aws"]>, "region" | "audience"> &
87
95
  TokenFileOption & {
88
- /** Default `us-east-1`. */
96
+ /** AWS_REGION and AWS_DEFAULT_REGION. Unset: the job keeps its own region (#4930). */
89
97
  region?: string;
90
98
  /** The token's audience. Default `sts.amazonaws.com`. */
91
99
  audience?: string;
@@ -106,11 +114,74 @@ export interface CloudLoginSpec {
106
114
  };
107
115
  }
108
116
 
117
+ /**
118
+ * The variable the login sets (#4912): the token files it wrote itself,
119
+ * joined by `:`. A runner's `tokenFile` is not among them.
120
+ * {@link LOGIN_CLEAR_TOKENS} empties them.
121
+ */
122
+ export const LOGIN_TOKEN_FILES_ENV = "CHANT_CLOUD_TOKEN_FILES";
123
+
124
+ /**
125
+ * A shell line that empties each file {@link LOGIN_TOKEN_FILES_ENV} names
126
+ * (#4912), so a step that runs after the cloud's tool finds no token in
127
+ * them. It truncates and deletes nothing. The login's `restart` runs it
128
+ * when the step exits. A job whose login is a step of its own runs it in
129
+ * the step after the tool's last use.
130
+ */
131
+ export const LOGIN_CLEAR_TOKENS = `(set -f; IFS=:; for f in \${${LOGIN_TOKEN_FILES_ENV}:-}; do [ ! -f "$f" ] || : > "$f"; done)`;
132
+
133
+ /** The marker of a step the login's `restart` started again (#4912): its login is done. */
134
+ export const LOGIN_RESTART_MARKER = "CHANT_CLOUD_LOGGED_IN";
135
+
136
+ /** The variables a GitHub or Forgejo step requests an OIDC token with. */
137
+ const ACTIONS_REQUEST_VARS = ["ACTIONS_ID_TOKEN_REQUEST_URL", "ACTIONS_ID_TOKEN_REQUEST_TOKEN"] as const;
138
+
139
+ /** What the login's `restart` takes (#4912). */
140
+ export interface CloudLoginRestart {
141
+ /** The shell the step restarts in, with `-e` (bash also `-o pipefail`). Default `bash`. */
142
+ shell?: "bash" | "sh";
143
+ /** More variables the restarted step starts without, such as the forge tokens (`FORGE_TOKEN_VARS`). */
144
+ also?: readonly string[];
145
+ }
146
+
147
+ /** How a login is rendered. */
148
+ export interface CloudLoginOptions {
149
+ /**
150
+ * The login's variables in the step that runs it (#4930). GitHub and
151
+ * Forgejo then evaluate the `export` lines the login prints, as GitLab
152
+ * does, and nothing goes to `$GITHUB_ENV`: a product that logs in and
153
+ * runs its tool in one step (terragucci's, after it fetched its tokens
154
+ * and restarted the step without the token request variables) puts
155
+ * `steps[0].run` in that step. The lines stop the step on a failed login
156
+ * with `|| exit 1`, for a script that runs with `-e` off. Default false.
157
+ */
158
+ sameStep?: boolean;
159
+ /**
160
+ * Log in, then start the step's script again without the token request
161
+ * variables (#4912): the login's lines with `sameStep`, run once, then
162
+ * the restart (ci-handover's `restartWithout`) without
163
+ * `ACTIONS_ID_TOKEN_REQUEST_URL`, `ACTIONS_ID_TOKEN_REQUEST_TOKEN` and
164
+ * `also`, so the change's code and the tool cannot request another token,
165
+ * and on Forgejo cannot reach the run's runtime token through them. The
166
+ * restarted step keeps the login's variables and empties the login's
167
+ * token files when it exits ({@link LOGIN_CLEAR_TOKENS}, an `EXIT` trap;
168
+ * a step that sets its own `EXIT` trap runs that line in it). The lines
169
+ * go at the top of the step, since the restart runs the script again from
170
+ * its first line. A script that is no file (`bash -c`) is not restarted:
171
+ * the variables are unset and it runs on. On GitLab the login already
172
+ * unsets the `id_tokens` variables, and the script is no file, so
173
+ * `restart` adds the unset of `also` and the trap. Implies `sameStep`.
174
+ * terragucci's `stageTokens` and `restartWithout`.
175
+ */
176
+ restart?: boolean | CloudLoginRestart;
177
+ }
178
+
109
179
  /** A job's login: its steps, and the OIDC tokens the job requests. */
110
180
  export interface CloudLoginSteps {
111
181
  /**
112
182
  * The steps, in order. GitHub and Forgejo: each one `run:` step, its lines
113
- * joined by newlines. GitLab: their lines in the job's script.
183
+ * joined by newlines. GitLab, and any forge with `sameStep`: their lines
184
+ * in the job's script or step.
114
185
  */
115
186
  steps: OpWaveRunStep[];
116
187
  /**
@@ -139,7 +210,8 @@ export function cloudLoginSpec(spec: CloudLoginSpec): CloudLoginSpec {
139
210
  if (extra.length > 0) throw new Error(`a cloud login covers ${LOGIN_CLOUDS.join(", ")}; ${extra.join(", ")} ${extra.includes("pulumi") ? "(Pulumi Cloud) is traded, with ci-identity's trade step" : "is no cloud it knows"}`);
140
211
  if ((spec.azure as { database?: unknown } | undefined)?.database) throw new Error("a cloud login gives Azure no database token: trade the token with ci-identity's trade step for azure.database");
141
212
  const out: CloudLoginSpec = {};
142
- if (spec.aws) out.aws = { ...spec.aws, region: spec.aws.region ?? "us-east-1", audience: spec.aws.audience ?? "sts.amazonaws.com" };
213
+ // #4930: no default region, so the job's own stays. A named one stays where the spec put it, so the step renders as before.
214
+ if (spec.aws) out.aws = { ...spec.aws, audience: spec.aws.audience ?? "sts.amazonaws.com" };
143
215
  if (spec.gcp) {
144
216
  const provider = providerPath(spec.gcp.provider);
145
217
  out.gcp = { ...spec.gcp, provider, audience: spec.gcp.audience ?? `https://iam.googleapis.com/${provider}` };
@@ -150,7 +222,8 @@ export function cloudLoginSpec(spec: CloudLoginSpec): CloudLoginSpec {
150
222
  if (!c) continue;
151
223
  const key = IDENTITY_KEY[cloud];
152
224
  const ids = [c[key], ...(c.targets ?? []).map((t) => t[key])].filter((v) => v !== undefined);
153
- if (ids.length === 0) throw new Error(`the ${cloud} login names no identity: give it ${key}, or targets`);
225
+ // #4930: AWS with no role is the token file alone. GCP's credential file and Azure's variables name an identity.
226
+ if (ids.length === 0 && cloud !== "aws") throw new Error(`the ${cloud} login names no identity: give it ${key}, or targets`);
154
227
  for (const [k, v] of Object.entries(c)) {
155
228
  if (typeof v === "string" && !SAFE.test(v)) throw new Error(`the ${cloud} login's ${k} is ${JSON.stringify(v)}; a job holds printable ASCII with no space`);
156
229
  }
@@ -181,6 +254,7 @@ export const LOGIN_JS = [
181
254
  'const rand=()=>crypto.randomBytes(8).toString("hex");',
182
255
  'const NO={github:"it needs permissions: id-token: write, and a pull request from a fork gets none",forgejo:"Forgejo serves one from version 15, with Forgejo Runner 12.5 or later, to a job with enable-openid-connect: true; on an older Forgejo give the cloud a tokenFile the runner provides"};',
183
256
  // A cloud's token: the runner's file, else GitLab's id_tokens variable, else the forge's request URL, into a file of its own.
257
+ "const mine=[];",
184
258
  "const tokenFile=async(cloud,s)=>{",
185
259
  'if(s.tokenFile){const f=s.tokenFile.replace(/^\\$\\{?([A-Za-z_][A-Za-z0-9_]*)\\}?/,(m,v)=>process.env[v]||"");let t;try{t=fs.readFileSync(f,"utf8").trim()}catch{throw new Error(cloud+"\\u0027s tokenFile "+f+" cannot be read")}if(!t)throw new Error(cloud+"\\u0027s tokenFile "+f+" is empty");return f}',
186
260
  'const name="CHANT_ID_TOKEN_"+cloud.toUpperCase();let v=process.env[name];',
@@ -191,18 +265,22 @@ export const LOGIN_JS = [
191
265
  'if(!r.ok)throw new Error("the OIDC token request answered "+r.status);',
192
266
  'try{v=JSON.parse(await r.text()).value}catch{throw new Error("the OIDC token request answered with no JSON")}}',
193
267
  'if(!clean(v))throw new Error("the job\\u0027s OIDC token for "+cloud+" is not a token");',
194
- 'const f=tmp+"/chant-oidc-"+cloud+"-"+rand();fs.writeFileSync(f,v,{mode:0o600,flag:"wx"});return f};',
268
+ 'const f=tmp+"/chant-oidc-"+cloud+"-"+rand();fs.writeFileSync(f,v,{mode:0o600,flag:"wx"});mine.push(f);return f};',
195
269
  `const KEY=${JSON.stringify(IDENTITY_KEY)};`,
196
270
  'const ids=(c)=>{const s=spec[c],l=[];if(s[KEY[c]])l.push(s[KEY[c]]);for(const t of s.targets||[])if(!l.includes(t[KEY[c]]))l.push(t[KEY[c]]);return l};',
197
271
  "const vars={},said=[],by={};",
198
272
  "const run=async()=>{",
199
273
  'if(spec.aws){const a=spec.aws;const f=await tokenFile("aws",a);by.aws={};',
200
- 'for(const role of ids("aws")){by.aws[role]={AWS_ROLE_ARN:role,AWS_WEB_IDENTITY_TOKEN_FILE:f,AWS_ROLE_SESSION_NAME:a.sessionName||"chant",AWS_REGION:a.region,AWS_DEFAULT_REGION:a.region,...(a.endpoint?{AWS_ENDPOINT_URL_STS:trim(a.endpoint)}:{})};said.push(role)}',
201
- "if(a.role)Object.assign(vars,by.aws[a.role])}",
274
+ // #4930: the region only when the spec names one; with no role of the job's own, the token file and session name alone.
275
+ 'const base={AWS_WEB_IDENTITY_TOKEN_FILE:f,AWS_ROLE_SESSION_NAME:a.sessionName||"chant",...(a.region?{AWS_REGION:a.region,AWS_DEFAULT_REGION:a.region}:{}),...(a.endpoint?{AWS_ENDPOINT_URL_STS:trim(a.endpoint)}:{})};',
276
+ 'for(const role of ids("aws")){by.aws[role]={AWS_ROLE_ARN:role,...base};said.push(role)}',
277
+ 'if(a.role)Object.assign(vars,by.aws[a.role]);else{Object.assign(vars,base);console.error("chant: wrote the aws OIDC token file, with no role of the job\\u0027s own")}}',
202
278
  'if(spec.gcp){const c=spec.gcp;const f=await tokenFile("gcp",c);by.gcp={};',
203
279
  'const sts=trim(c.stsEndpoint||"https://sts.googleapis.com"),iam=trim(c.iamEndpoint||"https://iamcredentials.googleapis.com");',
280
+ // #4912: stsEndpoint is Google's STS, or its full token URL (terragucci's `token_url`).
281
+ 'const tu=/\\/token$/.test(sts)?sts:sts+"/v1/token";',
204
282
  'for(const sa of ids("gcp")){const cf=tmp+"/chant-gcp-"+rand()+".json";',
205
- 'fs.writeFileSync(cf,JSON.stringify({type:"external_account",audience:"//iam.googleapis.com/"+c.provider,subject_token_type:"urn:ietf:params:oauth:token-type:jwt",token_url:sts+"/v1/token",service_account_impersonation_url:iam+"/v1/projects/-/serviceAccounts/"+sa+":generateAccessToken",credential_source:{file:f}})+"\\n",{mode:0o600,flag:"wx"});',
283
+ 'fs.writeFileSync(cf,JSON.stringify({type:"external_account",audience:"//iam.googleapis.com/"+c.provider,subject_token_type:"urn:ietf:params:oauth:token-type:jwt",token_url:tu,service_account_impersonation_url:iam+"/v1/projects/-/serviceAccounts/"+sa+":generateAccessToken",credential_source:{file:f}})+"\\n",{mode:0o600,flag:"wx"});',
206
284
  "by.gcp[sa]={GOOGLE_APPLICATION_CREDENTIALS:cf,CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE:cf};said.push(sa)}",
207
285
  "if(c.serviceAccount)Object.assign(vars,by.gcp[c.serviceAccount])}",
208
286
  'if(spec.azure){const z=spec.azure;const f=await tokenFile("azure",z);by.azure={};',
@@ -216,6 +294,8 @@ export const LOGIN_JS = [
216
294
  'const clouds=Object.keys(by);if(clouds.some((c)=>(spec[c].targets||[]).length>0)){',
217
295
  'const doc={version:1,clouds:{}};for(const c of clouds){const s=spec[c];doc.clouds[c]={...(s[KEY[c]]?{default:s[KEY[c]]}:{}),targets:(s.targets||[]).map((t)=>({targets:t.targets,identity:t[KEY[c]]})),vars:by[c]}}',
218
296
  `const tf=tmp+"/chant-cloud-targets-"+rand()+".json";fs.writeFileSync(tf,JSON.stringify(doc),{mode:0o600,flag:"wx"});vars.${CLOUD_TARGETS_ENV}=tf}`,
297
+ // #4912: the token files the login wrote, which LOGIN_CLEAR_TOKENS empties; a runner's own stays out.
298
+ `if(mine.length)vars.${LOGIN_TOKEN_FILES_ENV}=mine.join(":");`,
219
299
  'for(const [k,v] of Object.entries(vars))if(!clean(v))throw new Error(k+" is not a value the job can hold");',
220
300
  'if(format==="github-env")fs.appendFileSync(out,Object.entries(vars).map(([k,v])=>k+"="+v+"\\n").join(""));',
221
301
  'else process.stdout.write(Object.entries(vars).map(([k,v])=>"export "+k+"="+Q+v.split(Q).join(Q+"\\\\"+Q+Q)+Q+"\\n").join(""));',
@@ -238,10 +318,37 @@ export function loginLine(out: string, format: "github-env" | "sh", forge: Login
238
318
  return `(cd / && node -e '${LOGIN_JS}' "${out}" ${format} ${forge})`;
239
319
  }
240
320
 
241
- /** A GitHub Actions or Forgejo Actions login: one step that appends the variables to `$GITHUB_ENV`. */
242
- function actionsLogin(forge: "github" | "forgejo", given: CloudLoginSpec): CloudLoginSteps {
321
+ /**
322
+ * The lines that log in and evaluate the variables in the shell that runs
323
+ * them, then unset what held them and `unset`: GitLab's script, and with
324
+ * `sameStep` (#4930) any forge's step. `exit` stops a script with `-e` off.
325
+ */
326
+ function shellLines(spec: CloudLoginSpec, forge: LoginForge, unset: readonly string[], exit: boolean): string[] {
327
+ return [
328
+ `export ${LOGIN_SPEC_ENV}=${sh(JSON.stringify(spec))}`,
329
+ // An assignment's status is its command substitution's, so a failed login stops the script.
330
+ `${GITLAB_LOGIN_VARS}="$${loginLine("-", "sh", forge)}"${exit ? " || exit 1" : ""}`,
331
+ `eval "$${GITLAB_LOGIN_VARS}"`,
332
+ `unset ${[GITLAB_LOGIN_VARS, LOGIN_SPEC_ENV, ...unset].join(" ")}`,
333
+ ];
334
+ }
335
+
336
+ /** The `restart` option, filled: undefined without it. */
337
+ const restartOf = (options: CloudLoginOptions): CloudLoginRestart | undefined => (options.restart ? (options.restart === true ? {} : options.restart) : undefined);
338
+
339
+ /** The trap a restarted login sets: the login's token files emptied when the step exits (#4912). */
340
+ const clearOnExit = `trap ${sh(LOGIN_CLEAR_TOKENS)} EXIT`;
341
+
342
+ /** A GitHub Actions or Forgejo Actions login: one step that appends the variables to `$GITHUB_ENV`, or with `sameStep` exports them in its own shell. */
343
+ function actionsLogin(forge: "github" | "forgejo", given: CloudLoginSpec, options: CloudLoginOptions = {}): CloudLoginSteps {
243
344
  const spec = cloudLoginSpec(given);
244
345
  if (Object.keys(spec).length === 0) return { steps: [], idTokens: {} };
346
+ const restart = restartOf(options);
347
+ if (restart) {
348
+ const lines = [`if [ -z "\${${LOGIN_RESTART_MARKER}:-}" ]; then`, ...shellLines(spec, forge, [], true), "fi", restartWithout(restart.shell ?? "bash", [...ACTIONS_REQUEST_VARS, ...(restart.also ?? [])], LOGIN_RESTART_MARKER), clearOnExit];
349
+ return { steps: [{ name: stepName(spec), run: lines }], idTokens: loginIdTokens(spec) };
350
+ }
351
+ if (options.sameStep) return { steps: [{ name: stepName(spec), run: shellLines(spec, forge, [], true) }], idTokens: loginIdTokens(spec) };
245
352
  return {
246
353
  steps: [{ name: stepName(spec), run: [`export ${LOGIN_SPEC_ENV}=${sh(JSON.stringify(spec))}`, loginLine("$GITHUB_ENV", "github-env", forge)] }],
247
354
  idTokens: loginIdTokens(spec),
@@ -254,8 +361,8 @@ function actionsLogin(forge: "github" | "forgejo", given: CloudLoginSpec): Cloud
254
361
  * variables to `$GITHUB_ENV`, so every later step has them. The job needs
255
362
  * `id-token: write`, which `idTokens` asks chant's generators for.
256
363
  */
257
- export function githubCloudLogin(spec: CloudLoginSpec): CloudLoginSteps {
258
- return actionsLogin("github", spec);
364
+ export function githubCloudLogin(spec: CloudLoginSpec, options?: CloudLoginOptions): CloudLoginSteps {
365
+ return actionsLogin("github", spec, options);
259
366
  }
260
367
 
261
368
  /**
@@ -265,11 +372,11 @@ export function githubCloudLogin(spec: CloudLoginSpec): CloudLoginSteps {
265
372
  * that asks for `id-token: write`. On an older Forgejo, give each cloud a
266
373
  * `tokenFile` the runner provides; the job then requests none.
267
374
  */
268
- export function forgejoCloudLogin(spec: CloudLoginSpec): CloudLoginSteps {
269
- return actionsLogin("forgejo", spec);
375
+ export function forgejoCloudLogin(spec: CloudLoginSpec, options?: CloudLoginOptions): CloudLoginSteps {
376
+ return actionsLogin("forgejo", spec, options);
270
377
  }
271
378
 
272
- /** The GitLab variable the login's `export` lines are kept in until the script evaluates them. */
379
+ /** The variable the login's `export` lines are kept in until the script evaluates them: GitLab's, and with `sameStep` any forge's (#4930). */
273
380
  export const GITLAB_LOGIN_VARS = "CHANT_CLOUD_LOGIN_VARS";
274
381
 
275
382
  /**
@@ -279,29 +386,20 @@ export const GITLAB_LOGIN_VARS = "CHANT_CLOUD_LOGIN_VARS";
279
386
  * only in its file. The job's `id_tokens:` are `idTokens`, each
280
387
  * `{ aud: <audience> }`.
281
388
  */
282
- export function gitlabCloudLogin(given: CloudLoginSpec): CloudLoginSteps {
389
+ export function gitlabCloudLogin(given: CloudLoginSpec, options: CloudLoginOptions = {}): CloudLoginSteps {
283
390
  const spec = cloudLoginSpec(given);
284
391
  if (Object.keys(spec).length === 0) return { steps: [], idTokens: {} };
285
392
  const idTokens = loginIdTokens(spec);
286
- return {
287
- steps: [
288
- {
289
- name: stepName(spec),
290
- run: [
291
- `export ${LOGIN_SPEC_ENV}=${sh(JSON.stringify(spec))}`,
292
- // An assignment's status is its command substitution's, so a failed login stops the script.
293
- `${GITLAB_LOGIN_VARS}="$${loginLine("-", "sh", "gitlab")}"`,
294
- `eval "$${GITLAB_LOGIN_VARS}"`,
295
- `unset ${[GITLAB_LOGIN_VARS, LOGIN_SPEC_ENV, ...Object.keys(idTokens)].join(" ")}`,
296
- ],
297
- },
298
- ],
299
- idTokens,
300
- };
393
+ const restart = restartOf(options);
394
+ // A GitLab script is one shell already; sameStep adds `|| exit 1`, for a script with -e off.
395
+ const lines = shellLines(spec, "gitlab", Object.keys(idTokens), options.sameStep === true || restart !== undefined);
396
+ // #4912: GitLab's script is no file to restart; the id_tokens variables are unset above, `also` here.
397
+ if (restart) lines.push(...(restart.also?.length ? [`unset ${restart.also.join(" ")}`] : []), clearOnExit);
398
+ return { steps: [{ name: stepName(spec), run: lines }], idTokens };
301
399
  }
302
400
 
303
401
  /** A job's cloud login on `forge` (#4788): {@link githubCloudLogin}, {@link gitlabCloudLogin} or {@link forgejoCloudLogin}. */
304
- export function cloudLogin(forge: LoginForge, spec: CloudLoginSpec): CloudLoginSteps {
305
- return forge === "gitlab" ? gitlabCloudLogin(spec) : actionsLogin(forge, spec);
402
+ export function cloudLogin(forge: LoginForge, spec: CloudLoginSpec, options?: CloudLoginOptions): CloudLoginSteps {
403
+ return forge === "gitlab" ? gitlabCloudLogin(spec, options) : actionsLogin(forge, spec, options);
306
404
  }
307
405