@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,140 @@
1
+ /**
2
+ * How a generated waves pipeline signs each wave's checks (#4926), for the
3
+ * forge lexicons to render. No import beyond the spec's helpers and the
4
+ * claim file names, so the generators' bundles stay small.
5
+ *
6
+ * With a pipeline `evidence` identity, each wave's own or deciding job:
7
+ *
8
+ * - runs the wave's policy (`holds.policy`) as a step of its own before the
9
+ * command, `chant run wave --policy-only`; on GitLab, which reports no
10
+ * steps, as a `<wave job>-policy` job the wave job needs. Its result is
11
+ * the forge's to report, and `policy:<wave>` is signed from it alone.
12
+ * - is followed by `<wave job>-evidence`, which runs none of the change's
13
+ * code, reads the wave job's record through the forge and signs with
14
+ * `chant ci evidence sign --from-job`: `policy:<wave>` when the wave has a
15
+ * policy, and `plan:<wave>` too when the wave trades cloud credentials and
16
+ * signs keyless, since after the trade no step of the wave job may request
17
+ * the signing token (#4869).
18
+ * - signs `plan:<wave>` in its command step otherwise, as before (#4870),
19
+ * except on GitLab with a runner key (#4964): a wave job names its own
20
+ * deploy environment, so it cannot name the `chant-evidence` one the
21
+ * key's variable is scoped to, and the evidence job, which does, signs
22
+ * `plan:<wave>` from the wave job's status and claim file.
23
+ *
24
+ * A wave with no policy and no keyless cloud trade renders as before.
25
+ * A later wave whose `evidence.requires` names a check an earlier wave's
26
+ * evidence job signs needs that job, so it reads the evidence once signed.
27
+ */
28
+
29
+ import { EVIDENCE_SOURCES_ENV, WAVE_EVIDENCE_ENV, type EvidenceSourceSpec } from "../ci-evidence-claims";
30
+ import { opWaveBinArgv, opWaveChecksDir, type OpWaveJob, type OpWavesSpec } from "./op-waves";
31
+
32
+ export { EVIDENCE_SOURCES_ENV, WAVE_EVIDENCE_ENV };
33
+
34
+ /** The `id` of a wave job's policy step on GitHub and Forgejo, which the command step's `if:` reads. */
35
+ export const OP_WAVE_POLICY_STEP_ID = "chant-policy";
36
+
37
+ /** How one wave job signs its checks (#4926). */
38
+ export interface OpWaveEvidencePlan {
39
+ /** The wave's two check names. */
40
+ plan: string;
41
+ policy: string;
42
+ /** The wave runs its policy as a step (GitLab: a job) of its own. */
43
+ policyStep: boolean;
44
+ /** `CHANT_WAVE_EVIDENCE` on the command step: `plan` signs plan only, `job` signs nothing there. Unset: as before. */
45
+ commandMode?: "plan" | "job";
46
+ /** The command step holds the signing identity (a key, or keyless with the job's own token). */
47
+ commandSigns: boolean;
48
+ /** The evidence job after the wave job, and the checks it signs. */
49
+ evidenceJob?: { name: string; checks: string[] };
50
+ }
51
+
52
+ /**
53
+ * What wave job `job` renders for its evidence, or undefined when the job
54
+ * signs nothing (a share or job group's job, or no `evidence` on the
55
+ * pipeline). `keylessCloud` is whether the job signs keyless and trades
56
+ * cloud credentials.
57
+ */
58
+ export function opWaveEvidencePlan(spec: Pick<OpWavesSpec, "holds" | "waves">, job: Pick<OpWaveJob, "kind" | "jobName" | "wave">, opts: { signs: boolean; keylessCloud: boolean; keyOutOfWave?: boolean }): OpWaveEvidencePlan | undefined {
59
+ if (!opts.signs || (job.kind !== "wave" && job.kind !== "decide")) return undefined;
60
+ const name = spec.waves[job.wave - 1]!.name;
61
+ const plan = `plan:${name}`;
62
+ const policy = `policy:${name}`;
63
+ const policyStep = spec.holds?.policy === true;
64
+ // #4964: with `keyOutOfWave` (GitLab with a runner key) the wave job holds no key, so its evidence job signs the plan too.
65
+ const inJob = opts.keylessCloud || opts.keyOutOfWave === true;
66
+ const checks = [...(inJob ? [plan] : []), ...(policyStep ? [policy] : [])];
67
+ if (checks.length === 0) return { plan, policy, policyStep, commandSigns: true };
68
+ return { plan, policy, policyStep, commandMode: inJob ? "job" : "plan", commandSigns: !inJob, evidenceJob: { name: `${job.jobName}-evidence`, checks } };
69
+ }
70
+
71
+ /** The GitLab job a wave's policy runs in (#4926). */
72
+ export function opWavePolicyJobName(job: Pick<OpWaveJob, "jobName">): string {
73
+ return `${job.jobName}-policy`;
74
+ }
75
+
76
+ /** The policy step's command: the wave job's own, with `--policy-only`. */
77
+ export function opWavePolicyCommand(job: Pick<OpWaveJob, "command">): string[] {
78
+ return [...job.command, "--policy-only"];
79
+ }
80
+
81
+ /** The policy step's name on GitHub and Forgejo, which the evidence job finds it by. */
82
+ export function opWavePolicyStepName(wave: number, name: string): string {
83
+ return `Check wave ${wave} (${name})'s plans against the policy`;
84
+ }
85
+
86
+ /**
87
+ * The evidence job's `CHANT_EVIDENCE_SOURCES`: on GitHub and Forgejo the
88
+ * command step for `plan:<wave>` and the policy step for `policy:<wave>`, by
89
+ * name; on GitLab the wave job and its policy job.
90
+ */
91
+ export function opWaveEvidenceSources(forge: "github" | "forgejo" | "gitlab", plan: OpWaveEvidencePlan, job: Pick<OpWaveJob, "jobName" | "wave">, waveName: string, commandStep: string): Record<string, EvidenceSourceSpec> {
92
+ const out: Record<string, EvidenceSourceSpec> = {};
93
+ for (const check of plan.evidenceJob?.checks ?? []) {
94
+ if (forge === "gitlab") out[check] = check === plan.policy ? { job: opWavePolicyJobName(job) } : {};
95
+ else out[check] = { step: check === plan.policy ? opWavePolicyStepName(job.wave, waveName) : commandStep };
96
+ }
97
+ return out;
98
+ }
99
+
100
+ /**
101
+ * The evidence job's lines (#4926): note the base and check it out, so the
102
+ * setup and the product's command after it are the base's code and none of
103
+ * the change's runs, then sign from the wave job. `sha` is the run's commit
104
+ * as the shell reads it; the first line keeps the base in
105
+ * {@link OP_WAVE_EVIDENCE_BASE_VAR}.
106
+ */
107
+ export function opWaveEvidenceLines(spec: Pick<OpWavesSpec, "name" | "base">, plan: OpWaveEvidencePlan, job: Pick<OpWaveJob, "jobName">, opts: { sha: string; bin?: string }): { checkout: string[]; sign: string[] } {
108
+ const base = spec.base ?? "HEAD^1";
109
+ const quoted = `'${base.replace(/'/g, "'\\''")}'`;
110
+ return {
111
+ checkout: [`${OP_WAVE_EVIDENCE_BASE_VAR}="$(git rev-parse --verify ${quoted}^{commit})" || exit 1`, `git checkout --quiet --detach "$${OP_WAVE_EVIDENCE_BASE_VAR}" || exit 1`],
112
+ sign: [
113
+ [
114
+ ...opWaveBinArgv(opts.bin),
115
+ "ci evidence sign --from-job",
116
+ job.jobName,
117
+ "--check-id",
118
+ plan.evidenceJob!.checks.join(","),
119
+ "--claims",
120
+ opWaveChecksDir(spec),
121
+ "--at",
122
+ opts.sha,
123
+ "--base",
124
+ `"$${OP_WAVE_EVIDENCE_BASE_VAR}"`,
125
+ ].join(" "),
126
+ ],
127
+ };
128
+ }
129
+
130
+ /** The variable the evidence job keeps the base commit in between its lines. */
131
+ export const OP_WAVE_EVIDENCE_BASE_VAR = "CHANT_EVIDENCE_BASE";
132
+
133
+ /**
134
+ * The evidence jobs each later wave job needs (#4926): those of earlier waves
135
+ * that sign a check `evidence.requires` names, by the wave's number.
136
+ */
137
+ export function opWaveEvidenceNeeds(spec: Pick<OpWavesSpec, "evidence">, plans: ReadonlyArray<{ wave: number; plan: OpWaveEvidencePlan | undefined }>): (wave: number) => string[] {
138
+ const requires = new Set(spec.evidence?.requires ?? []);
139
+ return (wave) => plans.filter((p) => p.wave < wave && p.plan?.evidenceJob && p.plan.evidenceJob.checks.some((c) => requires.has(c))).map((p) => p.plan!.evidenceJob!.name);
140
+ }
@@ -7,7 +7,8 @@
7
7
 
8
8
  import { execFileSync } from "node:child_process";
9
9
  import { generateKeyPairSync } from "node:crypto";
10
- import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
10
+ import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
11
+ import { readCheckClaimFile } from "../ci-evidence-claims";
11
12
  import { tmpdir } from "node:os";
12
13
  import { join } from "node:path";
13
14
  import { describe, expect, test } from "vitest";
@@ -36,14 +37,14 @@ const spec: OpWavesSpec = {
36
37
  };
37
38
 
38
39
  /** A base commit with the spec and a runner key in .chant/trust.json, and a merge on top of it. */
39
- function repo(): { cwd: string; base: string; head: string; pem: string } {
40
+ function repo(atBase: OpWavesSpec = spec): { cwd: string; base: string; head: string; pem: string } {
40
41
  const cwd = mkdtempSync(join(tmpdir(), "chant-4870-waves-"));
41
42
  const { privateKey } = generateKeyPairSync("ed25519");
42
43
  const pem = privateKey.export({ format: "pem", type: "pkcs8" }).toString();
43
44
  git(cwd, "init", "--quiet");
44
45
  mkdirSync(join(cwd, ".chant"));
45
46
  writeFileSync(join(cwd, ".chant/trust.json"), JSON.stringify({ schema: 1, runners: [{ principal: "ci", class: "runner", key: loadRunnerKey(pem).publicKey }] }));
46
- writeFileSync(join(cwd, "waves.json"), JSON.stringify(spec));
47
+ writeFileSync(join(cwd, "waves.json"), JSON.stringify(atBase));
47
48
  git(cwd, "add", ".");
48
49
  git(cwd, "commit", "--quiet", "-m", "base");
49
50
  const base = git(cwd, "rev-parse", "HEAD");
@@ -127,4 +128,36 @@ describe("evidence.requires (#4870)", () => {
127
128
  // No key, nothing signed and nothing said.
128
129
  expect(await signOpWaveChecks({ cwd, head, base, wave: "dev", policyRows: none, log: (l) => logs.push(l), env: {}, push: false })).toEqual([]);
129
130
  });
131
+
132
+ test("#4926: beside an evidence job the command step signs only its plan, or nothing, and leaves the plan's claim file", async () => {
133
+ const { cwd, base, head, pem } = repo();
134
+ const checksDir = join(cwd, "checks");
135
+ const passed = new Map([["network", { source: "ci.policy", result: "passed" as const, rules: [] }]]);
136
+ const env = { CHANT_RUNNER_KEY: pem, CHANT_WAVE_EVIDENCE: "plan" } as NodeJS.ProcessEnv;
137
+ expect(await signOpWaveChecks({ cwd, head, base, wave: "dev", planDigest: digest("1"), policyRows: passed, log: () => {}, env, push: false, checksDir })).toEqual(["plan:dev"]);
138
+ expect(readCheckClaimFile(checksDir, "plan:dev")).toEqual({ check: "plan:dev", passed: true, claim: digest("1") });
139
+ expect(await signOpWaveChecks({ cwd, head, base, wave: "dev", policyRows: passed, log: () => {}, env: { ...env, CHANT_WAVE_EVIDENCE: "job" }, push: false, checksDir })).toEqual([]);
140
+ });
141
+ });
142
+
143
+ describe("chant run wave --policy-only (#4926)", () => {
144
+ const policySpec: OpWavesSpec = { name: "roots", op: "tf-apply", step: { kind: "fake-apply", root: "{target}" }, waves: [{ name: "dev", runs: [{ target: "network" }], gate: "never" }] };
145
+
146
+ test("with no policy over the plans it fails, applies nothing, and its claim file says policy did not pass", async () => {
147
+ const { cwd, head } = repo(policySpec);
148
+ const { registry, ran } = fakeCapability();
149
+ const logs: string[] = [];
150
+ const result = await runOpWave({ spec: policySpec, specFile: "waves.json", wave: 1, policyOnly: true, cwd, head, show: atBase, gates: memoryGateLedgerPort(), capabilities: registry, runs, log: (l) => logs.push(l) });
151
+ expect(result.exitCode).toBe(CHANT_EXIT.failed);
152
+ expect(result.policyRows).toEqual([]);
153
+ expect(ran).toEqual([]);
154
+ expect(logs.at(-1)).toContain("no ci.policy ran over its plans");
155
+ expect(readCheckClaimFile(join(cwd, ".chant/op-waves/roots/checks"), "policy:dev")).toEqual({ check: "policy:dev", passed: false });
156
+ expect(existsSync(join(cwd, ".chant/op-waves/roots/outcomes/outcome-wave-1.json"))).toBe(false);
157
+ });
158
+
159
+ test("a share job has no policy step of its own", async () => {
160
+ const { cwd, head } = repo();
161
+ await expect(runOpWave({ spec: policySpec, specFile: "waves.json", wave: 1, policyOnly: true, share: 1, cwd, head, show: atBase, gates: memoryGateLedgerPort(), runs })).rejects.toThrow(/a share or job group's job has none/);
162
+ });
130
163
  });
@@ -13,6 +13,12 @@
13
13
  * `policy:<wave>` when `ci.policy` ran over the plans and denied nothing.
14
14
  * They are attached under `refs/notes/chant/evidence` and pushed, where #4867's ref gate
15
15
  * and a later wave read them.
16
+ * - A generated pipeline (#4926) runs the wave's policy as a step of its own
17
+ * (`--policy-only`; on GitLab a `<wave job>-policy` job) and signs
18
+ * `policy:<wave>` in an evidence job after the wave job, from the forge's
19
+ * record of that step; a wave that trades cloud credentials and signs
20
+ * keyless signs `plan:<wave>` there too. `CHANT_WAVE_EVIDENCE` tells the
21
+ * command step which of the two it still signs itself.
16
22
  *
17
23
  * See ../workspace/trust/check-evidence.ts.
18
24
  */
@@ -20,6 +26,7 @@
20
26
  import { execFileSync } from "node:child_process";
21
27
  import type { OpRunPolicyRow } from "./runtime";
22
28
  export { opWavesEvidenceProblems, type OpWavesEvidence } from "./op-waves-evidence-spec";
29
+ import { WAVE_EVIDENCE_ENV, writeCheckClaimFile } from "../ci-evidence-claims";
23
30
  import { CHECK_EVIDENCE_KEY_ENV, missingCheckEvidence, recordChecks, RUNNER_IDENTITY_ENV, runnerEvidenceSigner, signChecks } from "../workspace/trust/check-evidence";
24
31
 
25
32
  function top(cwd: string): string {
@@ -32,20 +39,33 @@ export async function opWaveEvidenceRefusal(cwd: string, head: string, base: str
32
39
  return missingCheckEvidence(top(cwd), head, base, requires);
33
40
  }
34
41
 
42
+ export { WAVE_EVIDENCE_ENV };
43
+
35
44
  /**
36
45
  * Sign the wave's plan and policy checks when the job has a runner identity.
37
46
  * Never fails the wave: a key or identity the policy at base does not list, or a
38
- * notes push that does not land, is a line in the log.
47
+ * notes push that does not land, is a line in the log. With
48
+ * `CHANT_WAVE_EVIDENCE` (#4926) it signs only what that leaves to the step,
49
+ * and writes the plan's claim file in `checksDir`.
39
50
  */
40
- export async function signOpWaveChecks(input: { cwd: string; head: string; base: string; wave: string; planDigest?: string; policyRows: ReadonlyMap<string, OpRunPolicyRow>; log: (line: string) => void; env?: NodeJS.ProcessEnv; push?: boolean; fetch?: typeof fetch }): Promise<string[]> {
51
+ export async function signOpWaveChecks(input: { cwd: string; head: string; base: string; wave: string; planDigest?: string; policyRows: ReadonlyMap<string, OpRunPolicyRow>; log: (line: string) => void; env?: NodeJS.ProcessEnv; push?: boolean; fetch?: typeof fetch; checksDir?: string }): Promise<string[]> {
41
52
  const env = input.env ?? process.env;
53
+ const mode = env[WAVE_EVIDENCE_ENV];
54
+ if (mode && input.checksDir) {
55
+ try {
56
+ writeCheckClaimFile(input.checksDir, { check: `plan:${input.wave}`, passed: true, ...(input.planDigest ? { claim: input.planDigest } : {}) });
57
+ } catch (err) {
58
+ input.log(`wave ${input.wave}: the plan's claim file was not written: ${err instanceof Error ? err.message : String(err)}`);
59
+ }
60
+ }
61
+ if (mode === "job") return [];
42
62
  if (!env[CHECK_EVIDENCE_KEY_ENV] && !env[RUNNER_IDENTITY_ENV]) return [];
43
63
  try {
44
64
  const repo = top(input.cwd);
45
65
  const signer = (await runnerEvidenceSigner(repo, input.base, { env, ...(input.fetch ? { fetch: input.fetch } : {}) }))!;
46
66
  const rows = [...input.policyRows.values()];
47
67
  const checks: Array<{ check: string; claim?: string }> = [{ check: `plan:${input.wave}`, ...(input.planDigest ? { claim: input.planDigest } : {}) }];
48
- if (rows.length > 0 && rows.every((r) => r.result !== "denied")) checks.push({ check: `policy:${input.wave}`, claim: JSON.stringify(rows) });
68
+ if (mode !== "plan" && rows.length > 0 && rows.every((r) => r.result !== "denied")) checks.push({ check: `policy:${input.wave}`, claim: JSON.stringify(rows) });
49
69
  const signed = await signChecks(repo, input.head, checks, signer);
50
70
  const pushed = await recordChecks(repo, signed, { push: input.push !== false });
51
71
  if (input.push !== false && !pushed.pushed && pushed.pushWarning) input.log(`wave ${input.wave}: ${pushed.pushWarning}`);
@@ -7,6 +7,7 @@ import { afterEach, describe, expect, test } from "vitest";
7
7
  import { assertProductWords, CHANT_WORDS, notifyWaveLabel, productWordsProblems, resolveProductWords, setActiveProductWords } from "../ci-product-words";
8
8
  import { makeNotifyEvent, slackMessage, teamsMessage, verifyWebhook, type NotifyFetch, type NotifyFields } from "../notify";
9
9
  import { driftNotifyFields, productSendOptions } from "../notify-product";
10
+ import { driftRunFingerprint, type DriftIssueRecord } from "../drift-issue";
10
11
  import type { OpWavesSpec } from "./op-waves";
11
12
  import { notifyOpWave, opWaveNotifyFields, type OpWaveOutcome } from "./op-waves-notify";
12
13
 
@@ -97,6 +98,23 @@ describe("notify words (#4610)", () => {
97
98
  expect(driftNotifyFields(CHANT_WORDS, { changed: ["net"], failed: ["db"] }).summary).toBe("1 member drifted: net; 1 member could not be refreshed: db");
98
99
  });
99
100
 
101
+ test("a drift notice given the stacks' records names the drifted ones and computes the run's fingerprint (#4944)", () => {
102
+ const record = (member: string, status: "drifted" | "in-sync"): DriftIssueRecord => ({ member, address: "bucket", status, ...(status === "drifted" ? { attributes: [{ path: "acl", before: "private", after: "public-read" }] } : {}) });
103
+ const stacks = [
104
+ { stack: "shop-prod", records: [record("shop-prod", "drifted")] },
105
+ { stack: "shop-dev", records: [record("shop-dev", "in-sync")] },
106
+ { stack: "shop-eu", records: [record("shop-eu", "drifted")] },
107
+ ];
108
+ const fields = driftNotifyFields(PLYWOOD, { stacks, failed: ["shop-us"] });
109
+ expect(fields).toMatchObject({
110
+ summary: "2 stacks drifted: shop-prod, shop-eu; 1 stack could not be refreshed: shop-us",
111
+ targets: ["shop-prod", "shop-eu"],
112
+ drift: { changed: ["shop-prod", "shop-eu"], failed: ["shop-us"], fingerprint: driftRunFingerprint(stacks) },
113
+ });
114
+ expect(driftNotifyFields(PLYWOOD, { stacks, fingerprint: "fp" }).drift?.fingerprint).toBe("fp");
115
+ expect(driftNotifyFields(PLYWOOD, { stacks, changed: ["shop-prod"] }).drift?.changed).toEqual(["shop-prod"]);
116
+ });
117
+
100
118
  test("sql-yodeler's words keep source sql-yodeler while its product word is yodel", () => {
101
119
  expect(YODEL.notify).toEqual({ source: "sql-yodeler", wave: "wave {k} ({name}) of {spec}", headers: "x-yodel" });
102
120
  expect(opWaveNotifyFields(spec, 2, outcomes.failed!, {}, YODEL)).toMatchObject({ source: "sql-yodeler" });
@@ -0,0 +1,160 @@
1
+ /**
2
+ * #4982: a waves spec the job renders at run time. The product's command
3
+ * prints the spec at the commit chant hands it, the job runs on the spec it
4
+ * printed at base, and the gate policy is read from that same render, so a
5
+ * change that loosens the product's config at its head does not loosen its
6
+ * own gate.
7
+ */
8
+
9
+ import { afterEach, beforeEach, describe, expect, test } from "vitest";
10
+ import { execFileSync } from "node:child_process";
11
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { tmpdir } from "node:os";
14
+ import { gitShowAtBase, parseOpWavesSpec, readOpWavePolicy, runOpWave, type OpWaveExec } from "./op-waves-run";
15
+ import { memoryGateLedgerPort } from "./gate";
16
+ import {
17
+ commandSpecRender,
18
+ OP_WAVES_SPEC_COMMAND_ENV,
19
+ opWavesRenderSpecEnv,
20
+ opWavesSpecCommandFromEnv,
21
+ renderedJobMissing,
22
+ renderedSpecShow,
23
+ renderOpWavesSpecFile,
24
+ RUNTIME_WAVES_SPEC_FLOOR,
25
+ } from "./op-waves-render-spec";
26
+ import { NEXT_RELEASE } from "../release-floors";
27
+ import type { OpWavesSpec } from "./op-waves";
28
+ import { parseArgs } from "../cli/parse-args";
29
+ import { runOpWaveCommand } from "../cli/handlers/run-wave";
30
+ import type { CommandContext } from "../cli/registry";
31
+
32
+ const SPEC_FILE = ".chant/op-waves/tf-apply.spec.json";
33
+
34
+ /** A product's command: the spec, with wave dev's gate and shares read from `config.json` at the commit chant names. */
35
+ const RENDER_JS = `
36
+ const { execFileSync } = require("node:child_process");
37
+ const at = process.env.CHANT_WAVES_SPEC_AT;
38
+ if (process.env.RENDER_FAIL) process.exit(2);
39
+ let config;
40
+ try { config = JSON.parse(execFileSync("git", ["show", at + ":config.json"], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] })); } catch { process.exit(0); }
41
+ process.stdout.write(JSON.stringify({
42
+ name: "tf-apply", op: "tf-apply",
43
+ plan: ["tool", "plan", "{target}", "--out", "{plan}"], apply: ["tool", "apply", "{target}", "--plan", "{plan}"],
44
+ waves: [{ name: "dev", gate: config.gate, shares: config.shares, runs: [{ target: "a" }, { target: "b" }] }],
45
+ }));
46
+ `;
47
+
48
+ let repo: string;
49
+ let tools: string;
50
+ let command: string[];
51
+ const git = (...args: string[]) => execFileSync("git", args, { cwd: repo, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
52
+
53
+ beforeEach(() => {
54
+ repo = mkdtempSync(join(tmpdir(), "op-waves-render-"));
55
+ tools = mkdtempSync(join(tmpdir(), "op-waves-render-tool-"));
56
+ writeFileSync(join(tools, "render.cjs"), RENDER_JS);
57
+ command = [process.execPath, join(tools, "render.cjs")];
58
+ git("init", "-q", "-b", "main");
59
+ git("config", "user.email", "t@example.com");
60
+ git("config", "user.name", "t");
61
+ writeFileSync(join(repo, "config.json"), JSON.stringify({ gate: "always", shares: 2 }));
62
+ git("add", ".");
63
+ git("commit", "-q", "-m", "base");
64
+ // The change loosens the gate in the product's config.
65
+ writeFileSync(join(repo, "config.json"), JSON.stringify({ gate: "never", shares: 2 }));
66
+ git("commit", "-q", "-am", "loosen");
67
+ });
68
+
69
+ afterEach(() => {
70
+ delete process.env.RENDER_FAIL;
71
+ rmSync(repo, { recursive: true, force: true });
72
+ rmSync(tools, { recursive: true, force: true });
73
+ });
74
+
75
+ describe("a waves spec the job renders at run time (#4982)", () => {
76
+ test("the gate policy comes from the spec the command prints at base, not from the change's config", () => {
77
+ const show = renderedSpecShow(SPEC_FILE, commandSpecRender(command, SPEC_FILE, repo), gitShowAtBase);
78
+ const rules = readOpWavePolicy(SPEC_FILE, "dev", "HEAD^1", repo, show);
79
+ expect(rules).toMatchObject({ policy: "always", source: "base", base: git("rev-parse", "HEAD^1") });
80
+ // Without the render there is no spec at base at all.
81
+ expect(readOpWavePolicy(SPEC_FILE, "dev", "HEAD^1", repo).source).toBe("absent-at-base");
82
+ });
83
+
84
+ test("the job's spec is rendered once per commit and written over the spec file", () => {
85
+ let calls = 0;
86
+ const render = commandSpecRender(command, SPEC_FILE, repo);
87
+ const show = renderedSpecShow(SPEC_FILE, (sha) => (calls++, render(sha)), gitShowAtBase);
88
+ const { spec, sha } = renderOpWavesSpecFile({ specFile: SPEC_FILE, base: "HEAD^1", cwd: repo, show, parse: parseOpWavesSpec });
89
+ expect(sha).toBe(git("rev-parse", "HEAD^1"));
90
+ expect(spec.waves[0]).toMatchObject({ name: "dev", gate: "always" });
91
+ expect(parseOpWavesSpec(readFileSync(join(repo, SPEC_FILE), "utf-8"), "file").waves[0]!.gate).toBe("always");
92
+ readOpWavePolicy(SPEC_FILE, "dev", "HEAD^1", repo, show);
93
+ expect(calls).toBe(1);
94
+ // Any other file is read through git.
95
+ expect(show("HEAD", "config.json", repo).text).toContain('"never"');
96
+ });
97
+
98
+ test("a wave on the rendered spec waits under the gate at base, whatever the change's config says", async () => {
99
+ const show = renderedSpecShow(SPEC_FILE, commandSpecRender(command, SPEC_FILE, repo), gitShowAtBase);
100
+ const { spec } = renderOpWavesSpecFile({ specFile: SPEC_FILE, base: "HEAD^1", cwd: repo, show, parse: parseOpWavesSpec });
101
+ const applied: string[] = [];
102
+ const exec: OpWaveExec = (argv, dir) => {
103
+ if (argv[1] === "plan") writeFileSync(join(dir, argv[4]!), JSON.stringify({ planDigest: `sha256:${"1".repeat(64)}`, changes: { create: 1 } }));
104
+ if (argv[1] === "apply") applied.push(argv[2]!);
105
+ return 0;
106
+ };
107
+ const result = await runOpWave({ spec: { ...spec, waves: [{ ...spec.waves[0]!, shares: undefined }] }, specFile: SPEC_FILE, wave: 1, cwd: repo, exec, show, gates: memoryGateLedgerPort(), head: git("rev-parse", "HEAD") });
108
+ expect(result.exitCode).toBe(3);
109
+ expect(result.decision).toMatchObject({ status: "waiting", policy: "always" });
110
+ expect(applied).toEqual([]);
111
+ });
112
+
113
+ test("a command that fails fails the job; one that prints nothing reads as no spec at that commit", () => {
114
+ process.env.RENDER_FAIL = "1";
115
+ const failing = renderedSpecShow(SPEC_FILE, commandSpecRender(command, SPEC_FILE, repo), gitShowAtBase);
116
+ expect(() => readOpWavePolicy(SPEC_FILE, "dev", "HEAD^1", repo, failing)).toThrow(/the spec command \(.*render\.cjs\) exited 2 at [0-9a-f]{12}/);
117
+ delete process.env.RENDER_FAIL;
118
+ git("rm", "-q", "config.json");
119
+ git("commit", "-q", "-m", "drop the config");
120
+ const empty = renderedSpecShow(SPEC_FILE, commandSpecRender(command, SPEC_FILE, repo), gitShowAtBase);
121
+ expect(readOpWavePolicy(SPEC_FILE, "dev", "HEAD", repo, empty)).toMatchObject({ policy: "always", source: "absent-at-base" });
122
+ expect(() => renderOpWavesSpecFile({ specFile: SPEC_FILE, base: "HEAD", cwd: repo, show: empty, parse: parseOpWavesSpec })).toThrow(/printed no spec at HEAD/);
123
+ });
124
+
125
+ test("a share or job group the shape has and the rendered spec does not has nothing to apply", () => {
126
+ const spec: OpWavesSpec = { name: "s", op: "o", plan: ["p"], apply: ["a"], waves: [{ name: "w", runs: [{ target: "a" }, { target: "b" }], shares: 2 }, { name: "g", runs: [{ target: "a" }], jobs: [{ name: "eu", runs: ["a"], shares: 2 }] }] };
127
+ expect(renderedJobMissing(spec, 1, { share: 2 })).toBeUndefined();
128
+ expect(renderedJobMissing(spec, 1, { share: 3 })).toBe("wave 1 (w) has 2 shares in the spec rendered at base");
129
+ expect(renderedJobMissing(spec, 2, { group: "us" })).toBe('wave 2 (g) has no job group "us" in the spec rendered at base');
130
+ expect(renderedJobMissing(spec, 2, { group: "eu", share: 3 })).toBe('job group "eu" of wave 2 (g) has 2 shares in the spec rendered at base');
131
+ expect(renderedJobMissing(spec, 2, { group: "eu", share: 1 })).toBeUndefined();
132
+ });
133
+
134
+ test("the command comes from CHANT_WAVES_SPEC_COMMAND as a JSON list of words", () => {
135
+ expect(opWavesSpecCommandFromEnv({ [OP_WAVES_SPEC_COMMAND_ENV]: '["terragucci","waves-spec"]' })).toEqual(["terragucci", "waves-spec"]);
136
+ expect(() => opWavesSpecCommandFromEnv({})).toThrow(/CHANT_WAVES_SPEC_COMMAND names, and it is unset/);
137
+ expect(() => opWavesSpecCommandFromEnv({ [OP_WAVES_SPEC_COMMAND_ENV]: "terragucci waves-spec" })).toThrow(/must be a JSON list of words/);
138
+ expect(opWavesRenderSpecEnv({ command: ["terragucci", "waves-spec"] })).toEqual({ CHANT_WAVES_SPEC_COMMAND: '["terragucci","waves-spec"]' });
139
+ expect(opWavesRenderSpecEnv(undefined)).toEqual({});
140
+ expect(() => opWavesRenderSpecEnv({ command: [] })).toThrow(/renderSpec.command must be/);
141
+ expect(RUNTIME_WAVES_SPEC_FLOOR).toBe(NEXT_RELEASE);
142
+ });
143
+
144
+ test("chant run wave --render-spec writes the rendered spec, and a share it does not have exits 0", async () => {
145
+ const was = process.cwd();
146
+ const env = process.env[OP_WAVES_SPEC_COMMAND_ENV];
147
+ process.env[OP_WAVES_SPEC_COMMAND_ENV] = JSON.stringify(command);
148
+ process.chdir(repo);
149
+ try {
150
+ const ctx = { args: parseArgs(["run", "wave", "--spec", SPEC_FILE, "--wave", "1", "--share", "3", "--render-spec"]), plugins: [], serializers: [] } as unknown as CommandContext;
151
+ expect(ctx.args.renderSpec).toBe(true);
152
+ expect(await runOpWaveCommand(ctx)).toBe(0);
153
+ expect(parseOpWavesSpec(readFileSync(join(repo, SPEC_FILE), "utf-8"), "file").waves[0]).toMatchObject({ gate: "always", shares: 2 });
154
+ } finally {
155
+ process.chdir(was);
156
+ if (env === undefined) delete process.env[OP_WAVES_SPEC_COMMAND_ENV];
157
+ else process.env[OP_WAVES_SPEC_COMMAND_ENV] = env;
158
+ }
159
+ });
160
+ });
@@ -0,0 +1,171 @@
1
+ /**
2
+ * A waves spec the job renders at run time (#4982).
3
+ *
4
+ * A generated waves pipeline reads its spec from the file at `specFile`,
5
+ * and each wave job reads the gate policy from that file at the base
6
+ * commit. A product whose spec is built from its own config (terragucci
7
+ * builds `tf-apply` from `terragucci.yml` at base: the gate per
8
+ * environment, the approval mode, the policy and cost holds) cannot commit
9
+ * the spec once, so it used to render its own apply-wave jobs.
10
+ *
11
+ * With `renderSpec` on the generator's options, every wave, deciding and
12
+ * share job, and the policy step, runs `chant run wave --render-spec`, and
13
+ * `CHANT_WAVES_SPEC_COMMAND` on the job holds the product command that
14
+ * prints the spec, as a JSON argv. chant runs that command with
15
+ * `CHANT_WAVES_SPEC_AT` set to a commit and reads the spec from its
16
+ * standard output:
17
+ *
18
+ * - at the base, for the spec the job runs, which chant writes over the
19
+ * file at `specFile` so the hooks, the decision record and the share
20
+ * jobs read the same one;
21
+ * - at the base again, for the gate policy, the holds, the hooks and the
22
+ * evidence rules (`readOpWavePolicy`), in place of `git show
23
+ * <base>:<specFile>`;
24
+ * - at a newer commit on the branch, for the stand-down (#4581).
25
+ *
26
+ * The command's output is the gate policy, so it must read the product's
27
+ * config at the commit it is handed (`git show "$CHANT_WAVES_SPEC_AT:<file>"`),
28
+ * never from the working tree, which holds the change. It exits 0 and
29
+ * prints nothing when that commit has no config, which reads as a spec
30
+ * missing at base: every wave's gate is `always`. Any other exit fails the
31
+ * job.
32
+ *
33
+ * The spec the generator is handed is the pipeline's shape: its waves'
34
+ * names, shares and job groups, runners, environments, `cloud` and
35
+ * `holds.policy` decide the jobs and their steps. The rendered spec decides
36
+ * the rules. A share or job group the shape has and the rendered spec does
37
+ * not applies nothing and exits 0, since the job exists before the runs
38
+ * are known.
39
+ *
40
+ * Nothing here imports the wave runner, so the generators' bundles take
41
+ * the variables without it; `chant run wave` hands in its git reader.
42
+ */
43
+
44
+ import { execFileSync } from "node:child_process";
45
+ import { writeFileSync, mkdirSync } from "node:fs";
46
+ import { dirname, isAbsolute, join, posix } from "node:path";
47
+ import type { OpWaveShowAtBase } from "./op-waves-run";
48
+ import type { OpWavesSpec } from "./op-waves";
49
+
50
+ export { RUNTIME_WAVES_SPEC_FLOOR } from "../release-floors";
51
+
52
+ /** The job variable that holds the product command printing the spec, as a JSON argv. */
53
+ export const OP_WAVES_SPEC_COMMAND_ENV = "CHANT_WAVES_SPEC_COMMAND";
54
+ /** The variable chant hands that command: the full commit to render the spec at. */
55
+ export const OP_WAVES_SPEC_AT_ENV = "CHANT_WAVES_SPEC_AT";
56
+ /** The variable chant hands that command: the spec file's path, as the job names it. */
57
+ export const OP_WAVES_SPEC_FILE_ENV = "CHANT_WAVES_SPEC_FILE";
58
+ /** The `chant run wave` flag that renders the spec before the job runs. */
59
+ export const OP_WAVES_RENDER_SPEC_FLAG = "--render-spec";
60
+
61
+ /** `OpWavesPipelineOptions.renderSpec` (#4982). */
62
+ export interface OpWavesRenderSpec {
63
+ /** The product command that prints the spec at `CHANT_WAVES_SPEC_AT`, such as `["terragucci", "waves-spec"]`. */
64
+ command: string[];
65
+ }
66
+
67
+ /** What is wrong with a `renderSpec`, or nothing. */
68
+ export function opWavesRenderSpecProblems(value: unknown): string[] {
69
+ const command = (value as { command?: unknown } | null)?.command;
70
+ if (!Array.isArray(command) || command.length === 0 || command.some((w) => typeof w !== "string" || w.length === 0)) {
71
+ return ['renderSpec.command must be the product command that prints the spec, as a list of words: ["terragucci", "waves-spec"]'];
72
+ }
73
+ return [];
74
+ }
75
+
76
+ /** The variables a wave job carries for `renderSpec`, or none without it. Throws on a `renderSpec` that is wrong. */
77
+ export function opWavesRenderSpecEnv(renderSpec: OpWavesRenderSpec | undefined): Record<string, string> {
78
+ if (renderSpec === undefined) return {};
79
+ const problems = opWavesRenderSpecProblems(renderSpec);
80
+ if (problems.length > 0) throw new Error(problems.join("; "));
81
+ return { [OP_WAVES_SPEC_COMMAND_ENV]: JSON.stringify(renderSpec.command) };
82
+ }
83
+
84
+ /** The product command `CHANT_WAVES_SPEC_COMMAND` names. Throws when it is unset or not a JSON list of words. */
85
+ export function opWavesSpecCommandFromEnv(env: NodeJS.ProcessEnv = process.env): string[] {
86
+ const raw = env[OP_WAVES_SPEC_COMMAND_ENV];
87
+ if (!raw) throw new Error(`${OP_WAVES_RENDER_SPEC_FLAG} runs the command ${OP_WAVES_SPEC_COMMAND_ENV} names, and it is unset`);
88
+ let command: unknown;
89
+ try {
90
+ command = JSON.parse(raw);
91
+ } catch {
92
+ command = undefined;
93
+ }
94
+ if (opWavesRenderSpecProblems({ command }).length > 0) throw new Error(`${OP_WAVES_SPEC_COMMAND_ENV} must be a JSON list of words, such as ["terragucci","waves-spec"]: got ${raw}`);
95
+ return command as string[];
96
+ }
97
+
98
+ /** Prints the spec at a full commit, or null when that commit has none. Injected for tests. */
99
+ export type OpWavesSpecRender = (sha: string) => string | null;
100
+
101
+ /** {@link OpWavesSpecRender} through the product's command, run in `cwd`. Its standard error goes to the job's log. */
102
+ export function commandSpecRender(command: readonly string[], specFile: string, cwd: string): OpWavesSpecRender {
103
+ return (sha) => {
104
+ let out: string;
105
+ try {
106
+ out = execFileSync(command[0]!, command.slice(1), {
107
+ cwd,
108
+ encoding: "utf-8",
109
+ stdio: ["ignore", "pipe", "inherit"],
110
+ env: { ...process.env, [OP_WAVES_SPEC_AT_ENV]: sha, [OP_WAVES_SPEC_FILE_ENV]: specFile },
111
+ maxBuffer: 64 * 1024 * 1024,
112
+ });
113
+ } catch (err) {
114
+ const status = (err as { status?: number | null }).status;
115
+ throw new Error(`the spec command (${command.join(" ")}) ${typeof status === "number" ? `exited ${status}` : `did not run: ${err instanceof Error ? err.message : String(err)}`} at ${sha.slice(0, 12)}, so the wave's spec cannot be read`);
116
+ }
117
+ return out.trim() === "" ? null : out;
118
+ };
119
+ }
120
+
121
+ const posixPath = (p: string): string => p.replace(/^\.\//, "").split("\\").join(posix.sep);
122
+
123
+ /**
124
+ * An {@link OpWaveShowAtBase} that reads `specFile` at any commit from
125
+ * `render`, once per commit, and every other file through `fallback`
126
+ * (git, `gitShowAtBase`), which also resolves the commit.
127
+ */
128
+ export function renderedSpecShow(specFile: string, render: OpWavesSpecRender, fallback: OpWaveShowAtBase): OpWaveShowAtBase {
129
+ const target = posixPath(specFile);
130
+ const seen = new Map<string, string | null>();
131
+ return (base, path, cwd) => {
132
+ if (posixPath(path) !== target) return fallback(base, path, cwd);
133
+ const { sha } = fallback(base, path, cwd);
134
+ if (!seen.has(sha)) seen.set(sha, render(sha));
135
+ return { sha, text: seen.get(sha)! };
136
+ };
137
+ }
138
+
139
+ /**
140
+ * Render the job's spec at `base` (#4982): read it through `show`, parse it
141
+ * with `parse` (`parseOpWavesSpec`), write it over `specFile` in `cwd`, and
142
+ * return it. Throws when the command printed no spec, or one chant cannot
143
+ * read.
144
+ */
145
+ export function renderOpWavesSpecFile(options: { specFile: string; base: string; cwd: string; show: OpWaveShowAtBase; parse: (text: string, where: string) => OpWavesSpec }): { spec: OpWavesSpec; sha: string } {
146
+ const { sha, text } = options.show(options.base, options.specFile, options.cwd);
147
+ if (text === null) throw new Error(`the spec command printed no spec at ${options.base} (${sha.slice(0, 12)}), so the wave has nothing to run`);
148
+ const spec = options.parse(text, `the spec rendered at ${sha.slice(0, 12)}`);
149
+ const path = isAbsolute(options.specFile) ? options.specFile : join(options.cwd, options.specFile);
150
+ mkdirSync(dirname(path), { recursive: true });
151
+ writeFileSync(path, text.endsWith("\n") ? text : `${text}\n`);
152
+ return { spec, sha };
153
+ }
154
+
155
+ /**
156
+ * Whether job `job` of wave `k` has anything in the rendered spec: a share
157
+ * past the wave's (or the group's) shares, or a group the wave does not
158
+ * have, has nothing. Undefined when it has; otherwise why not.
159
+ */
160
+ export function renderedJobMissing(spec: OpWavesSpec, k: number, job: { share?: number; group?: string }): string | undefined {
161
+ const wave = spec.waves[k - 1];
162
+ if (!wave) return undefined;
163
+ if (job.group !== undefined) {
164
+ const group = wave.jobs?.find((g) => g.name === job.group);
165
+ if (!group) return `wave ${k} (${wave.name}) has no job group "${job.group}" in the spec rendered at base`;
166
+ if (job.share !== undefined && job.share > (group.shares ?? 1)) return `job group "${job.group}" of wave ${k} (${wave.name}) has ${group.shares ?? 1} share${(group.shares ?? 1) === 1 ? "" : "s"} in the spec rendered at base`;
167
+ return undefined;
168
+ }
169
+ if (job.share !== undefined && wave.jobs === undefined && job.share > (wave.shares ?? 1)) return `wave ${k} (${wave.name}) has ${wave.shares ?? 1} share${(wave.shares ?? 1) === 1 ? "" : "s"} in the spec rendered at base`;
170
+ return undefined;
171
+ }