@intentius/chant 0.124.86 → 0.124.88

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 (384) 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 +12 -0
  5. package/dist/actor.d.ts.map +1 -0
  6. package/dist/actor.js +18 -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 +204 -2
  13. package/dist/ci-commit.d.ts.map +1 -1
  14. package/dist/ci-commit.js +1 -2
  15. package/dist/ci-control.d.ts +1 -1
  16. package/dist/ci-control.d.ts.map +1 -1
  17. package/dist/ci-control.js +1 -1
  18. package/dist/ci-evidence-claims.d.ts +59 -0
  19. package/dist/ci-evidence-claims.d.ts.map +1 -0
  20. package/dist/ci-evidence-claims.js +87 -0
  21. package/dist/ci-evidence-from-job.d.ts +103 -0
  22. package/dist/ci-evidence-from-job.d.ts.map +1 -0
  23. package/dist/ci-evidence-from-job.js +162 -0
  24. package/dist/ci-evidence-jobs.d.ts +69 -10
  25. package/dist/ci-evidence-jobs.d.ts.map +1 -1
  26. package/dist/ci-evidence-jobs.js +72 -8
  27. package/dist/ci-handover.d.ts +12 -0
  28. package/dist/ci-handover.d.ts.map +1 -1
  29. package/dist/ci-handover.js +15 -3
  30. package/dist/ci-identity.d.ts +32 -6
  31. package/dist/ci-identity.d.ts.map +1 -1
  32. package/dist/ci-identity.js +40 -8
  33. package/dist/ci-image.d.ts +47 -9
  34. package/dist/ci-image.d.ts.map +1 -1
  35. package/dist/ci-image.js +45 -18
  36. package/dist/ci-jobs.d.ts +1 -1
  37. package/dist/ci-jobs.d.ts.map +1 -1
  38. package/dist/ci-jobs.js +7 -2
  39. package/dist/ci-login.d.ts +75 -13
  40. package/dist/ci-login.d.ts.map +1 -1
  41. package/dist/ci-login.js +89 -37
  42. package/dist/ci-product-words.d.ts +20 -1
  43. package/dist/ci-product-words.d.ts.map +1 -1
  44. package/dist/ci-product-words.js +27 -1
  45. package/dist/ci-product.d.ts +20 -1
  46. package/dist/ci-product.d.ts.map +1 -1
  47. package/dist/ci-product.js +21 -2
  48. package/dist/cli/handlers/approve-confirm.d.ts +14 -0
  49. package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
  50. package/dist/cli/handlers/approve-confirm.js +46 -0
  51. package/dist/cli/handlers/build.d.ts +1 -1
  52. package/dist/cli/handlers/build.d.ts.map +1 -1
  53. package/dist/cli/handlers/build.js +22 -1
  54. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  55. package/dist/cli/handlers/ci-check.js +38 -14
  56. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
  57. package/dist/cli/handlers/ci-evidence.js +238 -26
  58. package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
  59. package/dist/cli/handlers/ci-forge-check.js +34 -17
  60. package/dist/cli/handlers/generated-check.d.ts +3 -0
  61. package/dist/cli/handlers/generated-check.d.ts.map +1 -0
  62. package/dist/cli/handlers/generated-check.js +41 -0
  63. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  64. package/dist/cli/handlers/lifecycle.js +3 -0
  65. package/dist/cli/handlers/local-chant.d.ts +13 -0
  66. package/dist/cli/handlers/local-chant.d.ts.map +1 -1
  67. package/dist/cli/handlers/local-chant.js +42 -1
  68. package/dist/cli/handlers/pr.d.ts.map +1 -1
  69. package/dist/cli/handlers/pr.js +42 -5
  70. package/dist/cli/handlers/run-wave.js +8 -0
  71. package/dist/cli/main.d.ts.map +1 -1
  72. package/dist/cli/main.js +38 -4
  73. package/dist/cli/parse-args.d.ts.map +1 -1
  74. package/dist/cli/parse-args.js +66 -0
  75. package/dist/cli/registry.d.ts +24 -0
  76. package/dist/cli/registry.d.ts.map +1 -1
  77. package/dist/components/check-hooks.d.ts +10 -0
  78. package/dist/components/check-hooks.d.ts.map +1 -1
  79. package/dist/components/check-hooks.js +21 -3
  80. package/dist/components/check-steps.js +1 -1
  81. package/dist/components/pr-checks.d.ts +105 -0
  82. package/dist/components/pr-checks.d.ts.map +1 -0
  83. package/dist/components/pr-checks.js +119 -0
  84. package/dist/components/pr-pipeline.d.ts +34 -0
  85. package/dist/components/pr-pipeline.d.ts.map +1 -1
  86. package/dist/components/pr-pipeline.js +14 -1
  87. package/dist/components/product-pipeline.d.ts +16 -1
  88. package/dist/components/product-pipeline.d.ts.map +1 -1
  89. package/dist/components/product-pipeline.js +17 -2
  90. package/dist/components/product-plan.d.ts +262 -3
  91. package/dist/components/product-plan.d.ts.map +1 -1
  92. package/dist/components/product-plan.js +243 -11
  93. package/dist/config.d.ts +10 -6
  94. package/dist/config.d.ts.map +1 -1
  95. package/dist/config.js +11 -6
  96. package/dist/control/consumers.d.ts +6 -0
  97. package/dist/control/consumers.d.ts.map +1 -1
  98. package/dist/control/consumers.js +6 -0
  99. package/dist/dead-guards.d.ts.map +1 -1
  100. package/dist/dead-guards.js +9 -6
  101. package/dist/discovery/files.d.ts +1 -1
  102. package/dist/discovery/files.js +1 -1
  103. package/dist/drift-issue.d.ts +20 -3
  104. package/dist/drift-issue.d.ts.map +1 -1
  105. package/dist/drift-issue.js +16 -0
  106. package/dist/drift-record.d.ts +45 -5
  107. package/dist/drift-record.d.ts.map +1 -1
  108. package/dist/drift-record.js +27 -6
  109. package/dist/floor-table.d.ts +6 -6
  110. package/dist/floor-table.d.ts.map +1 -1
  111. package/dist/floor-table.data.d.ts.map +1 -1
  112. package/dist/floor-table.data.js +58 -20
  113. package/dist/floor-table.js +10 -7
  114. package/dist/forge-check/contract.d.ts +8 -0
  115. package/dist/forge-check/contract.d.ts.map +1 -1
  116. package/dist/forge-check/contract.js +4 -1
  117. package/dist/forge-check/index.d.ts +2 -0
  118. package/dist/forge-check/index.d.ts.map +1 -1
  119. package/dist/forge-check/index.js +2 -0
  120. package/dist/forge-flags.d.ts +10 -0
  121. package/dist/forge-flags.d.ts.map +1 -1
  122. package/dist/forge-flags.js +31 -0
  123. package/dist/forge-remote.d.ts +47 -0
  124. package/dist/forge-remote.d.ts.map +1 -0
  125. package/dist/forge-remote.js +69 -0
  126. package/dist/generated-check.d.ts +74 -0
  127. package/dist/generated-check.d.ts.map +1 -0
  128. package/dist/generated-check.js +216 -0
  129. package/dist/lexicon.d.ts +16 -0
  130. package/dist/lexicon.d.ts.map +1 -1
  131. package/dist/lifecycle/publish-npm.d.ts +15 -0
  132. package/dist/lifecycle/publish-npm.d.ts.map +1 -1
  133. package/dist/lifecycle/publish-npm.js +49 -3
  134. package/dist/lifecycle/release-images.d.ts +22 -1
  135. package/dist/lifecycle/release-images.d.ts.map +1 -1
  136. package/dist/lifecycle/release-images.js +27 -3
  137. package/dist/lifecycle/release-ledger.d.ts +4 -3
  138. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  139. package/dist/lifecycle/release-ledger.js +3 -2
  140. package/dist/local-chant.d.ts +57 -3
  141. package/dist/local-chant.d.ts.map +1 -1
  142. package/dist/local-chant.js +122 -13
  143. package/dist/op/op-waves-evidence-jobs.d.ts +92 -0
  144. package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
  145. package/dist/op/op-waves-evidence-jobs.js +112 -0
  146. package/dist/op/op-waves-evidence.d.ts +17 -4
  147. package/dist/op/op-waves-evidence.d.ts.map +1 -1
  148. package/dist/op/op-waves-evidence.js +32 -10
  149. package/dist/op/op-waves-run.d.ts +12 -1
  150. package/dist/op/op-waves-run.d.ts.map +1 -1
  151. package/dist/op/op-waves-run.js +54 -3
  152. package/dist/op/op-waves.d.ts +8 -0
  153. package/dist/op/op-waves.d.ts.map +1 -1
  154. package/dist/op/op-waves.js +10 -0
  155. package/dist/op/schedule-overdue.d.ts +39 -2
  156. package/dist/op/schedule-overdue.d.ts.map +1 -1
  157. package/dist/op/schedule-overdue.js +89 -7
  158. package/dist/pr-forge-reads.d.ts +21 -1
  159. package/dist/pr-forge-reads.d.ts.map +1 -1
  160. package/dist/pr-forge-reads.js +19 -1
  161. package/dist/pr-forge.d.ts +7 -1
  162. package/dist/pr-forge.d.ts.map +1 -1
  163. package/dist/pr-forge.js +7 -2
  164. package/dist/pr-plan-note.d.ts +24 -0
  165. package/dist/pr-plan-note.d.ts.map +1 -1
  166. package/dist/pr-plan-note.js +11 -1
  167. package/dist/pr-plan-record.d.ts +47 -0
  168. package/dist/pr-plan-record.d.ts.map +1 -0
  169. package/dist/pr-plan-record.js +89 -0
  170. package/dist/pr-post.d.ts +40 -0
  171. package/dist/pr-post.d.ts.map +1 -1
  172. package/dist/pr-post.js +79 -6
  173. package/dist/pr-requires.d.ts +8 -0
  174. package/dist/pr-requires.d.ts.map +1 -1
  175. package/dist/pr-requires.js +3 -1
  176. package/dist/ref-gate-init.d.ts +76 -0
  177. package/dist/ref-gate-init.d.ts.map +1 -0
  178. package/dist/ref-gate-init.js +144 -0
  179. package/dist/ref-gate-rules.d.ts +19 -0
  180. package/dist/ref-gate-rules.d.ts.map +1 -0
  181. package/dist/ref-gate-rules.js +17 -0
  182. package/dist/release-floors.d.ts +51 -1
  183. package/dist/release-floors.d.ts.map +1 -1
  184. package/dist/release-floors.js +66 -16
  185. package/dist/state-migration.d.ts +23 -0
  186. package/dist/state-migration.d.ts.map +1 -1
  187. package/dist/state-migration.js +39 -3
  188. package/dist/state-unlock.d.ts +32 -1
  189. package/dist/state-unlock.d.ts.map +1 -1
  190. package/dist/state-unlock.js +31 -0
  191. package/dist/wave-runtime.mjs +310 -303
  192. package/dist/workspace/ci-green-cli.d.ts.map +1 -1
  193. package/dist/workspace/ci-green-cli.js +13 -7
  194. package/dist/workspace/ci-green.d.ts.map +1 -1
  195. package/dist/workspace/ci-green.js +4 -3
  196. package/dist/workspace/drift-cli.d.ts +1 -1
  197. package/dist/workspace/drift-cli.d.ts.map +1 -1
  198. package/dist/workspace/drift-cli.js +5 -12
  199. package/dist/workspace/forge-work.d.ts +3 -2
  200. package/dist/workspace/forge-work.d.ts.map +1 -1
  201. package/dist/workspace/forge-work.js +7 -17
  202. package/dist/workspace/lexicon-outputs.js +2 -2
  203. package/dist/workspace/release-workflow.d.ts +26 -3
  204. package/dist/workspace/release-workflow.d.ts.map +1 -1
  205. package/dist/workspace/release-workflow.js +48 -6
  206. package/dist/workspace/trust/check-evidence-report.d.ts +25 -0
  207. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
  208. package/dist/workspace/trust/check-evidence-report.js +20 -0
  209. package/dist/workspace/trust/check-evidence.d.ts +59 -13
  210. package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
  211. package/dist/workspace/trust/check-evidence.js +101 -24
  212. package/dist/workspace/trust/ci-tag-statement.d.ts +2 -2
  213. package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
  214. package/dist/workspace/trust/dsse.d.ts +40 -2
  215. package/dist/workspace/trust/dsse.d.ts.map +1 -1
  216. package/dist/workspace/trust/dsse.js +34 -2
  217. package/dist/workspace/trust/evidence.d.ts +7 -2
  218. package/dist/workspace/trust/evidence.d.ts.map +1 -1
  219. package/dist/workspace/trust/evidence.js +5 -0
  220. package/dist/workspace/trust/keyless-fixture.d.ts +41 -0
  221. package/dist/workspace/trust/keyless-fixture.d.ts.map +1 -0
  222. package/dist/workspace/trust/keyless-fixture.js +161 -0
  223. package/dist/workspace/trust/keyless.d.ts +202 -0
  224. package/dist/workspace/trust/keyless.d.ts.map +1 -0
  225. package/dist/workspace/trust/keyless.js +488 -0
  226. package/dist/workspace/trust/local-evidence.d.ts +3 -0
  227. package/dist/workspace/trust/local-evidence.d.ts.map +1 -1
  228. package/dist/workspace/trust/op-run-statement.d.ts +2 -2
  229. package/dist/workspace/trust/op-run-statement.d.ts.map +1 -1
  230. package/dist/workspace/trust/open-evidence.d.ts +67 -0
  231. package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
  232. package/dist/workspace/trust/open-evidence.js +92 -0
  233. package/dist/workspace/trust/policy.d.ts +56 -1
  234. package/dist/workspace/trust/policy.d.ts.map +1 -1
  235. package/dist/workspace/trust/policy.js +103 -2
  236. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
  237. package/dist/workspace/trust/ref-gate-cli.js +65 -3
  238. package/dist/workspace/trust/ref-gate.d.ts +62 -3
  239. package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
  240. package/dist/workspace/trust/ref-gate.js +75 -8
  241. package/dist/workspace/trust/run-statement.d.ts +3 -3
  242. package/dist/workspace/trust/run-statement.d.ts.map +1 -1
  243. package/dist/workspace/trust/runner-identity.d.ts +56 -0
  244. package/dist/workspace/trust/runner-identity.d.ts.map +1 -0
  245. package/dist/workspace/trust/runner-identity.js +65 -0
  246. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  247. package/dist/workspace/trust/trust-files.js +8 -1
  248. package/package.json +1 -1
  249. package/src/action-pins.ts +2 -0
  250. package/src/actor.test.ts +12 -0
  251. package/src/actor.ts +19 -0
  252. package/src/bundle-check.test.ts +22 -0
  253. package/src/bundle-check.ts +33 -5
  254. package/src/chant-install.test.ts +109 -1
  255. package/src/chant-install.ts +243 -2
  256. package/src/ci-commit.test.ts +51 -5
  257. package/src/ci-commit.ts +1 -2
  258. package/src/ci-control.ts +1 -0
  259. package/src/ci-evidence-claims.ts +102 -0
  260. package/src/ci-evidence-from-job.test.ts +147 -0
  261. package/src/ci-evidence-from-job.ts +195 -0
  262. package/src/ci-evidence-jobs.ts +85 -10
  263. package/src/ci-handover.ts +16 -3
  264. package/src/ci-identity.test.ts +3 -3
  265. package/src/ci-identity.ts +51 -11
  266. package/src/ci-image.test.ts +60 -10
  267. package/src/ci-image.ts +78 -19
  268. package/src/ci-jobs.ts +7 -2
  269. package/src/ci-login.test.ts +131 -3
  270. package/src/ci-login.token-drop.test.ts +204 -0
  271. package/src/ci-login.ts +137 -39
  272. package/src/ci-product-words.ts +30 -0
  273. package/src/ci-product.ts +26 -1
  274. package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
  275. package/src/cli/handlers/approve-confirm.test.ts +35 -0
  276. package/src/cli/handlers/approve-confirm.ts +44 -0
  277. package/src/cli/handlers/build-source-dir.test.ts +4 -0
  278. package/src/cli/handlers/build.ts +20 -2
  279. package/src/cli/handlers/ci-check.ts +35 -13
  280. package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
  281. package/src/cli/handlers/ci-evidence.ts +223 -24
  282. package/src/cli/handlers/ci-forge-check.ts +22 -9
  283. package/src/cli/handlers/generated-check.ts +39 -0
  284. package/src/cli/handlers/lifecycle.test.ts +20 -0
  285. package/src/cli/handlers/lifecycle.ts +4 -0
  286. package/src/cli/handlers/local-chant.ts +39 -1
  287. package/src/cli/handlers/pr.ts +43 -5
  288. package/src/cli/handlers/run-wave.ts +7 -0
  289. package/src/cli/main.ts +38 -4
  290. package/src/cli/parse-args.ts +46 -0
  291. package/src/cli/registry.ts +24 -0
  292. package/src/components/check-hooks.ts +25 -3
  293. package/src/components/check-report-summary.test.ts +78 -0
  294. package/src/components/check-steps.ts +1 -1
  295. package/src/components/pr-checks.ts +159 -0
  296. package/src/components/pr-pipeline.ts +41 -1
  297. package/src/components/product-pipeline.ts +25 -3
  298. package/src/components/product-plan.test.ts +102 -1
  299. package/src/components/product-plan.ts +419 -14
  300. package/src/config.ts +13 -8
  301. package/src/control/consumers.ts +7 -0
  302. package/src/dead-guards.test.ts +27 -5
  303. package/src/dead-guards.ts +9 -6
  304. package/src/discovery/files.ts +1 -1
  305. package/src/drift-issue.test.ts +29 -1
  306. package/src/drift-issue.ts +28 -3
  307. package/src/drift-record.test.ts +25 -0
  308. package/src/drift-record.ts +55 -6
  309. package/src/floor-table.data.ts +58 -20
  310. package/src/floor-table.ts +12 -9
  311. package/src/forge-check/contract.ts +11 -1
  312. package/src/forge-check/forge-check.test.ts +8 -0
  313. package/src/forge-check/index.ts +2 -0
  314. package/src/forge-flags.test.ts +25 -1
  315. package/src/forge-flags.ts +34 -0
  316. package/src/forge-remote.test.ts +37 -0
  317. package/src/forge-remote.ts +79 -0
  318. package/src/generated-check.e2e.test.ts +98 -0
  319. package/src/generated-check.test.ts +104 -0
  320. package/src/generated-check.ts +269 -0
  321. package/src/lexicon.ts +17 -0
  322. package/src/lifecycle/publish-npm.ts +56 -3
  323. package/src/lifecycle/release-catalog.test.ts +2 -2
  324. package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
  325. package/src/lifecycle/release-images.test.ts +44 -0
  326. package/src/lifecycle/release-images.ts +39 -3
  327. package/src/lifecycle/release-ledger.ts +4 -3
  328. package/src/local-chant.e2e.test.ts +81 -6
  329. package/src/local-chant.test.ts +22 -3
  330. package/src/local-chant.ts +130 -13
  331. package/src/op/op-waves-evidence-jobs.ts +134 -0
  332. package/src/op/op-waves-evidence.test.ts +37 -4
  333. package/src/op/op-waves-evidence.ts +32 -11
  334. package/src/op/op-waves-run.ts +57 -2
  335. package/src/op/op-waves.ts +11 -0
  336. package/src/op/schedule-overdue.test.ts +83 -1
  337. package/src/op/schedule-overdue.ts +107 -9
  338. package/src/pr-forge-reads-compare.test.ts +2 -1
  339. package/src/pr-forge-reads.ts +37 -1
  340. package/src/pr-forge.ts +14 -3
  341. package/src/pr-plan-note.ts +32 -3
  342. package/src/pr-plan-record.test.ts +75 -0
  343. package/src/pr-plan-record.ts +101 -0
  344. package/src/pr-post-plan-note.test.ts +60 -0
  345. package/src/pr-post.test.ts +30 -0
  346. package/src/pr-post.ts +110 -6
  347. package/src/pr-requires.test.ts +20 -0
  348. package/src/pr-requires.ts +10 -1
  349. package/src/ref-gate-init.ts +189 -0
  350. package/src/ref-gate-rules.ts +26 -0
  351. package/src/release-floors.ts +88 -16
  352. package/src/state-migration-record.test.ts +90 -0
  353. package/src/state-migration.test.ts +1 -1
  354. package/src/state-migration.ts +52 -3
  355. package/src/state-unlock.test.ts +33 -1
  356. package/src/state-unlock.ts +49 -1
  357. package/src/workspace/ci-green-cli.ts +12 -6
  358. package/src/workspace/ci-green.ts +4 -3
  359. package/src/workspace/drift-cli.ts +6 -18
  360. package/src/workspace/forge-work.ts +7 -14
  361. package/src/workspace/lexicon-outputs.ts +2 -2
  362. package/src/workspace/release-workflow.test.ts +70 -0
  363. package/src/workspace/release-workflow.ts +56 -8
  364. package/src/workspace/trust/check-evidence-report.ts +33 -0
  365. package/src/workspace/trust/check-evidence.test.ts +3 -3
  366. package/src/workspace/trust/check-evidence.ts +110 -28
  367. package/src/workspace/trust/ci-tag-statement.ts +2 -2
  368. package/src/workspace/trust/dsse.ts +48 -4
  369. package/src/workspace/trust/evidence.ts +7 -2
  370. package/src/workspace/trust/keyless-fixture.ts +214 -0
  371. package/src/workspace/trust/keyless.test.ts +220 -0
  372. package/src/workspace/trust/keyless.ts +557 -0
  373. package/src/workspace/trust/local-evidence.ts +3 -1
  374. package/src/workspace/trust/op-run-statement.ts +2 -2
  375. package/src/workspace/trust/open-evidence.ts +129 -0
  376. package/src/workspace/trust/policy.ts +129 -2
  377. package/src/workspace/trust/ref-gate-cli.ts +59 -3
  378. package/src/workspace/trust/ref-gate-pieces.test.ts +175 -0
  379. package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
  380. package/src/workspace/trust/ref-gate.ts +90 -8
  381. package/src/workspace/trust/run-statement.ts +3 -3
  382. package/src/workspace/trust/runner-identity.ts +92 -0
  383. package/src/workspace/trust/trust-files.test.ts +6 -0
  384. package/src/workspace/trust/trust-files.ts +14 -1
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
 
@@ -500,6 +500,26 @@ export const PRODUCT_COMMENT_ASK_MAX = 2000;
500
500
  /** Commands a comment never runs, named in the reply so nobody waits on them. */
501
501
  const NEVER = new Set(["approve", "override", "force-unlock", "unlock-state", "import", "state", "destroy", "merge"]);
502
502
 
503
+ /** {@link parseProductComment}'s options. */
504
+ export interface ProductCommentOptions {
505
+ /** Leave every comment for a commit word to the commit job (#4890): it is undefined here, a refused one included. */
506
+ leaveCommit?: boolean;
507
+ }
508
+
509
+ /**
510
+ * The commit word a comment names (#4890): its first two words, split on
511
+ * any space, are `/<product> <word>` and the words map `<word>` onto
512
+ * `commit`. The commit job replies to a refused comment by this rule
513
+ * (#4838), so a comment job that skips these never answers a comment the
514
+ * commit job answers. Undefined for any other comment.
515
+ */
516
+ export function commitWordOf(words: CiProductWords, body: unknown): string | undefined {
517
+ if (typeof body !== "string") return undefined;
518
+ const said = body.trim().split(/[ \t\r\n]+/);
519
+ if (said[0] !== `/${words.product}` || said[1] === undefined) return undefined;
520
+ return words.commands[said[1]] === "commit" ? said[1] : undefined;
521
+ }
522
+
503
523
  /**
504
524
  * Read a comment against the product's grammar (moved from terragucci's
505
525
  * comment.ts). Undefined when it is not addressed to the product. A comment
@@ -512,14 +532,22 @@ const NEVER = new Set(["approve", "override", "force-unlock", "unlock-state", "i
512
532
  * names the commit words that take one argument after them (#4820), each
513
533
  * with the pattern it must match; it must also match
514
534
  * {@link COMMIT_COMMENT_ARG}. Any other commit word takes nothing.
535
+ *
536
+ * `leaveCommit` (#4890) is for a comment job that is not the commit job: a
537
+ * comment for a commit word is undefined, a malformed one included
538
+ * ({@link commitWordOf}), because the commit job answers it, refusals and
539
+ * all (#4838). Without it, a malformed `/<product> <commit word> x` would
540
+ * get a reply from both jobs.
515
541
  */
516
542
  export function parseProductComment(
517
543
  words: CiProductWords,
518
544
  body: unknown,
519
545
  env: Record<string, string | undefined> = {},
520
546
  commitArgs: Readonly<Record<string, RegExp>> = {},
547
+ options: ProductCommentOptions = {},
521
548
  ): ParsedProductComment | undefined {
522
549
  if (typeof body !== "string") return undefined;
550
+ if (options.leaveCommit && commitWordOf(words, body) !== undefined) return undefined;
523
551
  let text = body.trim();
524
552
  const prefix = `/${words.product}`;
525
553
  for (const a of words.aliases) {
@@ -562,6 +590,8 @@ export function parseProductComment(
562
590
  case "unlock":
563
591
  return parts.length === 2 ? { kind: command } : { kind: "refused", reason: `${line} takes nothing after it` };
564
592
  case "commit": {
593
+ // An alias for a commit word, which commitWordOf does not read, is the commit job's too.
594
+ if (options.leaveCommit) return undefined;
565
595
  if (parts.length === 2) return { kind: "commit", word: typed };
566
596
  const pattern = Object.prototype.hasOwnProperty.call(commitArgs, typed) ? commitArgs[typed] : undefined;
567
597
  if (pattern === undefined) return { kind: "refused", reason: `${line} takes nothing after it` };
package/src/ci-product.ts CHANGED
@@ -37,6 +37,7 @@ export {
37
37
  CiProductWordsError,
38
38
  commandWord,
39
39
  commentLine,
40
+ commitWordOf,
40
41
  isChantWords,
41
42
  notifyWaveLabel,
42
43
  overrideLine,
@@ -63,6 +64,7 @@ export {
63
64
  type CiProductWordsInput,
64
65
  type OverrideLineInput,
65
66
  type ParsedProductComment,
67
+ type ProductCommentOptions,
66
68
  type ProductActionRequest,
67
69
  } from "./ci-product-words";
68
70
  export { driftNotifyFields, NOTIFY_MESSAGE_WORDS_FLOOR, productNotifySource, productNotifyWords, productSendOptions, type DriftNotifyInput } from "./notify-product";
@@ -131,10 +133,33 @@ export { prActionJob, PR_ACTION_JOB, prApplyComment, prCommentLockJobs, prCommen
131
133
  * `components/product-plan-pipeline`. A product feature-detects on this
132
134
  * floor.
133
135
  */
134
- export const PRODUCT_PLAN_FLOOR = NEXT_RELEASE;
136
+ export const PRODUCT_PLAN_FLOOR = "0.124.86";
135
137
  export { productPlanJobs, PR_PLAN_NOTE_WORDS_ENV, type ProductPlanJob, type ProductPlanOptions, type ProductPlanTarget } from "./components/product-plan";
136
138
  export { planNoteHandoff, PR_PLAN_NOTE_FILE, type PrPlanNoteHandoff } from "./pr-plan-note";
137
139
 
140
+ /**
141
+ * The first chant whose product plan carries the plan-job steps beside the plan verb and the note job's own lines (#4899, #4931): `productPlan.login` and a target's `login` (ci-login) with the job's OIDC token, `idTokens`, `pending`, `controlRead`, `setup` steps, job-level `env`, `report`, `concurrency`, the comment re-plan `replan`, and `noteSteps`; a hand-off's `marker` kept under the note words' `productMarker`; and the note job's notices and overdue Ops under a hand-off's counts.
142
+ */
143
+ export const PRODUCT_PLAN_STEPS_FLOOR = NEXT_RELEASE;
144
+ export { PLAN_ARGUMENT_ENV, PLAN_NOTE_NOTICES_ENV, type ProductPlanReplanJob, type ProductPlanSetupStep } from "./components/product-plan";
145
+
146
+ /**
147
+ * The first chant whose `parseProductComment` takes `leaveCommit` and that has `commitWordOf` (#4890): a comment job that is not the commit job leaves every comment for a commit word to it, a malformed one included, so the comment gets one reply.
148
+ */
149
+ export const COMMENT_LEAVES_COMMIT_FLOOR = NEXT_RELEASE;
150
+
151
+ /**
152
+ * The first chant whose product plan takes `watches`, the product's own scheduled jobs the note job's `pr-post` checks for having stopped with the job's token (#4888), and whose `checkOverdueOps` and `overdueOpsAt` take a product's `logPrefix` and `label`.
153
+ */
154
+ export const PRODUCT_PLAN_WATCHES_FLOOR = NEXT_RELEASE;
155
+ export { PLAN_WATCHES_ENV } from "./op/schedule-overdue";
156
+
157
+ /**
158
+ * The first chant whose product plan takes `record` (#4899): the plan step writes the plan job's run record into the hand-off, and the note job keeps it as Op `pr-plan` on `chant/lifecycle` with `pr-post --record-run <plan job>` (`--open` on GitLab), as `chant ci run plan --in-place` records `pr-plan`'s.
159
+ */
160
+ export const PRODUCT_PLAN_RECORD_FLOOR = NEXT_RELEASE;
161
+ export { PLAN_RUN_OP, PLAN_RUN_RECORD_FILE, readPlanRunRecord } from "./pr-plan-record";
162
+
138
163
  /**
139
164
  * Day-2 actions in the product pipeline (#4654): the `action` comment
140
165
  * command counted as answered by the product's own workflow
@@ -0,0 +1,3 @@
1
+ // A migration's backfill script: a root build that loads it fails (#4921).
2
+ export const backfill = "ran";
3
+ throw new Error("migrations/0001-init/backfill.ts was loaded");
@@ -14,6 +14,8 @@ import { composeChangeSet, lifecyclePlanPart, type ChangeSetDocument } from "../
14
14
  import type { ChangeSet as LifecycleChangeSet } from "../../lifecycle/change-set";
15
15
  import { persistChangeSet } from "../../lifecycle/change-set-store";
16
16
  import { appendPendingGate, readGateLedger } from "../../lifecycle/gate-ledger";
17
+ import { gatedRequestAttachmentPath } from "../../lifecycle/gated-request-digest";
18
+ import { writeBlobToPath } from "../../lifecycle/git";
17
19
  import { resetGateOrigin } from "../../lifecycle/gate-origin";
18
20
  import { CHANT_EXIT } from "../../exit-codes";
19
21
  import type { ParsedArgs } from "../registry";
@@ -203,6 +205,39 @@ describe("confirmApproval (#4575)", () => {
203
205
  });
204
206
  });
205
207
 
208
+ describe("confirmApproval on a gated request's attachment (#4928)", () => {
209
+ const cwd = process.cwd();
210
+ afterEach(() => {
211
+ process.chdir(cwd);
212
+ resetGateOrigin();
213
+ });
214
+
215
+ test("a migration's request shows its roots and the product's record, which its digest binds", async () => {
216
+ await withTestDir(async (dir) => {
217
+ git(["init", "-q", "-b", "main"], dir);
218
+ git(["config", "user.email", "t@chant.dev"], dir);
219
+ git(["config", "user.name", "T"], dir);
220
+ writeFileSync(join(dir, "README.md"), "x\n");
221
+ git(["add", "."], dir);
222
+ git(["commit", "-q", "-m", "init"], dir);
223
+ const digest = `sha256:${"a".repeat(64)}`;
224
+ const attachment = `${JSON.stringify({ name: "move-queues", roots: [{ root: "queues", location: "s3://acme/queues.tfstate" }], record: { moves: [{ addresses: ["aws_sqs_queue.jobs"], from: "platform", to: "queues" }], stamps: [] } })}\n`;
225
+ const { dir: at, file } = gatedRequestAttachmentPath("tf-migrate", digest);
226
+ await writeBlobToPath(at, file, attachment, "Request migrate on move-queues", { cwd: dir });
227
+ await appendPendingGate({ op: "tf-migrate", gate: "move-queues", timestamp: "2026-11-09T00:00:00.000Z", expiresAt: "2999-01-01T00:00:00.000Z", planDigest: digest, description: "migration move-queues: queues" }, { cwd: dir });
228
+ process.chdir(dir);
229
+ let shown = "";
230
+ let said = "";
231
+ const c = await confirmApproval("tf-migrate", "move-queues", { cwd: dir, out: (t) => (shown += t), err: (t) => (said += t), ask: async () => "move-queues" });
232
+ expect(c).toEqual({ status: "confirmed", plan: digest, target: "move-queues" });
233
+ expect(shown).toContain(`The request binds _gates/tf-migrate/requests/sha256_${"a".repeat(64)}.json`);
234
+ expect(shown).toContain('"aws_sqs_queue.jobs"');
235
+ expect(shown).toContain('"record"');
236
+ expect(said).not.toContain("No plan is stored");
237
+ });
238
+ });
239
+ });
240
+
206
241
  describe("chant approve with a faked terminal (#4575)", () => {
207
242
  const cwd = process.cwd();
208
243
  const stdinTTY = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");
@@ -24,6 +24,14 @@ import type { ParsedArgs } from "../registry";
24
24
  import type { PendingGateRecord } from "../../lifecycle/gate-ledger";
25
25
  import { CHANT_EXIT } from "../../exit-codes";
26
26
 
27
+ /**
28
+ * The first chant with `confirmApproval` here, the type-the-name
29
+ * confirmation a product's approve word asks through (#4575). #4916
30
+ * declared it after the fact, so `chant dev dead-guards` sees a product's
31
+ * lazy load of this subpath.
32
+ */
33
+ export const APPROVE_CONFIRM_FLOOR = "0.124.55";
34
+
27
35
  /** The streams the terminal check reads. `process` in the CLI; tests pass their own. */
28
36
  export interface ApprovalTerminal {
29
37
  stdin: { isTTY?: boolean };
@@ -167,6 +175,8 @@ export async function confirmApproval(opName: string, gate: string, opts: Confir
167
175
  err(`The stored plan can't be read: ${e instanceof Error ? e.message : String(e)}\n`);
168
176
  }
169
177
  }
178
+ // #4928: a gated request's attachment (a state migration's roots and the product's record) is what its digest binds; show it.
179
+ if (!shown) shown = await showAttachment(opName, digest, cwd, out, err);
170
180
  if (!shown) {
171
181
  err(
172
182
  `No plan is stored on chant/lifecycle under ${changeSet}. The run that stopped at the gate printed it; ` +
@@ -198,3 +208,37 @@ export async function confirmApproval(opName: string, gate: string, opts: Confir
198
208
  }
199
209
  return { status: "confirmed", plan: digest, target };
200
210
  }
211
+
212
+ /** The most of an attachment `chant approve` prints before it says where the rest is (#4928). */
213
+ const ATTACHMENT_SHOWN_BYTES = 64 * 1024;
214
+
215
+ /**
216
+ * Print the attachment a gated request stored under `digest` (#4928), such
217
+ * as a state migration's roots and the product's record. JSON is printed
218
+ * indented, anything else as stored, and either is cut at
219
+ * {@link ATTACHMENT_SHOWN_BYTES} with the path of the whole. False when none is stored.
220
+ */
221
+ export async function showAttachment(op: string, digest: string, cwd: string, out: (text: string) => void, err: (text: string) => void): Promise<boolean> {
222
+ const { gatedRequestAttachmentPath } = await import("../../lifecycle/gated-request-digest");
223
+ const { readBlobFromPath } = await import("../../lifecycle/git");
224
+ const { dir, file } = gatedRequestAttachmentPath(op, digest);
225
+ let text: string | null;
226
+ try {
227
+ text = await readBlobFromPath(dir, file, { cwd });
228
+ } catch (e) {
229
+ err(`The request's attachment can't be read: ${e instanceof Error ? e.message : String(e)}\n`);
230
+ return false;
231
+ }
232
+ if (text === null) return false;
233
+ let shown = text;
234
+ try {
235
+ shown = `${JSON.stringify(JSON.parse(text), null, 2)}\n`;
236
+ } catch {
237
+ // Not JSON: shown as stored.
238
+ }
239
+ const cut = Buffer.byteLength(shown, "utf8") > ATTACHMENT_SHOWN_BYTES;
240
+ out(`The request binds ${dir}/${file}:\n`);
241
+ out(cut ? `${Buffer.from(shown, "utf8").subarray(0, ATTACHMENT_SHOWN_BYTES).toString("utf8")}\n...\n` : shown);
242
+ if (cut) err(`The attachment is longer than ${ATTACHMENT_SHOWN_BYTES} bytes; the whole is at ${dir}/${file} on chant/lifecycle.\n`);
243
+ return true;
244
+ }
@@ -38,6 +38,10 @@ describe("a root build (#4794)", () => {
38
38
  expect(await loaded(root, root)).toEqual(["infra.ts"]);
39
39
  });
40
40
 
41
+ test("nor its top-level migrations/, whose backfill scripts run on load (#4921)", async () => {
42
+ expect((await findInfraFiles(root)).map((f) => relative(root, f).split("\\").join("/"))).toEqual(["infra.ts"]);
43
+ });
44
+
41
45
  test("include brings scripts/ back", async () => {
42
46
  expect((await findInfraFiles(include)).map((f) => relative(include, f).split("\\").join("/")).sort()).toEqual(["infra.ts", "scripts/run-on-load.ts"]);
43
47
  });
@@ -65,7 +65,11 @@ async function engineSetupFor(path: string): Promise<string[]> {
65
65
  * `--merge auto --merge-token-env <VAR> [--merge-method <m>]` (#4636) merges
66
66
  * the pull request after its update before merge. `--respond <list>`,
67
67
  * `--decide-backend` and `--decide-model` (#4629) set the apply and note
68
- * jobs' responses and the description check's service. {@link prLoopFlagsProblem}
68
+ * jobs' responses and the description check's service.
69
+ * `--evidence-runner-key-secret <NAME>`, or `--evidence-identity oidc` with
70
+ * `--evidence-audience` (#4935), give the loop its runner identity: the note
71
+ * job signs `plan` and `policy`. `--check-job` and `--ref-gate-status`
72
+ * (#4935) write the check job and the ref gate's status job. {@link prLoopFlagsProblem}
69
73
  * has checked all of them first.
70
74
  */
71
75
  function prLoopOption(args: CommandContext["args"], reportUrl: string | undefined, requireReview = false, requireRunnerStart = false): PrLoopPipelineOptions {
@@ -105,6 +109,11 @@ function prLoopOption(args: CommandContext["args"], reportUrl: string | undefine
105
109
  // #4629: the responses on the apply and note jobs, and the description check's service.
106
110
  ...(respond && Object.keys(respond).length > 0 ? { respond } : {}),
107
111
  ...(args.decideBackend && args.decideModel ? { decide: { backend: args.decideBackend, model: args.decideModel } } : {}),
112
+ // #4935: the runner identity the note job signs with, the check job and the ref gate's status job.
113
+ ...(args.evidenceRunnerKeySecret ? { evidence: { runnerKeySecret: args.evidenceRunnerKeySecret } } : {}),
114
+ ...(args.evidenceIdentity === "oidc" ? { evidence: { identity: "oidc" as const, ...(args.evidenceAudience ? { audience: args.evidenceAudience } : {}) } } : {}),
115
+ ...(args.checkJob ? { checkJob: true } : {}),
116
+ ...(args.refGateStatus ? { refGateStatus: true } : {}),
108
117
  };
109
118
  }
110
119
 
@@ -114,8 +123,13 @@ function prLoopOption(args: CommandContext["args"], reportUrl: string | undefine
114
123
  * they do. Each value is refused by name, as `pr-apply` and `pr-post` refuse
115
124
  * it, so a build never writes a job that fails on its own line.
116
125
  */
117
- export function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents"> & Partial<Pick<CommandContext["args"], "controlRepo" | "controlSettings">>): string | undefined {
126
+ export function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents"> & Partial<Pick<CommandContext["args"], "controlRepo" | "controlSettings" | "evidenceRunnerKeySecret" | "evidenceIdentity" | "evidenceAudience" | "checkJob" | "refGateStatus">>): string | undefined {
118
127
  const given = [
128
+ ...(args.evidenceRunnerKeySecret !== undefined ? ["--evidence-runner-key-secret"] : []),
129
+ ...(args.evidenceIdentity !== undefined ? ["--evidence-identity"] : []),
130
+ ...(args.evidenceAudience !== undefined ? ["--evidence-audience"] : []),
131
+ ...(args.checkJob ? ["--check-job"] : []),
132
+ ...(args.refGateStatus ? ["--ref-gate-status"] : []),
119
133
  ...(args.controlRepo !== undefined ? ["--control"] : []),
120
134
  ...(args.controlSettings !== undefined ? ["--control-setting"] : []),
121
135
  ...(args.merge !== undefined ? ["--merge"] : []),
@@ -140,6 +154,10 @@ export function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" |
140
154
  if (args.mergeMethod !== undefined && !(PR_MERGE_METHODS as readonly string[]).includes(args.mergeMethod)) return `--merge-method takes ${PR_MERGE_METHODS.join(", ")}, not ${args.mergeMethod}`;
141
155
  }
142
156
  if (args.controlSettings !== undefined && args.controlRepo === undefined) return "--control-setting sets the control repo's settings, so it needs --control <repo>";
157
+ // #4935: one runner identity, as PipelineEvidence takes it.
158
+ if (args.evidenceRunnerKeySecret !== undefined && args.evidenceIdentity !== undefined) return "--evidence-runner-key-secret and --evidence-identity each name the runner identity the jobs sign with; give one of them";
159
+ if (args.evidenceAudience !== undefined && args.evidenceIdentity === undefined) return "--evidence-audience is the keyless signing token's audience, so it goes with --evidence-identity oidc";
160
+ if (args.evidenceRunnerKeySecret !== undefined && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(args.evidenceRunnerKeySecret)) return `--evidence-runner-key-secret takes a secret name of letters, digits and _, not ${args.evidenceRunnerKeySecret}`;
143
161
  const respond = args.respond ? parseRespondList(args.respond) : {};
144
162
  if ("error" in respond) return respond.error;
145
163
  const check = respond.description === "check";